Canonical param types and restrict array index qualifiers

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 17 10:07:02 PDT 2017


I've run into a case where I am calling ASTContext::getFunctionType()
and getting a failed assertion because a parameter we thought we
canonicalized isn't actually canonical. The function is declared as:

extern int regexec (int __pmatch[__restrict]);

When we call getCanonicalParamType() on that parameter, it results in
a type that is a decayed pointer that still has the restrict
qualifier, because getArrayDecayedType() leaves on index type
qualifiers. However, isCanonicalAsParam() checks for the presence of
any local qualifiers and returns false if any are present. This
results in the assertion failing.

I believe this is a bug, but I'm not certain where. Should
getCanonicalParamType() be stripping the restrict array index
qualifier? Should isCanonicalAsParam() be modified? Or is something
else going on that I'm not quite understanding?

Thanks!

~Aaron


More information about the cfe-commits mailing list