clang-tools  3.9.0
ClangTidyMain.cpp
Go to the documentation of this file.
1 //===--- tools/extra/clang-tidy/ClangTidyMain.cpp - Clang tidy tool -------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file This file implements a clang-tidy tool.
11 ///
12 /// This tool uses the Clang Tooling infrastructure, see
13 /// http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
14 /// for details on setting it up with LLVM source tree.
15 ///
16 //===----------------------------------------------------------------------===//
17 
18 #include "../ClangTidy.h"
19 #include "clang/Tooling/CommonOptionsParser.h"
20 #include "llvm/Support/Process.h"
21 
22 using namespace clang::ast_matchers;
23 using namespace clang::driver;
24 using namespace clang::tooling;
25 using namespace llvm;
26 
27 static cl::OptionCategory ClangTidyCategory("clang-tidy options");
28 
29 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
30 static cl::extrahelp ClangTidyHelp(R"(
31 Configuration files:
32  clang-tidy attempts to read configuration for each source file from a
33  .clang-tidy file located in the closest parent directory of the source
34  file. If any configuration options have a corresponding command-line
35  option, command-line option takes precedence. The effective
36  configuration can be inspected using -dump-config:
37 
38  $ clang-tidy -dump-config - --
39  ---
40  Checks: '-*,some-check'
41  WarningsAsErrors: ''
42  HeaderFilterRegex: ''
43  AnalyzeTemporaryDtors: false
44  User: user
45  CheckOptions:
46  - key: some-check.SomeOption
47  value: 'some value'
48  ...
49 
50 )");
51 
52 const char DefaultChecks[] = // Enable these checks:
53  "clang-diagnostic-*," // * compiler diagnostics
54  "clang-analyzer-*," // * Static Analyzer checks
55  "-clang-analyzer-alpha*"; // * but not alpha checks: many false positives
56 
57 static cl::opt<std::string> Checks("checks", cl::desc(R"(
58 Comma-separated list of globs with optional '-'
59 prefix. Globs are processed in order of
60 appearance in the list. Globs without '-'
61 prefix add checks with matching names to the
62 set, globs with the '-' prefix remove checks
63 with matching names from the set of enabled
64 checks. This option's value is appended to the
65 value of the 'Checks' option in .clang-tidy
66 file, if any.
67 )"),
68  cl::init(""), cl::cat(ClangTidyCategory));
69 
70 static cl::opt<std::string> WarningsAsErrors("warnings-as-errors", cl::desc(R"(
71 Upgrades warnings to errors. Same format as
72 '-checks'.
73 This option's value is appended to the value of
74 the 'WarningsAsErrors' option in .clang-tidy
75 file, if any.
76 )"),
77  cl::init(""),
78  cl::cat(ClangTidyCategory));
79 
80 static cl::opt<std::string> HeaderFilter("header-filter", cl::desc(R"(
81 Regular expression matching the names of the
82 headers to output diagnostics from. Diagnostics
83 from the main file of each translation unit are
84 always displayed.
85 Can be used together with -line-filter.
86 This option overrides the 'HeaderFilter' option
87 in .clang-tidy file, if any.
88 )"),
89  cl::init(""),
90  cl::cat(ClangTidyCategory));
91 
92 static cl::opt<bool>
93  SystemHeaders("system-headers",
94  cl::desc("Display the errors from system headers."),
95  cl::init(false), cl::cat(ClangTidyCategory));
96 static cl::opt<std::string>
97  LineFilter("line-filter",
98  cl::desc(R"(
99 List of files with line ranges to filter the
100 warnings. Can be used together with
101 -header-filter. The format of the list is a
102 JSON array of objects:
103  [
104  {"name":"file1.cpp","lines":[[1,3],[5,7]]},
105  {"name":"file2.h"}
106  ]
107 )"),
108  cl::init(""), cl::cat(ClangTidyCategory));
109 
110 static cl::opt<bool> Fix("fix", cl::desc(R"(
111 Apply suggested fixes. Without -fix-errors
112 clang-tidy will bail out if any compilation
113 errors were found.
114 )"),
115  cl::init(false), cl::cat(ClangTidyCategory));
116 
117 static cl::opt<bool> FixErrors("fix-errors", cl::desc(R"(
118 Apply suggested fixes even if compilation
119 errors were found. If compiler errors have
120 attached fix-its, clang-tidy will apply them as
121 well.
122 )"),
123  cl::init(false), cl::cat(ClangTidyCategory));
124 
125 static cl::opt<bool> ListChecks("list-checks", cl::desc(R"(
126 List all enabled checks and exit. Use with
127 -checks=* to list all available checks.
128 )"),
129  cl::init(false), cl::cat(ClangTidyCategory));
130 
131 static cl::opt<bool> ExplainConfig("explain-config", cl::desc(R"(
132 for each enabled check explains, where it is enabled, i.e. in clang-tidy binary,
133 command line or a specific configuration file.
134 )"),
135  cl::init(false), cl::cat(ClangTidyCategory));
136 
137 static cl::opt<std::string> Config("config", cl::desc(R"(
138 Specifies a configuration in YAML/JSON format:
139  -config="{Checks: '*',
140  CheckOptions: [{key: x,
141  value: y}]}"
142 When the value is empty, clang-tidy will
143 attempt to find a file named .clang-tidy for
144 each source file in its parent directories.
145 )"),
146  cl::init(""), cl::cat(ClangTidyCategory));
147 
148 static cl::opt<bool> DumpConfig("dump-config", cl::desc(R"(
149 Dumps configuration in the YAML format to
150 stdout. This option can be used along with a
151 file name (and '--' if the file is outside of a
152 project with configured compilation database).
153 The configuration used for this file will be
154 printed.
155 Use along with -checks=* to include
156 configuration of all checks.
157 )"),
158  cl::init(false), cl::cat(ClangTidyCategory));
159 
160 static cl::opt<bool> EnableCheckProfile("enable-check-profile", cl::desc(R"(
161 Enable per-check timing profiles, and print a
162 report to stderr.
163 )"),
164  cl::init(false),
165  cl::cat(ClangTidyCategory));
166 
167 static cl::opt<bool> AnalyzeTemporaryDtors("analyze-temporary-dtors",
168  cl::desc(R"(
169 Enable temporary destructor-aware analysis in
170 clang-analyzer- checks.
171 This option overrides the value read from a
172 .clang-tidy file.
173 )"),
174  cl::init(false),
175  cl::cat(ClangTidyCategory));
176 
177 static cl::opt<std::string> ExportFixes("export-fixes", cl::desc(R"(
178 YAML file to store suggested fixes in. The
179 stored fixes can be applied to the input sorce
180 code with clang-apply-replacements.
181 )"),
182  cl::value_desc("filename"),
183  cl::cat(ClangTidyCategory));
184 
185 namespace clang {
186 namespace tidy {
187 
188 static void printStats(const ClangTidyStats &Stats) {
189  if (Stats.errorsIgnored()) {
190  llvm::errs() << "Suppressed " << Stats.errorsIgnored() << " warnings (";
191  StringRef Separator = "";
192  if (Stats.ErrorsIgnoredNonUserCode) {
193  llvm::errs() << Stats.ErrorsIgnoredNonUserCode << " in non-user code";
194  Separator = ", ";
195  }
196  if (Stats.ErrorsIgnoredLineFilter) {
197  llvm::errs() << Separator << Stats.ErrorsIgnoredLineFilter
198  << " due to line filter";
199  Separator = ", ";
200  }
201  if (Stats.ErrorsIgnoredNOLINT) {
202  llvm::errs() << Separator << Stats.ErrorsIgnoredNOLINT << " NOLINT";
203  Separator = ", ";
204  }
205  if (Stats.ErrorsIgnoredCheckFilter)
206  llvm::errs() << Separator << Stats.ErrorsIgnoredCheckFilter
207  << " with check filters";
208  llvm::errs() << ").\n";
209  if (Stats.ErrorsIgnoredNonUserCode)
210  llvm::errs() << "Use -header-filter=.* to display errors from all "
211  "non-system headers. Use -system-headers to display "
212  "errors from system headers as well.\n";
213  }
214 }
215 
216 static void printProfileData(const ProfileData &Profile,
217  llvm::raw_ostream &OS) {
218  // Time is first to allow for sorting by it.
219  std::vector<std::pair<llvm::TimeRecord, StringRef>> Timers;
220  TimeRecord Total;
221 
222  for (const auto& P : Profile.Records) {
223  Timers.emplace_back(P.getValue(), P.getKey());
224  Total += P.getValue();
225  }
226 
227  std::sort(Timers.begin(), Timers.end());
228 
229  std::string Line = "===" + std::string(73, '-') + "===\n";
230  OS << Line;
231 
232  if (Total.getUserTime())
233  OS << " ---User Time---";
234  if (Total.getSystemTime())
235  OS << " --System Time--";
236  if (Total.getProcessTime())
237  OS << " --User+System--";
238  OS << " ---Wall Time---";
239  if (Total.getMemUsed())
240  OS << " ---Mem---";
241  OS << " --- Name ---\n";
242 
243  // Loop through all of the timing data, printing it out.
244  for (auto I = Timers.rbegin(), E = Timers.rend(); I != E; ++I) {
245  I->first.print(Total, OS);
246  OS << I->second << '\n';
247  }
248 
249  Total.print(Total, OS);
250  OS << "Total\n";
251  OS << Line << "\n";
252  OS.flush();
253 }
254 
255 static std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider() {
256  ClangTidyGlobalOptions GlobalOptions;
257  if (std::error_code Err = parseLineFilter(LineFilter, GlobalOptions)) {
258  llvm::errs() << "Invalid LineFilter: " << Err.message() << "\n\nUsage:\n";
259  llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
260  return nullptr;
261  }
262 
263  ClangTidyOptions DefaultOptions;
264  DefaultOptions.Checks = DefaultChecks;
265  DefaultOptions.WarningsAsErrors = "";
266  DefaultOptions.HeaderFilterRegex = HeaderFilter;
267  DefaultOptions.SystemHeaders = SystemHeaders;
268  DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
269  DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
270  // USERNAME is used on Windows.
271  if (!DefaultOptions.User)
272  DefaultOptions.User = llvm::sys::Process::GetEnv("USERNAME");
273 
274  ClangTidyOptions OverrideOptions;
275  if (Checks.getNumOccurrences() > 0)
276  OverrideOptions.Checks = Checks;
277  if (WarningsAsErrors.getNumOccurrences() > 0)
278  OverrideOptions.WarningsAsErrors = WarningsAsErrors;
279  if (HeaderFilter.getNumOccurrences() > 0)
280  OverrideOptions.HeaderFilterRegex = HeaderFilter;
281  if (SystemHeaders.getNumOccurrences() > 0)
282  OverrideOptions.SystemHeaders = SystemHeaders;
283  if (AnalyzeTemporaryDtors.getNumOccurrences() > 0)
284  OverrideOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
285 
286  if (!Config.empty()) {
287  if (llvm::ErrorOr<ClangTidyOptions> ParsedConfig =
289  return llvm::make_unique<ConfigOptionsProvider>(
290  GlobalOptions,
291  ClangTidyOptions::getDefaults().mergeWith(DefaultOptions),
292  *ParsedConfig, OverrideOptions);
293  } else {
294  llvm::errs() << "Error: invalid configuration specified.\n"
295  << ParsedConfig.getError().message() << "\n";
296  return nullptr;
297  }
298  }
299  return llvm::make_unique<FileOptionsProvider>(GlobalOptions, DefaultOptions,
300  OverrideOptions);
301 }
302 
303 static int clangTidyMain(int argc, const char **argv) {
304  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
305  cl::ZeroOrMore);
306 
307  auto OptionsProvider = createOptionsProvider();
308  if (!OptionsProvider)
309  return 1;
310 
311  StringRef FileName("dummy");
312  auto PathList = OptionsParser.getSourcePathList();
313  if (!PathList.empty()) {
314  FileName = PathList.front();
315  }
316 
317  SmallString<256> FilePath(FileName);
318  if (std::error_code EC = llvm::sys::fs::make_absolute(FilePath)) {
319  llvm::errs() << "Can't make absolute path from " << FileName << ": "
320  << EC.message() << "\n";
321  }
322  ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
323  std::vector<std::string> EnabledChecks = getCheckNames(EffectiveOptions);
324 
325  if (ExplainConfig) {
326  //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
327  std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
328  RawOptions = OptionsProvider->getRawOptions(FilePath);
329  for (const std::string &Check : EnabledChecks) {
330  for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
331  if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
332  llvm::outs() << "'" << Check << "' is enabled in the " << It->second
333  << ".\n";
334  break;
335  }
336  }
337  }
338  return 0;
339  }
340 
341  if (ListChecks) {
342  if (EnabledChecks.empty()) {
343  llvm::errs() << "No checks enabled.\n";
344  return 1;
345  }
346  llvm::outs() << "Enabled checks:";
347  for (const auto &CheckName : EnabledChecks)
348  llvm::outs() << "\n " << CheckName;
349  llvm::outs() << "\n\n";
350  return 0;
351  }
353  if (DumpConfig) {
354  EffectiveOptions.CheckOptions = getCheckOptions(EffectiveOptions);
355  llvm::outs() << configurationAsText(
356  ClangTidyOptions::getDefaults().mergeWith(
357  EffectiveOptions))
358  << "\n";
359  return 0;
360  }
361 
362  if (EnabledChecks.empty()) {
363  llvm::errs() << "Error: no checks enabled.\n";
364  llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
365  return 1;
366  }
368  if (PathList.empty()) {
369  llvm::errs() << "Error: no input files specified.\n";
370  llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
371  return 1;
372  }
374  ProfileData Profile;
375 
376  std::vector<ClangTidyError> Errors;
377  ClangTidyStats Stats =
378  runClangTidy(std::move(OptionsProvider), OptionsParser.getCompilations(),
379  PathList, &Errors,
380  EnableCheckProfile ? &Profile : nullptr);
381  bool FoundErrors =
382  std::find_if(Errors.begin(), Errors.end(), [](const ClangTidyError &E) {
383  return E.DiagLevel == ClangTidyError::Error;
384  }) != Errors.end();
385 
386  const bool DisableFixes = Fix && FoundErrors && !FixErrors;
387 
388  unsigned WErrorCount = 0;
389 
390  // -fix-errors implies -fix.
391  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
392 
393  if (!ExportFixes.empty() && !Errors.empty()) {
394  std::error_code EC;
395  llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
396  if (EC) {
397  llvm::errs() << "Error opening output file: " << EC.message() << '\n';
398  return 1;
399  }
400  exportReplacements(Errors, OS);
401  }
402 
403  printStats(Stats);
404  if (DisableFixes)
405  llvm::errs()
406  << "Found compiler errors, but -fix-errors was not specified.\n"
407  "Fixes have NOT been applied.\n\n";
408 
409  if (EnableCheckProfile)
410  printProfileData(Profile, llvm::errs());
411 
412  if (WErrorCount) {
413  StringRef Plural = WErrorCount == 1 ? "" : "s";
414  llvm::errs() << WErrorCount << " warning" << Plural << " treated as error"
415  << Plural << "\n";
416  return WErrorCount;
417  }
418 
419  return 0;
420 }
421 
422 // This anchor is used to force the linker to link the CERTModule.
423 extern volatile int CERTModuleAnchorSource;
424 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
426 
427 // This anchor is used to force the linker to link the BoostModule.
428 extern volatile int BoostModuleAnchorSource;
429 static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
431 
432 // This anchor is used to force the linker to link the LLVMModule.
433 extern volatile int LLVMModuleAnchorSource;
434 static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
436 
437 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
438 extern volatile int CppCoreGuidelinesModuleAnchorSource;
439 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
441 
442 // This anchor is used to force the linker to link the GoogleModule.
443 extern volatile int GoogleModuleAnchorSource;
444 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
446 
447 // This anchor is used to force the linker to link the MiscModule.
448 extern volatile int MiscModuleAnchorSource;
449 static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
451 
452 // This anchor is used to force the linker to link the ModernizeModule.
453 extern volatile int ModernizeModuleAnchorSource;
454 static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
456 
457 // This anchor is used to force the linker to link the PerformanceModule.
458 extern volatile int PerformanceModuleAnchorSource;
459 static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
461 
462 // This anchor is used to force the linker to link the ReadabilityModule.
463 extern volatile int ReadabilityModuleAnchorSource;
464 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
466 
467 } // namespace tidy
468 } // namespace clang
469 
470 int main(int argc, const char **argv) {
471  return clang::tidy::clangTidyMain(argc, argv);
472 }
volatile int GoogleModuleAnchorSource
SetLongJmpCheck & Check
static void printStats(const ClangTidyStats &Stats)
static cl::extrahelp ClangTidyHelp(R"( Configuration files: clang-tidy attempts to read configuration for each source file from a .clang-tidy file located in the closest parent directory of the source file. If any configuration options have a corresponding command-line option, command-line option takes precedence. The effective configuration can be inspected using -dump-config: $ clang-tidy -dump-config - -- --- Checks: '-*,some-check' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false User: user CheckOptions: - key: some-check.SomeOption value: 'some value' ... )")
static cl::opt< bool > SystemHeaders("system-headers", cl::desc("Display the errors from system headers."), cl::init(false), cl::cat(ClangTidyCategory))
Read-only set of strings represented as a list of positive and negative globs.
volatile int ReadabilityModuleAnchorSource
static cl::opt< bool > FixErrors("fix-errors", cl::desc(R"( Apply suggested fixes even if compilation errors were found. If compiler errors have attached fix-its, clang-tidy will apply them as well. )"), cl::init(false), cl::cat(ClangTidyCategory))
static cl::opt< std::string > HeaderFilter("header-filter", cl::desc(R"( Regular expression matching the names of the headers to output diagnostics from. Diagnostics from the main file of each translation unit are always displayed. Can be used together with -line-filter. This option overrides the 'HeaderFilter' option in .clang-tidy file, if any. )"), cl::init(""), cl::cat(ClangTidyCategory))
bool contains(StringRef S)
Returns true if the pattern matches S.
static cl::opt< bool > DumpConfig("dump-config", cl::desc(R"( Dumps configuration in the YAML format to stdout. This option can be used along with a file name (and '--' if the file is outside of a project with configured compilation database). The configuration used for this file will be printed. Use along with -checks=* to include configuration of all checks. )"), cl::init(false), cl::cat(ClangTidyCategory))
ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options)
Returns the effective check-specific options.
Definition: ClangTidy.cpp:403
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination
std::error_code parseLineFilter(StringRef LineFilter, clang::tidy::ClangTidyGlobalOptions &Options)
Parses -line-filter option and stores it to the Options.
static cl::opt< bool > AnalyzeTemporaryDtors("analyze-temporary-dtors", cl::desc(R"( Enable temporary destructor-aware analysis in clang-analyzer- checks. This option overrides the value read from a .clang-tidy file. )"), cl::init(false), cl::cat(ClangTidyCategory))
llvm::ErrorOr< ClangTidyOptions > parseConfiguration(StringRef Config)
static cl::opt< bool > ListChecks("list-checks", cl::desc(R"( List all enabled checks and exit. Use with -checks=* to list all available checks. )"), cl::init(false), cl::cat(ClangTidyCategory))
volatile int LLVMModuleAnchorSource
volatile int PerformanceModuleAnchorSource
void exportReplacements(const std::vector< ClangTidyError > &Errors, raw_ostream &OS)
Serializes replacements into YAML and writes them to the specified output stream. ...
Definition: ClangTidy.cpp:510
volatile int CppCoreGuidelinesModuleAnchorSource
static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination
static cl::opt< std::string > LineFilter("line-filter", cl::desc(R"( List of files with line ranges to filter the warnings. Can be used together with -header-filter. The format of the list is a JSON array of objects: [ {"name":"file1.cpp","lines":[[1,3],[5,7]]}, {"name":"file2.h"} ] )"), cl::init(""), cl::cat(ClangTidyCategory))
std::string configurationAsText(const ClangTidyOptions &Options)
Serializes configuration to a YAML-encoded string.
volatile int CERTModuleAnchorSource
static cl::OptionCategory ClangTidyCategory("clang-tidy options")
static cl::opt< std::string > WarningsAsErrors("warnings-as-errors", cl::desc(R"( Upgrades warnings to errors. Same format as '-checks'. This option's value is appended to the value of the 'WarningsAsErrors' option in .clang-tidy file, if any. )"), cl::init(""), cl::cat(ClangTidyCategory))
static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination
std::vector< std::string > getCheckNames(const ClangTidyOptions &Options)
Fills the list of check names that are enabled when the provided filters are applied.
Definition: ClangTidy.cpp:395
ClangTidyStats runClangTidy(std::unique_ptr< ClangTidyOptionsProvider > OptionsProvider, const tooling::CompilationDatabase &Compilations, ArrayRef< std::string > InputFiles, std::vector< ClangTidyError > *Errors, ProfileData *Profile)
Run a set of clang-tidy checks on a set of files.
Definition: ClangTidy.cpp:412
static cl::opt< std::string > Config("config", cl::desc(R"( Specifies a configuration in YAML/JSON format: -config="{Checks: '*', CheckOptions:[{key:x, value:y}]}" When the value is empty, clang-tidy will attempt to find a file named .clang-tidy for each source file in its parent directories. )"), cl::init(""), cl::cat(ClangTidyCategory))
static cl::opt< bool > EnableCheckProfile("enable-check-profile", cl::desc(R"( Enable per-check timing profiles, and print a report to stderr. )"), cl::init(false), cl::cat(ClangTidyCategory))
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage)
static void printProfileData(const ProfileData &Profile, llvm::raw_ostream &OS)
volatile int BoostModuleAnchorSource
volatile int MiscModuleAnchorSource
static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination
static int clangTidyMain(int argc, const char **argv)
static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination
static cl::opt< std::string > ExportFixes("export-fixes", cl::desc(R"( YAML file to store suggested fixes in. The stored fixes can be applied to the input sorce code with clang-apply-replacements. )"), cl::value_desc("filename"), cl::cat(ClangTidyCategory))
const char DefaultChecks[]
static std::unique_ptr< ClangTidyOptionsProvider > createOptionsProvider()
int main(int argc, const char **argv)
Contains displayed and ignored diagnostic counters for a ClangTidy run.
static cl::opt< bool > ExplainConfig("explain-config", cl::desc(R"( for each enabled check explains, where it is enabled, i.e. in clang-tidy binary, command line or a specific configuration file. )"), cl::init(false), cl::cat(ClangTidyCategory))
void handleErrors(const std::vector< ClangTidyError > &Errors, bool Fix, unsigned &WarningsAsErrorsCount)
Displays the found Errors to the users.
Definition: ClangTidy.cpp:485
volatile int ModernizeModuleAnchorSource
static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination
static cl::opt< std::string > Checks("checks", cl::desc(R"( Comma-separated list of globs with optional '-' prefix. Globs are processed in order of appearance in the list. Globs without '-' prefix add checks with matching names to the set, globs with the '-' prefix remove checks with matching names from the set of enabled checks. This option's value is appended to the value of the 'Checks' option in .clang-tidy file, if any. )"), cl::init(""), cl::cat(ClangTidyCategory))
static cl::opt< bool > Fix("fix", cl::desc(R"( Apply suggested fixes. Without -fix-errors clang-tidy will bail out if any compilation errors were found. )"), cl::init(false), cl::cat(ClangTidyCategory))
static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination