From: David Majnemer Date: Mon, 2 Feb 2015 19:05:46 +0000 (+0000) Subject: MS ABI: Add more documentation and tests for novtable X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8970d3cb4bb56d4903c1e5ee2c841cdc32ad0e6f;p=clang MS ABI: Add more documentation and tests for novtable git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227838 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 00fc5be3cc..7245e49da8 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -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 { diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td index 918abb6072..933bc3628b 100644 --- a/include/clang/Basic/AttrDocs.td +++ b/include/clang/Basic/AttrDocs.td @@ -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 index 0000000000..8d54878d23 --- /dev/null +++ b/test/CodeGenCXX/ms-novtable.cpp @@ -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 index 0000000000..6dd949d57d --- /dev/null +++ b/test/SemaCXX/ms-novtable.cpp @@ -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}}