Skip to content

Commit ce2f310

Browse files
committed
[clang][CodeGen] Always use CLANG_VENDOR as a quoted string
In 9a38a72 `ProductId` was assigned from the stringified value of `CLANG_VENDOR`, if that macro was defined. However, `CLANG_VENDOR` is supposed to be a string, as it is defined (optionally) as such in the top-level clang `CMakeLists.txt`. Move the addition of `-DCLANG_VENDOR` to the compiler flags from `clang/lib/Basic/CMakeLists.txt` to the top-level `CMakeLists.txt`, so it is consistent across the whole clang codebase. Then remove the stringification from `CodeGenModule.cpp`, to make it work correctly. Fixes: 9a38a72
1 parent 92fc4b4 commit ce2f310

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

clang/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch")
241241
set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
242242
"Vendor-specific text for showing with version information.")
243243

244+
if(CLANG_VENDOR)
245+
add_definitions(-DCLANG_VENDOR="${CLANG_VENDOR}")
246+
endif()
247+
244248
set(CLANG_REPOSITORY_STRING "" CACHE STRING
245249
"Vendor-specific text for showing the repository the source is taken from.")
246250

clang/lib/Basic/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ set_source_files_properties("${version_inc}"
4949
PROPERTIES GENERATED TRUE
5050
HEADER_FILE_ONLY TRUE)
5151

52-
if(CLANG_VENDOR)
53-
set_source_files_properties(Version.cpp
54-
PROPERTIES COMPILE_DEFINITIONS "CLANG_VENDOR=\"${CLANG_VENDOR} \"")
55-
endif()
56-
5752
add_clang_library(clangBasic
5853
Attributes.cpp
5954
Builtins.cpp

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ void CodeGenModule::Release() {
997997
uint32_t(CLANG_VERSION_PATCHLEVEL));
998998
std::string ProductId;
999999
#ifdef CLANG_VENDOR
1000-
ProductId = #CLANG_VENDOR;
1000+
ProductId = CLANG_VENDOR;
10011001
#else
10021002
ProductId = "clang";
10031003
#endif

0 commit comments

Comments
 (0)