[clang] 0e08374 - [clang][NFC] Add a notice to desugarForDiagnostic
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 20:55:13 PDT 2023
Author: Younan Zhang
Date: 2023-06-15T11:55:06+08:00
New Revision: 0e08374abb2c61a3ae5c24d5f60be3b548da9778
URL: https://github.com/llvm/llvm-project/commit/0e08374abb2c61a3ae5c24d5f60be3b548da9778
DIFF: https://github.com/llvm/llvm-project/commit/0e08374abb2c61a3ae5c24d5f60be3b548da9778.diff
LOG: [clang][NFC] Add a notice to desugarForDiagnostic
`desugarForDiagnostic` only sets ShouldAKA to true if desugaring
happens, otherwise ShouldAKA is left intact and might be uninitialized.
Victims (including me):
https://github.com/llvm/llvm-project/commit/25bf8cb3c0e3c41231289a6ff0a37b6d49b24011
https://github.com/llvm/llvm-project/commit/0e8384a0fe4f03d60cd92aba1cae074512481ca2
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D152880
Added:
Modified:
clang/include/clang/AST/ASTDiagnostic.h
clang/lib/AST/ASTDiagnostic.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/ASTDiagnostic.h b/clang/include/clang/AST/ASTDiagnostic.h
index 4cd9097517258..ef22249828629 100644
--- a/clang/include/clang/AST/ASTDiagnostic.h
+++ b/clang/include/clang/AST/ASTDiagnostic.h
@@ -34,7 +34,8 @@ namespace clang {
ArrayRef<intptr_t> QualTypeVals);
/// Returns a desugared version of the QualType, and marks ShouldAKA as true
- /// whenever we remove significant sugar from the type.
+ /// whenever we remove significant sugar from the type. Make sure ShouldAKA
+ /// is initialized before passing it in.
QualType desugarForDiagnostic(ASTContext &Context, QualType QT,
bool &ShouldAKA);
} // end namespace clang
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 08877aa12c024..f96a4fa3c35b0 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -25,7 +25,8 @@
using namespace clang;
// Returns a desugared version of the QualType, and marks ShouldAKA as true
-// whenever we remove significant sugar from the type.
+// whenever we remove significant sugar from the type. Make sure ShouldAKA
+// is initialized before passing it in.
QualType clang::desugarForDiagnostic(ASTContext &Context, QualType QT,
bool &ShouldAKA) {
QualifierCollector QC;
More information about the cfe-commits
mailing list