diff options
| author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-05-11 01:38:27 +0000 |
|---|---|---|
| committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-05-11 01:38:27 +0000 |
| commit | e8f10cc0b9a9f6d30a25da68de700c2bac745b5c (patch) | |
| tree | 12db01eb7b89ad7057dd19cc67c0de3ceaf83fed /clang/lib/Sema | |
| parent | 095c27113192bba9a79959c687f5bcd7fed690db (diff) | |
| download | bcm5719-llvm-e8f10cc0b9a9f6d30a25da68de700c2bac745b5c.tar.gz bcm5719-llvm-e8f10cc0b9a9f6d30a25da68de700c2bac745b5c.zip | |
[Sema] Fix value-dependent enable_if bug.
This patch fixes a bug where we would assume all value-dependent
enable_if conditions give successful results.
Instead, we consider value-dependent enable_if conditions to always
fail. While this isn't ideal, this is the best we can realistically do
without changing both enable_if's semantics and large parts of Sema
(specifically, all of the parts that don't expect type dependence to
come out of nowhere, and that may interact with overload resolution).
Differential Revision: http://reviews.llvm.org/D20130
llvm-svn: 269154
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 36e79f7bb48..481c245bdd8 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5984,7 +5984,6 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args, SFINAETrap Trap(*this); SmallVector<Expr *, 16> ConvertedArgs; bool InitializationFailed = false; - bool ContainsValueDependentExpr = false; // Convert the arguments. for (unsigned I = 0, E = Args.size(); I != E; ++I) { @@ -6006,7 +6005,6 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args, break; } - ContainsValueDependentExpr |= R.get()->isValueDependent(); ConvertedArgs.push_back(R.get()); } @@ -6027,7 +6025,6 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args, InitializationFailed = true; break; } - ContainsValueDependentExpr |= R.get()->isValueDependent(); ConvertedArgs.push_back(R.get()); } @@ -6037,18 +6034,14 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args, for (auto *EIA : EnableIfAttrs) { APValue Result; - if (EIA->getCond()->isValueDependent()) { - // Don't even try now, we'll examine it after instantiation. - continue; - } - + // FIXME: This doesn't consider value-dependent cases, because doing so is + // very difficult. Ideally, we should handle them more gracefully. if (!EIA->getCond()->EvaluateWithSubstitution( - Result, Context, Function, llvm::makeArrayRef(ConvertedArgs))) { - if (!ContainsValueDependentExpr) - return EIA; - } else if (!Result.isInt() || !Result.getInt().getBoolValue()) { + Result, Context, Function, llvm::makeArrayRef(ConvertedArgs))) + return EIA; + + if (!Result.isInt() || !Result.getInt().getBoolValue()) return EIA; - } } return nullptr; } |

