aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-11-09 12:50:28 +0000
committerSteve Naroff <snaroff@apple.com>2007-11-09 12:50:28 +0000
commit32174826f58d38c20f376fe64ceac4a278133883 (patch)
tree2778387f1bd896722d0b939c52c83fe329d7cb83 /Driver/RewriteTest.cpp
parent3b0eff8a12f7b3e48fa1022c3ce5a07ac03a85cd (diff)
- add typedef guards.
- tweak scanForProtocolRefs heuristic. - disable RewriteInclude() for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43942 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index b985e03cb5..885da01429 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -177,7 +177,7 @@ void RewriteTest::HandleTopLevelDecl(Decl *D) {
// Otherwise, see if there is a #import in the main file that should be
// rewritten.
- RewriteInclude(Loc);
+ //RewriteInclude(Loc);
}
/// HandleDeclInMainFile - This is called for each top-level decl defined in the
@@ -299,10 +299,15 @@ void RewriteTest::RewriteForwardClassDecl(ObjcClassDecl *ClassDecl) {
ObjcInterfaceDecl *ForwardDecl = ForwardDecls[i];
if (ObjcForwardDecls.count(ForwardDecl))
continue;
+ typedefString += "#ifndef _REWRITER_typedef_";
+ typedefString += ForwardDecl->getName();
+ typedefString += "\n";
+ typedefString += "#define _REWRITER_typedef_";
+ typedefString += ForwardDecl->getName();
+ typedefString += "\n";
typedefString += "typedef struct objc_object ";
typedefString += ForwardDecl->getName();
- typedefString += ";\n";
-
+ typedefString += ";\n#endif\n";
// Mark this typedef as having been generated.
if (!ObjcForwardDecls.insert(ForwardDecl))
assert(false && "typedef already output");
@@ -377,9 +382,15 @@ void RewriteTest::RewriteInterfaceDecl(ObjcInterfaceDecl *ClassDecl) {
std::string ResultStr;
if (!ObjcForwardDecls.count(ClassDecl)) {
// we haven't seen a forward decl - generate a typedef.
+ ResultStr += "#ifndef _REWRITER_typedef_";
+ ResultStr += ClassDecl->getName();
+ ResultStr += "\n";
+ ResultStr += "#define _REWRITER_typedef_";
+ ResultStr += ClassDecl->getName();
+ ResultStr += "\n";
ResultStr += "typedef struct objc_object ";
ResultStr += ClassDecl->getName();
- ResultStr += ";";
+ ResultStr += ";\n#endif\n";
// Mark this typedef as having been generated.
ObjcForwardDecls.insert(ClassDecl);
@@ -671,9 +682,11 @@ static bool scanForProtocolRefs(const char *startBuf, const char *endBuf,
if (*startBuf == '<')
startRef = startBuf; // mark the start.
if (*startBuf == '>') {
- assert((startRef && *startRef == '<') && "rewrite scanning error");
- endRef = startBuf; // mark the end.
- return true;
+ if (startRef && *startRef == '<') {
+ endRef = startBuf; // mark the end.
+ return true;
+ }
+ return false;
}
startBuf++;
}