2010-08-12 10:53:12 +08:00
|
|
|
//===--- ExecuteCompilerInvocation.cpp ------------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-08-12 10:53:12 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file holds ExecuteCompilerInvocation(). It is split into its own file to
|
|
|
|
// minimize the impact of pulling in essentially everything else in Clang.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-06-17 00:17:05 +08:00
|
|
|
#include "clang/ARCMigrate/ARCMTActions.h"
|
2010-08-12 10:53:12 +08:00
|
|
|
#include "clang/CodeGen/CodeGenAction.h"
|
2017-07-18 16:55:03 +08:00
|
|
|
#include "clang/Config/config.h"
|
2012-05-01 22:57:16 +08:00
|
|
|
#include "clang/Driver/Options.h"
|
2010-08-12 10:53:12 +08:00
|
|
|
#include "clang/Frontend/CompilerInstance.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "clang/Frontend/CompilerInvocation.h"
|
2010-08-12 10:53:12 +08:00
|
|
|
#include "clang/Frontend/FrontendActions.h"
|
|
|
|
#include "clang/Frontend/FrontendDiagnostic.h"
|
|
|
|
#include "clang/Frontend/FrontendPluginRegistry.h"
|
2013-12-27 16:11:08 +08:00
|
|
|
#include "clang/Frontend/Utils.h"
|
2018-11-18 02:04:13 +08:00
|
|
|
#include "clang/FrontendTool/Utils.h"
|
2012-09-01 13:09:24 +08:00
|
|
|
#include "clang/Rewrite/Frontend/FrontendActions.h"
|
2020-02-28 22:07:50 +08:00
|
|
|
#include "clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
|
2013-06-15 01:17:23 +08:00
|
|
|
#include "llvm/Option/OptTable.h"
|
|
|
|
#include "llvm/Option/Option.h"
|
2018-11-18 02:04:13 +08:00
|
|
|
#include "llvm/Support/BuryPointer.h"
|
2010-11-30 02:12:39 +08:00
|
|
|
#include "llvm/Support/DynamicLibrary.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2010-08-12 10:53:12 +08:00
|
|
|
using namespace clang;
|
2013-06-15 01:17:23 +08:00
|
|
|
using namespace llvm::opt;
|
2010-08-12 10:53:12 +08:00
|
|
|
|
2018-02-10 22:04:45 +08:00
|
|
|
namespace clang {
|
|
|
|
|
2016-02-08 03:28:36 +08:00
|
|
|
static std::unique_ptr<FrontendAction>
|
|
|
|
CreateFrontendBaseAction(CompilerInstance &CI) {
|
2010-08-12 10:53:12 +08:00
|
|
|
using namespace clang::frontend;
|
2013-11-28 03:44:04 +08:00
|
|
|
StringRef Action("unknown");
|
|
|
|
(void)Action;
|
2010-08-12 10:53:12 +08:00
|
|
|
|
|
|
|
switch (CI.getFrontendOpts().ProgramAction) {
|
2019-08-15 07:04:18 +08:00
|
|
|
case ASTDeclList: return std::make_unique<ASTDeclListAction>();
|
|
|
|
case ASTDump: return std::make_unique<ASTDumpAction>();
|
|
|
|
case ASTPrint: return std::make_unique<ASTPrintAction>();
|
|
|
|
case ASTView: return std::make_unique<ASTViewAction>();
|
2018-05-31 21:57:09 +08:00
|
|
|
case DumpCompilerOptions:
|
2019-08-15 07:04:18 +08:00
|
|
|
return std::make_unique<DumpCompilerOptionsAction>();
|
|
|
|
case DumpRawTokens: return std::make_unique<DumpRawTokensAction>();
|
|
|
|
case DumpTokens: return std::make_unique<DumpTokensAction>();
|
|
|
|
case EmitAssembly: return std::make_unique<EmitAssemblyAction>();
|
|
|
|
case EmitBC: return std::make_unique<EmitBCAction>();
|
|
|
|
case EmitHTML: return std::make_unique<HTMLPrintAction>();
|
|
|
|
case EmitLLVM: return std::make_unique<EmitLLVMAction>();
|
|
|
|
case EmitLLVMOnly: return std::make_unique<EmitLLVMOnlyAction>();
|
|
|
|
case EmitCodeGenOnly: return std::make_unique<EmitCodeGenOnlyAction>();
|
|
|
|
case EmitObj: return std::make_unique<EmitObjAction>();
|
|
|
|
case FixIt: return std::make_unique<FixItAction>();
|
2016-08-26 08:14:38 +08:00
|
|
|
case GenerateModule:
|
2019-08-15 07:04:18 +08:00
|
|
|
return std::make_unique<GenerateModuleFromModuleMapAction>();
|
2016-08-26 08:14:38 +08:00
|
|
|
case GenerateModuleInterface:
|
2019-08-15 07:04:18 +08:00
|
|
|
return std::make_unique<GenerateModuleInterfaceAction>();
|
2018-09-15 09:21:15 +08:00
|
|
|
case GenerateHeaderModule:
|
2019-08-15 07:04:18 +08:00
|
|
|
return std::make_unique<GenerateHeaderModuleAction>();
|
|
|
|
case GeneratePCH: return std::make_unique<GeneratePCHAction>();
|
2020-03-28 16:08:27 +08:00
|
|
|
case GenerateInterfaceStubs:
|
|
|
|
return std::make_unique<GenerateInterfaceStubsAction>();
|
2019-08-15 07:04:18 +08:00
|
|
|
case InitOnly: return std::make_unique<InitOnlyAction>();
|
|
|
|
case ParseSyntaxOnly: return std::make_unique<SyntaxOnlyAction>();
|
|
|
|
case ModuleFileInfo: return std::make_unique<DumpModuleInfoAction>();
|
|
|
|
case VerifyPCH: return std::make_unique<VerifyPCHAction>();
|
|
|
|
case TemplightDump: return std::make_unique<TemplightDumpAction>();
|
2010-08-12 10:53:12 +08:00
|
|
|
|
|
|
|
case PluginAction: {
|
2020-06-19 07:40:00 +08:00
|
|
|
for (const FrontendPluginRegistry::entry &Plugin :
|
|
|
|
FrontendPluginRegistry::entries()) {
|
|
|
|
if (Plugin.getName() == CI.getFrontendOpts().ActionName) {
|
|
|
|
std::unique_ptr<PluginASTAction> P(Plugin.instantiate());
|
2016-03-15 20:51:40 +08:00
|
|
|
if ((P->getActionType() != PluginASTAction::ReplaceAction &&
|
|
|
|
P->getActionType() != PluginASTAction::Cmdline) ||
|
2020-01-29 03:23:46 +08:00
|
|
|
!P->ParseArgs(
|
|
|
|
CI,
|
2020-06-19 07:40:00 +08:00
|
|
|
CI.getFrontendOpts().PluginArgs[std::string(Plugin.getName())]))
|
2014-05-26 14:21:51 +08:00
|
|
|
return nullptr;
|
2016-02-08 03:28:36 +08:00
|
|
|
return std::move(P);
|
2010-08-12 10:53:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CI.getDiagnostics().Report(diag::err_fe_invalid_plugin_name)
|
|
|
|
<< CI.getFrontendOpts().ActionName;
|
2014-05-26 14:21:51 +08:00
|
|
|
return nullptr;
|
2010-08-12 10:53:12 +08:00
|
|
|
}
|
|
|
|
|
2019-08-15 07:04:18 +08:00
|
|
|
case PrintPreamble: return std::make_unique<PrintPreambleAction>();
|
2012-06-15 01:36:09 +08:00
|
|
|
case PrintPreprocessedInput: {
|
2017-06-10 05:24:02 +08:00
|
|
|
if (CI.getPreprocessorOutputOpts().RewriteIncludes ||
|
|
|
|
CI.getPreprocessorOutputOpts().RewriteImports)
|
2019-08-15 07:04:18 +08:00
|
|
|
return std::make_unique<RewriteIncludesAction>();
|
|
|
|
return std::make_unique<PrintPreprocessedAction>();
|
2012-06-15 01:36:09 +08:00
|
|
|
}
|
|
|
|
|
2019-08-15 07:04:18 +08:00
|
|
|
case RewriteMacros: return std::make_unique<RewriteMacrosAction>();
|
|
|
|
case RewriteTest: return std::make_unique<RewriteTestAction>();
|
2017-10-18 13:21:17 +08:00
|
|
|
#if CLANG_ENABLE_OBJC_REWRITER
|
2019-08-15 07:04:18 +08:00
|
|
|
case RewriteObjC: return std::make_unique<RewriteObjCAction>();
|
2012-12-14 00:09:42 +08:00
|
|
|
#else
|
|
|
|
case RewriteObjC: Action = "RewriteObjC"; break;
|
|
|
|
#endif
|
2017-10-18 13:21:17 +08:00
|
|
|
#if CLANG_ENABLE_ARCMT
|
2016-02-08 03:28:36 +08:00
|
|
|
case MigrateSource:
|
2019-08-15 07:04:18 +08:00
|
|
|
return std::make_unique<arcmt::MigrateSourceAction>();
|
2012-12-14 00:09:42 +08:00
|
|
|
#else
|
|
|
|
case MigrateSource: Action = "MigrateSource"; break;
|
|
|
|
#endif
|
2017-10-18 13:21:17 +08:00
|
|
|
#if CLANG_ENABLE_STATIC_ANALYZER
|
2019-08-15 07:04:18 +08:00
|
|
|
case RunAnalysis: return std::make_unique<ento::AnalysisAction>();
|
2012-12-14 00:09:42 +08:00
|
|
|
#else
|
|
|
|
case RunAnalysis: Action = "RunAnalysis"; break;
|
|
|
|
#endif
|
2019-08-15 07:04:18 +08:00
|
|
|
case RunPreprocessorOnly: return std::make_unique<PreprocessOnlyAction>();
|
2019-06-04 06:59:17 +08:00
|
|
|
case PrintDependencyDirectivesSourceMinimizerOutput:
|
2019-08-15 07:04:18 +08:00
|
|
|
return std::make_unique<PrintDependencyDirectivesSourceMinimizerAction>();
|
2010-08-12 10:53:12 +08:00
|
|
|
}
|
2012-12-14 00:09:42 +08:00
|
|
|
|
2017-10-18 13:21:17 +08:00
|
|
|
#if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \
|
|
|
|
|| !CLANG_ENABLE_OBJC_REWRITER
|
2012-12-14 00:09:42 +08:00
|
|
|
CI.getDiagnostics().Report(diag::err_fe_action_not_available) << Action;
|
|
|
|
return 0;
|
|
|
|
#else
|
2012-01-17 10:30:50 +08:00
|
|
|
llvm_unreachable("Invalid program action!");
|
2012-12-14 00:09:42 +08:00
|
|
|
#endif
|
2010-08-12 10:53:12 +08:00
|
|
|
}
|
|
|
|
|
2018-02-10 22:04:45 +08:00
|
|
|
std::unique_ptr<FrontendAction>
|
2016-02-08 03:28:36 +08:00
|
|
|
CreateFrontendAction(CompilerInstance &CI) {
|
2010-08-12 10:53:12 +08:00
|
|
|
// Create the underlying action.
|
2016-02-08 03:28:36 +08:00
|
|
|
std::unique_ptr<FrontendAction> Act = CreateFrontendBaseAction(CI);
|
2010-08-12 10:53:12 +08:00
|
|
|
if (!Act)
|
2014-05-26 14:21:51 +08:00
|
|
|
return nullptr;
|
2010-08-12 10:53:12 +08:00
|
|
|
|
2012-02-04 09:36:04 +08:00
|
|
|
const FrontendOptions &FEOpts = CI.getFrontendOpts();
|
|
|
|
|
|
|
|
if (FEOpts.FixAndRecompile) {
|
2019-08-15 07:04:18 +08:00
|
|
|
Act = std::make_unique<FixItRecompile>(std::move(Act));
|
2012-01-26 10:40:48 +08:00
|
|
|
}
|
2018-07-31 03:24:48 +08:00
|
|
|
|
2017-10-18 13:21:17 +08:00
|
|
|
#if CLANG_ENABLE_ARCMT
|
2014-05-17 12:35:12 +08:00
|
|
|
if (CI.getFrontendOpts().ProgramAction != frontend::MigrateSource &&
|
|
|
|
CI.getFrontendOpts().ProgramAction != frontend::GeneratePCH) {
|
2013-11-14 07:38:17 +08:00
|
|
|
// Potentially wrap the base FE action in an ARC Migrate Tool action.
|
|
|
|
switch (FEOpts.ARCMTAction) {
|
|
|
|
case FrontendOptions::ARCMT_None:
|
|
|
|
break;
|
|
|
|
case FrontendOptions::ARCMT_Check:
|
2019-08-15 07:04:18 +08:00
|
|
|
Act = std::make_unique<arcmt::CheckAction>(std::move(Act));
|
2013-11-14 07:38:17 +08:00
|
|
|
break;
|
|
|
|
case FrontendOptions::ARCMT_Modify:
|
2019-08-15 07:04:18 +08:00
|
|
|
Act = std::make_unique<arcmt::ModifyAction>(std::move(Act));
|
2013-11-14 07:38:17 +08:00
|
|
|
break;
|
|
|
|
case FrontendOptions::ARCMT_Migrate:
|
2019-08-15 07:04:18 +08:00
|
|
|
Act = std::make_unique<arcmt::MigrateAction>(std::move(Act),
|
2013-11-14 07:38:17 +08:00
|
|
|
FEOpts.MTMigrateDir,
|
|
|
|
FEOpts.ARCMTMigrateReportOut,
|
|
|
|
FEOpts.ARCMTMigrateEmitARCErrors);
|
|
|
|
break;
|
|
|
|
}
|
2011-06-17 00:17:05 +08:00
|
|
|
|
2013-11-14 07:38:17 +08:00
|
|
|
if (FEOpts.ObjCMTAction != FrontendOptions::ObjCMT_None) {
|
2019-08-15 07:04:18 +08:00
|
|
|
Act = std::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
|
2016-02-08 03:28:36 +08:00
|
|
|
FEOpts.MTMigrateDir,
|
|
|
|
FEOpts.ObjCMTAction);
|
2013-11-14 07:38:17 +08:00
|
|
|
}
|
2012-03-07 04:06:33 +08:00
|
|
|
}
|
2012-12-14 00:09:42 +08:00
|
|
|
#endif
|
2012-03-07 04:06:33 +08:00
|
|
|
|
2010-08-12 10:53:12 +08:00
|
|
|
// If there are any AST files to merge, create a frontend action
|
|
|
|
// adaptor to perform the merge.
|
2012-02-04 09:36:04 +08:00
|
|
|
if (!FEOpts.ASTMergeFiles.empty())
|
2019-08-15 07:04:18 +08:00
|
|
|
Act = std::make_unique<ASTMergeAction>(std::move(Act),
|
2016-02-08 03:28:36 +08:00
|
|
|
FEOpts.ASTMergeFiles);
|
2010-08-12 10:53:12 +08:00
|
|
|
|
|
|
|
return Act;
|
|
|
|
}
|
|
|
|
|
2018-02-10 22:04:45 +08:00
|
|
|
bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
|
2010-08-12 10:53:12 +08:00
|
|
|
// Honor -help.
|
|
|
|
if (Clang->getFrontendOpts().ShowHelp) {
|
2019-09-04 22:26:28 +08:00
|
|
|
driver::getDriverOptTable().PrintHelp(
|
|
|
|
llvm::outs(), "clang -cc1 [options] file...",
|
|
|
|
"LLVM 'Clang' Compiler: http://clang.llvm.org",
|
|
|
|
/*Include=*/driver::options::CC1Option,
|
|
|
|
/*Exclude=*/0, /*ShowAllAliases=*/false);
|
2013-08-07 20:54:47 +08:00
|
|
|
return true;
|
2010-08-12 10:53:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Honor -version.
|
|
|
|
//
|
|
|
|
// FIXME: Use a better -version message?
|
|
|
|
if (Clang->getFrontendOpts().ShowVersion) {
|
|
|
|
llvm::cl::PrintVersionMessage();
|
2013-08-07 20:54:47 +08:00
|
|
|
return true;
|
2010-08-12 10:53:12 +08:00
|
|
|
}
|
|
|
|
|
2011-10-10 09:23:06 +08:00
|
|
|
// Load any requested plugins.
|
2020-06-19 07:40:00 +08:00
|
|
|
for (const std::string &Path : Clang->getFrontendOpts().Plugins) {
|
2011-10-10 09:23:06 +08:00
|
|
|
std::string Error;
|
2016-02-12 00:33:20 +08:00
|
|
|
if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
|
2011-10-10 09:23:06 +08:00
|
|
|
Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
|
|
|
|
<< Path << Error;
|
|
|
|
}
|
|
|
|
|
2016-03-15 20:51:40 +08:00
|
|
|
// Check if any of the loaded plugins replaces the main AST action
|
2020-06-19 07:40:00 +08:00
|
|
|
for (const FrontendPluginRegistry::entry &Plugin :
|
|
|
|
FrontendPluginRegistry::entries()) {
|
|
|
|
std::unique_ptr<PluginASTAction> P(Plugin.instantiate());
|
2016-03-15 20:51:40 +08:00
|
|
|
if (P->getActionType() == PluginASTAction::ReplaceAction) {
|
|
|
|
Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
|
2020-06-19 07:40:00 +08:00
|
|
|
Clang->getFrontendOpts().ActionName = Plugin.getName().str();
|
2016-03-15 20:51:40 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-12 10:53:12 +08:00
|
|
|
// Honor -mllvm.
|
|
|
|
//
|
|
|
|
// FIXME: Remove this, one day.
|
2011-10-10 09:23:06 +08:00
|
|
|
// This should happen AFTER plugins have been loaded!
|
2010-08-12 10:53:12 +08:00
|
|
|
if (!Clang->getFrontendOpts().LLVMArgs.empty()) {
|
|
|
|
unsigned NumArgs = Clang->getFrontendOpts().LLVMArgs.size();
|
2019-08-15 07:04:18 +08:00
|
|
|
auto Args = std::make_unique<const char*[]>(NumArgs + 2);
|
2010-08-12 10:53:12 +08:00
|
|
|
Args[0] = "clang (LLVM option parsing)";
|
|
|
|
for (unsigned i = 0; i != NumArgs; ++i)
|
|
|
|
Args[i + 1] = Clang->getFrontendOpts().LLVMArgs[i].c_str();
|
2014-05-26 14:21:51 +08:00
|
|
|
Args[NumArgs + 1] = nullptr;
|
2014-05-03 16:39:35 +08:00
|
|
|
llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
|
2010-08-12 10:53:12 +08:00
|
|
|
}
|
|
|
|
|
2017-10-18 13:21:17 +08:00
|
|
|
#if CLANG_ENABLE_STATIC_ANALYZER
|
[analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden
During my work on analyzer dependencies, I created a great amount of new
checkers that emitted no diagnostics at all, and were purely modeling some
function or another.
However, the user shouldn't really disable/enable these by hand, hence this
patch, which hides these by default. I intentionally chose not to hide alpha
checkers, because they have a scary enough name, in my opinion, to cause no
surprise when they emit false positives or cause crashes.
The patch introduces the Hidden bit into the TableGen files (you may remember
it before I removed it in D53995), and checkers that are either marked as
hidden, or are in a package that is marked hidden won't be displayed under
-analyzer-checker-help. -analyzer-checker-help-hidden, a new flag meant for
developers only, displays the full list.
Differential Revision: https://reviews.llvm.org/D60925
llvm-svn: 359720
2019-05-02 03:56:47 +08:00
|
|
|
// These should happen AFTER plugins have been loaded!
|
|
|
|
|
|
|
|
AnalyzerOptions &AnOpts = *Clang->getAnalyzerOpts();
|
2020-02-28 22:07:50 +08:00
|
|
|
|
[analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden
During my work on analyzer dependencies, I created a great amount of new
checkers that emitted no diagnostics at all, and were purely modeling some
function or another.
However, the user shouldn't really disable/enable these by hand, hence this
patch, which hides these by default. I intentionally chose not to hide alpha
checkers, because they have a scary enough name, in my opinion, to cause no
surprise when they emit false positives or cause crashes.
The patch introduces the Hidden bit into the TableGen files (you may remember
it before I removed it in D53995), and checkers that are either marked as
hidden, or are in a package that is marked hidden won't be displayed under
-analyzer-checker-help. -analyzer-checker-help-hidden, a new flag meant for
developers only, displays the full list.
Differential Revision: https://reviews.llvm.org/D60925
llvm-svn: 359720
2019-05-02 03:56:47 +08:00
|
|
|
// Honor -analyzer-checker-help and -analyzer-checker-help-hidden.
|
2019-05-24 05:46:51 +08:00
|
|
|
if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha ||
|
|
|
|
AnOpts.ShowCheckerHelpDeveloper) {
|
2020-02-28 22:07:50 +08:00
|
|
|
ento::printCheckerHelp(llvm::outs(), *Clang);
|
2019-05-24 04:47:28 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Honor -analyzer-checker-option-help.
|
2019-05-24 06:52:09 +08:00
|
|
|
if (AnOpts.ShowCheckerOptionList || AnOpts.ShowCheckerOptionAlphaList ||
|
|
|
|
AnOpts.ShowCheckerOptionDeveloperList) {
|
2020-02-28 22:07:50 +08:00
|
|
|
ento::printCheckerConfigList(llvm::outs(), *Clang);
|
2013-08-07 20:54:47 +08:00
|
|
|
return true;
|
2011-08-17 05:24:21 +08:00
|
|
|
}
|
2018-11-02 23:59:37 +08:00
|
|
|
|
|
|
|
// Honor -analyzer-list-enabled-checkers.
|
[analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden
During my work on analyzer dependencies, I created a great amount of new
checkers that emitted no diagnostics at all, and were purely modeling some
function or another.
However, the user shouldn't really disable/enable these by hand, hence this
patch, which hides these by default. I intentionally chose not to hide alpha
checkers, because they have a scary enough name, in my opinion, to cause no
surprise when they emit false positives or cause crashes.
The patch introduces the Hidden bit into the TableGen files (you may remember
it before I removed it in D53995), and checkers that are either marked as
hidden, or are in a package that is marked hidden won't be displayed under
-analyzer-checker-help. -analyzer-checker-help-hidden, a new flag meant for
developers only, displays the full list.
Differential Revision: https://reviews.llvm.org/D60925
llvm-svn: 359720
2019-05-02 03:56:47 +08:00
|
|
|
if (AnOpts.ShowEnabledCheckerList) {
|
2020-02-28 22:07:50 +08:00
|
|
|
ento::printEnabledCheckerList(llvm::outs(), *Clang);
|
2019-09-13 02:53:48 +08:00
|
|
|
return true;
|
2016-08-08 21:41:04 +08:00
|
|
|
}
|
2018-11-02 23:59:37 +08:00
|
|
|
|
|
|
|
// Honor -analyzer-config-help.
|
[analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden
During my work on analyzer dependencies, I created a great amount of new
checkers that emitted no diagnostics at all, and were purely modeling some
function or another.
However, the user shouldn't really disable/enable these by hand, hence this
patch, which hides these by default. I intentionally chose not to hide alpha
checkers, because they have a scary enough name, in my opinion, to cause no
surprise when they emit false positives or cause crashes.
The patch introduces the Hidden bit into the TableGen files (you may remember
it before I removed it in D53995), and checkers that are either marked as
hidden, or are in a package that is marked hidden won't be displayed under
-analyzer-checker-help. -analyzer-checker-help-hidden, a new flag meant for
developers only, displays the full list.
Differential Revision: https://reviews.llvm.org/D60925
llvm-svn: 359720
2019-05-02 03:56:47 +08:00
|
|
|
if (AnOpts.ShowConfigOptionsList) {
|
2018-11-02 23:59:37 +08:00
|
|
|
ento::printAnalyzerConfigList(llvm::outs());
|
|
|
|
return true;
|
|
|
|
}
|
2012-12-14 00:09:42 +08:00
|
|
|
#endif
|
2011-08-17 05:24:21 +08:00
|
|
|
|
2010-08-12 10:53:12 +08:00
|
|
|
// If there were errors in processing arguments, don't do anything else.
|
2013-01-06 15:49:41 +08:00
|
|
|
if (Clang->getDiagnostics().hasErrorOccurred())
|
|
|
|
return false;
|
|
|
|
// Create and execute the frontend action.
|
2014-03-08 04:03:18 +08:00
|
|
|
std::unique_ptr<FrontendAction> Act(CreateFrontendAction(*Clang));
|
2013-01-06 15:49:41 +08:00
|
|
|
if (!Act)
|
|
|
|
return false;
|
|
|
|
bool Success = Clang->ExecuteAction(*Act);
|
|
|
|
if (Clang->getFrontendOpts().DisableFree)
|
2018-11-18 02:04:13 +08:00
|
|
|
llvm::BuryPointer(std::move(Act));
|
2010-08-12 10:53:12 +08:00
|
|
|
return Success;
|
|
|
|
}
|
2018-02-10 22:04:45 +08:00
|
|
|
|
2018-07-31 03:24:48 +08:00
|
|
|
} // namespace clang
|