forked from OSchip/llvm-project
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:
parent
4d54e543ab
commit
3d05c56ef2
|
@ -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
|
||||
|
|
|
@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
|
|||
|
||||
add_clang_unittest(ClangCodeGenTests
|
||||
BufferSourceTest.cpp
|
||||
IncrementalProcessingTest.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(ClangCodeGenTests
|
||||
|
|
Loading…
Reference in New Issue