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"
|
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) {
|
2016-02-08 03:28:36 +08:00
|
|
|
case ASTDeclList: return llvm::make_unique<ASTDeclListAction>();
|
|
|
|
case ASTDump: return llvm::make_unique<ASTDumpAction>();
|
|
|
|
case ASTPrint: return llvm::make_unique<ASTPrintAction>();
|
|
|
|
case ASTView: return llvm::make_unique<ASTViewAction>();
|
2018-05-31 21:57:09 +08:00
|
|
|
case DumpCompilerOptions:
|
|
|
|
return llvm::make_unique<DumpCompilerOptionsAction>();
|
2016-02-08 03:28:36 +08:00
|
|
|
case DumpRawTokens: return llvm::make_unique<DumpRawTokensAction>();
|
|
|
|
case DumpTokens: return llvm::make_unique<DumpTokensAction>();
|
|
|
|
case EmitAssembly: return llvm::make_unique<EmitAssemblyAction>();
|
|
|
|
case EmitBC: return llvm::make_unique<EmitBCAction>();
|
|
|
|
case EmitHTML: return llvm::make_unique<HTMLPrintAction>();
|
|
|
|
case EmitLLVM: return llvm::make_unique<EmitLLVMAction>();
|
|
|
|
case EmitLLVMOnly: return llvm::make_unique<EmitLLVMOnlyAction>();
|
|
|
|
case EmitCodeGenOnly: return llvm::make_unique<EmitCodeGenOnlyAction>();
|
|
|
|
case EmitObj: return llvm::make_unique<EmitObjAction>();
|
|
|
|
case FixIt: return llvm::make_unique<FixItAction>();
|
2016-08-26 08:14:38 +08:00
|
|
|
case GenerateModule:
|
|
|
|
return llvm::make_unique<GenerateModuleFromModuleMapAction>();
|
|
|
|
case GenerateModuleInterface:
|
|
|
|
return llvm::make_unique<GenerateModuleInterfaceAction>();
|
2018-09-15 09:21:15 +08:00
|
|
|
case GenerateHeaderModule:
|
|
|
|
return llvm::make_unique<GenerateHeaderModuleAction>();
|
2016-02-08 03:28:36 +08:00
|
|
|
case GeneratePCH: return llvm::make_unique<GeneratePCHAction>();
|
2019-06-21 00:59:48 +08:00
|
|
|
case GenerateInterfaceYAMLExpV1:
|
|
|
|
return llvm::make_unique<GenerateInterfaceYAMLExpV1Action>();
|
|
|
|
case GenerateInterfaceTBEExpV1:
|
|
|
|
return llvm::make_unique<GenerateInterfaceTBEExpV1Action>();
|
2016-02-08 03:28:36 +08:00
|
|
|
case InitOnly: return llvm::make_unique<InitOnlyAction>();
|
|
|
|
case ParseSyntaxOnly: return llvm::make_unique<SyntaxOnlyAction>();
|
|
|
|
case ModuleFileInfo: return llvm::make_unique<DumpModuleInfoAction>();
|
|
|
|
case VerifyPCH: return llvm::make_unique<VerifyPCHAction>();
|
2018-02-10 22:04:45 +08:00
|
|
|
case TemplightDump: return llvm::make_unique<TemplightDumpAction>();
|
2010-08-12 10:53:12 +08:00
|
|
|
|
|
|
|
case PluginAction: {
|
|
|
|
for (FrontendPluginRegistry::iterator it =
|
|
|
|
FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end();
|
|
|
|
it != ie; ++it) {
|
|
|
|
if (it->getName() == CI.getFrontendOpts().ActionName) {
|
2014-03-08 04:03:18 +08:00
|
|
|
std::unique_ptr<PluginASTAction> P(it->instantiate());
|
2016-03-15 20:51:40 +08:00
|
|
|
if ((P->getActionType() != PluginASTAction::ReplaceAction &&
|
|
|
|
P->getActionType() != PluginASTAction::Cmdline) ||
|
|
|
|
!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->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
|
|
|
}
|
|
|
|
|
2016-02-08 03:28:36 +08:00
|
|
|
case PrintPreamble: return llvm::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)
|
2016-02-08 03:28:36 +08:00
|
|
|
return llvm::make_unique<RewriteIncludesAction>();
|
|
|
|
return llvm::make_unique<PrintPreprocessedAction>();
|
2012-06-15 01:36:09 +08:00
|
|
|
}
|
|
|
|
|
2016-02-08 03:28:36 +08:00
|
|
|
case RewriteMacros: return llvm::make_unique<RewriteMacrosAction>();
|
|
|
|
case RewriteTest: return llvm::make_unique<RewriteTestAction>();
|
2017-10-18 13:21:17 +08:00
|
|
|
#if CLANG_ENABLE_OBJC_REWRITER
|
2016-02-08 03:28:36 +08:00
|
|
|
case RewriteObjC: return llvm::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:
|
|
|
|
return llvm::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
|
2016-02-08 03:28:36 +08:00
|
|
|
case RunAnalysis: return llvm::make_unique<ento::AnalysisAction>();
|
2012-12-14 00:09:42 +08:00
|
|
|
#else
|
|
|
|
case RunAnalysis: Action = "RunAnalysis"; break;
|
|
|
|
#endif
|
2016-02-08 03:28:36 +08:00
|
|
|
case RunPreprocessorOnly: return llvm::make_unique<PreprocessOnlyAction>();
|
2019-06-04 06:59:17 +08:00
|
|
|
case PrintDependencyDirectivesSourceMinimizerOutput:
|
|
|
|
return llvm::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) {
|
2016-02-08 03:28:36 +08:00
|
|
|
Act = llvm::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:
|
2016-02-08 03:28:36 +08:00
|
|
|
Act = llvm::make_unique<arcmt::CheckAction>(std::move(Act));
|
2013-11-14 07:38:17 +08:00
|
|
|
break;
|
|
|
|
case FrontendOptions::ARCMT_Modify:
|
2016-02-08 03:28:36 +08:00
|
|
|
Act = llvm::make_unique<arcmt::ModifyAction>(std::move(Act));
|
2013-11-14 07:38:17 +08:00
|
|
|
break;
|
|
|
|
case FrontendOptions::ARCMT_Migrate:
|
2016-02-08 03:28:36 +08:00
|
|
|
Act = llvm::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) {
|
2016-02-08 03:28:36 +08:00
|
|
|
Act = llvm::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
|
|
|
|
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())
|
2016-02-08 03:28:36 +08:00
|
|
|
Act = llvm::make_unique<ASTMergeAction>(std::move(Act),
|
|
|
|
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) {
|
2017-01-14 01:34:15 +08:00
|
|
|
std::unique_ptr<OptTable> Opts = driver::createDriverOptTable();
|
2018-10-10 08:15:33 +08:00
|
|
|
Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
|
2012-11-10 06:36:44 +08:00
|
|
|
"LLVM 'Clang' Compiler: http://clang.llvm.org",
|
2017-07-26 17:10:17 +08:00
|
|
|
/*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.
|
|
|
|
for (unsigned i = 0,
|
|
|
|
e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
|
|
|
|
const std::string &Path = Clang->getFrontendOpts().Plugins[i];
|
|
|
|
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
|
|
|
|
for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
|
|
|
|
ie = FrontendPluginRegistry::end();
|
|
|
|
it != ie; ++it) {
|
|
|
|
std::unique_ptr<PluginASTAction> P(it->instantiate());
|
|
|
|
if (P->getActionType() == PluginASTAction::ReplaceAction) {
|
|
|
|
Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
|
|
|
|
Clang->getFrontendOpts().ActionName = it->getName();
|
|
|
|
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();
|
2014-05-03 16:39:35 +08:00
|
|
|
auto Args = llvm::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();
|
|
|
|
// Honor -analyzer-checker-help and -analyzer-checker-help-hidden.
|
2019-05-24 05:46:51 +08:00
|
|
|
if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha ||
|
|
|
|
AnOpts.ShowCheckerHelpDeveloper) {
|
2019-01-26 23:59:21 +08:00
|
|
|
ento::printCheckerHelp(llvm::outs(),
|
|
|
|
Clang->getFrontendOpts().Plugins,
|
[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
|
|
|
AnOpts,
|
2019-01-26 23:59:21 +08:00
|
|
|
Clang->getDiagnostics(),
|
|
|
|
Clang->getLangOpts());
|
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) {
|
2019-05-24 04:47:28 +08:00
|
|
|
ento::printCheckerConfigList(llvm::outs(),
|
|
|
|
Clang->getFrontendOpts().Plugins,
|
|
|
|
*Clang->getAnalyzerOpts(),
|
|
|
|
Clang->getDiagnostics(),
|
|
|
|
Clang->getLangOpts());
|
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) {
|
2016-08-08 21:41:04 +08:00
|
|
|
ento::printEnabledCheckerList(llvm::outs(),
|
|
|
|
Clang->getFrontendOpts().Plugins,
|
[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
|
|
|
AnOpts,
|
2019-01-26 22:23:08 +08:00
|
|
|
Clang->getDiagnostics(),
|
|
|
|
Clang->getLangOpts());
|
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
|