Skip to content

Commit ed740e7

Browse files
committed
[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...
1 parent b505ef5 commit ed740e7

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,6 @@ void UnsafeFunctionsCheck::registerPPCallbacks(
226226
const SourceManager &SM, Preprocessor *PP,
227227
Preprocessor * /*ModuleExpanderPP*/) {
228228
this->PP = PP;
229-
}
230-
231-
void UnsafeFunctionsCheck::onEndOfTranslationUnit() {
232-
this->PP = nullptr;
233229
IsAnnexKAvailable.reset();
234230
}
235231

clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class UnsafeFunctionsCheck : public ClangTidyCheck {
3232

3333
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
3434
Preprocessor *ModuleExpanderPP) override;
35-
void onEndOfTranslationUnit() override;
3635

3736
private:
3837
/// If true, additional functions from widely used API-s (such as POSIX) are

clang-tools-extra/test/clang-tidy/checkers/bugprone/unsafe-functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ size_t wcslen(const wchar_t *S);
1515

1616
void f1(char *S) {
1717
gets(S);
18-
// 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
19-
// 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
18+
// 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]
19+
// 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
2020
// 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
2121

2222
strlen(S);

0 commit comments

Comments
 (0)