[clang] [Clang][Sema] Fix crash when diagnosing near-match for 'constexpr' redeclaration in C++11 (PR #92452)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 14:01:37 PDT 2024


================
@@ -1527,20 +1527,20 @@ struct DeclaratorChunk {
 
     /// Retrieve the location of the 'const' qualifier.
     SourceLocation getConstQualifierLoc() const {
-      assert(MethodQualifiers);
-      return MethodQualifiers->getConstSpecLoc();
+      return MethodQualifiers ? MethodQualifiers->getConstSpecLoc()
----------------
erichkeane wrote:

Hmm... these asserts make sense in just about every situation except for the 'fixits'.  I wonder if there is instead value in capturing that we did it with a 'fixit' instead?  So the assert becomes `MethodQualifiers || WasFixConstFixit`.  

https://github.com/llvm/llvm-project/pull/92452


More information about the cfe-commits mailing list