[PATCH] D61522: Added an assertion to constant evaluation enty points that prohibits dependent expressions

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 17 01:20:28 PDT 2019


rsmith accepted this revision.
rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:6369
     // very difficult. Ideally, we should handle them more gracefully.
-    if (!EIA->getCond()->EvaluateWithSubstitution(
+    if (EIA->getCond()->isValueDependent() ||
+        !EIA->getCond()->EvaluateWithSubstitution(
----------------
gribozavr wrote:
> rsmith wrote:
> > This is treating value-dependent `enable_if` conditions as having failed. Is that really appropriate? (When do we call this with value-depnedent `enable_if` attributes? I'd expect it to only be called after substitution)
> This test case in `llvm-project/clang/test/SemaCXX/enable_if.cpp` passes a dependent condition:
> 
> ```
> void h(int);
> template <typename T> void outer() {
>   void local_function() __attribute__((enable_if(::h(T()), "")));
>   local_function();
> };
> ```
> 
> According to https://reviews.llvm.org/D20130, it seems like it was decided to document implementation details as specification, and say that `enable_if` is evaluated during overload resolution, whenever that happens to happen.
Hm. Yeah, I suppose we disable `enable_if` functions if the condition can't be evaluated, and this is a "can't be evaluated" case in some sense. I don't like it (the right thing would be to treat this as a dependent overload resolution), but as a short-term fix for this patch I suppose it's the right local choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61522





More information about the cfe-commits mailing list