Skip to content

Commit b8d6885

Browse files
authored
[NFC] Add explicit #include llvm-config.h where its macros are used, clang part. (#107301)
(this is clang related part) Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects. For example, `clagd` may report even `llvm-config.h` as "no used" in case it defines a macro, that is explicitly used with #ifdef. It is actually amplified with different build configs which use different set of macros.
1 parent 2461bc1 commit b8d6885

File tree

11 files changed

+12
-0
lines changed

11 files changed

+12
-0
lines changed

clang-tools-extra/clangd/Feature.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "Feature.h"
1010
#include "clang/Basic/Version.h"
11+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
1112
#include "llvm/Support/Compiler.h"
1213
#include "llvm/TargetParser/Host.h"
1314

clang-tools-extra/clangd/unittests/ClangdTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/ADT/SmallVector.h"
3030
#include "llvm/ADT/StringMap.h"
3131
#include "llvm/ADT/StringRef.h"
32+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
3233
#include "llvm/Support/Allocator.h"
3334
#include "llvm/Support/Error.h"
3435
#include "llvm/Support/Path.h"

clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/ScopeExit.h"
1919
#include "llvm/ADT/StringExtras.h"
2020
#include "llvm/ADT/StringRef.h"
21+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
2122
#include "llvm/Support/FileSystem.h"
2223
#include "llvm/Support/Path.h"
2324
#include "llvm/Support/Process.h"

clang-tools-extra/clangd/unittests/SerializationTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "support/Logger.h"
1313
#include "clang/Tooling/CompilationDatabase.h"
1414
#include "llvm/ADT/StringExtras.h"
15+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
1516
#include "llvm/Support/Compression.h"
1617
#include "llvm/Support/Error.h"
1718
#include "llvm/Support/ScopedPrinter.h"

clang/include/clang/Interpreter/Value.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#ifndef LLVM_CLANG_INTERPRETER_VALUE_H
3434
#define LLVM_CLANG_INTERPRETER_VALUE_H
3535

36+
#include "llvm/Config/llvm-config.h" // for LLVM_BUILD_LLVM_DYLIB, LLVM_BUILD_SHARED_LIBS
3637
#include "llvm/Support/Compiler.h"
3738
#include <cstdint>
3839

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "clang/Driver/InputInfo.h"
1818
#include "clang/Driver/Options.h"
1919
#include "llvm/ADT/StringExtras.h"
20+
#include "llvm/Config/llvm-config.h" // for LLVM_HOST_TRIPLE
2021
#include "llvm/Option/ArgList.h"
2122
#include "llvm/Support/FileSystem.h"
2223
#include "llvm/Support/FormatAdapters.h"

clang/lib/Driver/ToolChains/MinGW.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Driver/InputInfo.h"
1616
#include "clang/Driver/Options.h"
1717
#include "clang/Driver/SanitizerArgs.h"
18+
#include "llvm/Config/llvm-config.h" // for LLVM_HOST_TRIPLE
1819
#include "llvm/Option/ArgList.h"
1920
#include "llvm/Support/FileSystem.h"
2021
#include "llvm/Support/Path.h"

clang/lib/Driver/ToolChains/WebAssembly.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Driver/Driver.h"
1616
#include "clang/Driver/DriverDiagnostic.h"
1717
#include "clang/Driver/Options.h"
18+
#include "llvm/Config/llvm-config.h" // for LLVM_VERSION_STRING
1819
#include "llvm/Option/ArgList.h"
1920
#include "llvm/Support/FileSystem.h"
2021
#include "llvm/Support/Path.h"

clang/lib/Frontend/FrontendActions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "clang/Serialization/ASTReader.h"
2727
#include "clang/Serialization/ASTWriter.h"
2828
#include "clang/Serialization/ModuleFile.h"
29+
#include "llvm/Config/llvm-config.h" // for LLVM_HOST_TRIPLE
2930
#include "llvm/Support/ErrorHandling.h"
3031
#include "llvm/Support/FileSystem.h"
3132
#include "llvm/Support/MemoryBuffer.h"

clang/tools/driver/driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/ADT/SmallString.h"
3030
#include "llvm/ADT/SmallVector.h"
3131
#include "llvm/ADT/StringSet.h"
32+
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
3233
#include "llvm/Option/ArgList.h"
3334
#include "llvm/Option/OptTable.h"
3435
#include "llvm/Option/Option.h"
@@ -52,6 +53,7 @@
5253
#include <optional>
5354
#include <set>
5455
#include <system_error>
56+
5557
using namespace clang;
5658
using namespace clang::driver;
5759
using namespace llvm::opt;

clang/unittests/Driver/GCCVersionTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "../../lib/Driver/ToolChains/Gnu.h"
14+
#include "llvm/Config/llvm-config.h" // for LLVM_BUILD_LLVM_DYLIB, LLVM_BUILD_SHARED_LIBS
1415
#include "gtest/gtest.h"
1516

1617
// The Generic_GCC class is hidden in dylib/shared library builds, so

0 commit comments

Comments
 (0)