r330692 - [libclang] Only mark CXCursors for explicit attributes with a type
Erik Verbruggen via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 24 01:39:46 PDT 2018
Author: erikjv
Date: Tue Apr 24 01:39:46 2018
New Revision: 330692
URL: http://llvm.org/viewvc/llvm-project?rev=330692&view=rev
Log:
[libclang] Only mark CXCursors for explicit attributes with a type
All attributes have a source range associated with it. However, implicit
attributes are added by the compiler, and not added because the user
wrote something in the input. So no token type should be set to
CXCursor_*Attr.
The problem was visible when a class gets marked by e.g.
MSInheritanceAttr, which has the full CXXRecordDecl's range as its
own range. The effect of marking that range as CXCursor_UnexposedAttr
was that all cursors for the record decl, including all child decls,
would become CXCursor_UnexposedAttr.
Added:
cfe/trunk/test/Index/annotate-tokens-unexposed.cpp
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Added: cfe/trunk/test/Index/annotate-tokens-unexposed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens-unexposed.cpp?rev=330692&view=auto
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens-unexposed.cpp (added)
+++ cfe/trunk/test/Index/annotate-tokens-unexposed.cpp Tue Apr 24 01:39:46 2018
@@ -0,0 +1,20 @@
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:16:1 %s -target x86_64-pc-windows-msvc | FileCheck %s
+class Foo
+{
+public:
+ void step(int v);
+ Foo();
+};
+
+void bar()
+{
+ // Introduce a MSInheritanceAttr node on the CXXRecordDecl for Foo. The
+ // existance of this attribute should not mark all cursors for tokens in
+ // Foo as UnexposedAttr.
+ &Foo::step;
+}
+
+Foo::Foo()
+{}
+
+// CHECK-NOT: UnexposedAttr=
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=330692&r1=330691&r2=330692&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Apr 24 01:39:46 2018
@@ -1796,7 +1796,7 @@ bool CursorVisitor::VisitCXXRecordDecl(C
bool CursorVisitor::VisitAttributes(Decl *D) {
for (const auto *I : D->attrs())
- if (Visit(MakeCXCursor(I, D, TU)))
+ if (!I->isImplicit() && Visit(MakeCXCursor(I, D, TU)))
return true;
return false;
More information about the cfe-commits
mailing list