diff options
author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-08-27 11:27:30 +0000 |
---|---|---|
committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-08-27 11:27:30 +0000 |
commit | 3d05c56ef25ee3d7cf1741c226a60c4bc6d6dd1a (patch) | |
tree | daecfa517c40a159955f47623ff24cae170cf996 /clang/lib/CodeGen/CGDeclCXX.cpp | |
parent | 4d54e543abd5d0a8b0a321f8c292252f4895693a (diff) | |
download | bcm5719-llvm-3d05c56ef25ee3d7cf1741c226a60c4bc6d6dd1a.tar.gz bcm5719-llvm-3d05c56ef25ee3d7cf1741c226a60c4bc6d6dd1a.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CGDeclCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDeclCXX.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 98d9e364d9c..4db207cc2da 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -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 |