[PATCH] D67992: [Sema] Add FunctionTypeUnwrapper
Leonard Chan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 15:27:43 PDT 2019
leonardchan created this revision.
leonardchan added a reviewer: rsmith.
leonardchan added a project: clang.
Herald added a subscriber: kristof.beyls.
This is a fix for PR43315. An assertion error is hit for this minimal example:
//clang -cc1 -triple x86_64-- -S tstVMStructRC-min.cpp
#define a __attribute__((__cdecl__, __regparm__(0)))
int (a b)(); // Assertion `Chunk.Kind == DeclaratorChunk::Function' failed.
This is because we do not cover the case in the `FunctionTypeUnwrapper` where it receives a `MacroQualifiedType`. We have not run into this earlier because this is a unique case where the `__attribute__` contains both `__cdecl__` and `__regparm__` (in that order), and we are compiling for x86_64. Changing the architecture or the order of `__cdecl__` and `__regparm__` does not raise the assertion.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D67992
Files:
clang/lib/Sema/SemaType.cpp
clang/test/Frontend/macro_defined_type.cpp
Index: clang/test/Frontend/macro_defined_type.cpp
===================================================================
--- clang/test/Frontend/macro_defined_type.cpp
+++ clang/test/Frontend/macro_defined_type.cpp
@@ -19,3 +19,7 @@
struct A {
_LIBCPP_FLOAT_ABI int operator()() throw(); // expected-warning{{'pcs' calling convention is not supported for this target}}
};
+
+// Added test for fix for PR43315
+#define a __attribute__((__cdecl__, __regparm__(0)))
+int(a b)();
Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6291,7 +6291,8 @@
Pointer,
BlockPointer,
Reference,
- MemberPointer
+ MemberPointer,
+ MacroQualified,
};
QualType Original;
@@ -6322,6 +6323,9 @@
} else if (isa<AttributedType>(Ty)) {
T = cast<AttributedType>(Ty)->getEquivalentType();
Stack.push_back(Attributed);
+ } else if (isa<MacroQualifiedType>(Ty)) {
+ T = cast<MacroQualifiedType>(Ty)->getUnderlyingType();
+ Stack.push_back(MacroQualified);
} else {
const Type *DTy = Ty->getUnqualifiedDesugaredType();
if (Ty == DTy) {
@@ -6378,6 +6382,9 @@
return C.getParenType(New);
}
+ case MacroQualified:
+ return wrap(C, cast<MacroQualifiedType>(Old)->getUnderlyingType(), I);
+
case Pointer: {
QualType New = wrap(C, cast<PointerType>(Old)->getPointeeType(), I);
return C.getPointerType(New);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67992.221608.patch
Type: text/x-patch
Size: 1584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190924/f66c810d/attachment.bin>
More information about the cfe-commits
mailing list