[clang] [clang][ASTImporter] Link FunctionDecl into its DeclContext before importing its body (PR #214009)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 10 06:45:53 PDT 2026
================
@@ -6529,43 +6528,6 @@ TEST_P(ErrorHandlingTest,
EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
}
-// Check a case when a new AST node is created and linked to the AST before
-// encountering the error. The error is set for the counterpart of the nodes in
-// the "from" context.
-TEST_P(ErrorHandlingTest, ErrorHappensAfterNodeIsCreatedAndLinked) {
- TranslationUnitDecl *FromTU = getTuDecl(std::string(R"(
- void f();
- void f() { )") + ErroneousStmt + R"( }
- )",
- Lang_CXX03);
- auto *FromProto = FirstDeclMatcher<FunctionDecl>().match(
- FromTU, functionDecl(hasName("f")));
- auto *FromDef =
- LastDeclMatcher<FunctionDecl>().match(FromTU, functionDecl(hasName("f")));
- FunctionDecl *ImportedProto = Import(FromProto, Lang_CXX03);
- EXPECT_FALSE(ImportedProto); // Could not import.
- // However, we created two nodes in the AST. 1) the fwd decl 2) the
- // definition. The definition is not added to its DC, but the fwd decl is
- // there.
- TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
- EXPECT_EQ(DeclCounter<FunctionDecl>().match(ToTU, functionDecl(hasName("f"))),
- 1u);
----------------
balazske wrote:
This test checks if the error is set at failed import. I would not remove it, only set the count here to 2.
https://github.com/llvm/llvm-project/pull/214009
More information about the cfe-commits
mailing list