[cfe-commits] r44333 - in /cfe/trunk: Driver/RewriteTest.cpp test/Sema/rewrite-api-bug.m
Fariborz Jahanian
fjahanian at apple.com
Mon Nov 26 11:52:58 PST 2007
Author: fjahanian
Date: Mon Nov 26 13:52:57 2007
New Revision: 44333
URL: http://llvm.org/viewvc/llvm-project?rev=44333&view=rev
Log:
Patch to fix a regression caused by recent rewrite changes.
A potential API bug in ReplaceText pending (A FIXME is added).
Added:
cfe/trunk/test/Sema/rewrite-api-bug.m
Modified:
cfe/trunk/Driver/RewriteTest.cpp
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44333&r1=44332&r2=44333&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Mon Nov 26 13:52:57 2007
@@ -1310,20 +1310,26 @@
}
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, '{');
Added: cfe/trunk/test/Sema/rewrite-api-bug.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/rewrite-api-bug.m?rev=44333&view=auto
==============================================================================
--- cfe/trunk/test/Sema/rewrite-api-bug.m (added)
+++ cfe/trunk/test/Sema/rewrite-api-bug.m Mon Nov 26 13:52:57 2007
@@ -0,0 +1,13 @@
+// RUN: clang -rewrite-test %s
+
+#include <Objc/objc.h>
+
+ at interface MyDerived
+- (void) instanceMethod;
+ at end
+
+ at implementation MyDerived
+- (void) instanceMethod {
+}
+ at end
+
More information about the cfe-commits
mailing list