forked from apple/swift-clang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] Fix a crash when doing RVO from within blocks.
When looking for the location context of the call site, unwrap block invocation contexts because they are attached to the current AnalysisDeclContext while what we need is the previous AnalysisDeclContext. Differential Revision: https://reviews.llvm.org/D61545 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360202 91177308-0d34-0410-b5e6-96231b3b80d8 (cherry picked from commit f587801)
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=core -fblocks -verify %s | ||
|
||
// expected-no-diagnostics | ||
|
||
namespace block_rvo_crash { | ||
struct A {}; | ||
|
||
A getA(); | ||
void use(A a) {} | ||
|
||
void foo() { | ||
// This used to crash when finding construction context for getA() | ||
// (which is use()'s argument due to RVO). | ||
use(^{ | ||
return getA(); // no-crash | ||
}()); | ||
} | ||
} // namespace block_rvo_crash |