[PATCH] D125770: [clang-tidy] modernize-deprecated-headers should ignore system headers

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 18 02:56:36 PDT 2022


steakhal updated this revision to Diff 430305.
steakhal marked an inline comment as done.
steakhal retitled this revision from "[clang-tidy] modernize-deprecated-headers should ignore  system headers" to "[clang-tidy] modernize-deprecated-headers should ignore system headers".
steakhal added a comment.

Rebased after changing the name of the option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125770

Files:
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -34,8 +34,7 @@
 #include <stdbool.h>
 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
 
-#include <mysystemlib.h> // FIXME: We should have no warning into system headers.
-// CHECK-MESSAGES-CHECK-HEADER-FILE: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+#include <mysystemlib.h> // no-warning: Don't warn into system headers.
 
 #include <mylib.h>
 // CHECK-MESSAGES-CHECK-HEADER-FILE: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -188,6 +188,10 @@
   if (!CheckHeaderFile && !SM.isInMainFile(HashLoc))
     return;
 
+  // Ignore system headers.
+  if (SM.isInSystemHeader(HashLoc))
+    return;
+
   // FIXME: Take care of library symbols from the global namespace.
   //
   // Reasonable options for the check:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125770.430305.patch
Type: text/x-patch
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220518/8f2af9da/attachment.bin>


More information about the cfe-commits mailing list