aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp2
-rw-r--r--test/CodeGenCXX/debug-info.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index ab8f6637d6..cc97d19a5a 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -1001,7 +1001,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
const Decl *D = GD.getDecl();
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
Name = getFunctionName(FD);
- if (Name[0] == '\01')
+ if (!Name.empty() && Name[0] == '\01')
Name = Name.substr(1);
// Use mangled name as linkage name for c/c++ functions.
LinkageName = CGM.getMangledName(GD);
diff --git a/test/CodeGenCXX/debug-info.cpp b/test/CodeGenCXX/debug-info.cpp
index 705491e3a9..cb6e830a49 100644
--- a/test/CodeGenCXX/debug-info.cpp
+++ b/test/CodeGenCXX/debug-info.cpp
@@ -18,3 +18,9 @@ void f() {
int B::*a = 0;
void (B::*b)() = 0;
}
+
+namespace EmptyNameCrash {
+ struct A { A(); };
+ typedef struct { A x; } B;
+ B x;
+}