[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)
JJ Marr via cfe-commits
cfe-commits at lists.llvm.org
Sun May 11 01:04:49 PDT 2025
================
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
Definition->hasAttr<MSConstexprAttr>())))
return true;
- if (Info.getLangOpts().CPlusPlus11) {
- const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
+ const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
+ // Special note for the assert() macro, as the normal error message falsely
+ // implies we cannot use an assertion during constant evaluation.
+ if (CallLoc.isMacroID() && DiagDecl->getIdentifier()) {
+ // FIXME: Instead of checking for an implementation-defined function,
+ // check and evaluate the assert() macro.
----------------
jj-marr wrote:
I have no idea how to access the preprocessor from this method and I am too inexperienced to know where to start.
If you can give me a hint on where to look I would appreciate that. Do I just do a big refactor and pass it in as a parameter to the function? Or is there some method on an object I already have?
https://github.com/llvm/llvm-project/pull/130458
More information about the cfe-commits
mailing list