annotate clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @ 223:5f17cb93ff66 llvm-original

LLVM13 (2021/7/18)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:43:00 +0900
parents 79ff65ed7e25
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===--- ExecuteCompilerInvocation.cpp ------------------------------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // This file holds ExecuteCompilerInvocation(). It is split into its own file to
anatofuz
parents:
diff changeset
10 // minimize the impact of pulling in essentially everything else in Clang.
anatofuz
parents:
diff changeset
11 //
anatofuz
parents:
diff changeset
12 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 #include "clang/ARCMigrate/ARCMTActions.h"
anatofuz
parents:
diff changeset
15 #include "clang/CodeGen/CodeGenAction.h"
anatofuz
parents:
diff changeset
16 #include "clang/Config/config.h"
anatofuz
parents:
diff changeset
17 #include "clang/Driver/Options.h"
anatofuz
parents:
diff changeset
18 #include "clang/Frontend/CompilerInstance.h"
anatofuz
parents:
diff changeset
19 #include "clang/Frontend/CompilerInvocation.h"
anatofuz
parents:
diff changeset
20 #include "clang/Frontend/FrontendActions.h"
anatofuz
parents:
diff changeset
21 #include "clang/Frontend/FrontendDiagnostic.h"
anatofuz
parents:
diff changeset
22 #include "clang/Frontend/FrontendPluginRegistry.h"
anatofuz
parents:
diff changeset
23 #include "clang/Frontend/Utils.h"
anatofuz
parents:
diff changeset
24 #include "clang/FrontendTool/Utils.h"
anatofuz
parents:
diff changeset
25 #include "clang/Rewrite/Frontend/FrontendActions.h"
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
26 #include "clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h"
150
anatofuz
parents:
diff changeset
27 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
anatofuz
parents:
diff changeset
28 #include "llvm/Option/OptTable.h"
anatofuz
parents:
diff changeset
29 #include "llvm/Option/Option.h"
anatofuz
parents:
diff changeset
30 #include "llvm/Support/BuryPointer.h"
anatofuz
parents:
diff changeset
31 #include "llvm/Support/DynamicLibrary.h"
anatofuz
parents:
diff changeset
32 #include "llvm/Support/ErrorHandling.h"
anatofuz
parents:
diff changeset
33 using namespace clang;
anatofuz
parents:
diff changeset
34 using namespace llvm::opt;
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 namespace clang {
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 static std::unique_ptr<FrontendAction>
anatofuz
parents:
diff changeset
39 CreateFrontendBaseAction(CompilerInstance &CI) {
anatofuz
parents:
diff changeset
40 using namespace clang::frontend;
anatofuz
parents:
diff changeset
41 StringRef Action("unknown");
anatofuz
parents:
diff changeset
42 (void)Action;
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 switch (CI.getFrontendOpts().ProgramAction) {
anatofuz
parents:
diff changeset
45 case ASTDeclList: return std::make_unique<ASTDeclListAction>();
anatofuz
parents:
diff changeset
46 case ASTDump: return std::make_unique<ASTDumpAction>();
anatofuz
parents:
diff changeset
47 case ASTPrint: return std::make_unique<ASTPrintAction>();
anatofuz
parents:
diff changeset
48 case ASTView: return std::make_unique<ASTViewAction>();
anatofuz
parents:
diff changeset
49 case DumpCompilerOptions:
anatofuz
parents:
diff changeset
50 return std::make_unique<DumpCompilerOptionsAction>();
anatofuz
parents:
diff changeset
51 case DumpRawTokens: return std::make_unique<DumpRawTokensAction>();
anatofuz
parents:
diff changeset
52 case DumpTokens: return std::make_unique<DumpTokensAction>();
anatofuz
parents:
diff changeset
53 case EmitAssembly: return std::make_unique<EmitAssemblyAction>();
anatofuz
parents:
diff changeset
54 case EmitBC: return std::make_unique<EmitBCAction>();
anatofuz
parents:
diff changeset
55 case EmitHTML: return std::make_unique<HTMLPrintAction>();
anatofuz
parents:
diff changeset
56 case EmitLLVM: return std::make_unique<EmitLLVMAction>();
anatofuz
parents:
diff changeset
57 case EmitLLVMOnly: return std::make_unique<EmitLLVMOnlyAction>();
anatofuz
parents:
diff changeset
58 case EmitCodeGenOnly: return std::make_unique<EmitCodeGenOnlyAction>();
anatofuz
parents:
diff changeset
59 case EmitObj: return std::make_unique<EmitObjAction>();
anatofuz
parents:
diff changeset
60 case FixIt: return std::make_unique<FixItAction>();
anatofuz
parents:
diff changeset
61 case GenerateModule:
anatofuz
parents:
diff changeset
62 return std::make_unique<GenerateModuleFromModuleMapAction>();
anatofuz
parents:
diff changeset
63 case GenerateModuleInterface:
anatofuz
parents:
diff changeset
64 return std::make_unique<GenerateModuleInterfaceAction>();
anatofuz
parents:
diff changeset
65 case GenerateHeaderModule:
anatofuz
parents:
diff changeset
66 return std::make_unique<GenerateHeaderModuleAction>();
anatofuz
parents:
diff changeset
67 case GeneratePCH: return std::make_unique<GeneratePCHAction>();
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
68 case GenerateInterfaceStubs:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
69 return std::make_unique<GenerateInterfaceStubsAction>();
150
anatofuz
parents:
diff changeset
70 case InitOnly: return std::make_unique<InitOnlyAction>();
anatofuz
parents:
diff changeset
71 case ParseSyntaxOnly: return std::make_unique<SyntaxOnlyAction>();
anatofuz
parents:
diff changeset
72 case ModuleFileInfo: return std::make_unique<DumpModuleInfoAction>();
anatofuz
parents:
diff changeset
73 case VerifyPCH: return std::make_unique<VerifyPCHAction>();
anatofuz
parents:
diff changeset
74 case TemplightDump: return std::make_unique<TemplightDumpAction>();
anatofuz
parents:
diff changeset
75
anatofuz
parents:
diff changeset
76 case PluginAction: {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
77 for (const FrontendPluginRegistry::entry &Plugin :
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
78 FrontendPluginRegistry::entries()) {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
79 if (Plugin.getName() == CI.getFrontendOpts().ActionName) {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
80 std::unique_ptr<PluginASTAction> P(Plugin.instantiate());
150
anatofuz
parents:
diff changeset
81 if ((P->getActionType() != PluginASTAction::ReplaceAction &&
anatofuz
parents:
diff changeset
82 P->getActionType() != PluginASTAction::Cmdline) ||
anatofuz
parents:
diff changeset
83 !P->ParseArgs(
anatofuz
parents:
diff changeset
84 CI,
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
85 CI.getFrontendOpts().PluginArgs[std::string(Plugin.getName())]))
150
anatofuz
parents:
diff changeset
86 return nullptr;
anatofuz
parents:
diff changeset
87 return std::move(P);
anatofuz
parents:
diff changeset
88 }
anatofuz
parents:
diff changeset
89 }
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 CI.getDiagnostics().Report(diag::err_fe_invalid_plugin_name)
anatofuz
parents:
diff changeset
92 << CI.getFrontendOpts().ActionName;
anatofuz
parents:
diff changeset
93 return nullptr;
anatofuz
parents:
diff changeset
94 }
anatofuz
parents:
diff changeset
95
anatofuz
parents:
diff changeset
96 case PrintPreamble: return std::make_unique<PrintPreambleAction>();
anatofuz
parents:
diff changeset
97 case PrintPreprocessedInput: {
anatofuz
parents:
diff changeset
98 if (CI.getPreprocessorOutputOpts().RewriteIncludes ||
anatofuz
parents:
diff changeset
99 CI.getPreprocessorOutputOpts().RewriteImports)
anatofuz
parents:
diff changeset
100 return std::make_unique<RewriteIncludesAction>();
anatofuz
parents:
diff changeset
101 return std::make_unique<PrintPreprocessedAction>();
anatofuz
parents:
diff changeset
102 }
anatofuz
parents:
diff changeset
103
anatofuz
parents:
diff changeset
104 case RewriteMacros: return std::make_unique<RewriteMacrosAction>();
anatofuz
parents:
diff changeset
105 case RewriteTest: return std::make_unique<RewriteTestAction>();
anatofuz
parents:
diff changeset
106 #if CLANG_ENABLE_OBJC_REWRITER
anatofuz
parents:
diff changeset
107 case RewriteObjC: return std::make_unique<RewriteObjCAction>();
anatofuz
parents:
diff changeset
108 #else
anatofuz
parents:
diff changeset
109 case RewriteObjC: Action = "RewriteObjC"; break;
anatofuz
parents:
diff changeset
110 #endif
anatofuz
parents:
diff changeset
111 #if CLANG_ENABLE_ARCMT
anatofuz
parents:
diff changeset
112 case MigrateSource:
anatofuz
parents:
diff changeset
113 return std::make_unique<arcmt::MigrateSourceAction>();
anatofuz
parents:
diff changeset
114 #else
anatofuz
parents:
diff changeset
115 case MigrateSource: Action = "MigrateSource"; break;
anatofuz
parents:
diff changeset
116 #endif
anatofuz
parents:
diff changeset
117 #if CLANG_ENABLE_STATIC_ANALYZER
anatofuz
parents:
diff changeset
118 case RunAnalysis: return std::make_unique<ento::AnalysisAction>();
anatofuz
parents:
diff changeset
119 #else
anatofuz
parents:
diff changeset
120 case RunAnalysis: Action = "RunAnalysis"; break;
anatofuz
parents:
diff changeset
121 #endif
anatofuz
parents:
diff changeset
122 case RunPreprocessorOnly: return std::make_unique<PreprocessOnlyAction>();
anatofuz
parents:
diff changeset
123 case PrintDependencyDirectivesSourceMinimizerOutput:
anatofuz
parents:
diff changeset
124 return std::make_unique<PrintDependencyDirectivesSourceMinimizerAction>();
anatofuz
parents:
diff changeset
125 }
anatofuz
parents:
diff changeset
126
anatofuz
parents:
diff changeset
127 #if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \
anatofuz
parents:
diff changeset
128 || !CLANG_ENABLE_OBJC_REWRITER
anatofuz
parents:
diff changeset
129 CI.getDiagnostics().Report(diag::err_fe_action_not_available) << Action;
anatofuz
parents:
diff changeset
130 return 0;
anatofuz
parents:
diff changeset
131 #else
anatofuz
parents:
diff changeset
132 llvm_unreachable("Invalid program action!");
anatofuz
parents:
diff changeset
133 #endif
anatofuz
parents:
diff changeset
134 }
anatofuz
parents:
diff changeset
135
anatofuz
parents:
diff changeset
136 std::unique_ptr<FrontendAction>
anatofuz
parents:
diff changeset
137 CreateFrontendAction(CompilerInstance &CI) {
anatofuz
parents:
diff changeset
138 // Create the underlying action.
anatofuz
parents:
diff changeset
139 std::unique_ptr<FrontendAction> Act = CreateFrontendBaseAction(CI);
anatofuz
parents:
diff changeset
140 if (!Act)
anatofuz
parents:
diff changeset
141 return nullptr;
anatofuz
parents:
diff changeset
142
anatofuz
parents:
diff changeset
143 const FrontendOptions &FEOpts = CI.getFrontendOpts();
anatofuz
parents:
diff changeset
144
anatofuz
parents:
diff changeset
145 if (FEOpts.FixAndRecompile) {
anatofuz
parents:
diff changeset
146 Act = std::make_unique<FixItRecompile>(std::move(Act));
anatofuz
parents:
diff changeset
147 }
anatofuz
parents:
diff changeset
148
anatofuz
parents:
diff changeset
149 #if CLANG_ENABLE_ARCMT
anatofuz
parents:
diff changeset
150 if (CI.getFrontendOpts().ProgramAction != frontend::MigrateSource &&
anatofuz
parents:
diff changeset
151 CI.getFrontendOpts().ProgramAction != frontend::GeneratePCH) {
anatofuz
parents:
diff changeset
152 // Potentially wrap the base FE action in an ARC Migrate Tool action.
anatofuz
parents:
diff changeset
153 switch (FEOpts.ARCMTAction) {
anatofuz
parents:
diff changeset
154 case FrontendOptions::ARCMT_None:
anatofuz
parents:
diff changeset
155 break;
anatofuz
parents:
diff changeset
156 case FrontendOptions::ARCMT_Check:
anatofuz
parents:
diff changeset
157 Act = std::make_unique<arcmt::CheckAction>(std::move(Act));
anatofuz
parents:
diff changeset
158 break;
anatofuz
parents:
diff changeset
159 case FrontendOptions::ARCMT_Modify:
anatofuz
parents:
diff changeset
160 Act = std::make_unique<arcmt::ModifyAction>(std::move(Act));
anatofuz
parents:
diff changeset
161 break;
anatofuz
parents:
diff changeset
162 case FrontendOptions::ARCMT_Migrate:
anatofuz
parents:
diff changeset
163 Act = std::make_unique<arcmt::MigrateAction>(std::move(Act),
anatofuz
parents:
diff changeset
164 FEOpts.MTMigrateDir,
anatofuz
parents:
diff changeset
165 FEOpts.ARCMTMigrateReportOut,
anatofuz
parents:
diff changeset
166 FEOpts.ARCMTMigrateEmitARCErrors);
anatofuz
parents:
diff changeset
167 break;
anatofuz
parents:
diff changeset
168 }
anatofuz
parents:
diff changeset
169
anatofuz
parents:
diff changeset
170 if (FEOpts.ObjCMTAction != FrontendOptions::ObjCMT_None) {
anatofuz
parents:
diff changeset
171 Act = std::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
anatofuz
parents:
diff changeset
172 FEOpts.MTMigrateDir,
anatofuz
parents:
diff changeset
173 FEOpts.ObjCMTAction);
anatofuz
parents:
diff changeset
174 }
anatofuz
parents:
diff changeset
175 }
anatofuz
parents:
diff changeset
176 #endif
anatofuz
parents:
diff changeset
177
anatofuz
parents:
diff changeset
178 // If there are any AST files to merge, create a frontend action
anatofuz
parents:
diff changeset
179 // adaptor to perform the merge.
anatofuz
parents:
diff changeset
180 if (!FEOpts.ASTMergeFiles.empty())
anatofuz
parents:
diff changeset
181 Act = std::make_unique<ASTMergeAction>(std::move(Act),
anatofuz
parents:
diff changeset
182 FEOpts.ASTMergeFiles);
anatofuz
parents:
diff changeset
183
anatofuz
parents:
diff changeset
184 return Act;
anatofuz
parents:
diff changeset
185 }
anatofuz
parents:
diff changeset
186
anatofuz
parents:
diff changeset
187 bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
anatofuz
parents:
diff changeset
188 // Honor -help.
anatofuz
parents:
diff changeset
189 if (Clang->getFrontendOpts().ShowHelp) {
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 221
diff changeset
190 driver::getDriverOptTable().printHelp(
150
anatofuz
parents:
diff changeset
191 llvm::outs(), "clang -cc1 [options] file...",
anatofuz
parents:
diff changeset
192 "LLVM 'Clang' Compiler: http://clang.llvm.org",
anatofuz
parents:
diff changeset
193 /*Include=*/driver::options::CC1Option,
anatofuz
parents:
diff changeset
194 /*Exclude=*/0, /*ShowAllAliases=*/false);
anatofuz
parents:
diff changeset
195 return true;
anatofuz
parents:
diff changeset
196 }
anatofuz
parents:
diff changeset
197
anatofuz
parents:
diff changeset
198 // Honor -version.
anatofuz
parents:
diff changeset
199 //
anatofuz
parents:
diff changeset
200 // FIXME: Use a better -version message?
anatofuz
parents:
diff changeset
201 if (Clang->getFrontendOpts().ShowVersion) {
anatofuz
parents:
diff changeset
202 llvm::cl::PrintVersionMessage();
anatofuz
parents:
diff changeset
203 return true;
anatofuz
parents:
diff changeset
204 }
anatofuz
parents:
diff changeset
205
anatofuz
parents:
diff changeset
206 // Load any requested plugins.
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
207 for (const std::string &Path : Clang->getFrontendOpts().Plugins) {
150
anatofuz
parents:
diff changeset
208 std::string Error;
anatofuz
parents:
diff changeset
209 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
anatofuz
parents:
diff changeset
210 Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
anatofuz
parents:
diff changeset
211 << Path << Error;
anatofuz
parents:
diff changeset
212 }
anatofuz
parents:
diff changeset
213
anatofuz
parents:
diff changeset
214 // Check if any of the loaded plugins replaces the main AST action
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
215 for (const FrontendPluginRegistry::entry &Plugin :
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
216 FrontendPluginRegistry::entries()) {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
217 std::unique_ptr<PluginASTAction> P(Plugin.instantiate());
150
anatofuz
parents:
diff changeset
218 if (P->getActionType() == PluginASTAction::ReplaceAction) {
anatofuz
parents:
diff changeset
219 Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction;
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
220 Clang->getFrontendOpts().ActionName = Plugin.getName().str();
150
anatofuz
parents:
diff changeset
221 break;
anatofuz
parents:
diff changeset
222 }
anatofuz
parents:
diff changeset
223 }
anatofuz
parents:
diff changeset
224
anatofuz
parents:
diff changeset
225 // Honor -mllvm.
anatofuz
parents:
diff changeset
226 //
anatofuz
parents:
diff changeset
227 // FIXME: Remove this, one day.
anatofuz
parents:
diff changeset
228 // This should happen AFTER plugins have been loaded!
anatofuz
parents:
diff changeset
229 if (!Clang->getFrontendOpts().LLVMArgs.empty()) {
anatofuz
parents:
diff changeset
230 unsigned NumArgs = Clang->getFrontendOpts().LLVMArgs.size();
anatofuz
parents:
diff changeset
231 auto Args = std::make_unique<const char*[]>(NumArgs + 2);
anatofuz
parents:
diff changeset
232 Args[0] = "clang (LLVM option parsing)";
anatofuz
parents:
diff changeset
233 for (unsigned i = 0; i != NumArgs; ++i)
anatofuz
parents:
diff changeset
234 Args[i + 1] = Clang->getFrontendOpts().LLVMArgs[i].c_str();
anatofuz
parents:
diff changeset
235 Args[NumArgs + 1] = nullptr;
anatofuz
parents:
diff changeset
236 llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
anatofuz
parents:
diff changeset
237 }
anatofuz
parents:
diff changeset
238
anatofuz
parents:
diff changeset
239 #if CLANG_ENABLE_STATIC_ANALYZER
anatofuz
parents:
diff changeset
240 // These should happen AFTER plugins have been loaded!
anatofuz
parents:
diff changeset
241
anatofuz
parents:
diff changeset
242 AnalyzerOptions &AnOpts = *Clang->getAnalyzerOpts();
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
243
150
anatofuz
parents:
diff changeset
244 // Honor -analyzer-checker-help and -analyzer-checker-help-hidden.
anatofuz
parents:
diff changeset
245 if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha ||
anatofuz
parents:
diff changeset
246 AnOpts.ShowCheckerHelpDeveloper) {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
247 ento::printCheckerHelp(llvm::outs(), *Clang);
150
anatofuz
parents:
diff changeset
248 return true;
anatofuz
parents:
diff changeset
249 }
anatofuz
parents:
diff changeset
250
anatofuz
parents:
diff changeset
251 // Honor -analyzer-checker-option-help.
anatofuz
parents:
diff changeset
252 if (AnOpts.ShowCheckerOptionList || AnOpts.ShowCheckerOptionAlphaList ||
anatofuz
parents:
diff changeset
253 AnOpts.ShowCheckerOptionDeveloperList) {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
254 ento::printCheckerConfigList(llvm::outs(), *Clang);
150
anatofuz
parents:
diff changeset
255 return true;
anatofuz
parents:
diff changeset
256 }
anatofuz
parents:
diff changeset
257
anatofuz
parents:
diff changeset
258 // Honor -analyzer-list-enabled-checkers.
anatofuz
parents:
diff changeset
259 if (AnOpts.ShowEnabledCheckerList) {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
260 ento::printEnabledCheckerList(llvm::outs(), *Clang);
150
anatofuz
parents:
diff changeset
261 return true;
anatofuz
parents:
diff changeset
262 }
anatofuz
parents:
diff changeset
263
anatofuz
parents:
diff changeset
264 // Honor -analyzer-config-help.
anatofuz
parents:
diff changeset
265 if (AnOpts.ShowConfigOptionsList) {
anatofuz
parents:
diff changeset
266 ento::printAnalyzerConfigList(llvm::outs());
anatofuz
parents:
diff changeset
267 return true;
anatofuz
parents:
diff changeset
268 }
anatofuz
parents:
diff changeset
269 #endif
anatofuz
parents:
diff changeset
270
anatofuz
parents:
diff changeset
271 // If there were errors in processing arguments, don't do anything else.
anatofuz
parents:
diff changeset
272 if (Clang->getDiagnostics().hasErrorOccurred())
anatofuz
parents:
diff changeset
273 return false;
anatofuz
parents:
diff changeset
274 // Create and execute the frontend action.
anatofuz
parents:
diff changeset
275 std::unique_ptr<FrontendAction> Act(CreateFrontendAction(*Clang));
anatofuz
parents:
diff changeset
276 if (!Act)
anatofuz
parents:
diff changeset
277 return false;
anatofuz
parents:
diff changeset
278 bool Success = Clang->ExecuteAction(*Act);
anatofuz
parents:
diff changeset
279 if (Clang->getFrontendOpts().DisableFree)
anatofuz
parents:
diff changeset
280 llvm::BuryPointer(std::move(Act));
anatofuz
parents:
diff changeset
281 return Success;
anatofuz
parents:
diff changeset
282 }
anatofuz
parents:
diff changeset
283
anatofuz
parents:
diff changeset
284 } // namespace clang