diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-10-10 10:51:48 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-10-10 10:51:48 +0000 |
| commit | 37521757fa2168cc9b401c37069623f19d07b0b7 (patch) | |
| tree | 98ee4774cbfb8276ed6c53084afb5efd0d179dfa /lib | |
| parent | 5dd71ba3b2275890f3056b943debdf4c62c5637f (diff) | |
| download | clang-37521757fa2168cc9b401c37069623f19d07b0b7.tar.gz | |
[CodeComplete] Fix crash when completing params function declarations.
Summary:
In a decl like `int AA(BB cc)` where BB isn't defined, we end up trying to
parse `BB cc` as an expression (vexing parse) and end up triggering the
parser's "recovery-in-function" completion with no actual function
scope.
This patch avoids the assumption that such a scope exists in this context.
Reviewers: kadircet
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D53070
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 33bb1229ac..bdf538b9dc 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -1881,7 +1881,8 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, } // Switch-specific statements. - if (!SemaRef.getCurFunction()->SwitchStack.empty()) { + if (SemaRef.getCurFunction() && + !SemaRef.getCurFunction()->SwitchStack.empty()) { // case expression: Builder.AddTypedTextChunk("case"); Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); |
