r299354 - [ASTImporter] Lookup SearchName instead of Name

Gabor Horvath via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 3 02:30:20 PDT 2017


Author: xazax
Date: Mon Apr  3 04:30:20 2017
New Revision: 299354

URL: http://llvm.org/viewvc/llvm-project?rev=299354&view=rev
Log:
[ASTImporter] Lookup SearchName instead of Name

When the SearchName is already calculated we should use that for the lookup.

Patch by Peter Szecsi!

Differential Revision: https://reviews.llvm.org/D30877

Modified:
    cfe/trunk/lib/AST/ASTImporter.cpp
    cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
    cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
    cfe/trunk/test/ASTMerge/struct/test.c

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=299354&r1=299353&r2=299354&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr  3 04:30:20 2017
@@ -2919,7 +2919,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(Enu
   if (!DC->isFunctionOrMethod() && SearchName) {
     SmallVector<NamedDecl *, 4> ConflictingDecls;
     SmallVector<NamedDecl *, 2> FoundDecls;
-    DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
+    DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
     for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
       if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
         continue;
@@ -3008,7 +3008,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   if (!DC->isFunctionOrMethod()) {
     SmallVector<NamedDecl *, 4> ConflictingDecls;
     SmallVector<NamedDecl *, 2> FoundDecls;
-    DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
+    DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
     for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
       if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
         continue;

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c?rev=299354&r1=299353&r2=299354&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct1.c Mon Apr  3 04:30:20 2017
@@ -61,3 +61,19 @@ struct {
   Int i;
   float f;
 } x11;
+
+// Matches
+typedef struct {
+  Int i;
+  float f;
+} S12;
+
+S12 x12;
+
+// Mismatch
+typedef struct {
+  Float i; // Mismatch here.
+  float f;
+} S13;
+
+S13 x13;

Modified: cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c?rev=299354&r1=299353&r2=299354&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c (original)
+++ cfe/trunk/test/ASTMerge/struct/Inputs/struct2.c Mon Apr  3 04:30:20 2017
@@ -58,3 +58,19 @@ struct {
   int i;
   float f;
 } x11;
+
+// Matches
+typedef struct {
+  int i;
+  float f;
+} S12;
+
+S12 x12;
+
+// Mismatch
+typedef struct {
+  int i; // Mismatch here.
+  float f;
+} S13;
+
+S13 x13;

Modified: cfe/trunk/test/ASTMerge/struct/test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct/test.c?rev=299354&r1=299353&r2=299354&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/struct/test.c (original)
+++ cfe/trunk/test/ASTMerge/struct/test.c Mon Apr  3 04:30:20 2017
@@ -39,4 +39,9 @@
 // CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError *' here
 // CHECK: struct2.c:54:3: error: external variable 'xDeep' declared with incompatible types in different translation units ('struct DeepError' vs. 'struct DeepError')
 // CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError'
-// CHECK: 8 warnings and 7 errors generated
+// CHECK: struct1.c:74:9: warning: type 'S13' has incompatible definitions in different translation units
+// CHECK: struct1.c:75:9: note: field 'i' has type 'Float' (aka 'float') here
+// CHECK: struct2.c:72:7: note: field 'i' has type 'int' here
+// CHECK: struct2.c:76:5: error: external variable 'x13' declared with incompatible types in different translation units ('S13' vs. 'S13')
+// CHECK: struct1.c:79:5: note: declared here with type 'S13'
+// CHECK: 9 warnings and 8 errors generated




More information about the cfe-commits mailing list