-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Crash on simple invalid C++ code, when parsed in objective-c++ mode #64836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Originally reported at clangd/clangd#1737 (a clangd user ran into this while they were in the middle of typing, hence the syntax error on the incomplete line). |
@llvm/issue-subscribers-clang-frontend |
We are crashing here: llvm-project/clang/lib/Parse/ParseDecl.cpp Lines 6679 to 6681 in 4320722
During generating diagnostic we get to > frame var Tok
(clang::Token) Tok = (Loc = 121, UintData = 133, PtrData = 0x0000000000000001, Kind = annot_decltype, Flags = 2048) The assumption that calling godbolt: https://godbolt.org/z/6z15hanTv |
I think you would guard this via: |
I'm not sure I know why this diagnostic path is specific to Objective-C++. I guess it's more likely that someone would try to declare a C++ method like Anyway, I agree with Aaron that the easiest fix for the crash is to just check for |
…at token is not an annotation token In Parser::ParseDirectDeclarator(...) in some cases ill-formed code can cause an annotation token to end up where it was not expected. The fix is to add a !Tok.isAnnotation() guard before attempting to access identifier info. This fixes: llvm#64836 Differential Revision: https://reviews.llvm.org/D158804
Steps to reproduce
Create a file named
test.h
containing:With recent clang trunk, compile with
clang -c -xobjective-c++-header test.h
.Clang crashes with the following output:
The text was updated successfully, but these errors were encountered: