|
@@ -8,13 +8,14 @@
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
#include "TestModuleFileExtension.h"
|
|
|
-#include "clang/Frontend/CompilerInvocation.h"
|
|
|
+#include "clang/Basic/Builtins.h"
|
|
|
#include "clang/Basic/FileManager.h"
|
|
|
#include "clang/Basic/Version.h"
|
|
|
#include "clang/Config/config.h"
|
|
|
#include "clang/Driver/DriverDiagnostic.h"
|
|
|
#include "clang/Driver/Options.h"
|
|
|
#include "clang/Driver/Util.h"
|
|
|
+#include "clang/Frontend/CompilerInvocation.h"
|
|
|
#include "clang/Frontend/FrontendDiagnostic.h"
|
|
|
#include "clang/Frontend/LangStandard.h"
|
|
|
#include "clang/Frontend/Utils.h"
|
|
@@ -135,6 +136,20 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static void getAllNoBuiltinFuncValues(ArgList &Args,
|
|
|
+ std::vector<std::string> &Funcs) {
|
|
|
+ SmallVector<const char *, 8> Values;
|
|
|
+ for (const auto &Arg : Args) {
|
|
|
+ const Option &O = Arg->getOption();
|
|
|
+ if (O.matches(options::OPT_fno_builtin_)) {
|
|
|
+ const char *FuncName = Arg->getValue();
|
|
|
+ if (Builtin::Context::isBuiltinFunc(FuncName))
|
|
|
+ Values.push_back(FuncName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Funcs.insert(Funcs.end(), Values.begin(), Values.end());
|
|
|
+}
|
|
|
+
|
|
|
static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
|
|
|
DiagnosticsEngine &Diags) {
|
|
|
using namespace options;
|
|
@@ -452,6 +467,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|
|
Opts.OptimizeSize = getOptimizationLevelSize(Args);
|
|
|
Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
|
|
|
Args.hasArg(OPT_ffreestanding));
|
|
|
+ if (Opts.SimplifyLibCalls)
|
|
|
+ getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
|
|
|
Opts.UnrollLoops =
|
|
|
Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
|
|
|
(Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
|
|
@@ -1669,6 +1686,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
|
|
|
Opts.ShortEnums = Args.hasArg(OPT_fshort_enums);
|
|
|
Opts.Freestanding = Args.hasArg(OPT_ffreestanding);
|
|
|
Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
|
|
|
+ if (!Opts.NoBuiltin)
|
|
|
+ getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
|
|
|
Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
|
|
|
Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);
|
|
|
Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation);
|