[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 07:50:15 PST 2024


================
@@ -10181,6 +10184,151 @@ TEST_P(ImportTemplateParmDeclDefaultValue,
       FromD, FromDInherited);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportIntoReopenedNamespaceNoMatch1) {
+  const char *ToCode =
+      R"(
+      namespace a {
+      }
+      namespace a {
+        struct X { int A; };
+      }
+      )";
+  Decl *ToTU = getToTuDecl(ToCode, Lang_CXX11);
+  const char *Code =
+      R"(
+      namespace a {
+        struct X { char A; };
+      }
+      )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromX = FirstDeclMatcher<CXXRecordDecl>().match(
+      FromTU, cxxRecordDecl(hasName("X")));
+  auto *ImportedX = Import(FromX, Lang_CXX11);
+  EXPECT_FALSE(ImportedX);
----------------
balazske wrote:

This test should pass in the previous code too. This is because all of the declarations are added to the primary context at the lookup table (before the changes), `struct X` should be added to `a` already in the `ToTU`. This test is added to ensure that it works with the new code too.

https://github.com/llvm/llvm-project/pull/118466


More information about the cfe-commits mailing list