aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2019-11-12 16:22:13 -0800
committerTom Stellard <tstellar@redhat.com>2019-11-12 18:56:54 -0800
commitbc6d0f15c227530538fab484dc586975b11ff0ec (patch)
tree63f38b8d70b5a88bbbc5d5ba3fc6009b709c4c73
parent2cec4d0850afc3fdc46817d32ffd5b64682e004e (diff)
downloadllvm-bc6d0f15c227530538fab484dc586975b11ff0ec.zip
llvm-bc6d0f15c227530538fab484dc586975b11ff0ec.tar.gz
llvm-bc6d0f15c227530538fab484dc586975b11ff0ec.tar.bz2
[Sema] Add MacroQualified case for FunctionTypeUnwrapper
This is a fix for PR43315. An assertion error is hit for this minimal example: ``` //clang -cc1 -triple x86_64-- -S tstVMStructRC-min.cpp 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. Differential Revision: https://reviews.llvm.org/D67992 (cherry picked from commit e278c138a937a68f3e6c89df8eaeffa913f9b0f7)
-rw-r--r--clang/lib/Sema/SemaType.cpp9
-rw-r--r--clang/test/Frontend/macro_defined_type.cpp4
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 2b9d068..5bbaebe 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -6325,7 +6325,8 @@ namespace {
Pointer,
BlockPointer,
Reference,
- MemberPointer
+ MemberPointer,
+ MacroQualified,
};
QualType Original;
@@ -6356,6 +6357,9 @@ namespace {
} 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) {
@@ -6412,6 +6416,9 @@ namespace {
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);
diff --git a/clang/test/Frontend/macro_defined_type.cpp b/clang/test/Frontend/macro_defined_type.cpp
index d4f54b6..71a0ff1 100644
--- a/clang/test/Frontend/macro_defined_type.cpp
+++ b/clang/test/Frontend/macro_defined_type.cpp
@@ -19,3 +19,7 @@ void Func() {
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)();