]> granicus.if.org Git - clang/commitdiff
MS ABI: Add more documentation and tests for novtable
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 2 Feb 2015 19:05:46 +0000 (19:05 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 2 Feb 2015 19:05:46 +0000 (19:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227838 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
test/CodeGenCXX/ms-novtable.cpp [new file with mode: 0644]
test/SemaCXX/ms-novtable.cpp [new file with mode: 0644]

index 00fc5be3cc05354aa5f832ab045052581bbff03e..7245e49da8cae8242f5379c0365567aecbede620 100644 (file)
@@ -1764,7 +1764,7 @@ def TypeTagForDatatype : InheritableAttr {
 def MsNoVTable : InheritableAttr {
   let Spellings = [Declspec<"novtable">];
   let Subjects = SubjectList<[CXXRecord]>;
-  let Documentation = [Undocumented];
+  let Documentation = [MsNoVTableDocs];
 }
 
 def MsProperty : IgnoredAttr {
index 918abb6072ea11e905f5f725fc3fee1fb3337fa1..933bc3628b92f261d3d089c22f50cc5fb182a902 100644 (file)
@@ -1253,6 +1253,15 @@ an error:
 }];
 }
 
+def MsNoVTableDocs : Documentation {
+  let Category = DocCatType;
+  let Content = [{
+This attribute can be added to a class declaration or definition to signal to
+the compiler that constructors and destructors will not reference the virtual
+function table.
+  }];
+}
+
 def OptnoneDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
diff --git a/test/CodeGenCXX/ms-novtable.cpp b/test/CodeGenCXX/ms-novtable.cpp
new file mode 100644 (file)
index 0000000..8d54878
--- /dev/null
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-extensions -fms-compatibility -fno-rtti -o - | FileCheck %s
+
+// CHECK-NOT: @"\01??_7C@@6B@"
+
+// CHECK-DAG: @"\01??_7A2@@6B@"
+
+// CHECK-DAG: @"\01??_7B2@@6B@"
+
+// CHECK-NOT: @"\01??_7B1@@6B@"
+
+// CHECK-NOT: @"\01??_7A1@@6B@"
+
+struct __declspec(novtable) A1 {
+  virtual void a();
+} a1;
+struct                      A2 {
+  virtual void a();
+};
+struct __declspec(novtable) B1 : virtual A1 {} b1;
+struct                      B2 : virtual A1 {} b2;
+struct __declspec(novtable) C  : virtual A2 {} c;
diff --git a/test/SemaCXX/ms-novtable.cpp b/test/SemaCXX/ms-novtable.cpp
new file mode 100644 (file)
index 0000000..6dd949d
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11
+
+struct __declspec(novtable) S {};
+enum __declspec(novtable) E {}; // expected-warning{{'novtable' attribute only applies to classes}}
+int __declspec(novtable) I; // expected-warning{{'novtable' attribute only applies to classes}}
+typedef struct T __declspec(novtable) U; // expected-warning{{'novtable' attribute only applies to classes}}