llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: None (edisongz) <details> <summary>Changes</summary> …zed operand in ObjC++ In ObjC++ mode, code-completion after a C-style cast like `(int*)(0x200)` crashed because the inner parenthesized expression was parsed as a `ParenListExpr` (null type) due to `AllowTypes` propagation. Add a null-type guard in CodeCompletePostfixExpression. --- Full diff: https://github.com/llvm/llvm-project/pull/180343.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaCodeComplete.cpp (+1-1) - (added) clang/test/CodeCompletion/objc-cast-parenthesized-expr.m (+12) ``````````diff diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index aa93507ab5c30..0d8ed56a1ede3 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -5152,7 +5152,7 @@ void SemaCodeCompletion::CodeCompletePostfixExpression(Scope *S, ExprResult E, QualType PreferredType) { if (E.isInvalid()) CodeCompleteExpression(S, PreferredType); - else if (getLangOpts().ObjC) + else if (getLangOpts().ObjC && !E.get()->getType().isNull()) CodeCompleteObjCInstanceMessage(S, E.get(), {}, false); } diff --git a/clang/test/CodeCompletion/objc-cast-parenthesized-expr.m b/clang/test/CodeCompletion/objc-cast-parenthesized-expr.m new file mode 100644 index 0000000000000..171d62cf971f5 --- /dev/null +++ b/clang/test/CodeCompletion/objc-cast-parenthesized-expr.m @@ -0,0 +1,12 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +void func() { + int *foo = (int *)(0x200); + int *bar = (int *)((0x200)); +} + +// Make sure this doesn't crash +// RUN: %clang_cc1 -fsyntax-only -xobjective-c++-header -code-completion-at=%s:%(line-5):28 %s +// RUN: %clang_cc1 -fsyntax-only -xobjective-c++-header -code-completion-at=%s:%(line-5):30 %s + `````````` </details> https://github.com/llvm/llvm-project/pull/180343 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
