[clang] [clang] Add support for consteval null terminated strings (PR #173140)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 20 01:01:18 PST 2025
================
@@ -17726,6 +17764,10 @@ static bool EvaluateAsStringImpl(Sema &SemaRef, Expr *Message,
SourceLocation Loc = Message->getBeginLoc();
QualType T = Message->getType().getNonReferenceType();
+ if (T->isPointerType() && T->getPointeeType()->isCharType())
+ return EvaluateAsNullTerminatedCharBuffer(
+ SemaRef, Message, Result, Ctx, EvalContext, ErrorOnInvalidMessage);
+
----------------
cor3ntin wrote:
The problem of doing that here is that it is a non-standard behavior.
So at the minimum we'd need extension warnings. But I'm a bit uncomfortable adding that extension to begin with.
I think the functionality is best left to format string / ptrauth for now.
Which brings the question... how do we test this?
https://github.com/llvm/llvm-project/pull/173140
More information about the cfe-commits
mailing list