summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Ferrer Ibanez <roger.ferreribanez@arm.com>2017-04-19 12:23:28 +0000
committerRoger Ferrer Ibanez <roger.ferreribanez@arm.com>2017-04-19 12:23:28 +0000
commitcb89513bc74257178e8adb09029b64ab8b52bed5 (patch)
tree8946175d1e13fb74b73d37ad8979e1cd25d490d2
parentf3f923c9d22268f6ea468ebd3703b052b6dac16d (diff)
downloadbcm5719-llvm-cb89513bc74257178e8adb09029b64ab8b52bed5.tar.gz
bcm5719-llvm-cb89513bc74257178e8adb09029b64ab8b52bed5.zip
Avoid assert when a non-static member function is qualified with __unaligned
Under -fms-extensions __unaligned is a type-qualifier that can be applied to a non-static member function declaration. This causes an assertion when mangling the name under Itanium, where that qualifier is not mangled. This patch justs makes the minimal change to avoid the crash and avoid mangling __unaligned, as it currently happens with non-member functions. Differential Revision: https://reviews.llvm.org/D31976 llvm-svn: 300686
-rw-r--r--clang/lib/AST/ItaniumMangle.cpp4
-rw-r--r--clang/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp20
2 files changed, 23 insertions, 1 deletions
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 29fcdd7be92..7db0b4d8e4f 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -1455,10 +1455,12 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
Out << 'N';
if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND)) {
Qualifiers MethodQuals =
- Qualifiers::fromCVRMask(Method->getTypeQualifiers());
+ Qualifiers::fromCVRUMask(Method->getTypeQualifiers());
// We do not consider restrict a distinguishing attribute for overloading
// purposes so we must not mangle it.
MethodQuals.removeRestrict();
+ // __unaligned is not currently mangled in any way, so remove it.
+ MethodQuals.removeUnaligned();
mangleQualifiers(MethodQuals);
mangleRefQualifier(Method->getRefQualifier());
}
diff --git a/clang/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp b/clang/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
new file mode 100644
index 00000000000..a23e6a47ab0
--- /dev/null
+++ b/clang/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only %s -verify
+
+struct A
+{
+ int x;
+ void foo() __unaligned;
+ void foo();
+};
+
+void A::foo() __unaligned
+{
+ this->x++;
+}
+
+void A::foo() // expected-error {{definition with same mangled name as another definition}}
+ // expected-note@-6 {{previous definition is here}}
+{
+ this->x++;
+}
+
OpenPOWER on IntegriCloud