[clang] move ASTImporter into separate library (PR #140913)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 21 08:18:19 PDT 2025
=?utf-8?q?Balázs_Kéri?= <balazs.keri at ericsson.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/140913 at github.com>
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Balázs Kéri (balazske)
<details>
<summary>Changes</summary>
It became necessary to add `Sema` as dependency of `ASTImporter`.
This is needed to implement import of concept related nodes.
`Sema` can not be a dependency of `AST`, but this split of
`ASTImporter` makes it possible to add `Sema` as dependency
and not add `ASTImporter` as dependency of `AST`.
---
Full diff: https://github.com/llvm/llvm-project/pull/140913.diff
24 Files Affected:
- (renamed) clang/include/clang/ASTImporter/ASTImportError.h (+3-3)
- (renamed) clang/include/clang/ASTImporter/ASTImporter.h (+4-4)
- (renamed) clang/include/clang/ASTImporter/ASTImporterLookupTable.h (+3-3)
- (renamed) clang/include/clang/ASTImporter/ASTImporterSharedState.h (+5-5)
- (renamed) clang/include/clang/ASTImporter/ExternalASTMerger.h (+2-2)
- (modified) clang/include/clang/CrossTU/CrossTranslationUnit.h (+1-1)
- (modified) clang/lib/AST/CMakeLists.txt (-3)
- (modified) clang/lib/AST/ExternalASTSource.cpp (+1-1)
- (renamed) clang/lib/ASTImporter/ASTImporter.cpp (+2-2)
- (renamed) clang/lib/ASTImporter/ASTImporterLookupTable.cpp (+1-1)
- (added) clang/lib/ASTImporter/CMakeLists.txt (+18)
- (renamed) clang/lib/ASTImporter/ExternalASTMerger.cpp (+1-1)
- (modified) clang/lib/CMakeLists.txt (+1)
- (modified) clang/lib/CrossTU/CMakeLists.txt (+1)
- (modified) clang/lib/CrossTU/CrossTranslationUnit.cpp (+1-1)
- (modified) clang/lib/Frontend/ASTMerge.cpp (+2-2)
- (modified) clang/lib/Frontend/CMakeLists.txt (+1)
- (modified) clang/lib/Interpreter/CMakeLists.txt (+1)
- (modified) clang/lib/Interpreter/CodeCompletion.cpp (+1-1)
- (modified) clang/tools/clang-import-test/CMakeLists.txt (+1)
- (modified) clang/tools/clang-import-test/clang-import-test.cpp (+2-2)
- (modified) clang/unittests/AST/ASTImporterFixtures.cpp (-2)
- (modified) clang/unittests/AST/ASTImporterFixtures.h (+2-4)
- (modified) clang/unittests/AST/CMakeLists.txt (+1)
``````````diff
diff --git a/clang/include/clang/AST/ASTImportError.h b/clang/include/clang/ASTImporter/ASTImportError.h
similarity index 90%
rename from clang/include/clang/AST/ASTImportError.h
rename to clang/include/clang/ASTImporter/ASTImportError.h
index 728314ca0936e..efc279327dc2d 100644
--- a/clang/include/clang/AST/ASTImportError.h
+++ b/clang/include/clang/ASTImporter/ASTImportError.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
-#define LLVM_CLANG_AST_ASTIMPORTERROR_H
+#ifndef LLVM_CLANG_ASTIMPORTER_ASTIMPORTERROR_H
+#define LLVM_CLANG_ASTIMPORTER_ASTIMPORTERROR_H
#include "llvm/Support/Error.h"
@@ -47,4 +47,4 @@ class ASTImportError : public llvm::ErrorInfo<ASTImportError> {
} // namespace clang
-#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H
+#endif // LLVM_CLANG_ASTIMPORTER_ASTIMPORTERROR_H
diff --git a/clang/include/clang/AST/ASTImporter.h b/clang/include/clang/ASTImporter/ASTImporter.h
similarity index 99%
rename from clang/include/clang/AST/ASTImporter.h
rename to clang/include/clang/ASTImporter/ASTImporter.h
index c40b92666a2ff..78e44c2fcd92e 100644
--- a/clang/include/clang/AST/ASTImporter.h
+++ b/clang/include/clang/ASTImporter/ASTImporter.h
@@ -11,16 +11,16 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_AST_ASTIMPORTER_H
-#define LLVM_CLANG_AST_ASTIMPORTER_H
+#ifndef LLVM_CLANG_ASTIMPORTER_ASTIMPORTER_H
+#define LLVM_CLANG_ASTIMPORTER_ASTIMPORTER_H
-#include "clang/AST/ASTImportError.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/TemplateName.h"
#include "clang/AST/Type.h"
+#include "clang/ASTImporter/ASTImportError.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
@@ -597,4 +597,4 @@ class TypeSourceInfo;
} // namespace clang
-#endif // LLVM_CLANG_AST_ASTIMPORTER_H
+#endif // LLVM_CLANG_ASTIMPORTER_ASTIMPORTER_H
diff --git a/clang/include/clang/AST/ASTImporterLookupTable.h b/clang/include/clang/ASTImporter/ASTImporterLookupTable.h
similarity index 95%
rename from clang/include/clang/AST/ASTImporterLookupTable.h
rename to clang/include/clang/ASTImporter/ASTImporterLookupTable.h
index 2dbc44c5dcd44..c821edec95cc8 100644
--- a/clang/include/clang/AST/ASTImporterLookupTable.h
+++ b/clang/include/clang/ASTImporter/ASTImporterLookupTable.h
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
-#define LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
+#ifndef LLVM_CLANG_ASTIMPORTER_ASTIMPORTERLOOKUPTABLE_H
+#define LLVM_CLANG_ASTIMPORTER_ASTIMPORTERLOOKUPTABLE_H
#include "clang/AST/DeclBase.h" // lookup_result
#include "clang/AST/DeclarationName.h"
@@ -90,4 +90,4 @@ class ASTImporterLookupTable {
} // namespace clang
-#endif // LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
+#endif // LLVM_CLANG_ASTIMPORTER_ASTIMPORTERLOOKUPTABLE_H
diff --git a/clang/include/clang/AST/ASTImporterSharedState.h b/clang/include/clang/ASTImporter/ASTImporterSharedState.h
similarity index 90%
rename from clang/include/clang/AST/ASTImporterSharedState.h
rename to clang/include/clang/ASTImporter/ASTImporterSharedState.h
index 446d7ee61ea58..4f6dd3a3169ea 100644
--- a/clang/include/clang/AST/ASTImporterSharedState.h
+++ b/clang/include/clang/ASTImporter/ASTImporterSharedState.h
@@ -11,12 +11,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
-#define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
+#ifndef LLVM_CLANG_ASTIMPORTER_ASTIMPORTERSHAREDSTATE_H
+#define LLVM_CLANG_ASTIMPORTER_ASTIMPORTERSHAREDSTATE_H
-#include "clang/AST/ASTImportError.h"
-#include "clang/AST/ASTImporterLookupTable.h"
#include "clang/AST/Decl.h"
+#include "clang/ASTImporter/ASTImportError.h"
+#include "clang/ASTImporter/ASTImporterLookupTable.h"
#include "llvm/ADT/DenseMap.h"
#include <optional>
@@ -84,4 +84,4 @@ class ASTImporterSharedState {
};
} // namespace clang
-#endif // LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
+#endif // LLVM_CLANG_ASTIMPORTER_ASTIMPORTERSHAREDSTATE_H
diff --git a/clang/include/clang/AST/ExternalASTMerger.h b/clang/include/clang/ASTImporter/ExternalASTMerger.h
similarity index 98%
rename from clang/include/clang/AST/ExternalASTMerger.h
rename to clang/include/clang/ASTImporter/ExternalASTMerger.h
index 2c6f2a941311b..734db752965b3 100644
--- a/clang/include/clang/AST/ExternalASTMerger.h
+++ b/clang/include/clang/ASTImporter/ExternalASTMerger.h
@@ -13,9 +13,9 @@
#ifndef LLVM_CLANG_AST_EXTERNALASTMERGER_H
#define LLVM_CLANG_AST_EXTERNALASTMERGER_H
-#include "clang/AST/ASTImporter.h"
-#include "clang/AST/ASTImporterSharedState.h"
#include "clang/AST/ExternalASTSource.h"
+#include "clang/ASTImporter/ASTImporter.h"
+#include "clang/ASTImporter/ASTImporterSharedState.h"
#include "llvm/Support/raw_ostream.h"
namespace clang {
diff --git a/clang/include/clang/CrossTU/CrossTranslationUnit.h b/clang/include/clang/CrossTU/CrossTranslationUnit.h
index e6b608a10e61b..029d3fa315959 100644
--- a/clang/include/clang/CrossTU/CrossTranslationUnit.h
+++ b/clang/include/clang/CrossTU/CrossTranslationUnit.h
@@ -14,7 +14,7 @@
#ifndef LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H
#define LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H
-#include "clang/AST/ASTImporterSharedState.h"
+#include "clang/ASTImporter/ASTImporterSharedState.h"
#include "clang/Analysis/MacroExpansionContext.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index b5cd14b915673..fc4dd9da828a0 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -27,8 +27,6 @@ add_clang_library(clangAST
ASTContext.cpp
ASTDiagnostic.cpp
ASTDumper.cpp
- ASTImporter.cpp
- ASTImporterLookupTable.cpp
ASTStructuralEquivalence.cpp
ASTTypeTraits.cpp
AttrDocTable.cpp
@@ -63,7 +61,6 @@ add_clang_library(clangAST
ExprConstant.cpp
ExprCXX.cpp
ExprObjC.cpp
- ExternalASTMerger.cpp
ExternalASTSource.cpp
FormatString.cpp
InheritViz.cpp
diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp
index e8c1004089713..1c7ce10f7c80b 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
+#include "clang/AST/ExternalASTSource.h"
#include "clang/Basic/ASTSourceDescriptor.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/ASTImporter/ASTImporter.cpp
similarity index 99%
rename from clang/lib/AST/ASTImporter.cpp
rename to clang/lib/ASTImporter/ASTImporter.cpp
index b481ad5df667e..54f6bd928ec70 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/ASTImporter/ASTImporter.cpp
@@ -11,10 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/AST/ASTImporter.h"
+#include "clang/ASTImporter/ASTImporter.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
-#include "clang/AST/ASTImporterSharedState.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/ASTStructuralEquivalence.h"
#include "clang/AST/Attr.h"
@@ -45,6 +44,7 @@
#include "clang/AST/TypeLoc.h"
#include "clang/AST/TypeVisitor.h"
#include "clang/AST/UnresolvedSet.h"
+#include "clang/ASTImporter/ASTImporterSharedState.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/ExceptionSpecificationType.h"
#include "clang/Basic/FileManager.h"
diff --git a/clang/lib/AST/ASTImporterLookupTable.cpp b/clang/lib/ASTImporter/ASTImporterLookupTable.cpp
similarity index 99%
rename from clang/lib/AST/ASTImporterLookupTable.cpp
rename to clang/lib/ASTImporter/ASTImporterLookupTable.cpp
index 4ed3198d7ea62..7dda8c3a090ec 100644
--- a/clang/lib/AST/ASTImporterLookupTable.cpp
+++ b/clang/lib/ASTImporter/ASTImporterLookupTable.cpp
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/AST/ASTImporterLookupTable.h"
+#include "clang/ASTImporter/ASTImporterLookupTable.h"
#include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "llvm/Support/FormatVariadic.h"
diff --git a/clang/lib/ASTImporter/CMakeLists.txt b/clang/lib/ASTImporter/CMakeLists.txt
new file mode 100644
index 0000000000000..c8829d6850666
--- /dev/null
+++ b/clang/lib/ASTImporter/CMakeLists.txt
@@ -0,0 +1,18 @@
+set(LLVM_LINK_COMPONENTS
+ Core
+ Support
+ )
+
+add_clang_library(clangASTImporter
+ ASTImporter.cpp
+ ASTImporterLookupTable.cpp
+ ExternalASTMerger.cpp
+
+ LINK_LIBS
+ clangAST
+ clangBasic
+
+ DEPENDS
+ ClangAttrDocTable
+ Opcodes
+ )
diff --git a/clang/lib/AST/ExternalASTMerger.cpp b/clang/lib/ASTImporter/ExternalASTMerger.cpp
similarity index 99%
rename from clang/lib/AST/ExternalASTMerger.cpp
rename to clang/lib/ASTImporter/ExternalASTMerger.cpp
index 1c903b5104bf4..f2fe1987d2e34 100644
--- a/clang/lib/AST/ExternalASTMerger.cpp
+++ b/clang/lib/ASTImporter/ExternalASTMerger.cpp
@@ -16,7 +16,7 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
-#include "clang/AST/ExternalASTMerger.h"
+#include "clang/ASTImporter/ExternalASTMerger.h"
using namespace clang;
diff --git a/clang/lib/CMakeLists.txt b/clang/lib/CMakeLists.txt
index 4f2218b583e41..c6d5992acbf01 100644
--- a/clang/lib/CMakeLists.txt
+++ b/clang/lib/CMakeLists.txt
@@ -4,6 +4,7 @@ add_subdirectory(APINotes)
add_subdirectory(Lex)
add_subdirectory(Parse)
add_subdirectory(AST)
+add_subdirectory(ASTImporter)
add_subdirectory(ASTMatchers)
add_subdirectory(CrossTU)
add_subdirectory(Sema)
diff --git a/clang/lib/CrossTU/CMakeLists.txt b/clang/lib/CrossTU/CMakeLists.txt
index 3349fc283925d..82bae8adddf9b 100644
--- a/clang/lib/CrossTU/CMakeLists.txt
+++ b/clang/lib/CrossTU/CMakeLists.txt
@@ -8,6 +8,7 @@ add_clang_library(clangCrossTU
LINK_LIBS
clangAST
+ clangASTImporter
clangBasic
clangFrontend
clangIndex
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index ef395f497216c..c8cce79bb9bc5 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -10,9 +10,9 @@
//
//===----------------------------------------------------------------------===//
#include "clang/CrossTU/CrossTranslationUnit.h"
-#include "clang/AST/ASTImporter.h"
#include "clang/AST/Decl.h"
#include "clang/AST/ParentMapContext.h"
+#include "clang/ASTImporter/ASTImporter.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CrossTU/CrossTUDiagnostic.h"
#include "clang/Frontend/ASTUnit.h"
diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp
index b6b06440bc3f8..a30357976336e 100644
--- a/clang/lib/Frontend/ASTMerge.cpp
+++ b/clang/lib/Frontend/ASTMerge.cpp
@@ -8,8 +8,8 @@
#include "clang/Frontend/ASTUnit.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
-#include "clang/AST/ASTImporter.h"
-#include "clang/AST/ASTImporterSharedState.h"
+#include "clang/ASTImporter/ASTImporter.h"
+#include "clang/ASTImporter/ASTImporterSharedState.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
diff --git a/clang/lib/Frontend/CMakeLists.txt b/clang/lib/Frontend/CMakeLists.txt
index a916667208845..67b4cf6e4b16f 100644
--- a/clang/lib/Frontend/CMakeLists.txt
+++ b/clang/lib/Frontend/CMakeLists.txt
@@ -50,6 +50,7 @@ add_clang_library(clangFrontend
LINK_LIBS
clangAPINotes
clangAST
+ clangASTImporter
clangBasic
clangDriver
clangEdit
diff --git a/clang/lib/Interpreter/CMakeLists.txt b/clang/lib/Interpreter/CMakeLists.txt
index bf70cdfbee01e..13460e75ada7a 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -37,6 +37,7 @@ add_clang_library(clangInterpreter
LINK_LIBS
clangAST
+ clangASTImporter
clangAnalysis
clangBasic
clangCodeGen
diff --git a/clang/lib/Interpreter/CodeCompletion.cpp b/clang/lib/Interpreter/CodeCompletion.cpp
index aa90663538128..588cb747ffdd9 100644
--- a/clang/lib/Interpreter/CodeCompletion.cpp
+++ b/clang/lib/Interpreter/CodeCompletion.cpp
@@ -11,10 +11,10 @@
//===----------------------------------------------------------------------===//
#include "clang/Interpreter/CodeCompletion.h"
-#include "clang/AST/ASTImporter.h"
#include "clang/AST/DeclLookups.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/ExternalASTSource.h"
+#include "clang/ASTImporter/ASTImporter.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
diff --git a/clang/tools/clang-import-test/CMakeLists.txt b/clang/tools/clang-import-test/CMakeLists.txt
index 6b70bebd8850e..69a9140d52cd9 100644
--- a/clang/tools/clang-import-test/CMakeLists.txt
+++ b/clang/tools/clang-import-test/CMakeLists.txt
@@ -12,6 +12,7 @@ add_clang_executable(clang-import-test
set(CLANG_IMPORT_TEST_LIB_DEPS
clangAST
+ clangASTImporter
clangBasic
clangCodeGen
clangDriver
diff --git a/clang/tools/clang-import-test/clang-import-test.cpp b/clang/tools/clang-import-test/clang-import-test.cpp
index 765f342947046..9b2e2cc3f161b 100644
--- a/clang/tools/clang-import-test/clang-import-test.cpp
+++ b/clang/tools/clang-import-test/clang-import-test.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
-#include "clang/AST/ASTImporter.h"
#include "clang/AST/DeclObjC.h"
-#include "clang/AST/ExternalASTMerger.h"
+#include "clang/ASTImporter/ASTImporter.h"
+#include "clang/ASTImporter/ExternalASTMerger.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/IdentifierTable.h"
diff --git a/clang/unittests/AST/ASTImporterFixtures.cpp b/clang/unittests/AST/ASTImporterFixtures.cpp
index 897b370dd3cdc..dffd679142960 100644
--- a/clang/unittests/AST/ASTImporterFixtures.cpp
+++ b/clang/unittests/AST/ASTImporterFixtures.cpp
@@ -13,8 +13,6 @@
#include "ASTImporterFixtures.h"
-#include "clang/AST/ASTImporter.h"
-#include "clang/AST/ASTImporterSharedState.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Tooling/Tooling.h"
diff --git a/clang/unittests/AST/ASTImporterFixtures.h b/clang/unittests/AST/ASTImporterFixtures.h
index 87e62cbda422a..7982207ccd0af 100644
--- a/clang/unittests/AST/ASTImporterFixtures.h
+++ b/clang/unittests/AST/ASTImporterFixtures.h
@@ -16,8 +16,8 @@
#include "gmock/gmock.h"
-#include "clang/AST/ASTImporter.h"
-#include "clang/AST/ASTImporterSharedState.h"
+#include "clang/ASTImporter/ASTImporter.h"
+#include "clang/ASTImporter/ASTImporterSharedState.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Testing/CommandLineArgs.h"
#include "llvm/Support/Error.h"
@@ -30,8 +30,6 @@
namespace clang {
-class ASTImporter;
-class ASTImporterSharedState;
class ASTUnit;
namespace ast_matchers {
diff --git a/clang/unittests/AST/CMakeLists.txt b/clang/unittests/AST/CMakeLists.txt
index f27d34e8a0719..257bebc6c3c58 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -38,6 +38,7 @@ add_clang_unittest(ASTTests
UnresolvedSetTest.cpp
CLANG_LIBS
clangAST
+ clangASTImporter
clangASTMatchers
clangBasic
clangFrontend
``````````
</details>
https://github.com/llvm/llvm-project/pull/140913
More information about the cfe-commits
mailing list