summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-01-09 22:16:16 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-01-09 22:16:16 +0000
commitcf63b845dfd6b9e94a690f5110e9099185fe85e4 (patch)
treea9a9ec5488327964144dba2eb61eb17baa785b89
parentfa328947302724f3e3b6af4836c0a153c60aa5a8 (diff)
downloadbcm5719-llvm-cf63b845dfd6b9e94a690f5110e9099185fe85e4.tar.gz
bcm5719-llvm-cf63b845dfd6b9e94a690f5110e9099185fe85e4.zip
MSVC seems to use (void) in __FUNCSIG__ for a zero-parameter function even in C++. Follow suit.
llvm-svn: 291489
-rw-r--r--clang/lib/AST/Expr.cpp5
-rw-r--r--clang/test/CodeGenCXX/funcsig.cpp10
2 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index edb218871ab..14f31d0c6b8 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -582,12 +582,13 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
if (i) POut << ", ";
POut << Decl->getParamDecl(i)->getType().stream(Policy);
}
- if (!Context.getLangOpts().CPlusPlus && !Decl->getNumParams())
- POut << "void";
if (FT->isVariadic()) {
if (FD->getNumParams()) POut << ", ";
POut << "...";
+ } else if ((IT == FuncSig || !Context.getLangOpts().CPlusPlus) &&
+ !Decl->getNumParams()) {
+ POut << "void";
}
}
POut << ")";
diff --git a/clang/test/CodeGenCXX/funcsig.cpp b/clang/test/CodeGenCXX/funcsig.cpp
index c064946e92d..16e5f7e1c9b 100644
--- a/clang/test/CodeGenCXX/funcsig.cpp
+++ b/clang/test/CodeGenCXX/funcsig.cpp
@@ -13,13 +13,12 @@ void funcNoProto() {
printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
}
// CHECK-C: @"\01??_C@_0BL@IHLLLCAO@void?5__cdecl?5funcNoProto?$CI?$CJ?$AA@" = linkonce_odr unnamed_addr constant [27 x i8] c"void __cdecl funcNoProto()\00"
-// CHECK-CXX: @"\01??_C@_0BL@IHLLLCAO@void?5__cdecl?5funcNoProto?$CI?$CJ?$AA@" = linkonce_odr unnamed_addr constant [27 x i8] c"void __cdecl funcNoProto()\00"
+// CHECK-CXX: @"\01??_C@_0BP@PJOECCJN@void?5__cdecl?5funcNoProto?$CIvoid?$CJ?$AA@" = linkonce_odr unnamed_addr constant [31 x i8] c"void __cdecl funcNoProto(void)\00"
void funcNoParams(void) {
printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
}
-// CHECK-C: @"\01??_C@_0CA@GBIDFNBN@void?5__cdecl?5funcNoParams?$CIvoid?$CJ?$AA@" = linkonce_odr unnamed_addr constant [32 x i8] c"void __cdecl funcNoParams(void)\00"
-// CHECK-CXX: @"\01??_C@_0BM@GDFBOAEE@void?5__cdecl?5funcNoParams?$CI?$CJ?$AA@" = linkonce_odr unnamed_addr constant [28 x i8] c"void __cdecl funcNoParams()\00"
+// CHECK: @"\01??_C@_0CA@GBIDFNBN@void?5__cdecl?5funcNoParams?$CIvoid?$CJ?$AA@" = linkonce_odr unnamed_addr constant [32 x i8] c"void __cdecl funcNoParams(void)\00"
void freeFunc(int *p, char c) {
printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
@@ -27,6 +26,11 @@ void freeFunc(int *p, char c) {
// CHECK: @"\01??_C@_0CD@KLGMNNL@void?5__cdecl?5freeFunc?$CIint?5?$CK?0?5cha@" = linkonce_odr unnamed_addr constant [{{.*}} x i8] c"void __cdecl freeFunc(int *, char)\00"
#ifdef __cplusplus
+void funcVarargs(...) {
+ printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
+}
+// CHECK-CXX: @"\01??_C@_0BO@BOBPLEKP@void?5__cdecl?5funcVarargs?$CI?4?4?4?$CJ?$AA@" = linkonce_odr unnamed_addr constant [30 x i8] c"void __cdecl funcVarargs(...)\00"
+
struct TopLevelClass {
void topLevelMethod(int *, char);
};
OpenPOWER on IntegriCloud