[LLVMbugs] [Bug 10958] New: ASTImporter: Lookup for empty DeclarationName when searching for typedef

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Sep 19 11:16:10 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10958

           Summary: ASTImporter: Lookup for empty DeclarationName when
                    searching for typedef
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: llvm at meinersbur.de
                CC: llvmbugs at cs.uiuc.edu


ASTImporter looks for existing declarations/definitions of structs before
importing it again. This behavior is implemented in
ASTNodeImporter::VisitRecordDecl. It also looks for anonymous structs in
typedefs, i.e.

typedef struct {
  int x;
} NameOfStruct;

It will save the typedef's name in the variable "SearchName". However, when
looking up the identifier, it uses the original "Name" variable that contains
the struct's name which is empty for anonymous structs. I suggest to replace it
with SearchName. Same applies for the copy&pasted
ASTNodeImporter::VisitEnumDecl.

Bug found in clang 2.9 and Revision 140031
Suggested fix (below) works for clang 2.9

Generally, ASTImporter is very immature.


Index: ASTImporter.cpp
===================================================================
--- ASTImporter.cpp    (revision 140023)
+++ ASTImporter.cpp    (working copy)
@@ -2178,7 +2178,7 @@
   // We may already have an enum of the same name; try to find and match it.
   if (!DC->isFunctionOrMethod() && SearchName) {
     SmallVector<NamedDecl *, 4> ConflictingDecls;
-    for (DeclContext::lookup_result Lookup = DC->lookup(Name);
+    for (DeclContext::lookup_result Lookup = DC->lookup(SearchName);
          Lookup.first != Lookup.second; 
          ++Lookup.first) {
       if (!(*Lookup.first)->isInIdentifierNamespace(IDNS))
@@ -2264,7 +2264,7 @@
   RecordDecl *AdoptDecl = 0;
   if (!DC->isFunctionOrMethod() && SearchName) {
     SmallVector<NamedDecl *, 4> ConflictingDecls;
-    for (DeclContext::lookup_result Lookup = DC->lookup(Name);
+    for (DeclContext::lookup_result Lookup = DC->lookup(SearchName);
          Lookup.first != Lookup.second; 
          ++Lookup.first) {
       if (!(*Lookup.first)->isInIdentifierNamespace(IDNS))

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list