[PATCH] Allow per-file clang-tidy options.

Manuel Klimek klimek at google.com
Mon Jun 2 10:51:18 PDT 2014


================
Comment at: clang-tidy/ClangTidy.cpp:208
@@ +207,3 @@
+
+  SmallVector<ClangTidyCheck*, 8> Checks;
+  ChecksFilter &Filter = Context.getChecksFilter();
----------------
Any reasons for not using a vector of unique_ptr's an moving that into the ASTConsumer?

================
Comment at: clang-tidy/ClangTidy.cpp:216
@@ -204,1 +215,3 @@
+    Check->setContext(&Context);
+    Check->registerMatchers(&*Finder);
     Check->registerPPCallbacks(Compiler);
----------------
Finder.get()?

================
Comment at: clang-tidy/ClangTidy.cpp:269
@@ +268,3 @@
+    AnalyzerChecksEnabled =
+        AnalyzerChecksEnabled | !CheckName.startswith("debug") &&
+        Filter.isCheckEnabled(Checker);
----------------
Wait, this seems to have been incorrect before (| instead of logical ||), and I think we're missing parens.

================
Comment at: clang-tidy/ClangTidyDiagnosticConsumer.h:170
@@ +169,3 @@
+
+  StringRef CurrentFile;
+  std::unique_ptr<ChecksFilter> CheckFilter;
----------------
Any reason not to store a std::string here? Seems fragile to store a StringRef.

================
Comment at: clang-tidy/ClangTidyOptions.h:30-31
@@ -25,1 +29,4 @@
+
+  /// \brief A list of line ranges in this file, from where the warnings may be
+  /// displayed.
   std::vector<LineRange> LineRanges;
----------------
... for which we show warnings.

================
Comment at: clang-tidy/ClangTidyOptions.h:35
@@ -27,2 +34,3 @@
 
-/// \brief Contains options for clang-tidy.
+/// \brief Global options. These options are nor stored neither read from
+/// configuration files.
----------------
neither... nor...

================
Comment at: clang-tidy/ClangTidyOptions.h:38-39
@@ +37,4 @@
+struct ClangTidyGlobalOptions {
+  /// \brief Output warnings from certain line ranges of certain files only. If
+  /// this list is emtpy, it won't be applied.
+  std::vector<FileFilter> LineFilter;
----------------
I think the second sentence doesn't help. I'd delete it.

================
Comment at: clang-tidy/ClangTidyOptions.h:76-78
@@ +75,5 @@
+class DefaultOptionsProvider : public ClangTidyOptionsProvider {
+  ClangTidyGlobalOptions GlobalOptions;
+  ClangTidyOptions DefaultOptions;
+
+public:
----------------
I'd vote for putting members at the end of the class.

http://reviews.llvm.org/D3979






More information about the cfe-commits mailing list