From 22c460a0511c98431ae58a501a944cb27965228a Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 24 May 2013 21:24:35 +0000 Subject: [PATCH] PR16091: Error when attempting to emit debug info for undeduced auto return types Perhaps we should just suppress this, rather than erroring, but since we have the infrastructure for it I figured I'd use it - if this is determined to be not the right thing we should probably remove that infrastructure entirely. I guess it's lying around from the early days of implementing debug info support. llvm-svn: 182673 --- clang/lib/CodeGen/CGDebugInfo.cpp | 9 +++++++-- clang/test/CodeGenCXX/debug-info-cxx1y.cpp | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 clang/test/CodeGenCXX/debug-info-cxx1y.cpp diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 561490d25bea..e5c3a053b500 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1827,7 +1827,10 @@ static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) { T = cast(T)->getReplacementType(); break; case Type::Auto: - T = cast(T)->getDeducedType(); + QualType DT = cast(T)->getDeducedType(); + if (DT.isNull()) + return T; + T = DT; break; } @@ -2044,8 +2047,10 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) { case Type::TypeOf: case Type::Decltype: case Type::UnaryTransform: - case Type::Auto: llvm_unreachable("type should have been unwrapped!"); + case Type::Auto: + Diag = "auto"; + break; } assert(Diag && "Fall through without a diagnostic?"); diff --git a/clang/test/CodeGenCXX/debug-info-cxx1y.cpp b/clang/test/CodeGenCXX/debug-info-cxx1y.cpp new file mode 100644 index 000000000000..e5bfd5782eeb --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-cxx1y.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -emit-llvm-only -std=c++1y -g %s 2>&1 | FileCheck %s + +struct foo { + auto func(); // CHECK: error: debug information for auto is not yet supported +}; + +foo f;