[PATCH] [clang-tidy] Static Analyzer checker configuration options passthrough

Alexander Kornienko alexfh at google.com
Tue Mar 10 18:48:14 PDT 2015


In http://reviews.llvm.org/D8164#137453, @xazax.hun wrote:

> One minor question: the options are stored in std::map<std::string, std::string>. I wonder if there is any specific reason not to use llvm::StringMap in this case.


I don't remember any specific reason. You can try to replace map<> with StringMap in a separate patch.


================
Comment at: clang-tidy/ClangTidy.cpp:207
@@ -206,1 +206,3 @@
 
+static void getStaticAnalyzerCheckerOpts(AnalyzerOptionsRef AnalyzerOptions,
+                                         const ClangTidyOptions &Opts) {
----------------
I'd say that the function _sets_ static analyzer checker options, not gets them. Also, IMHO the other order of arguments would be better, as it seems more intuitive if the source comes first (it may be a matter of taste, though, and memcpy, for example, puts destination first).

================
Comment at: clang-tidy/ClangTidy.cpp:210
@@ +209,3 @@
+  StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
+  size_t Pos;
+  for (auto &Opt : Opts.CheckOptions) {
----------------
I'd move the declaration into the loop.

================
Comment at: clang-tidy/ClangTidy.cpp:211
@@ +210,3 @@
+  size_t Pos;
+  for (auto &Opt : Opts.CheckOptions) {
+    StringRef OptName(Opt.first);
----------------
`const auto &`

================
Comment at: clang-tidy/ClangTidy.cpp:218
@@ +217,3 @@
+        OptName.substr(AnalyzerPrefix.size(), Pos - AnalyzerPrefix.size());
+    AnalyzerOptions->Config[(Twine(AnalyzerCheckName) + ":" +
+                             OptName.substr(Pos + 1)).str()] = Opt.second;
----------------
Can we just use the same format in clang-tidy options (prepended with 'clang-analyzer-')?

http://reviews.llvm.org/D8164

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list