aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2007-11-26 19:52:57 +0000
committerFariborz Jahanian <fjahanian@apple.com>2007-11-26 19:52:57 +0000
commit2c7038b298c61e531ee4e79b9ff014ffb97b6ccc (patch)
tree3ea3cd364dc897c87c92d8edde3d28813f82e990 /Driver/RewriteTest.cpp
parent8e911c42ad6a5ae0fe0dd46058bd13236a0e9026 (diff)
Patch to fix a regression caused by recent rewrite changes.
A potential API bug in ReplaceText pending (A FIXME is added). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index 23bf240ac8..cc6d56959e 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -1310,20 +1310,26 @@ void RewriteTest::SynthesizeObjcInternalStruct(ObjcInterfaceDecl *CDecl,
}
int NumIvars = CDecl->getNumInstanceVariables();
+ SourceLocation LocStart = CDecl->getLocStart();
+ SourceLocation LocEnd = CDecl->getLocEnd();
+
+ const char *startBuf = SM->getCharacterData(LocStart);
+ const char *endBuf = SM->getCharacterData(LocEnd);
// If no ivars and no root or if its root, directly or indirectly,
// have no ivars (thus not synthesized) then no need to synthesize this class.
- if (NumIvars <= 0 && (!RCDecl || !ObjcSynthesizedStructs.count(RCDecl)))
+ if (NumIvars <= 0 && (!RCDecl || !ObjcSynthesizedStructs.count(RCDecl))) {
+ //FIXME: This does not replace @interface class-name with the
+ //Result text. Could be a bug in ReplaceText API.
+ endBuf += Lexer::MeasureTokenLength(LocEnd, *SM);
+ Rewrite.ReplaceText(LocStart, endBuf-startBuf,
+ Result.c_str(), Result.size());
return;
+ }
+
// FIXME: This has potential of causing problem. If
// SynthesizeObjcInternalStruct is ever called recursively.
Result += "\nstruct ";
Result += CDecl->getName();
-
- SourceLocation LocStart = CDecl->getLocStart();
- SourceLocation LocEnd = CDecl->getLocEnd();
-
- const char *startBuf = SM->getCharacterData(LocStart);
- const char *endBuf = SM->getCharacterData(LocEnd);
if (NumIvars > 0) {
const char *cursor = strchr(startBuf, '{');