diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-19 16:30:28 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-19 16:30:28 +0000 |
commit | b5863da6efbf4ad42e26aa56a04366da50b6a3c7 (patch) | |
tree | cffd9b5adec33e28f3f4f3f662eaabf547044cb6 /lib/Rewrite | |
parent | ae519c42a1e0a023be6c07ba1dc10f28e29d6bc3 (diff) |
objective-c modern translator: Further improving the last
patch fixing writing a spurious 'static' into
the wrong place. // rdar://11275241
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite')
-rw-r--r-- | lib/Rewrite/RewriteModernObjC.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/Rewrite/RewriteModernObjC.cpp b/lib/Rewrite/RewriteModernObjC.cpp index 256e8f6995..2e9941bdd9 100644 --- a/lib/Rewrite/RewriteModernObjC.cpp +++ b/lib/Rewrite/RewriteModernObjC.cpp @@ -2262,7 +2262,11 @@ void RewriteModernObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) { 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 @@ std::string RewriteModernObjC::SynthesizeBlockDescriptor(std::string DescTag, /// 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(); } |