]> granicus.if.org Git - clang/commitdiff
Remove completely irrelevant code from USR generation.
authorTed Kremenek <kremenek@apple.com>
Tue, 6 Nov 2012 06:36:45 +0000 (06:36 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 6 Nov 2012 06:36:45 +0000 (06:36 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167442 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndexUSRs.cpp

index 19b3f263a42977533ab48c8263e4cd582e335acd..614003272951d6a0b63593299718f3eb8496425d 100644 (file)
@@ -805,36 +805,11 @@ bool cxcursor::getDeclCursorUSR(const Decl *D, SmallVectorImpl<char> &Buf) {
   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;
 }