r291489 - MSVC seems to use (void) in __FUNCSIG__ for a zero-parameter function even in C++. Follow suit.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 9 14:16:17 PST 2017
Author: rsmith
Date: Mon Jan 9 16:16:16 2017
New Revision: 291489
URL: http://llvm.org/viewvc/llvm-project?rev=291489&view=rev
Log:
MSVC seems to use (void) in __FUNCSIG__ for a zero-parameter function even in C++. Follow suit.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/CodeGenCXX/funcsig.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=291489&r1=291488&r2=291489&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Jan 9 16:16:16 2017
@@ -582,12 +582,13 @@ std::string PredefinedExpr::ComputeName(
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 << ")";
Modified: cfe/trunk/test/CodeGenCXX/funcsig.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/funcsig.cpp?rev=291489&r1=291488&r2=291489&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/funcsig.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/funcsig.cpp Mon Jan 9 16:16:16 2017
@@ -13,13 +13,12 @@ void funcNoProto() {
printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
}
// CHECK-C: @"\01??_C at _0BL@IHLLLCAO at void?5__cdecl?5funcNoProto?$CI?$CJ?$AA@" = linkonce_odr unnamed_addr constant [27 x i8] c"void __cdecl funcNoProto()\00"
-// CHECK-CXX: @"\01??_C at _0BL@IHLLLCAO at void?5__cdecl?5funcNoProto?$CI?$CJ?$AA@" = linkonce_odr unnamed_addr constant [27 x i8] c"void __cdecl funcNoProto()\00"
+// CHECK-CXX: @"\01??_C at _0BP@PJOECCJN at 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 at _0CA@GBIDFNBN at 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 at _0BM@GDFBOAEE at void?5__cdecl?5funcNoParams?$CI?$CJ?$AA@" = linkonce_odr unnamed_addr constant [28 x i8] c"void __cdecl funcNoParams()\00"
+// CHECK: @"\01??_C at _0CA@GBIDFNBN at 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 at _0CD@KLGMNNL at 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 at _0BO@BOBPLEKP at 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);
};
More information about the cfe-commits
mailing list