[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (PR #90438)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 30 05:17:43 PDT 2024


================
@@ -350,6 +350,13 @@ class ResultObjectVisitor : public RecursiveASTVisitor<ResultObjectVisitor> {
     return RecursiveASTVisitor<ResultObjectVisitor>::TraverseDecl(D);
   }
 
+  bool TraverseDecltypeTypeLoc(DecltypeTypeLoc Node) {
----------------
martinboehme wrote:

Done -- ready for review again.

It turns out that for some of these (`typeid`, `sizeof`), the tests already passed even before I excluded them in `ResultObjectVisitor`. This is because `getReferencedDecls()` does actually collect declarations referenced in these unevaluated contexts (even though maybe it shouldn't). Nevertheless, I have decided to exclude these unevaluated contexts from `ResultObjectVisitor` because the transfer function will never visit them, so they don't need result objects to be propagated into them.

It also turns out that, even though the operand of the `noexcept` operator in an unevaluated operand, it still shows up in the CFG for some reason, and hence we also need to propagate result objects for it (see also comments added to the code). Maybe there's a reason for this, or maybe it's something that should be fixed in the CFG, but for the time being, I've chosen to leave this as it is here.

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


More information about the cfe-commits mailing list