From 913ffa6ba34794946fdeb3bdb469d8fbe6bc2088 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 17 May 2019 17:16:53 +0000 Subject: Added an assertion to constant evaluation enty points that prohibits dependent expressions Summary: Constant evaluator does not work on value-dependent or type-dependent expressions. Also fixed bugs uncovered by these assertions. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61522 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361050 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOverload.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/Sema/SemaOverload.cpp') diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 256c2343e5..eadc01e5ef 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -6376,7 +6376,8 @@ EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef Args, APValue Result; // 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( + if (EIA->getCond()->isValueDependent() || + !EIA->getCond()->EvaluateWithSubstitution( Result, Context, Function, llvm::makeArrayRef(ConvertedArgs))) return EIA; @@ -9562,7 +9563,8 @@ static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD) { for (auto *EnableIf : FD->specific_attrs()) { bool AlwaysTrue; - if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx)) + if (EnableIf->getCond()->isValueDependent() || + !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx)) return false; if (!AlwaysTrue) return false; -- cgit v1.2.1