aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-04-01 00:15:23 +0000
committerAnders Carlsson <andersca@mac.com>2009-04-01 00:15:23 +0000
commitc6c91bc019ff7fa09f6570025ba011aad4c0d004 (patch)
treede590db0fff977cd35d8d309c2059fb378017e9b
parent8e5c2b8072f4409c7c0004331d1db9652d5209c0 (diff)
Fix a mangling bug where functions with no arguments weren't getting the 'v' parameter specifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68162 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/Mangle.cpp5
-rw-r--r--test/CodeGenCXX/mangle.cpp2
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 7a7a480bdb..427cc76646 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -477,6 +477,11 @@ void CXXNameMangler::mangleBareFunctionType(const FunctionType *T,
const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(T);
assert(Proto && "Can't mangle K&R function prototypes");
+ if (Proto->getNumArgs() == 0) {
+ Out << 'v';
+ return;
+ }
+
for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
ArgEnd = Proto->arg_type_end();
Arg != ArgEnd; ++Arg)
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 855a2ae0a4..7acb31cc69 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -24,3 +24,5 @@ void f(u) { }
typedef struct { int a; } x,y;
void f(y) { }
+// RUN: grep _Z1fv %t | count 1
+void f() { }