[clang-tools-extra] ed740e7 - [clang-tidy] Attempt fixing wrong caching result in `bugprone-unsafe-functions`
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 2 06:25:12 PST 2023
Author: Whisperity
Date: 2023-02-02T15:24:40+01:00
New Revision: ed740e741ec22f9aaea09bfc0b87d0801a7c492f
URL: https://github.com/llvm/llvm-project/commit/ed740e741ec22f9aaea09bfc0b87d0801a7c492f
DIFF: https://github.com/llvm/llvm-project/commit/ed740e741ec22f9aaea09bfc0b87d0801a7c492f.diff
LOG: [clang-tidy] Attempt fixing wrong caching result in `bugprone-unsafe-functions`
There is a supposedly platform-specific crash related to not recognising
the availability of *Annex K.* properly? This patch is an attempt for
fixing this by moving the reset logic for the cache to a different
place.
It's really a coin-flip at this point whether this is really a fix...
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h
clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions.c
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index ebb49645b5904..c069cc3ea33ad 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -226,10 +226,6 @@ void UnsafeFunctionsCheck::registerPPCallbacks(
const SourceManager &SM, Preprocessor *PP,
Preprocessor * /*ModuleExpanderPP*/) {
this->PP = PP;
-}
-
-void UnsafeFunctionsCheck::onEndOfTranslationUnit() {
- this->PP = nullptr;
IsAnnexKAvailable.reset();
}
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h
index 369ea25f693cc..f04a220fd12e2 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h
@@ -32,7 +32,6 @@ class UnsafeFunctionsCheck : public ClangTidyCheck {
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
- void onEndOfTranslationUnit() override;
private:
/// If true, additional functions from widely used API-s (such as POSIX) are
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions.c
index e1f8238fd4f3f..62754fa68111b 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions.c
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions.c
@@ -15,8 +15,8 @@ size_t wcslen(const wchar_t *S);
void f1(char *S) {
gets(S);
- // CHECK-MESSAGES-WITH-ANNEX-K: :[[@LINE-1]]:3: warning: function 'gets' is insecure, was deprecated and removed in C11 and C++14; 'gets_s' should be used instead
- // CHECK-MESSAGES-WITH-ANNEX-K-CERT-ONLY: :[[@LINE-2]]:3: warning: function 'gets' is insecure, was deprecated and removed in C11 and C++14; 'gets_s' should be used instea
+ // CHECK-MESSAGES-WITH-ANNEX-K: :[[@LINE-1]]:3: warning: function 'gets' is insecure, was deprecated and removed in C11 and C++14; 'gets_s' should be used instead [bugprone-unsafe-functions]
+ // CHECK-MESSAGES-WITH-ANNEX-K-CERT-ONLY: :[[@LINE-2]]:3: warning: function 'gets' is insecure, was deprecated and removed in C11 and C++14; 'gets_s' should be used instead
// CHECK-MESSAGES-WITHOUT-ANNEX-K: :[[@LINE-3]]:3: warning: function 'gets' is insecure, was deprecated and removed in C11 and C++14; 'fgets' should be used instead
strlen(S);
More information about the cfe-commits
mailing list