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

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