Skip to content
Snippets Groups Projects
Commit b1d67d0c authored by Robert Lytton's avatar Robert Lytton
Browse files

Fix '-main-file-name <name>' so that it is used for the ModuleID.

Summary:
Previously, you could not specify the original file name when passing a preprocessed file into the compiler
Now you can use 'clang -Xclang -main-file-name -Xclang <original file name> ...'
Or 'clang -cc1 -main-file-name <original file name> ...'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209503 91177308-0d34-0410-b5e6-96231b3b80d8
parent 41a49d92
No related branches found
No related tags found
No related merge requests found
......@@ -551,9 +551,12 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI,
LinkModuleToUse = ModuleOrErr.get();
}
StringRef MainFileName = getCompilerInstance().getCodeGenOpts().MainFileName;
if (MainFileName.empty())
MainFileName = InFile;
BEConsumer = new BackendConsumer(BA, CI.getDiagnostics(), CI.getCodeGenOpts(),
CI.getTargetOpts(), CI.getLangOpts(),
CI.getFrontendOpts().ShowTimers, InFile,
CI.getFrontendOpts().ShowTimers, MainFileName,
LinkModuleToUse, OS.release(), *VMContext);
return BEConsumer;
}
......
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -o - %s -main-file-name some.name | FileCheck -check-prefix NAMED %s
// CHECK: ; ModuleID = '{{.*}}main-file-name.c'
// NAMED: ; ModuleID = 'some.name'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment