aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/LangOptions.def2
-rw-r--r--include/clang/Driver/Options.td2
-rw-r--r--lib/Driver/Tools.cpp2
-rw-r--r--lib/Frontend/CompilerInvocation.cpp3
-rw-r--r--test/Driver/clang_fopenmp_opt.c2
5 files changed, 10 insertions, 1 deletions
diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def
index 3463e2532a..126f166924 100644
--- a/include/clang/Basic/LangOptions.def
+++ b/include/clang/Basic/LangOptions.def
@@ -167,6 +167,8 @@ LANGOPT(ApplePragmaPack, 1, 0, "Apple gcc-compatible #pragma pack handling")
BENIGN_LANGOPT(EmitMicrosoftInlineAsm , 1, 0,
"Enable emission of MS-style inline assembly.")
+LANGOPT(OpenMP, 1, 0, "Enables OpenMP support.")
+
BENIGN_LANGOPT(RetainCommentsFromSystemHeaders, 1, 0, "retain documentation comments from system headers in the AST")
#undef LANGOPT
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index c14b0bccc1..4f7f635ddb 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -594,7 +594,7 @@ def fno_objc_nonfragile_abi : Flag<["-"], "fno-objc-nonfragile-abi">, Group<f_Gr
def fobjc_sender_dependent_dispatch : Flag<["-"], "fobjc-sender-dependent-dispatch">, Group<f_Group>;
def fobjc : Flag<["-"], "fobjc">, Group<f_Group>;
def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>;
-def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>;
+def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option]>;
def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group<f_Group>;
def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group<f_Group>;
def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 51228d7c1f..399daab210 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2412,6 +2412,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_pthread);
+ Args.AddLastArg(CmdArgs, options::OPT_fopenmp);
+
// -stack-protector=0 is default.
unsigned StackProtectorLevel = 0;
if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector,
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 78dc0d5fb0..20083d6518 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -870,6 +870,8 @@ static void LangOptsToArgs(const LangOptions &Opts, ToArgsList &Res) {
Res.push_back("-fapple-pragma-pack");
if (!Opts.CurrentModule.empty())
Res.push_back("-fmodule-name=" + Opts.CurrentModule);
+ if (Opts.OpenMP)
+ Res.push_back("-fopenmp");
}
static void PreprocessorOptsToArgs(const PreprocessorOptions &Opts,
@@ -2143,6 +2145,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.ThreadSanitizer = Args.hasArg(OPT_fthread_sanitizer);
Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name);
+ Opts.OpenMP = Args.hasArg(OPT_fopenmp);
// Record whether the __DEPRECATED define was requested.
Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro,
diff --git a/test/Driver/clang_fopenmp_opt.c b/test/Driver/clang_fopenmp_opt.c
new file mode 100644
index 0000000000..86aef0b31e
--- /dev/null
+++ b/test/Driver/clang_fopenmp_opt.c
@@ -0,0 +1,2 @@
+// RUN: %clang -### -S -o %t %s 2>&1 | not grep -w -- -fopenmp
+// RUN: %clang -### -S -o %t %s -fopenmp 2>&1 | grep -w -- -fopenmp