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