[clang] f77d115 - [clang] Move `ApplyHeaderSearchOptions` from Frontend to Lex

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 11 08:57:46 PST 2022


Author: Jan Svoboda
Date: 2022-01-11T17:57:40+01:00
New Revision: f77d115cc136585f39d30a78c741eb296f9e804d

URL: https://github.com/llvm/llvm-project/commit/f77d115cc136585f39d30a78c741eb296f9e804d
DIFF: https://github.com/llvm/llvm-project/commit/f77d115cc136585f39d30a78c741eb296f9e804d.diff

LOG: [clang] Move `ApplyHeaderSearchOptions` from Frontend to Lex

In D116750, the `clangFrontend` library was added as a dependency of `LexTests` in order to make `clang::ApplyHeaderSearchOptions()` available. This increased the number of TUs the test depends on.

This patch moves the function into `clangLex` and removes dependency of `LexTests` on `clangFrontend`.

Reviewed By: thakis

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

Added: 
    clang/lib/Lex/InitHeaderSearch.cpp

Modified: 
    clang/include/clang/Frontend/Utils.h
    clang/include/clang/Lex/HeaderSearch.h
    clang/lib/Frontend/CMakeLists.txt
    clang/lib/Lex/CMakeLists.txt
    clang/unittests/Lex/CMakeLists.txt
    clang/unittests/Lex/HeaderSearchTest.cpp

Removed: 
    clang/lib/Frontend/InitHeaderSearch.cpp


################################################################################
diff  --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h
index da2d79af2ebaa..a05584bfe5514 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -32,12 +32,6 @@
 #include <utility>
 #include <vector>
 
-namespace llvm {
-
-class Triple;
-
-} // namespace llvm
-
 namespace clang {
 
 class ASTReader;
@@ -46,20 +40,11 @@ class CompilerInvocation;
 class DiagnosticsEngine;
 class ExternalSemaSource;
 class FrontendOptions;
-class HeaderSearch;
-class HeaderSearchOptions;
-class LangOptions;
 class PCHContainerReader;
 class Preprocessor;
 class PreprocessorOptions;
 class PreprocessorOutputOptions;
 
-/// Apply the header search options to get given HeaderSearch object.
-void ApplyHeaderSearchOptions(HeaderSearch &HS,
-                              const HeaderSearchOptions &HSOpts,
-                              const LangOptions &Lang,
-                              const llvm::Triple &triple);
-
 /// InitializePreprocessor - Initialize the preprocessor getting it and the
 /// environment ready to process a single file.
 void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts,

diff  --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index 5507401f608a5..0b7ada8f9449c 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -34,6 +34,12 @@
 #include <utility>
 #include <vector>
 
+namespace llvm {
+
+class Triple;
+
+} // namespace llvm
+
 namespace clang {
 
 class DiagnosticsEngine;
@@ -853,6 +859,12 @@ class HeaderSearch {
                                         bool IsSystem, bool IsFramework);
 };
 
+/// Apply the header search options to get given HeaderSearch object.
+void ApplyHeaderSearchOptions(HeaderSearch &HS,
+                              const HeaderSearchOptions &HSOpts,
+                              const LangOptions &Lang,
+                              const llvm::Triple &triple);
+
 } // namespace clang
 
 #endif // LLVM_CLANG_LEX_HEADERSEARCH_H

diff  --git a/clang/lib/Frontend/CMakeLists.txt b/clang/lib/Frontend/CMakeLists.txt
index 90422855bd059..ca4ad8b2dab2e 100644
--- a/clang/lib/Frontend/CMakeLists.txt
+++ b/clang/lib/Frontend/CMakeLists.txt
@@ -24,7 +24,6 @@ add_clang_library(clangFrontend
   FrontendActions.cpp
   FrontendOptions.cpp
   HeaderIncludeGen.cpp
-  InitHeaderSearch.cpp
   InitPreprocessor.cpp
   LayoutOverrideSource.cpp
   LogDiagnosticPrinter.cpp

diff  --git a/clang/lib/Lex/CMakeLists.txt b/clang/lib/Lex/CMakeLists.txt
index d77e6ddb66a07..44f0149628c88 100644
--- a/clang/lib/Lex/CMakeLists.txt
+++ b/clang/lib/Lex/CMakeLists.txt
@@ -6,6 +6,7 @@ add_clang_library(clangLex
   DependencyDirectivesSourceMinimizer.cpp
   HeaderMap.cpp
   HeaderSearch.cpp
+  InitHeaderSearch.cpp
   Lexer.cpp
   LiteralSupport.cpp
   MacroArgs.cpp

diff  --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
similarity index 99%
rename from clang/lib/Frontend/InitHeaderSearch.cpp
rename to clang/lib/Lex/InitHeaderSearch.cpp
index 94ea7baa99c50..ec7b1505c7bf3 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -10,11 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Config/config.h" // C_INCLUDE_DIRS
-#include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"

diff  --git a/clang/unittests/Lex/CMakeLists.txt b/clang/unittests/Lex/CMakeLists.txt
index 3b3e3709ab062..97a4e5e44608c 100644
--- a/clang/unittests/Lex/CMakeLists.txt
+++ b/clang/unittests/Lex/CMakeLists.txt
@@ -15,7 +15,6 @@ clang_target_link_libraries(LexTests
   PRIVATE
   clangAST
   clangBasic
-  clangFrontend
   clangLex
   clangParse
   clangSema

diff  --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp
index b283ff45f2c91..3ea1e6339f50f 100644
--- a/clang/unittests/Lex/HeaderSearchTest.cpp
+++ b/clang/unittests/Lex/HeaderSearchTest.cpp
@@ -15,8 +15,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
-#include "clang/Frontend/Utils.h"
-#include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
 #include "llvm/Support/MemoryBuffer.h"


        


More information about the cfe-commits mailing list