[clang] [clang][ExtractAPI] fix a couple crashes when used via libclang (PR #132297)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 21 08:12:30 PDT 2025


================
@@ -0,0 +1,33 @@
+// Test is line- and column-sensitive. Run lines are below
+
+template <typename T>
+class basic_vector {
+public:
+    T x;
+    T y;
+};
+
+using my_vec = basic_vector<int>;
+
+class MyClass {
+    my_vec myVec;
+};
+
+struct OuterStruct {
+    struct InnerStruct;
+    int outer_field;
+};
+
+// RUN: c-index-test -single-symbol-sgf-at=%s:13:13 local %s | FileCheck --check-prefix=CHECK-MYVEC %s
+// CHECK-MYVEC: "parentContexts":[{"kind":"c++.class","name":"MyClass","usr":"c:@S at MyClass"},{"kind":"c++.property","name":"myVec","usr":"c:@S at MyClass@FI at myVec"}]
+// CHECK-MYVEC: "identifier":{"interfaceLanguage":"c++","precise":"c:@S at MyClass@FI at myVec"}
+// CHECK-MYVEC: "kind":{"displayName":"Instance Property","identifier":"c++.property"}
----------------
QuietMisdreavus wrote:

`myVec` was what was triggering the problem of template argument fragments. AFAIK it's because libclang is also checking for `my_vec` at the same time, but if you set the cursor position on the `my_vec` type there it works. I can add another cursor check for the `my_vec` type itself if you'd like.

https://github.com/llvm/llvm-project/pull/132297


More information about the cfe-commits mailing list