From 01c8c100c26973faf5e19bd38a029e58f0dbae8d Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 13 Jul 2010 16:23:13 +0000 Subject: [PATCH] Add volatile qualifiers for "this". llvm-svn: 108245 --- clang/lib/CodeGen/CGDebugInfo.cpp | 8 +++++++- .../CodeGenCXX/member-qual-debug-info.cpp | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGenCXX/member-qual-debug-info.cpp diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index a3c4003ff5be..4e158955f894 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -537,11 +537,17 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, llvm::DIType ThisPtrType = DebugFactory.CreateArtificialType(getOrCreateType(ThisPtr, Unit)); - if (Method->getTypeQualifiers() && Qualifiers::Const) + unsigned Quals = Method->getTypeQualifiers(); + if (Quals & Qualifiers::Const) ThisPtrType = DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_const_type, Unit, "", Unit, 0, 0, 0, 0, 0, ThisPtrType); + if (Quals & Qualifiers::Volatile) + ThisPtrType = + DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_volatile_type, + Unit, "", Unit, + 0, 0, 0, 0, 0, ThisPtrType); TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType; Elts.push_back(ThisPtrType); diff --git a/clang/test/CodeGenCXX/member-qual-debug-info.cpp b/clang/test/CodeGenCXX/member-qual-debug-info.cpp new file mode 100644 index 000000000000..c6e0991eeac9 --- /dev/null +++ b/clang/test/CodeGenCXX/member-qual-debug-info.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -g -S -masm-verbose -x c++ -o %t %s +// RUN: grep DW_TAG_volatile_type %t | count 3 +// RUN: grep DW_TAG_const_type %t | count 3 +// one for decl, one for def, one for abbrev + +namespace A { + class B { + public: + void dump() const volatile; + }; +} + +int main () { + using namespace A; + B b; + return 0; +} + +void A::B::dump() const volatile{ +}