[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 2 18:20:27 PDT 2018


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

I think this can be cleaned up a bit further, but I'm fine with that happening after the patch lands. Thanks!



================
Comment at: lib/AST/ExprConstant.cpp:455-456
     // values are stable.
-    typedef std::map<const void*, APValue> MapTy;
-    typedef MapTy::const_iterator temp_iterator;
+    typedef std::map<unsigned, APValue> VersionToValueMap;
+    typedef std::map<const void *, VersionToValueMap> MapTy;
     /// Temporaries - Temporary lvalues materialized within this stack frame.
----------------
Have you considered using a pair<const void*, unsigned> as the key rather than a map-of-maps? It'd be preferable to only allocate one heap node rather than two for the (hopefully common) case where there is only one version of an object.


================
Comment at: lib/AST/ExprConstant.cpp:466
 
+    /// The stack of integers for tracking version numbers for temporaries.
+    SmallVector<unsigned, 2> TempVersionStack = {1};
----------------
If we're using this for variables in loops too, we should generalize the name and the description to not talk about temporaries.


https://reviews.llvm.org/D42776





More information about the cfe-commits mailing list