[PATCH] D80981: [AST] Fix a crash on accessing a class without definition in constexpr function context.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 2 02:12:41 PDT 2020


sammccall added inline comments.


================
Comment at: clang/lib/AST/ExprConstant.cpp:4320
+    if (!RD->hasDefinition())
+      return APValue();
     APValue Struct(APValue::UninitStruct(), RD->getNumBases(),
----------------
This doesn't look all that safe - you're using a `None` value to indicate failure, but no current code path does that and none of the callers seem to check for failure.
(e.g. `evaluateVarDecl` returns true instead of false).
Presumably we're going to get a diagnostic somewhere (though it's not completely obvious to me) but can we be sure we won't assume this value has the right type somewhere down the line?

I get the feeling this is correct and I don't have enough context to understand why... how about you :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80981





More information about the cfe-commits mailing list