r311844 - D34059: Get the file name for the symbol from the Module, not the SourceManager.
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 27 04:27:30 PDT 2017
Author: vvassilev
Date: Sun Aug 27 04:27:30 2017
New Revision: 311844
URL: http://llvm.org/viewvc/llvm-project?rev=311844&view=rev
Log:
D34059: Get the file name for the symbol from the Module, not the SourceManager.
This allows multi-module / incremental compilation environments to have unique
initializer symbols.
Patch by Axel Naumann with minor modifications by me!
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/unittests/CodeGen/CMakeLists.txt
Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=311844&r1=311843&r2=311844&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Aug 27 04:27:30 2017
@@ -487,16 +487,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
PrioritizedCXXGlobalInits.clear();
}
- SmallString<128> FileName;
- SourceManager &SM = Context.getSourceManager();
- if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
- // Include the filename in the symbol name. Including "sub_" matches gcc and
- // makes sure these symbols appear lexicographically behind the symbols with
- // priority emitted above.
- FileName = llvm::sys::path::filename(MainFile->getName());
- } else {
+ // Include the filename in the symbol name. Including "sub_" matches gcc and
+ // makes sure these symbols appear lexicographically behind the symbols with
+ // priority emitted above.
+ SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
+ if (FileName.empty())
FileName = "<null>";
- }
for (size_t i = 0; i < FileName.size(); ++i) {
// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=311844&r1=311843&r2=311844&view=diff
==============================================================================
--- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Sun Aug 27 04:27:30 2017
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
add_clang_unittest(ClangCodeGenTests
BufferSourceTest.cpp
+ IncrementalProcessingTest.cpp
)
target_link_libraries(ClangCodeGenTests
More information about the cfe-commits
mailing list