[cfe-commits] r167442 - /cfe/trunk/tools/libclang/CIndexUSRs.cpp

Ted Kremenek kremenek at apple.com
Mon Nov 5 22:36:45 PST 2012


Author: kremenek
Date: Tue Nov  6 00:36:45 2012
New Revision: 167442

URL: http://llvm.org/viewvc/llvm-project?rev=167442&view=rev
Log:
Remove completely irrelevant code from USR generation.

Thanks to Richard Smith for pointing this out.  This code stopped
serving its purpose during r103212 in a refactoring.  My initial
fix was to add back the logic to abort the USR generation for
InternalLinkage, but enough tests broke suspiciously that I fear
that USR generation for cursors with InternalLinkage is now expected
by some clients (where it wasn't the case when the refactoring
took place).  I don't own this code anymore and have not looked
at it for some time, but clearly this code is dead and can be removed
pending further review on the proper logic here.

Modified:
    cfe/trunk/tools/libclang/CIndexUSRs.cpp

Modified: cfe/trunk/tools/libclang/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexUSRs.cpp?rev=167442&r1=167441&r2=167442&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexUSRs.cpp Tue Nov  6 00:36:45 2012
@@ -805,36 +805,11 @@
   if (!D || D->getLocStart().isInvalid())
     return true;
 
-  // Check if the cursor has 'NoLinkage'.
-  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
-    switch (ND->getLinkage()) {
-      case ExternalLinkage:
-        // Generate USRs for all entities with external linkage.
-        break;
-      case NoLinkage:
-      case UniqueExternalLinkage:
-        // We allow enums, typedefs, and structs that have no linkage to
-        // have USRs that are anchored to the file they were defined in
-        // (e.g., the header).  This is a little gross, but in principal
-        // enums/anonymous structs/etc. defined in a common header file
-        // are referred to across multiple translation units.
-        if (isa<TagDecl>(ND) || isa<TypedefDecl>(ND) ||
-            isa<EnumConstantDecl>(ND) || isa<FieldDecl>(ND) ||
-            isa<VarDecl>(ND) || isa<NamespaceDecl>(ND))
-          break;
-        // Fall-through.
-      case InternalLinkage:
-        if (isa<FunctionDecl>(ND))
-          break;
-    }
-
-  {
-    USRGenerator UG(&D->getASTContext(), &Buf);
-    UG->Visit(const_cast<Decl*>(D));
+  USRGenerator UG(&D->getASTContext(), &Buf);
+  UG->Visit(const_cast<Decl*>(D));
 
-    if (UG->ignoreResults())
-      return true;
-  }
+  if (UG->ignoreResults())
+    return true;
 
   return false;
 }





More information about the cfe-commits mailing list