From 697bc748f97736b294dd85b8f78530d023557b72 Mon Sep 17 00:00:00 2001 From: Renaud Kauffmann Date: Wed, 4 Sep 2024 08:59:55 -0700 Subject: Allow disabling of types from the command line (#107126) Adding hidden options to disable types through the `TargetCharacteristics`. I am seeing issues when I do this programmatically and would like, for anyone, to have the ability to reproduce them for development and testing purposes. I am planning to file a couple of issues following this patch. --- flang/lib/Frontend/CompilerInvocation.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 9e42fcc..90c3275 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -438,8 +438,19 @@ static void parseTargetArgs(TargetOptions &opts, llvm::opt::ArgList &args) { for (const llvm::opt::Arg *currentArg : args.filtered(clang::driver::options::OPT_target_feature)) opts.featuresAsWritten.emplace_back(currentArg->getValue()); -} + if (args.hasArg(clang::driver::options::OPT_fdisable_real_10)) + opts.disabledRealKinds.push_back(10); + + if (args.hasArg(clang::driver::options::OPT_fdisable_real_3)) + opts.disabledRealKinds.push_back(3); + + if (args.hasArg(clang::driver::options::OPT_fdisable_integer_2)) + opts.disabledIntegerKinds.push_back(2); + + if (args.hasArg(clang::driver::options::OPT_fdisable_integer_16)) + opts.disabledIntegerKinds.push_back(16); +} // Tweak the frontend configuration based on the frontend action static void setUpFrontendBasedOnAction(FrontendOptions &opts) { if (opts.programAction == DebugDumpParsingLog) @@ -1531,8 +1542,8 @@ CompilerInvocation::getSemanticsCtx( std::string compilerVersion = Fortran::common::getFlangFullVersion(); Fortran::tools::setUpTargetCharacteristics( - semanticsContext->targetCharacteristics(), targetMachine, compilerVersion, - allCompilerInvocOpts); + semanticsContext->targetCharacteristics(), targetMachine, getTargetOpts(), + compilerVersion, allCompilerInvocOpts); return semanticsContext; } -- cgit v1.1