[PATCH] D90835: [RFC][clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 5 12:36:46 PST 2020


njames93 added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:249-251
+  if (!HeaderFilter)
+    HeaderFilter =
+        std::make_unique<llvm::Regex>(*getOptions().HeaderFilterRegex);
----------------
This should also check if the Optional has a value


================
Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:349-351
+  // Skip macro from system headers.
+  if (!*Context.getOptions().SystemHeaders && SM.isInSystemHeader(SpellingLoc))
+    return true;
----------------
This looks suspicious, in clang-tidy land `SystemHeaders` is always set, however outside clang-tidy it may not be.
Perhaps `getValueOr(false)` should be used to prevent any asserts.

Also can a test be added to show this respecting the SystemHeaders setting.


================
Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:358-360
+  if (!File) {
+    return false;
+  }
----------------
Elide braces


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90835/new/

https://reviews.llvm.org/D90835



More information about the cfe-commits mailing list