[clang-tools-extra] 6fa82e3 - [clang-tidy] modernize-deprecated-headers should ignore system headers
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri May 20 12:44:35 PDT 2022
Author: Balazs Benics
Date: 2022-05-20T21:41:25+02:00
New Revision: 6fa82e344c291cf0e1134b357b1f09fd2dcd3f4f
URL: https://github.com/llvm/llvm-project/commit/6fa82e344c291cf0e1134b357b1f09fd2dcd3f4f
DIFF: https://github.com/llvm/llvm-project/commit/6fa82e344c291cf0e1134b357b1f09fd2dcd3f4f.diff
LOG: [clang-tidy] modernize-deprecated-headers should ignore system headers
The end-user has no way of 'fixing' bugs in the system library anyway.
Let's suppress these as well.
Reviewed By: LegalizeAdulthood
Differential Revision: https://reviews.llvm.org/D125770
Added:
Modified:
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 72508a99e4a1..64e70ad746c5 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -188,6 +188,10 @@ void IncludeModernizePPCallbacks::InclusionDirective(
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:
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
index 98d66ce00ceb..1193c2ad0a99 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -34,8 +34,7 @@ extern "C++" {
#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]
More information about the cfe-commits
mailing list