diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-31 00:45:09 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-31 00:45:09 +0000 |
commit | 2fdd95c1c823ebafc9286f7b730339c38636c5a8 (patch) | |
tree | ffae98dbc613c810a160202df437d4f6c607061b /clang/lib/Sema/AnalysisBasedWarnings.cpp | |
parent | 4a585a3edd1c96f19b819d44df25c376e4987a44 (diff) | |
download | bcm5719-llvm-2fdd95c1c823ebafc9286f7b730339c38636c5a8.tar.gz bcm5719-llvm-2fdd95c1c823ebafc9286f7b730339c38636c5a8.zip |
Defer capture initialization for blocks until after we've left the
function scope.
This removes one of the last few cases where we build expressions in the
wrong function scope context. No functionality change intended.
llvm-svn: 362178
Diffstat (limited to 'clang/lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r-- | clang/lib/Sema/AnalysisBasedWarnings.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index bac407b832e..ce01909f185 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -620,7 +620,7 @@ struct CheckFallThroughDiagnostics { /// of a noreturn function. We assume that functions and blocks not marked /// noreturn will return. static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body, - const BlockExpr *blkExpr, + QualType BlockType, const CheckFallThroughDiagnostics &CD, AnalysisDeclContext &AC, sema::FunctionScopeInfo *FSI) { @@ -641,9 +641,8 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body, HasNoReturn = MD->hasAttr<NoReturnAttr>(); } else if (isa<BlockDecl>(D)) { - QualType BlockTy = blkExpr->getType(); if (const FunctionType *FT = - BlockTy->getPointeeType()->getAs<FunctionType>()) { + BlockType->getPointeeType()->getAs<FunctionType>()) { if (FT->getReturnType()->isVoidType()) ReturnsVoid = true; if (FT->getNoReturnAttr()) @@ -2012,7 +2011,7 @@ static void flushDiagnostics(Sema &S, const sema::FunctionScopeInfo *fscope) { void clang::sema:: AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, sema::FunctionScopeInfo *fscope, - const Decl *D, const BlockExpr *blkExpr) { + const Decl *D, QualType BlockType) { // We avoid doing analysis-based warnings when there are errors for // two reasons: @@ -2138,7 +2137,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, : (fscope->isCoroutine() ? CheckFallThroughDiagnostics::MakeForCoroutine(D) : CheckFallThroughDiagnostics::MakeForFunction(D))); - CheckFallThroughForBody(S, D, Body, blkExpr, CD, AC, fscope); + CheckFallThroughForBody(S, D, Body, BlockType, CD, AC, fscope); } // Warning: check for unreachable code |