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!

llvm-svn: 311844
This commit is contained in:
Vassil Vassilev 2017-08-27 11:27:30 +00:00
parent 4d54e543ab
commit 3d05c56ef2
2 changed files with 6 additions and 9 deletions

View File

@ -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

View File

@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
add_clang_unittest(ClangCodeGenTests
BufferSourceTest.cpp
IncrementalProcessingTest.cpp
)
target_link_libraries(ClangCodeGenTests