[clang] [libclang] Fix evaluation of parenthesized string initializers (PR #243317)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 27 07:52:05 PST 2026


================
@@ -4748,7 +4748,7 @@ static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
 
   if (expr->getStmtClass() == Stmt::ImplicitCastExprClass) {
     const auto *I = cast<ImplicitCastExpr>(expr);
-    auto *subExpr = I->getSubExprAsWritten();
+    auto *subExpr = I->getSubExprAsWritten()->IgnoreParens();
----------------
Endilll wrote:

Thank you for looking into this.

> Currently, clang_Cursor_Evaluate returns `nullptr` for `const char *b = "hello" + 1;`, so we’d want to skip that case too.

I'd argue this is a bug worth fixing.

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


More information about the cfe-commits mailing list