diff options
| author | Reid Kleckner <rnk@google.com> | 2018-03-12 21:43:02 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2018-03-12 21:43:02 +0000 |
| commit | 87a3180343481a051ca3130969cfbceb41aee96f (patch) | |
| tree | e352bfc508e21e647fb94234ec2b07c0dbc8a9c4 /clang/lib/Sema/SemaExpr.cpp | |
| parent | 7147f32ec52939f70d54d977a38cedb78c6b94af (diff) | |
| download | bcm5719-llvm-87a3180343481a051ca3130969cfbceb41aee96f.tar.gz bcm5719-llvm-87a3180343481a051ca3130969cfbceb41aee96f.zip | |
Re-land "[Sema] Make getCurFunction() return null outside function parsing"
This relands r326965.
There was a null dereference in typo correction that was triggered in
Sema/diagnose_if.c. We are not always in a function scope when doing
typo correction. The fix is to add a null check.
LLVM's optimizer made it hard to find this bug. I wrote it up in a
not-very-well-editted blog post here:
http://qinsb.blogspot.com/2018/03/ub-will-delete-your-null-checks.html
llvm-svn: 327334
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 95b56a242a6..07eb02bec06 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -13126,7 +13126,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, for (const auto &CI : Result->getBlockDecl()->captures()) { const VarDecl *var = CI.getVariable(); if (var->getType().isDestructedType() != QualType::DK_none) { - getCurFunction()->setHasBranchProtectedScope(); + setFunctionHasBranchProtectedScope(); break; } } |

