]> granicus.if.org Git - clang/commitdiff
[ASTImporter] Lookup SearchName instead of Name
authorGabor Horvath <xazax.hun@gmail.com>
Mon, 3 Apr 2017 09:30:20 +0000 (09:30 +0000)
committerGabor Horvath <xazax.hun@gmail.com>
Mon, 3 Apr 2017 09:30:20 +0000 (09:30 +0000)
When the SearchName is already calculated we should use that for the lookup.

Patch by Peter Szecsi!

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

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

lib/AST/ASTImporter.cpp
test/ASTMerge/struct/Inputs/struct1.c
test/ASTMerge/struct/Inputs/struct2.c
test/ASTMerge/struct/test.c

index c0cbde2ea84a5ec3925194bc31ffe8fc69591e05..95492825eb9d7b5f726d2d71710db0c33ee8a332 100644 (file)
@@ -2919,7 +2919,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
   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(RecordDecl *D) {
   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;
index af2af8abc42ada53870422a6d356b003577b0154..0f3e8b9bc3ebfd3252143a09c8474ed569dcf2a2 100644 (file)
@@ -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;
index 4b43df71d8d68239c1e63f59e110fce35a722f04..7fe17a576b23ac9b55c3b10d1660400e91e01ba3 100644 (file)
@@ -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;
index 4f41cea26b189211e2149d9a16464a5e307ff827..ed7750f6beccadc70a47376106cc3840cc823a39 100644 (file)
@@ -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