From: Devang Patel Date: Mon, 24 Oct 2011 23:15:17 +0000 (+0000) Subject: Do not drop type qualifiers in -flimit-debug-info mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41422511e80e05d42bbf2d8460ca1b8b59db68ae;p=clang Do not drop type qualifiers in -flimit-debug-info mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142873 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 2e1d12d8ce..4448153591 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -486,7 +486,13 @@ llvm::DIType CGDebugInfo::CreatePointeeType(QualType PointeeTy, llvm::DIFile Unit) { if (!CGM.getCodeGenOpts().LimitDebugInfo) return getOrCreateType(PointeeTy, Unit); - + + // Limit debug info for the pointee type. + + // Handle qualifiers. + if (PointeeTy.hasLocalQualifiers()) + return CreateQualifiedType(PointeeTy, Unit); + if (const RecordType *RTy = dyn_cast(PointeeTy)) { RecordDecl *RD = RTy->getDecl(); llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation()); diff --git a/test/CodeGenCXX/debug-info-method2.cpp b/test/CodeGenCXX/debug-info-method2.cpp new file mode 100644 index 0000000000..0d0e31fb7b --- /dev/null +++ b/test/CodeGenCXX/debug-info-method2.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -flimit-debug-info -x c++ -g -S -emit-llvm < %s | FileCheck %s +// rdar://10336845 +// Preserve type qualifiers in -flimit-debug-info mode. + +// 720934 = DW_TAG_const_type | LLVMDebugVersion +// CHECK: metadata !{i32 720934 +class A { +public: + int bar(int arg) const; +}; + +int A::bar(int arg) const{ + return arg+2; +} + +int main() { + A a; + int i = a.bar(2); + return i; +}