blob: 19e9165ee12a342cf8170ce8caac156d3b1949d8 [file] [log] [blame]
Daniel Jasperd07c8402013-07-29 08:19:24 +00001//===--- 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"
Manuel Klimek814f9bd2013-11-14 15:49:44 +000019#include "clang/Tooling/CommonOptionsParser.h"
Alexander Kornienkoe9951542014-09-24 18:36:03 +000020#include "llvm/Support/Process.h"
Daniel Jasperd07c8402013-07-29 08:19:24 +000021
22using namespace clang::ast_matchers;
23using namespace clang::driver;
24using namespace clang::tooling;
25using namespace llvm;
26
Alexander Kornienko99c9d6a2014-02-05 13:43:27 +000027static cl::OptionCategory ClangTidyCategory("clang-tidy options");
Daniel Jasperd07c8402013-07-29 08:19:24 +000028
Manuel Klimek814f9bd2013-11-14 15:49:44 +000029static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +000030static cl::extrahelp ClangTidyHelp(R"(
31Configuration 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)");
Daniel Jasperd07c8402013-07-29 08:19:24 +000051
Alexander Kornienko50ab1562014-10-29 18:25:09 +000052const 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
Alexander Kornienkodad4acb2014-05-22 16:07:11 +000056
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +000057static cl::opt<std::string> Checks("checks", cl::desc(R"(
58Comma-separated list of globs with optional '-'
59prefix. Globs are processed in order of
60appearance in the list. Globs without '-'
61prefix add checks with matching names to the
62set, globs with the '-' prefix remove checks
63with matching names from the set of enabled
64checks. This option's value is appended to the
65value of the 'Checks' option in .clang-tidy
66file, if any.
67)"),
68 cl::init(""), cl::cat(ClangTidyCategory));
Alexander Kornienkodad4acb2014-05-22 16:07:11 +000069
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +000070static cl::opt<std::string> WarningsAsErrors("warnings-as-errors", cl::desc(R"(
71Upgrades warnings to errors. Same format as
72'-checks'.
73This option's value is appended to the value of
74the 'WarningsAsErrors' option in .clang-tidy
75file, if any.
76)"),
77 cl::init(""),
78 cl::cat(ClangTidyCategory));
Jonathan Roelofsd60388a2016-01-13 17:36:41 +000079
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +000080static cl::opt<std::string> HeaderFilter("header-filter", cl::desc(R"(
81Regular expression matching the names of the
82headers to output diagnostics from. Diagnostics
83from the main file of each translation unit are
84always displayed.
85Can be used together with -line-filter.
86This option overrides the 'HeaderFilter' option
87in .clang-tidy file, if any.
88)"),
89 cl::init(""),
90 cl::cat(ClangTidyCategory));
Alexander Kornienkodad4acb2014-05-22 16:07:11 +000091
Alexander Kornienko37f7abe2014-10-28 22:16:13 +000092static cl::opt<bool>
93 SystemHeaders("system-headers",
Alexander Kornienko5eac3c62014-11-03 14:06:31 +000094 cl::desc("Display the errors from system headers."),
Alexander Kornienko37f7abe2014-10-28 22:16:13 +000095 cl::init(false), cl::cat(ClangTidyCategory));
Alexander Kornienkodad4acb2014-05-22 16:07:11 +000096static cl::opt<std::string>
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +000097 LineFilter("line-filter",
98 cl::desc(R"(
99List of files with line ranges to filter the
100warnings. Can be used together with
101-header-filter. The format of the list is a
102JSON 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));
Alexander Kornienkodad4acb2014-05-22 16:07:11 +0000109
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000110static cl::opt<bool> Fix("fix", cl::desc(R"(
111Apply suggested fixes. Without -fix-errors
112clang-tidy will bail out if any compilation
113errors were found.
114)"),
115 cl::init(false), cl::cat(ClangTidyCategory));
Alexander Kornienko5eac3c62014-11-03 14:06:31 +0000116
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000117static cl::opt<bool> FixErrors("fix-errors", cl::desc(R"(
118Apply suggested fixes even if compilation
119errors were found. If compiler errors have
120attached fix-its, clang-tidy will apply them as
121well.
122)"),
123 cl::init(false), cl::cat(ClangTidyCategory));
Daniel Jasperd07c8402013-07-29 08:19:24 +0000124
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000125static cl::opt<bool> ListChecks("list-checks", cl::desc(R"(
126List all enabled checks and exit. Use with
127-checks=* to list all available checks.
128)"),
129 cl::init(false), cl::cat(ClangTidyCategory));
Daniel Jasperd07c8402013-07-29 08:19:24 +0000130
Haojian Wu12e6b8f2016-04-27 09:15:01 +0000131static cl::opt<bool> ExplainConfig("explain-config", cl::desc(R"(
132for each enabled check explains, where it is enabled, i.e. in clang-tidy binary,
133command line or a specific configuration file.
134)"),
135 cl::init(false), cl::cat(ClangTidyCategory));
136
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000137static cl::opt<std::string> Config("config", cl::desc(R"(
138Specifies a configuration in YAML/JSON format:
139 -config="{Checks: '*',
140 CheckOptions: [{key: x,
141 value: y}]}"
142When the value is empty, clang-tidy will
143attempt to find a file named .clang-tidy for
144each source file in its parent directories.
145)"),
146 cl::init(""), cl::cat(ClangTidyCategory));
Alexander Kornienkoeff4e922014-09-26 11:42:29 +0000147
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000148static cl::opt<bool> DumpConfig("dump-config", cl::desc(R"(
149Dumps configuration in the YAML format to
150stdout. This option can be used along with a
151file name (and '--' if the file is outside of a
152project with configured compilation database).
153The configuration used for this file will be
154printed.
155Use along with -checks=* to include
156configuration of all checks.
157)"),
158 cl::init(false), cl::cat(ClangTidyCategory));
Alexander Kornienkod53d2682014-09-04 14:23:36 +0000159
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000160static cl::opt<bool> EnableCheckProfile("enable-check-profile", cl::desc(R"(
161Enable per-check timing profiles, and print a
162report to stderr.
163)"),
164 cl::init(false),
165 cl::cat(ClangTidyCategory));
Samuel Benzaquenaedd9942014-10-23 17:23:20 +0000166
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000167static cl::opt<bool> AnalyzeTemporaryDtors("analyze-temporary-dtors",
168 cl::desc(R"(
169Enable temporary destructor-aware analysis in
170clang-analyzer- checks.
171This option overrides the value read from a
172.clang-tidy file.
173)"),
174 cl::init(false),
175 cl::cat(ClangTidyCategory));
Alex McCarthyfec08c72014-04-30 14:09:24 +0000176
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000177static cl::opt<std::string> ExportFixes("export-fixes", cl::desc(R"(
178YAML file to store suggested fixes in. The
179stored fixes can be applied to the input sorce
180code with clang-apply-replacements.
181)"),
182 cl::value_desc("filename"),
183 cl::cat(ClangTidyCategory));
Benjamin Kramerfb98b742014-09-04 10:31:23 +0000184
Alexander Kornienkoc28c32d2014-09-10 11:43:09 +0000185namespace clang {
186namespace tidy {
187
188static void printStats(const ClangTidyStats &Stats) {
Alexander Kornienkodad4acb2014-05-22 16:07:11 +0000189 if (Stats.errorsIgnored()) {
190 llvm::errs() << "Suppressed " << Stats.errorsIgnored() << " warnings (";
Alexander Kornienko5d174542014-05-07 09:06:53 +0000191 StringRef Separator = "";
192 if (Stats.ErrorsIgnoredNonUserCode) {
193 llvm::errs() << Stats.ErrorsIgnoredNonUserCode << " in non-user code";
194 Separator = ", ";
195 }
Alexander Kornienkodad4acb2014-05-22 16:07:11 +0000196 if (Stats.ErrorsIgnoredLineFilter) {
197 llvm::errs() << Separator << Stats.ErrorsIgnoredLineFilter
198 << " due to line filter";
199 Separator = ", ";
200 }
Alexander Kornienko5d174542014-05-07 09:06:53 +0000201 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)
Aaron Ballman5a4892b2015-07-27 13:41:30 +0000210 llvm::errs() << "Use -header-filter=.* to display errors from all "
Alexander Kornienkof1d54eb2016-02-08 00:19:29 +0000211 "non-system headers. Use -system-headers to display "
212 "errors from system headers as well.\n";
Alexander Kornienko5d174542014-05-07 09:06:53 +0000213 }
214}
215
Samuel Benzaquenaedd9942014-10-23 17:23:20 +0000216static 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
Benjamin Kramere7103712015-03-23 12:49:15 +0000255static std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider() {
Alexander Kornienkoc28c32d2014-09-10 11:43:09 +0000256 ClangTidyGlobalOptions GlobalOptions;
257 if (std::error_code Err = parseLineFilter(LineFilter, GlobalOptions)) {
Alexander Kornienkodad4acb2014-05-22 16:07:11 +0000258 llvm::errs() << "Invalid LineFilter: " << Err.message() << "\n\nUsage:\n";
259 llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
Alexander Kornienkoeff4e922014-09-26 11:42:29 +0000260 return nullptr;
Alexander Kornienkodad4acb2014-05-22 16:07:11 +0000261 }
Alexander Kornienko33a9bcc2014-04-29 15:20:10 +0000262
Alexander Kornienkoe9951542014-09-24 18:36:03 +0000263 ClangTidyOptions DefaultOptions;
264 DefaultOptions.Checks = DefaultChecks;
Jonathan Roelofsd60388a2016-01-13 17:36:41 +0000265 DefaultOptions.WarningsAsErrors = "";
Alexander Kornienkoe9951542014-09-24 18:36:03 +0000266 DefaultOptions.HeaderFilterRegex = HeaderFilter;
Alexander Kornienko37f7abe2014-10-28 22:16:13 +0000267 DefaultOptions.SystemHeaders = SystemHeaders;
Alexander Kornienkoe9951542014-09-24 18:36:03 +0000268 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");
Alexander Kornienkoa4695222014-06-05 13:31:45 +0000273
Alexander Kornienkoc28c32d2014-09-10 11:43:09 +0000274 ClangTidyOptions OverrideOptions;
Alexander Kornienkod53d2682014-09-04 14:23:36 +0000275 if (Checks.getNumOccurrences() > 0)
276 OverrideOptions.Checks = Checks;
Jonathan Roelofsd60388a2016-01-13 17:36:41 +0000277 if (WarningsAsErrors.getNumOccurrences() > 0)
278 OverrideOptions.WarningsAsErrors = WarningsAsErrors;
Alexander Kornienkod53d2682014-09-04 14:23:36 +0000279 if (HeaderFilter.getNumOccurrences() > 0)
280 OverrideOptions.HeaderFilterRegex = HeaderFilter;
Alexander Kornienko37f7abe2014-10-28 22:16:13 +0000281 if (SystemHeaders.getNumOccurrences() > 0)
282 OverrideOptions.SystemHeaders = SystemHeaders;
Alexander Kornienkod53d2682014-09-04 14:23:36 +0000283 if (AnalyzeTemporaryDtors.getNumOccurrences() > 0)
284 OverrideOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
285
Alexander Kornienkoeff4e922014-09-26 11:42:29 +0000286 if (!Config.empty()) {
287 if (llvm::ErrorOr<ClangTidyOptions> ParsedConfig =
288 parseConfiguration(Config)) {
Haojian Wu12e6b8f2016-04-27 09:15:01 +0000289 return llvm::make_unique<ConfigOptionsProvider>(
290 GlobalOptions,
291 ClangTidyOptions::getDefaults().mergeWith(DefaultOptions),
292 *ParsedConfig, OverrideOptions);
Alexander Kornienkoeff4e922014-09-26 11:42:29 +0000293 } 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
Benjamin Kramere7103712015-03-23 12:49:15 +0000303static int clangTidyMain(int argc, const char **argv) {
Alexander Kornienko65eccb42015-08-17 10:03:27 +0000304 CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
305 cl::ZeroOrMore);
Alexander Kornienkoeff4e922014-09-26 11:42:29 +0000306
307 auto OptionsProvider = createOptionsProvider();
308 if (!OptionsProvider)
309 return 1;
Alexander Kornienkod53d2682014-09-04 14:23:36 +0000310
Alexander Kornienko65eccb42015-08-17 10:03:27 +0000311 StringRef FileName("dummy");
312 auto PathList = OptionsParser.getSourcePathList();
313 if (!PathList.empty()) {
Alexander Kornienkoe0c900e2015-08-17 11:27:11 +0000314 FileName = PathList.front();
Alexander Kornienko65eccb42015-08-17 10:03:27 +0000315 }
Alexander Kornienkoc28c32d2014-09-10 11:43:09 +0000316 ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
317 std::vector<std::string> EnabledChecks = getCheckNames(EffectiveOptions);
Alexander Kornienkofbf92582014-06-02 20:32:06 +0000318
Haojian Wu12e6b8f2016-04-27 09:15:01 +0000319 if (ExplainConfig) {
320 //FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
321 std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
322 RawOptions = OptionsProvider->getRawOptions(FileName);
323 for (const std::string &Check : EnabledChecks) {
324 for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
325 if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
326 llvm::outs() << "'" << Check << "' is enabled in the " << It->second
327 << ".\n";
328 break;
329 }
330 }
331 }
332 return 0;
333 }
334
Alexander Kornienkofb9e92b2013-12-19 19:57:05 +0000335 if (ListChecks) {
Alexander Kornienkofb9e92b2013-12-19 19:57:05 +0000336 llvm::outs() << "Enabled checks:";
Alexander Kornienkofbf92582014-06-02 20:32:06 +0000337 for (auto CheckName : EnabledChecks)
Alexander Kornienko16ac6ce2014-03-05 13:14:32 +0000338 llvm::outs() << "\n " << CheckName;
Alexander Kornienkofb9e92b2013-12-19 19:57:05 +0000339 llvm::outs() << "\n\n";
340 return 0;
341 }
342
Alexander Kornienkod53d2682014-09-04 14:23:36 +0000343 if (DumpConfig) {
Alexander Kornienko6e0cbc82014-09-12 08:53:36 +0000344 EffectiveOptions.CheckOptions = getCheckOptions(EffectiveOptions);
Alexander Kornienko65eccb42015-08-17 10:03:27 +0000345 llvm::outs() << configurationAsText(
346 ClangTidyOptions::getDefaults().mergeWith(
347 EffectiveOptions))
Alexander Kornienkod53d2682014-09-04 14:23:36 +0000348 << "\n";
349 return 0;
350 }
351
Alexander Kornienkofbf92582014-06-02 20:32:06 +0000352 if (EnabledChecks.empty()) {
353 llvm::errs() << "Error: no checks enabled.\n";
354 llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
355 return 1;
356 }
357
Alexander Kornienko65eccb42015-08-17 10:03:27 +0000358 if (PathList.empty()) {
359 llvm::errs() << "Error: no input files specified.\n";
360 llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
361 return 1;
362 }
363
Samuel Benzaquenaedd9942014-10-23 17:23:20 +0000364 ProfileData Profile;
365
Alexander Kornienkoc28c32d2014-09-10 11:43:09 +0000366 std::vector<ClangTidyError> Errors;
367 ClangTidyStats Stats =
368 runClangTidy(std::move(OptionsProvider), OptionsParser.getCompilations(),
Alexander Kornienko65eccb42015-08-17 10:03:27 +0000369 PathList, &Errors,
Samuel Benzaquenaedd9942014-10-23 17:23:20 +0000370 EnableCheckProfile ? &Profile : nullptr);
Alexander Kornienko5eac3c62014-11-03 14:06:31 +0000371 bool FoundErrors =
372 std::find_if(Errors.begin(), Errors.end(), [](const ClangTidyError &E) {
373 return E.DiagLevel == ClangTidyError::Error;
374 }) != Errors.end();
375
376 const bool DisableFixes = Fix && FoundErrors && !FixErrors;
377
Jonathan Roelofsd60388a2016-01-13 17:36:41 +0000378 unsigned WErrorCount = 0;
379
Alexander Kornienko5eac3c62014-11-03 14:06:31 +0000380 // -fix-errors implies -fix.
Jonathan Roelofsd60388a2016-01-13 17:36:41 +0000381 handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
Daniel Jasperd07c8402013-07-29 08:19:24 +0000382
Alexander Kornienko4153da22014-09-04 15:19:49 +0000383 if (!ExportFixes.empty() && !Errors.empty()) {
Benjamin Kramerfb98b742014-09-04 10:31:23 +0000384 std::error_code EC;
385 llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
386 if (EC) {
387 llvm::errs() << "Error opening output file: " << EC.message() << '\n';
388 return 1;
389 }
Alexander Kornienkoc28c32d2014-09-10 11:43:09 +0000390 exportReplacements(Errors, OS);
Benjamin Kramerfb98b742014-09-04 10:31:23 +0000391 }
392
Alexander Kornienko5d174542014-05-07 09:06:53 +0000393 printStats(Stats);
Alexander Kornienko5eac3c62014-11-03 14:06:31 +0000394 if (DisableFixes)
Alexander Kornienkob0a9b702014-12-09 15:02:17 +0000395 llvm::errs()
396 << "Found compiler errors, but -fix-errors was not specified.\n"
397 "Fixes have NOT been applied.\n\n";
Alexander Kornienko5eac3c62014-11-03 14:06:31 +0000398
Samuel Benzaquenaedd9942014-10-23 17:23:20 +0000399 if (EnableCheckProfile)
400 printProfileData(Profile, llvm::errs());
401
Jonathan Roelofsd60388a2016-01-13 17:36:41 +0000402 if (WErrorCount) {
403 StringRef Plural = WErrorCount == 1 ? "" : "s";
404 llvm::errs() << WErrorCount << " warning" << Plural << " treated as error"
405 << Plural << "\n";
406 return WErrorCount;
407 }
408
Daniel Jasperd07c8402013-07-29 08:19:24 +0000409 return 0;
410}
Daniel Jasper89bbab02013-08-04 15:56:30 +0000411
Aaron Ballmanea2f90c2015-10-02 13:27:19 +0000412// This anchor is used to force the linker to link the CERTModule.
413extern volatile int CERTModuleAnchorSource;
414static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
415 CERTModuleAnchorSource;
416
Daniel Jasper89bbab02013-08-04 15:56:30 +0000417// This anchor is used to force the linker to link the LLVMModule.
418extern volatile int LLVMModuleAnchorSource;
Alexander Kornienkoe1292f82015-08-19 16:54:51 +0000419static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
420 LLVMModuleAnchorSource;
Daniel Jasper89bbab02013-08-04 15:56:30 +0000421
Aaron Ballmanaaa40802015-10-06 13:31:00 +0000422// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
423extern volatile int CppCoreGuidelinesModuleAnchorSource;
424static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
425 CppCoreGuidelinesModuleAnchorSource;
426
Daniel Jasper89bbab02013-08-04 15:56:30 +0000427// This anchor is used to force the linker to link the GoogleModule.
428extern volatile int GoogleModuleAnchorSource;
Alexander Kornienkoe1292f82015-08-19 16:54:51 +0000429static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
430 GoogleModuleAnchorSource;
Daniel Jasper89bbab02013-08-04 15:56:30 +0000431
Alexander Kornienko16ac6ce2014-03-05 13:14:32 +0000432// This anchor is used to force the linker to link the MiscModule.
433extern volatile int MiscModuleAnchorSource;
Alexander Kornienkoe1292f82015-08-19 16:54:51 +0000434static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
435 MiscModuleAnchorSource;
Alexander Kornienko16ac6ce2014-03-05 13:14:32 +0000436
Alexander Kornienkofc650862015-08-14 13:17:11 +0000437// This anchor is used to force the linker to link the ModernizeModule.
438extern volatile int ModernizeModuleAnchorSource;
Alexander Kornienkoe1292f82015-08-19 16:54:51 +0000439static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
440 ModernizeModuleAnchorSource;
Alexander Kornienkofc650862015-08-14 13:17:11 +0000441
Alexander Kornienkob959f4c2015-12-30 10:24:40 +0000442// This anchor is used to force the linker to link the PerformanceModule.
443extern volatile int PerformanceModuleAnchorSource;
444static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
445 PerformanceModuleAnchorSource;
446
Alexander Kornienko2192a8e2014-10-26 01:41:14 +0000447// This anchor is used to force the linker to link the ReadabilityModule.
448extern volatile int ReadabilityModuleAnchorSource;
Alexander Kornienkoe1292f82015-08-19 16:54:51 +0000449static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
450 ReadabilityModuleAnchorSource;
Alexander Kornienko2192a8e2014-10-26 01:41:14 +0000451
Daniel Jasper89bbab02013-08-04 15:56:30 +0000452} // namespace tidy
453} // namespace clang
Alexander Kornienkoc28c32d2014-09-10 11:43:09 +0000454
455int main(int argc, const char **argv) {
456 return clang::tidy::clangTidyMain(argc, argv);
457}