summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2016-04-08 17:42:32 +0000
committerWei Mi <wmi@google.com>2016-04-08 17:42:32 +0000
commit811ff92e1e20bf3f4c7895d5e8d986e5c985fa8e (patch)
tree0abad16ebcd6f59e7ac5b9b422f3cbb96304a61d /clang/lib/Frontend/CompilerInvocation.cpp
parent6d22d8a44a8363ccc84c98c81b29968090f269a0 (diff)
downloadbcm5719-llvm-811ff92e1e20bf3f4c7895d5e8d986e5c985fa8e.tar.gz
bcm5719-llvm-811ff92e1e20bf3f4c7895d5e8d986e5c985fa8e.zip
Always have clang pass -pie-level and -pic-level values to the code generator.
Patch by tmsriram! Differential Revision: http://reviews.llvm.org/D18843 llvm-svn: 265816
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 751d4334034..6b3d76dfe68 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2106,6 +2106,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
InputArgList Args =
Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
MissingArgCount, IncludedFlagsBitmask);
+ LangOptions &LangOpts = *Res.getLangOpts();
// Check for missing argument error.
if (MissingArgCount) {
@@ -2124,7 +2125,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags);
- ParseCommentArgs(Res.getLangOpts()->CommentOpts, Args);
+ ParseCommentArgs(LangOpts.CommentOpts, Args);
ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
// FIXME: We shouldn't have to pass the DashX option around here
InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags);
@@ -2137,22 +2138,26 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
// PassManager in BackendUtil.cpp. They need to be initializd no matter
// what the input type is.
if (Args.hasArg(OPT_fobjc_arc))
- Res.getLangOpts()->ObjCAutoRefCount = 1;
+ LangOpts.ObjCAutoRefCount = 1;
+ // PIClevel and PIELevel are needed during code generation and this should be
+ // set regardless of the input type.
+ LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+ LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
- Diags, Res.getLangOpts()->Sanitize);
+ Diags, LangOpts.Sanitize);
} else {
// Other LangOpts are only initialzed when the input is not AST or LLVM IR.
- ParseLangArgs(*Res.getLangOpts(), Args, DashX, Res.getTargetOpts(), Diags);
+ ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Diags);
if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
- Res.getLangOpts()->ObjCExceptions = 1;
+ LangOpts.ObjCExceptions = 1;
}
// FIXME: Override value name discarding when asan or msan is used because the
// backend passes depend on the name of the alloca in order to print out
// names.
Res.getCodeGenOpts().DiscardValueNames &=
- !Res.getLangOpts()->Sanitize.has(SanitizerKind::Address) &&
- !Res.getLangOpts()->Sanitize.has(SanitizerKind::Memory);
+ !LangOpts.Sanitize.has(SanitizerKind::Address) &&
+ !LangOpts.Sanitize.has(SanitizerKind::Memory);
// FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of
// PCH file and find the original header name. Remove the need to do that in
OpenPOWER on IntegriCloud