[clang-tidy] Attempt fixing wrong caching result in `bugprone-unsafe-functions`
authorWhisperity <whisperity@gmail.com>
Thu, 2 Feb 2023 14:22:04 +0000 (15:22 +0100)
committerWhisperity <whisperity@gmail.com>
Thu, 2 Feb 2023 14:24:40 +0000 (15:24 +0100)
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...

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

index ebb4964..c069cc3 100644 (file)
@@ -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();
 }
 
index 369ea25..f04a220 100644 (file)
@@ -32,7 +32,6 @@ public:
 
   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
index e1f8238..62754fa 100644 (file)
@@ -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);