Move MainFileName option variable into CodeGenOptions instead of LangOptions.

llvm-svn: 90051
This commit is contained in:
Daniel Dunbar
2009-11-29 02:38:34 +00:00
parent 58ccf88c36
commit 9eac065e67
6 changed files with 38 additions and 41 deletions

View File

@@ -101,11 +101,6 @@ private:
// on making enums signed. Set/Query this
// value using accessors.
/// The user provided name for the "main file", if non-null. This is
/// useful in situations where the input file name does not match
/// the original input file, for example with -save-temps.
const char *MainFileName;
public:
unsigned InstantiationDepth; // Maximum template instantiation depth.
@@ -164,8 +159,6 @@ public:
CharIsSigned = 1;
ShortWChar = 0;
MainFileName = 0;
}
GCMode getGCMode() const { return (GCMode) GC; }
@@ -178,9 +171,6 @@ public:
StackProtector = static_cast<unsigned>(m);
}
const char *getMainFileName() const { return MainFileName; }
void setMainFileName(const char *Name) { MainFileName = Name; }
VisibilityMode getVisibilityMode() const {
return (VisibilityMode) SymbolVisibility;
}

View File

@@ -52,6 +52,11 @@ public:
/// Inlining - The kind of inlining to perform.
InliningMethod Inlining;
/// The user provided name for the "main file", if non-empty. This is useful
/// in situations where the input file name does not match the original input
/// file, for example with -save-temps.
std::string MainFileName;
public:
CodeGenOptions() {
OptimizationLevel = 0;

View File

@@ -95,10 +95,10 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
// file at a time.
bool isMain = false;
const LangOptions &LO = M->getLangOptions();
const char *MainFileName = LO.getMainFileName();
const CodeGenOptions &CGO = M->getCodeGenOpts();
if (isMainCompileUnitCreated == false) {
if (MainFileName) {
if (!strcmp(AbsFileName.getLast().c_str(), MainFileName))
if (!CGO.MainFileName.empty()) {
if (AbsFileName.getLast() == CGO.MainFileName)
isMain = true;
} else {
if (Loc.isValid() && SM.isFromMainFile(Loc))

View File

@@ -172,6 +172,8 @@ static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args) {
Opts.SimplifyLibCalls = 1;
Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize);
Opts.MainFileName = getLastArgValue(Args, OPT_main_file_name);
// FIXME: Implement!
// FIXME: Eliminate this dependency?
// if (Lang.NoBuiltin)

View File

@@ -111,6 +111,10 @@ static void CodeGenOptsToArgs(const CodeGenOptions &Opts,
Res.push_back("-Os");
} else if (Opts.OptimizationLevel != 0)
Res.push_back("-O" + llvm::utostr(Opts.OptimizationLevel));
if (!Opts.MainFileName.empty()) {
Res.push_back("-main-file-name");
Res.push_back(Opts.MainFileName);
}
// SimplifyLibCalls is only derived.
// TimePasses is only derived.
// UnitAtATime is unused.
@@ -453,10 +457,6 @@ static void LangOptsToArgs(const LangOptions &Opts,
Res.push_back("-stack-protector");
Res.push_back(llvm::utostr(Opts.getStackProtectorMode()));
}
if (Opts.getMainFileName()) {
Res.push_back("-main-file-name");
Res.push_back(Opts.getMainFileName());
}
if (Opts.InstantiationDepth != DefaultLangOpts.InstantiationDepth) {
Res.push_back("-ftemplate-depth");
Res.push_back(llvm::utostr(Opts.InstantiationDepth));

View File

@@ -141,6 +141,10 @@ static llvm::cl::opt<bool>
GenerateDebugInfo("g",
llvm::cl::desc("Generate source level debug information"));
static llvm::cl::opt<std::string>
MainFileName("main-file-name",
llvm::cl::desc("Main file name to use for debug info"));
static llvm::cl::opt<bool>
NoCommon("fno-common",
llvm::cl::desc("Compile common globals like normal definitions"),
@@ -497,10 +501,6 @@ MSExtensions("fms-extensions",
llvm::cl::desc("Accept some non-standard constructs used in "
"Microsoft header files "));
static llvm::cl::opt<std::string>
MainFileName("main-file-name",
llvm::cl::desc("Main file name to use for debug info"));
static llvm::cl::opt<bool>
NoMathErrno("fno-math-errno",
llvm::cl::desc("Don't require math functions to respect errno"));
@@ -797,6 +797,9 @@ void clang::InitializeCodeGenOptions(CodeGenOptions &Opts,
#ifdef NDEBUG
Opts.VerifyModule = 0;
#endif
if (MainFileName.getPosition())
Opts.MainFileName = MainFileName;
}
void clang::InitializeDependencyOutputOptions(DependencyOutputOptions &Opts) {
@@ -1051,23 +1054,6 @@ void clang::InitializeLangOptions(LangOptions &Options,
Options.LaxVectorConversions = 1;
}
if (ObjCExclusiveGC)
Options.setGCMode(LangOptions::GCOnly);
else if (ObjCEnableGC)
Options.setGCMode(LangOptions::HybridGC);
if (ObjCEnableGCBitmapPrint)
Options.ObjCGCBitmapPrint = 1;
if (AltiVec)
Options.AltiVec = 1;
if (PThread)
Options.POSIXThreads = 1;
Options.setVisibilityMode(SymbolVisibility);
Options.OverflowChecking = OverflowChecking;
if (LangStd == LangStandard::lang_unspecified) {
// Based on the base language, pick one.
switch (IK) {
@@ -1106,6 +1092,23 @@ void clang::InitializeLangOptions(LangOptions &Options,
if (Options.CPlusPlus)
Options.CXXOperatorNames = !NoOperatorNames;
if (ObjCExclusiveGC)
Options.setGCMode(LangOptions::GCOnly);
else if (ObjCEnableGC)
Options.setGCMode(LangOptions::HybridGC);
if (ObjCEnableGCBitmapPrint)
Options.ObjCGCBitmapPrint = 1;
if (AltiVec)
Options.AltiVec = 1;
if (PThread)
Options.POSIXThreads = 1;
Options.setVisibilityMode(SymbolVisibility);
Options.OverflowChecking = OverflowChecking;
// Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
// is specified, or -std is set to a conforming mode.
Options.Trigraphs = !Options.GNUMode;
@@ -1204,9 +1207,6 @@ void clang::InitializeLangOptions(LangOptions &Options,
case 2: Options.setStackProtectorMode(LangOptions::SSPReq); break;
}
}
if (MainFileName.getPosition())
Options.setMainFileName(MainFileName.c_str());
}
void