r223633 - [libclang] Encode location info for anonymous embedded tag decls.

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Dec 8 00:48:37 PST 2014


Author: akirtzidis
Date: Mon Dec  8 02:48:37 2014
New Revision: 223633

URL: http://llvm.org/viewvc/llvm-project?rev=223633&view=rev
Log:
[libclang] Encode location info for anonymous embedded tag decls.

Otherwise the USR will conflict with different embedded tag decls.

Modified:
    cfe/trunk/lib/Index/USRGeneration.cpp
    cfe/trunk/test/Index/usrs.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=223633&r1=223632&r2=223633&view=diff
==============================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Dec  8 02:48:37 2014
@@ -471,9 +471,13 @@ void USRGenerator::VisitTagDecl(const Ta
       Buf[off] = 'A';
       Out << '@' << *TD;
     }
-    else
+  else {
+    if (D->isEmbeddedInDeclarator() && !D->isFreeStanding()) {
+      printLoc(Out, D->getLocation(), Context->getSourceManager(), true);
+    } else
       Buf[off] = 'a';
   }
+  }
   
   // For a class template specialization, mangle the template arguments.
   if (const ClassTemplateSpecializationDecl *Spec

Modified: cfe/trunk/test/Index/usrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/usrs.cpp?rev=223633&r1=223632&r2=223633&view=diff
==============================================================================
--- cfe/trunk/test/Index/usrs.cpp (original)
+++ cfe/trunk/test/Index/usrs.cpp Mon Dec  8 02:48:37 2014
@@ -87,6 +87,9 @@ void funWithChar(char c) {}
 void funWithChar(unsigned char c) {}
 void funWithChar(signed char c) {}
 
+struct { int x; } embedS1;
+struct { int x; } embedS2;
+
 // RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s
 // CHECK: usrs.cpp c:@N at foo Extent=[1:1 - 4:2]
 // CHECK: usrs.cpp c:@N at foo@x Extent=[2:3 - 2:8]
@@ -159,3 +162,6 @@ void funWithChar(signed char c) {}
 // CHECK: usrs.cpp c:@F at funWithChar#C# Extent=[86:1 - 86:28]
 // CHECK: usrs.cpp c:@F at funWithChar#c# Extent=[87:1 - 87:37]
 // CHECK: usrs.cpp c:@F at funWithChar#r# Extent=[88:1 - 88:35]
+
+// CHECK: usrs.cpp c:usrs.cpp at S@usrs.cpp at 1483@FI at x Extent=[90:10 - 90:15]
+// CHECK: usrs.cpp c:usrs.cpp at S@usrs.cpp at 1510@FI at x Extent=[91:10 - 91:15]





More information about the cfe-commits mailing list