#include "clang/Basic/IdentifierTable.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include "clang/Lex/Lexer.h"
using namespace clang;
using llvm::utostr;
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
- // FIXME: need to consider empty class decls (no vars, methods)...
- // @interface NSConstantString : NSSimpleCString
- // @end
-
- if (*endBuf != '>' && *endBuf != '}')
- // we have an identifier - scan ahead until the end of token.
- endBuf = strchr(endBuf, ' '); // FIXME: implement correctly.
+ endBuf += Lexer::MeasureTokenLength(LocEnd, *SM);
std::string ResultStr;
SynthesizeObjcInternalStruct(ClassDecl, ResultStr);
- Rewrite.ReplaceText(LocStart, endBuf-startBuf+1,
+ Rewrite.ReplaceText(LocStart, endBuf-startBuf,
ResultStr.c_str(), ResultStr.size());
int nInstanceMethods = ClassDecl->getNumInstanceMethods();
// FIXME: handle methods that are declared across multiple lines.
}
+ // Lastly, comment out the @end.
+ Rewrite.ReplaceText(ClassDecl->getAtEndLoc(), 0, "// ", 3);
}
//===----------------------------------------------------------------------===//
ParseDeclarationOrFunctionDefinition();
}
}
- if (allMethods.size())
- /// Insert collected methods declarations into the @interface object.
- Actions.ActOnAddMethodsToObjcDecl(CurScope, interfaceDecl, &allMethods[0],
- allMethods.size(), AtEndLoc);
+ /// Insert collected methods declarations into the @interface object.
+ /// This action is executed even if we don't have any methods (so the @end
+ /// can be recorded properly).
+ Actions.ActOnAddMethodsToObjcDecl(CurScope, interfaceDecl, &allMethods[0],
+ allMethods.size(), AtEndLoc);
}
/// Parse property attribute declarations.
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";