diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 7 |
3 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 59196b20e28..e07068aea14 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1823,12 +1823,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } - // We separately look for the '-ffast-math' flag, and if we find it, tell the - // frontend to provide the appropriate preprocessor macros. This is distinct - // from enabling any optimizations as it induces a language change which must - // survive serialization and deserialization, etc. + // We separately look for the '-ffast-math' and '-ffinite-math-only' flags, + // and if we find them, tell the frontend to provide the appropriate + // preprocessor macros. This is distinct from enabling any optimizations as + // these options induce language changes which must survive serialization + // and deserialization, etc. if (Args.hasArg(options::OPT_ffast_math)) CmdArgs.push_back("-ffast-math"); + if (Args.hasArg(options::OPT_ffinite_math_only)) + CmdArgs.push_back("-ffinite-math-only"); // Decide whether to use verbose asm. Verbose assembly is the default on // toolchains which have the integrated assembler on by default. diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 016783b1dc5..544c0a270a0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2100,6 +2100,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.NoInlineDefine = !Opt || Args.hasArg(OPT_fno_inline); Opts.FastMath = Args.hasArg(OPT_ffast_math); + Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only); unsigned SSP = Args.getLastArgIntValue(OPT_stack_protector, 0, Diags); switch (SSP) { diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 6120d117e3c..3979731ff6f 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -527,9 +527,10 @@ static void InitializePredefinedMacros(const TargetInfo &TI, if (const char *Prefix = TI.getUserLabelPrefix()) Builder.defineMacro("__USER_LABEL_PREFIX__", Prefix); - // Build configuration options. FIXME: these should be controlled by - // command line options or something. - Builder.defineMacro("__FINITE_MATH_ONLY__", "0"); + if (LangOpts.FastMath || LangOpts.FiniteMathOnly) + Builder.defineMacro("__FINITE_MATH_ONLY__", "1"); + else + Builder.defineMacro("__FINITE_MATH_ONLY__", "0"); if (LangOpts.GNUInline) Builder.defineMacro("__GNUC_GNU_INLINE__"); |