-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang-doc] Fix assertions error in Serialize.cpp #141990
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
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
We can only print and use a default arg, if it is instantiated. I was unable to reduce the test case for this to something of reasonable size, but this is easily hit by running clang-doc to generate clang's documentation. For now, we can fix the assertion quickly to unbreak users, and add the proper test once it is small enough.
ac37e01
to
d4e62ee
Compare
@llvm/pr-subscribers-clang-tools-extra Author: Paul Kirth (ilovepi) ChangesWe can only print and use a default arg, if it is instantiated. Full diff: https://github.com/llvm/llvm-project/pull/141990.diff 1 Files Affected:
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index 97ea1f02a6178..3932a939de973 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -113,9 +113,9 @@ getFunctionPrototype(const FunctionDecl *FuncDecl) {
Stream << " " << ParamDecl->getNameAsString();
// Print default argument if it exists
- if (ParamDecl->hasDefaultArg()) {
- const Expr *DefaultArg = ParamDecl->getDefaultArg();
- if (DefaultArg) {
+ if (ParamDecl->hasDefaultArg() &&
+ !ParamDecl->hasUninstantiatedDefaultArg()) {
+ if (const Expr *DefaultArg = ParamDecl->getDefaultArg()) {
Stream << " = ";
DefaultArg->printPretty(Stream, nullptr, Ctx.getPrintingPolicy());
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
We can only print and use a default arg, if it is instantiated. I was unable to reduce the test case for this to something of reasonable size, but this is easily hit by running clang-doc to generate clang's documentation. For now, we can fix the assertion quickly to unbreak users, and add the proper test once it is small enough.
We can only print and use a default arg, if it is instantiated. I was unable to reduce the test case for this to something of reasonable size, but this is easily hit by running clang-doc to generate clang's documentation. For now, we can fix the assertion quickly to unbreak users, and add the proper test once it is small enough.
When we landed the fix for the assertion in #141990, we hadn't yet reduced the test case sufficiently for a regression test.
We can only print and use a default arg, if it is instantiated. I was unable to reduce the test case for this to something of reasonable size, but this is easily hit by running clang-doc to generate clang's documentation. For now, we can fix the assertion quickly to unbreak users, and add the proper test once it is small enough.
We can only print and use a default arg, if it is instantiated.
I was unable to reduce the test case for this to something of reasonable
size, but this is easily hit by running clang-doc to generate clang's
documentation. For now, we can fix the assertion quickly to unbreak
users, and add the proper test once it is small enough.