[PATCH] D148206: [clang] Do not crash after suggesting typo correction to constexpr if condition

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 13 09:16:31 PDT 2023


Fznamznon added inline comments.


================
Comment at: clang/include/clang/Sema/Sema.h:12855
+                        !Condition.get()->isValueDependent() &&
+                        Condition.get()->isIntegerConstantExpr(S.Context)),
           KnownValue(HasKnownValue &&
----------------
aaron.ballman wrote:
> Oof, this adds quite a bit of expense to this constructor -- `isIntegerConstantExpr()` is implemented by evaluating the constant expression and throwing away the computed result... which we then recompute when setting `KnownValue` one line later. It'd be better to only do this computation once and use the computed value to initialize both members.
Oops, now it is evaluated only one time.
It seems clang's codebase have several places with the same mistake I've made here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148206



More information about the cfe-commits mailing list