[cfe-commits] r155130 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/rewrite-modern-extern-c-func-decl.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Apr 19 09:30:28 PDT 2012
Author: fjahanian
Date: Thu Apr 19 11:30:28 2012
New Revision: 155130
URL: http://llvm.org/viewvc/llvm-project?rev=155130&view=rev
Log:
objective-c modern translator: Further improving the last
patch fixing writing a spurious 'static' into
the wrong place. // rdar://11275241
Modified:
cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
cfe/trunk/test/Rewriter/rewrite-modern-extern-c-func-decl.mm
Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=155130&r1=155129&r2=155130&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Thu Apr 19 11:30:28 2012
@@ -2262,7 +2262,11 @@
if (i+1 < numArgs)
FdStr += ", ";
}
- FdStr += ");\n";
+ if (FD->isVariadic()) {
+ FdStr += (numArgs > 0) ? ", ...);\n" : "...);\n";
+ }
+ else
+ FdStr += ");\n";
InsertText(FunLocStart, FdStr);
}
@@ -4007,19 +4011,15 @@
/// extern "C" or extern "C" {...}
static SourceLocation getFunctionSourceLocation (RewriteModernObjC &R,
FunctionDecl *FD) {
- if (!FD->isExternC() || FD->isMain()) {
- if (FD->getStorageClassAsWritten() != SC_None)
- R.RewriteBlockLiteralFunctionDecl(FD);
- return FD->getTypeSpecStartLoc();
- }
- const DeclContext *DC = FD->getDeclContext();
- if (const LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
- SourceLocation BodyRBrace = LSD->getRBraceLoc();
- // if it is extern "C" {...}, return function decl's own location.
- if (BodyRBrace.isValid())
- return FD->getTypeSpecStartLoc();
- return LSD->getExternLoc();
+ if (FD->isExternC() && !FD->isMain()) {
+ const DeclContext *DC = FD->getDeclContext();
+ if (const LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(DC))
+ // if it is extern "C" {...}, return function decl's own location.
+ if (!LSD->getRBraceLoc().isValid())
+ return LSD->getExternLoc();
}
+ if (FD->getStorageClassAsWritten() != SC_None)
+ R.RewriteBlockLiteralFunctionDecl(FD);
return FD->getTypeSpecStartLoc();
}
Modified: cfe/trunk/test/Rewriter/rewrite-modern-extern-c-func-decl.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-extern-c-func-decl.mm?rev=155130&r1=155129&r2=155130&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-extern-c-func-decl.mm (original)
+++ cfe/trunk/test/Rewriter/rewrite-modern-extern-c-func-decl.mm Thu Apr 19 11:30:28 2012
@@ -49,8 +49,19 @@
char CFStringGetTypeID();
void x(void (^)());
-static void initStatics() {
+static void initStatics(int arg, ...) {
x(^{
stringtype = CFStringGetTypeID();
});
}
+static void initStatics1(...) {
+ x(^{
+ stringtype = CFStringGetTypeID();
+ });
+}
+static void initStatics2() {
+ x(^{
+ stringtype = CFStringGetTypeID();
+ });
+}
+
More information about the cfe-commits
mailing list