Blame SOURCES/bpftrace-0.9-fix-struct-definition-from-headers.patch

295890
From 151351ea22c855e4e605b8fd2058c19dc4ae5ed6 Mon Sep 17 00:00:00 2001
295890
From: Matheus Marchini <mat@mmarchini.me>
295890
Date: Tue, 16 Apr 2019 12:06:01 -0700
295890
Subject: [PATCH 2/2] fix struct definition from headers
295890
295890
Regression caused by iovisor/bpftrace@80ce138c7. With the changes on how
295890
we identify the parent struct, we ended up with our parent cursor in the
295890
header file sometimes instead of a valid cursor. This PR checks if the
295890
parent cursor is a struct, otherwise returns an empty string and let the
295890
caller handle the situation (which is similar to the previous behavior).
295890
---
295890
 src/clang_parser.cpp | 4 ++++
295890
 1 file changed, 4 insertions(+)
295890
295890
diff --git a/src/clang_parser.cpp b/src/clang_parser.cpp
295890
index b1db8ff..b787b67 100644
295890
--- a/src/clang_parser.cpp
295890
+++ b/src/clang_parser.cpp
295890
@@ -40,6 +40,10 @@ static std::string get_parent_struct_name(CXCursor c)
295890
 {
295890
   CXCursor parent = get_indirect_field_parent_struct(c);
295890
 
295890
+  if (clang_getCursorKind(parent) != CXCursor_StructDecl &&
295890
+      clang_getCursorKind(parent) != CXCursor_UnionDecl)
295890
+    return "";
295890
+
295890
   return get_clang_string(clang_getCursorSpelling(parent));
295890
 }
295890
 
295890
-- 
295890
2.20.1
295890