Remove hack, now that clang pulls the init symbol name from the Module!

This depends on the commit under review here: https://reviews.llvm.org/D34059
This commit is contained in:
Axel Naumann 2017-06-09 18:02:50 +02:00 committed by sftnight
parent 67cceed590
commit 48aa4b9096

View File

@ -527,22 +527,9 @@ namespace cling {
if (!T->isNestedTransaction() && hasCodeGenerator()) {
// The initializers are emitted to the symbol "_GLOBAL__sub_I_" + filename.
// Make that unique!
ASTContext& Context = getCI()->getASTContext();
SourceManager &SM = Context.getSourceManager();
const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID());
FileEntry* NcMainFile = const_cast<FileEntry*>(MainFile);
// Hack to temporarily set the file entry's name to a unique name.
assert(MainFile->getName() == *(const char**)NcMainFile
&& "FileEntry does not start with the name");
StringRef& FileName = *reinterpret_cast<StringRef*>(NcMainFile);
StringRef OldName = FileName;
std::string ModName = getCodeGenerator()->GetModule()->getName().str();
FileName = ModName;
deserT = beginTransaction(CompilationOptions());
// Reset the module builder to clean up global initializers, c'tors, d'tors
getCodeGenerator()->HandleTranslationUnit(Context);
FileName = OldName;
getCodeGenerator()->HandleTranslationUnit(getCI()->getASTContext());
auto PRT = endTransaction(deserT);
commitTransaction(PRT);
deserT = PRT.getPointer();