Add and pass AllowCXX not only in mergeFunctionTypes but all merge*Type
methods. Use it to determine if reference types should be stripped or
are invalid in mergeTypes. The reason for this is that
mergeFunctionTypes allows CXX functions with exception specifiers but
crashes on reference types (in the return or argument position). This is
going to be used by D88384.
Details
- Reviewers
aaron.ballman JonChesterfield
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Do you have test cases for this change? I didn't see any relevant ones in D88384.
clang/lib/AST/ASTContext.cpp | ||
---|---|---|
9174 | It seems possible to call typesAreBlockPointerCompatible() in C++ mode (ASTContext::areCommonBaseCompatible() calls sameObjCTypeArgs() which calls canAssignObjCObjectTypes() which calls ASTContext::typesAreBlockPointerCompatible(). I'm not certain if the assertion will actually trigger though, so tests would be appreciated. Are there other cases where mergeType() can be transitively called in C++ mode without having already stripped references? | |
9430–9433 | This will try to merge a T& and T&& based on T alone, is that expected or should this be caring about lvalue vs rvalue reference types? |
In the revert (rG4fc69ab002382675d84f611f22599cb3cb4a0787) I noted a test broke. I went back and it is clang/test/Headers/nvptx_device_math_complex.cpp which is already in tree.
I'll try to gracefully accept but reject reference types next. That might work.
clang/lib/AST/ASTContext.cpp | ||
---|---|---|
9174 | AllowCXX is only used from OpenMP code and probably named badly. The idea is that we want to allow roughly matching declarations, so far that meant we don't want to be too strict on exception qualifiers. | |
9430–9433 | This is debatable. The standard is all but clear about this and it is not 100% clear to me what is reasonable. As noted in the general comment, we might be able to get all the functionality we need by gracefully handling this case and saying it is not mergable. I'll give that a try. |
Changing the assume to a proper exit did the trick for the tests. I recommited D88384 with that minor modification. Apologies for the noise.
It seems possible to call typesAreBlockPointerCompatible() in C++ mode (ASTContext::areCommonBaseCompatible() calls sameObjCTypeArgs() which calls canAssignObjCObjectTypes() which calls ASTContext::typesAreBlockPointerCompatible(). I'm not certain if the assertion will actually trigger though, so tests would be appreciated.
Are there other cases where mergeType() can be transitively called in C++ mode without having already stripped references?