[clang][Index][NFC] Carve out USRGeneration from clangIndex (#185499)
Previously, USRGeneration was implemented by clangIndex. However, that poses too broad library layering constraints on the ever growing set of users of a tiny component of it, USRGeneration. This PR splits that into a small library, called: clangUnifiedSymbolResolution Anyone needing USRGeneration could simply link against this without pulling in everything from clangIndex. --- Importantly, clangIndex linked against clangFrontend to define its FrontendAction, and use some ASTUnit APIs. Some users may want to use USRGeneration but NOT depend on clangFrontend. This new clangUnifiedSymbolResolution library would solve such circular dependencies. PS: There were quite a few cases where libraries could just link against clangUnifiedSymbolResolution without linking to clangIndex. I've simplified those cases in this PR, to keep link deps minimal.
This commit is contained in:
parent
5e4f1e7b48
commit
65cb738ff4
@ -32,10 +32,10 @@ clang_target_link_libraries(clangDoc
|
||||
clangASTMatchers
|
||||
clangBasic
|
||||
clangFrontend
|
||||
clangIndex
|
||||
clangLex
|
||||
clangTooling
|
||||
clangToolingCore
|
||||
clangUnifiedSymbolResolution
|
||||
)
|
||||
|
||||
target_link_libraries(clangDoc
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#include "Mapper.h"
|
||||
#include "Serialize.h"
|
||||
#include "clang/AST/Comment.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/Support/Mutex.h"
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
#include "clang/AST/DeclFriend.h"
|
||||
#include "clang/AST/ExprConcepts.h"
|
||||
#include "clang/AST/Mangle.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Support/SHA1.h"
|
||||
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/Sema/HeuristicResolver.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
||||
@ -177,6 +177,7 @@ clang_target_link_libraries(clangDaemon
|
||||
clangToolingInclusions
|
||||
clangToolingInclusionsStdlib
|
||||
clangToolingSyntax
|
||||
clangUnifiedSymbolResolution
|
||||
)
|
||||
|
||||
target_link_libraries(clangDaemon
|
||||
|
||||
@ -10,8 +10,8 @@
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/Sema/CodeCompleteConsumer.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
|
||||
@ -49,10 +49,10 @@
|
||||
#include "clang/Index/IndexSymbol.h"
|
||||
#include "clang/Index/IndexingAction.h"
|
||||
#include "clang/Index/IndexingOptions.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "clang/Sema/HeuristicResolver.h"
|
||||
#include "clang/Tooling/Syntax/Tokens.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include "clang/ExtractAPI/API.h"
|
||||
#include "clang/ExtractAPI/DeclarationFragments.h"
|
||||
#include "clang/ExtractAPI/TypedefUnderlyingTypeResolver.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_INDEX_USRGENERATION_H
|
||||
#define LLVM_CLANG_INDEX_USRGENERATION_H
|
||||
#ifndef LLVM_CLANG_UNIFIEDSYMBOLRESOLUTION_USRGENERATION_H
|
||||
#define LLVM_CLANG_UNIFIEDSYMBOLRESOLUTION_USRGENERATION_H
|
||||
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
@ -101,4 +101,4 @@ bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS);
|
||||
} // namespace index
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_INDEX_USRGENERATION_H
|
||||
#endif // LLVM_CLANG_UNIFIEDSYMBOLRESOLUTION_USRGENERATION_H
|
||||
@ -13,7 +13,7 @@
|
||||
#include "clang/Analysis/Scalable/ASTEntityMapping.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/Analysis/Scalable/Model/BuildNamespace.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
|
||||
namespace clang::ssaf {
|
||||
|
||||
@ -26,9 +26,9 @@ add_clang_library(clangAnalysisScalable
|
||||
clangAST
|
||||
clangASTMatchers
|
||||
clangBasic
|
||||
clangIndex
|
||||
clangLex
|
||||
clangFrontend
|
||||
clangUnifiedSymbolResolution
|
||||
|
||||
DEPENDS
|
||||
)
|
||||
|
||||
@ -30,6 +30,7 @@ if(CLANG_INCLUDE_TESTS)
|
||||
endif()
|
||||
add_subdirectory(Interpreter)
|
||||
add_subdirectory(Support)
|
||||
add_subdirectory(UnifiedSymbolResolution)
|
||||
|
||||
if(CLANG_ENABLE_CIR)
|
||||
add_subdirectory(CIR)
|
||||
|
||||
@ -11,5 +11,5 @@ add_clang_library(clangCrossTU
|
||||
clangBasic
|
||||
clangDriver
|
||||
clangFrontend
|
||||
clangIndex
|
||||
clangUnifiedSymbolResolution
|
||||
)
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "clang/Frontend/ASTUnit.h"
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
#include "clang/Frontend/TextDiagnosticPrinter.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
|
||||
@ -15,7 +15,7 @@ add_clang_library(clangExtractAPI
|
||||
clangAST
|
||||
clangBasic
|
||||
clangFrontend
|
||||
clangIndex
|
||||
clangInstallAPI
|
||||
clangLex
|
||||
clangUnifiedSymbolResolution
|
||||
)
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/ExtractAPI/TypedefUnderlyingTypeResolver.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
@ -30,12 +30,12 @@
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
#include "clang/Frontend/FrontendOptions.h"
|
||||
#include "clang/Frontend/MultiplexConsumer.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/InstallAPI/HeaderFile.h"
|
||||
#include "clang/Lex/MacroInfo.h"
|
||||
#include "clang/Lex/PPCallbacks.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "clang/Lex/PreprocessorOptions.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include "clang/ExtractAPI/TypedefUnderlyingTypeResolver.h"
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
|
||||
using namespace clang;
|
||||
using namespace extractapi;
|
||||
|
||||
@ -12,7 +12,6 @@ add_clang_library(clangIndex
|
||||
IndexingContext.cpp
|
||||
IndexSymbol.cpp
|
||||
IndexTypeSourceInfo.cpp
|
||||
USRGeneration.cpp
|
||||
|
||||
ADDITIONAL_HEADERS
|
||||
IndexingContext.h
|
||||
@ -26,6 +25,7 @@ add_clang_library(clangIndex
|
||||
clangSema
|
||||
clangSerialization
|
||||
clangToolingCore
|
||||
clangUnifiedSymbolResolution
|
||||
|
||||
DEPENDS
|
||||
omp_gen
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Format/Format.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/TinyPtrVector.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
@ -61,10 +61,10 @@ add_clang_library(clangStaticAnalyzerCore
|
||||
clangBasic
|
||||
clangCrossTU
|
||||
clangFrontend
|
||||
clangIndex
|
||||
clangLex
|
||||
clangRewrite
|
||||
clangToolingCore
|
||||
clangUnifiedSymbolResolution
|
||||
|
||||
DEPENDS
|
||||
omp_gen
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#include "clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/Analysis/AnalysisDeclContext.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
|
||||
@ -19,10 +19,10 @@ add_clang_library(clangToolingRefactoring
|
||||
clangASTMatchers
|
||||
clangBasic
|
||||
clangFormat
|
||||
clangIndex
|
||||
clangLex
|
||||
clangRewrite
|
||||
clangToolingCore
|
||||
clangUnifiedSymbolResolution
|
||||
|
||||
DEPENDS
|
||||
omp_gen
|
||||
|
||||
@ -15,9 +15,9 @@
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/RecursiveASTVisitor.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
||||
15
clang/lib/UnifiedSymbolResolution/CMakeLists.txt
Normal file
15
clang/lib/UnifiedSymbolResolution/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
Support
|
||||
)
|
||||
|
||||
add_clang_library(clangUnifiedSymbolResolution
|
||||
USRGeneration.cpp
|
||||
|
||||
DEPENDS
|
||||
omp_gen
|
||||
|
||||
LINK_LIBS
|
||||
clangAST
|
||||
clangBasic
|
||||
clangLex
|
||||
)
|
||||
@ -6,7 +6,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/Attr.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
@ -31,6 +31,7 @@ else()
|
||||
clangFrontend
|
||||
clangIndex
|
||||
clangSerialization
|
||||
clangUnifiedSymbolResolution
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@ -16,10 +16,10 @@
|
||||
#include "clang/Frontend/Utils.h"
|
||||
#include "clang/Index/IndexDataConsumer.h"
|
||||
#include "clang/Index/IndexingAction.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "clang/Serialization/ASTReader.h"
|
||||
#include "clang/Serialization/ObjectFilePCHContainerReader.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/PrettyStackTrace.h"
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
#include "CXString.h"
|
||||
#include "CXTranslationUnit.h"
|
||||
#include "clang/Frontend/ASTUnit.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/Lex/PreprocessingRecord.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
|
||||
@ -70,6 +70,7 @@ set(LIBS
|
||||
clangSema
|
||||
clangSerialization
|
||||
clangTooling
|
||||
clangUnifiedSymbolResolution
|
||||
)
|
||||
|
||||
if (HAVE_LIBDL)
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
#include "clang/ExtractAPI/Serialization/SymbolGraphSerializer.h"
|
||||
#include "clang/Frontend/ASTUnit.h"
|
||||
#include "clang/Frontend/FrontendOptions.h"
|
||||
#include "clang/Index/USRGeneration.h"
|
||||
#include "clang/UnifiedSymbolResolution/USRGeneration.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Support/CBindingWrapping.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
@ -30,6 +30,7 @@ add_distinct_clang_unittest(ClangScalableAnalysisTests
|
||||
clangFrontend
|
||||
clangSerialization
|
||||
clangTooling
|
||||
clangUnifiedSymbolResolution
|
||||
LINK_LIBS
|
||||
clangTesting
|
||||
LLVMTestingSupport
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user