[llvm-pdbdump] Dump restrict type qualifier
authorAaron Smith <aaron.smith@microsoft.com>
Mon, 5 Mar 2018 18:29:43 +0000 (18:29 +0000)
committerAaron Smith <aaron.smith@microsoft.com>
Mon, 5 Mar 2018 18:29:43 +0000 (18:29 +0000)
Reviewers: zturner, llvm-commits, rnk

Reviewed By: zturner

Subscribers: majnemer

Differential Revision: https://reviews.llvm.org/D43639

llvm-svn: 326731

llvm/test/tools/llvm-pdbdump/Inputs/TypeQualifiersTest.cpp [new file with mode: 0644]
llvm/test/tools/llvm-pdbdump/Inputs/TypeQualifiersTest.pdb [new file with mode: 0644]
llvm/test/tools/llvm-pdbdump/type-qualifiers.test [new file with mode: 0644]
llvm/tools/llvm-pdbutil/PrettyFunctionDumper.cpp
llvm/tools/llvm-pdbutil/PrettyTypedefDumper.cpp
llvm/tools/llvm-pdbutil/PrettyVariableDumper.cpp

diff --git a/llvm/test/tools/llvm-pdbdump/Inputs/TypeQualifiersTest.cpp b/llvm/test/tools/llvm-pdbdump/Inputs/TypeQualifiersTest.cpp
new file mode 100644 (file)
index 0000000..02dce9f
--- /dev/null
@@ -0,0 +1,55 @@
+// Compile with "cl /c /Zi /GR- TypeQualifiersTest.cpp"
+// Link with "link TypeQualifiersTest.obj /debug /nodefaultlib /entry:main"
+
+union Union {
+  int * __restrict x_member;
+  float * __restrict y_member;
+  int* volatile __restrict m_volatile;
+  const char* m_const;
+};
+
+int f(const volatile int* __restrict arg_crv) {
+  Union u;
+  return 1;
+}
+
+void g(int& __restrict arg_ref) {
+}
+
+namespace NS {
+  class Class {
+  public:
+    int get() const { return 1;}
+    int set() __restrict { return 2; }
+    void help() volatile { return; }
+  };
+
+  struct Foo {
+    int a;
+    int b;
+    int func(int x) __restrict { return 1; }
+  };
+
+  Foo s = { 10 };
+
+  const int* __restrict p_object = &s.a;
+
+  volatile int Foo:: * __restrict p_data_member = &Foo::a;
+
+  int (Foo::* p_member_func)(int) __restrict = &Foo::func;
+}
+
+typedef long* __restrict RestrictTypedef;
+RestrictTypedef RestrictVar;
+
+typedef volatile int* __restrict RankNArray[10][100];
+RankNArray ArrayVar;
+
+int main() {
+  NS::Class ClassVar;
+  ClassVar.get();
+  ClassVar.help();
+  ClassVar.set();
+
+  return 0;
+}
diff --git a/llvm/test/tools/llvm-pdbdump/Inputs/TypeQualifiersTest.pdb b/llvm/test/tools/llvm-pdbdump/Inputs/TypeQualifiersTest.pdb
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/llvm/test/tools/llvm-pdbdump/type-qualifiers.test b/llvm/test/tools/llvm-pdbdump/type-qualifiers.test
new file mode 100644 (file)
index 0000000..ff68e2f
--- /dev/null
@@ -0,0 +1,25 @@
+; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
+; RUN:   %p/Inputs/TypeQualifiersTest.pdb > %t
+; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC
+; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_DATA
+; RUN: FileCheck -input-file=%t %s -check-prefix=QUALS
+
+; GLOBALS_FUNC: ---GLOBALS---
+; GLOBALS_FUNC-DAG: int __cdecl f(const volatile int* __restrict arg_crv)
+; GLOBALS_FUNC-DAG: void __cdecl g(int& __restrict arg_ref)
+
+; GLOBALS_DATA: ---GLOBALS---
+; GLOBALS_DATA-DAG: static volatile int* __restrict ArrayVar[10][100]
+; GLOBALS_DATA-DAG: static long* __restrict RestrictVar
+; GLOBALS_DATA-DAG: static const int* __restrict NS::p_object
+; GLOBALS_DATA-DAG: static NS::Foo NS::s
+; GLOBALS_DATA-DAG: static volatile int* __restrict NS::p_data_member
+
+; QUALS: ---TYPES---
+; QUALS-DAG: typedef RankNArray
+; QUALS-DAG: typedef long* __restrict RestrictTypedef
+; QUALS: union Union
+; QUALS-DAG: int* __restrict x_member
+; QUALS-DAG: float* __restrict y_member
+; QUALS-DAG: int* volatile __restrict m_volatile
+; QUALS-DAG: const char* m_const
index 13df74f20d56c126e0ad68629bac1ef44c96112f..177d8a009a2bc68e10db12fc0420595ba4f30af2 100644 (file)
@@ -252,6 +252,9 @@ void FunctionDumper::dump(const PDBSymbolTypePointer &Symbol) {
       WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
     PointeeType->dump(*this);
     Printer << (Symbol.isReference() ? "&" : "*");
+
+    if (Symbol.getRawSymbol().isRestrictedType())
+      WithColor(Printer, PDB_ColorItem::Keyword).get() << " __restrict";
   }
 }
 
index ba3b4c8035c53c695c7f7e642d8e0891fab16b46..65443d6bca9042b13faa0bfaa15e59c7a2e59bae 100644 (file)
@@ -63,6 +63,9 @@ void TypedefDumper::dump(const PDBSymbolTypePointer &Symbol) {
     PointeeType->dump(*this);
     Printer << ((Symbol.isReference()) ? "&" : "*");
   }
+
+  if (Symbol.getRawSymbol().isRestrictedType())
+    WithColor(Printer, PDB_ColorItem::Keyword).get() << " __restrict";
 }
 
 void TypedefDumper::dump(const PDBSymbolTypeFunctionSig &Symbol) {
index 4884fc8ee5a413322784be250924341569858b50..ddac8cf0da4a89c846a394a6f72ad4a2764947e5 100644 (file)
@@ -169,6 +169,9 @@ void VariableDumper::dumpRight(const PDBSymbolTypeFunctionSig &Symbol) {
     WithColor(Printer, PDB_ColorItem::Keyword).get() << " const";
   if (Symbol.isVolatileType())
     WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile";
+
+  if (Symbol.getRawSymbol().isRestrictedType())
+    WithColor(Printer, PDB_ColorItem::Keyword).get() << " __restrict";
 }
 
 void VariableDumper::dump(const PDBSymbolTypePointer &Symbol) {
@@ -189,6 +192,9 @@ void VariableDumper::dump(const PDBSymbolTypePointer &Symbol) {
     WithColor(Printer, PDB_ColorItem::Keyword).get() << " const ";
   if (Symbol.isVolatileType())
     WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile ";
+
+  if (Symbol.getRawSymbol().isRestrictedType())
+    WithColor(Printer, PDB_ColorItem::Keyword).get() << " __restrict ";
 }
 
 void VariableDumper::dumpRight(const PDBSymbolTypePointer &Symbol) {