diff options
author | Kaelyn Takata <rikka@google.com> | 2015-01-28 21:10:46 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2015-01-28 21:10:46 +0000 |
commit | c49838b33155a93ca83d3cc2279211ac2665da31 (patch) | |
tree | b4d4f42ee3db8c7015ace6fdd06571c6ed4ca879 | |
parent | 48eec8a90d9ba434c3ae6687bd290c6014bef928 (diff) | |
download | bcm5719-llvm-c49838b33155a93ca83d3cc2279211ac2665da31.tar.gz bcm5719-llvm-c49838b33155a93ca83d3cc2279211ac2665da31.zip |
Revert a change from r222797 that is no longer needed and can cause
infinite recursion.
Also guard against said infinite recursion by adding an assert that will
trigger if CorrectDelayedTyposInExpr is called before a previous call to
CorrectDelayedTyposInExpr returns (i.e. if the TreeTransform run by
CorrectDelayedTyposInExpr calls a sequence of methods that
end up calling CorrectDelayedTyposInExpr, as the new test case had done
prior to this commit). Fixes PR22292.
llvm-svn: 227368
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/typo-correction-delayed.cpp | 8 |
3 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index e75daa412fb..08b58850232 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4762,12 +4762,8 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, VK_RValue, RParenLoc); // Bail out early if calling a builtin with custom typechecking. - if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) { - ExprResult Res = CorrectDelayedTyposInExpr(TheCall); - if (!Res.isUsable() || !isa<CallExpr>(Res.get())) - return Res; - return CheckBuiltinFunctionCall(FDecl, BuiltinID, cast<CallExpr>(Res.get())); - } + if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) + return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall); retry: const FunctionType *FuncT; diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 9477c7f2f9e..96486e8d867 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -6235,8 +6235,12 @@ ExprResult Sema::CorrectDelayedTyposInExpr( if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos && (E->isTypeDependent() || E->isValueDependent() || E->isInstantiationDependent())) { + auto TyposInContext = ExprEvalContexts.back().NumTypos; + assert(TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr"); + ExprEvalContexts.back().NumTypos = ~0U; auto TyposResolved = DelayedTypos.size(); auto Result = TransformTypos(*this, Filter).Transform(E); + ExprEvalContexts.back().NumTypos = TyposInContext; TyposResolved -= DelayedTypos.size(); if (Result.isInvalid() || Result.get() != E) { ExprEvalContexts.back().NumTypos -= TyposResolved; diff --git a/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp index 516b600f422..64e6dd5966a 100644 --- a/clang/test/SemaCXX/typo-correction-delayed.cpp +++ b/clang/test/SemaCXX/typo-correction-delayed.cpp @@ -176,6 +176,14 @@ namespace PR22250 { int getenv_s(size_t *y, char(&z)) {} } +namespace PR22291 { +template <unsigned I> void f() { + unsigned *prio_bits_array; // expected-note {{'prio_bits_array' declared here}} + // expected-error@+1 {{use of undeclared identifier 'prio_op_array'; did you mean 'prio_bits_array'?}} + __atomic_store_n(prio_op_array + I, false, __ATOMIC_RELAXED); +} +} + namespace PR22297 { double pow(double x, double y); struct TimeTicks { |