[PATCH] D130906: [clang] format string checking for conpile-time evaluated str literal

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 4 05:33:50 PDT 2022


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from some small corrections. Thank you for this! Do you need me to commit on your behalf? If so, what name and email address would you like me to use for patch attribution?



================
Comment at: clang/lib/Sema/SemaChecking.cpp:8719
     }
-
+    if (auto *SLE = maybeConstEvalStringLiteral(S.Context, E))
+      return checkFormatStringExpr(S, SLE, Args, APK, format_idx, firstDataArg,
----------------



================
Comment at: clang/lib/Sema/SemaChecking.cpp:8840
+  if (E->EvaluateAsRValue(Result, Context) && Result.Val.isLValue()) {
+    auto *LVE = Result.Val.getLValueBase().dyn_cast<const Expr *>();
+    if (isa_and_nonnull<StringLiteral>(LVE))
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130906/new/

https://reviews.llvm.org/D130906



More information about the cfe-commits mailing list