[cfe-commits] r90051 - in /cfe/trunk: include/clang/Basic/LangOptions.h include/clang/CodeGen/CodeGenOptions.h lib/CodeGen/CGDebugInfo.cpp lib/Driver/CC1Options.cpp lib/Frontend/CompilerInvocation.cpp tools/clang-cc/Options.cpp
Daniel Dunbar
daniel at zuster.org
Sat Nov 28 18:38:34 PST 2009
Author: ddunbar
Date: Sat Nov 28 20:38:34 2009
New Revision: 90051
URL: http://llvm.org/viewvc/llvm-project?rev=90051&view=rev
Log:
Move MainFileName option variable into CodeGenOptions instead of LangOptions.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/CodeGen/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Driver/CC1Options.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/clang-cc/Options.cpp
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=90051&r1=90050&r2=90051&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Sat Nov 28 20:38:34 2009
@@ -101,11 +101,6 @@
// 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 @@
CharIsSigned = 1;
ShortWChar = 0;
-
- MainFileName = 0;
}
GCMode getGCMode() const { return (GCMode) GC; }
@@ -178,9 +171,6 @@
StackProtector = static_cast<unsigned>(m);
}
- const char *getMainFileName() const { return MainFileName; }
- void setMainFileName(const char *Name) { MainFileName = Name; }
-
VisibilityMode getVisibilityMode() const {
return (VisibilityMode) SymbolVisibility;
}
Modified: cfe/trunk/include/clang/CodeGen/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenOptions.h?rev=90051&r1=90050&r2=90051&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenOptions.h Sat Nov 28 20:38:34 2009
@@ -52,6 +52,11 @@
/// 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;
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=90051&r1=90050&r2=90051&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Nov 28 20:38:34 2009
@@ -95,10 +95,10 @@
// 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))
Modified: cfe/trunk/lib/Driver/CC1Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CC1Options.cpp?rev=90051&r1=90050&r2=90051&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/CC1Options.cpp (original)
+++ cfe/trunk/lib/Driver/CC1Options.cpp Sat Nov 28 20:38:34 2009
@@ -172,6 +172,8 @@
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)
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=90051&r1=90050&r2=90051&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Nov 28 20:38:34 2009
@@ -111,6 +111,10 @@
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 @@
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));
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=90051&r1=90050&r2=90051&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Sat Nov 28 20:38:34 2009
@@ -141,6 +141,10 @@
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 @@
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 @@
#ifdef NDEBUG
Opts.VerifyModule = 0;
#endif
+
+ if (MainFileName.getPosition())
+ Opts.MainFileName = MainFileName;
}
void clang::InitializeDependencyOutputOptions(DependencyOutputOptions &Opts) {
@@ -1051,23 +1054,6 @@
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 @@
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 @@
case 2: Options.setStackProtectorMode(LangOptions::SSPReq); break;
}
}
-
- if (MainFileName.getPosition())
- Options.setMainFileName(MainFileName.c_str());
}
void
More information about the cfe-commits
mailing list