Skip to content

Assertion failure on itype declaration in macro #594

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

Closed
mattmccutchen-cci opened this issue May 18, 2021 · 0 comments · Fixed by #693
Closed

Assertion failure on itype declaration in macro #594

mattmccutchen-cci opened this issue May 18, 2021 · 0 comments · Fixed by #693

Comments

@mattmccutchen-cci
Copy link
Member

Running 3c on the following code:

#define PARAM_DECL_WITH_ITYPE int *p : itype(_Ptr<int>)

void foo(PARAM_DECL_WITH_ITYPE);

produces:

3c: /home/matt/3c-2.wt/clang/lib/3C/ConstraintVariables.cpp:292: PointerVariableConstraint::PointerVariableConstraint(const clang::QualType&, clang::DeclaratorDecl*, std::string, ProgramInfo&, const clang::ASTContext&, std::string*, int, bool, clang::TypeSourceInfo*, const clang::QualType&): Assertion `ItypeStr.size() > 0' failed.

This is caused by the same problem with retrieval of the original source of a program element inside a macro that I partially worked around in #436; I added a note about this remaining case to clang/test/3C/params_in_macro.c. I decided to file an issue now because the problem came up in some of my manual tests related to #581. I guess we haven't run into this problem in real work yet because we don't tend to write Checked-C-specific constructs inside macros.

I don't have a good enough understanding of the code to know whether we can just remove the assertion or we might need to make other changes.

john-h-kastner added a commit that referenced this issue Sep 2, 2021
john-h-kastner added a commit that referenced this issue Sep 2, 2021
Fixes an assertion failure (#594) when
attempting to extract the string representation of an itype expression from the
original source code if the itype expression is inside a macro. The string
representation for itypes in macros is now re-generated from the AST.

The fix in its current form leads to some unnecessary expansion of macros. This
is discussed in #694.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant