Chris Lattner
e365c50a21
pass diagnostics into the rewrite test client.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44468 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-30 22:25:36 +00:00
Steve Naroff
1f64432558
Several fixes/simplifications surrounding how we stream top-level decl AST's.
...
The following code...
typedef struct cssm_data {} CSSM_DATA, *CSSM_DATA_PTR;
struct Y { int A; };
struct X { int A; } D;
struct X E, F;
...now produces the following output...
> ../../Debug/bin/clang xx.c -ast-print
Read top-level tag decl: 'cssm_data'
typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data *CSSM_DATA_PTR;
Read top-level tag decl: 'Y'
Read top-level tag decl: 'X'
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'F'
...which is much more accurate than the previous -ast-print output...
typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data CSSM_DATA;
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'E'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44421 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-28 22:54:11 +00:00
Chris Lattner
b751c28a1a
Fix a bug checking for 'int foo(void)' that didn't look through typedefs of void.
...
Bug pointed out by Michael Zolda, thanks!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44408 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-28 18:51:29 +00:00
Ted Kremenek
588e5ebee2
Moved logic for -Wfloat-equal to SemaChecking.cpp.
...
Moved utility functions IgnoreParen and friends to be static inline functions
defined in SemaUtil.h.
Added SemaUtil.h to Xcode project.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44312 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-25 00:58:00 +00:00
Steve Naroff
f68a63f9cf
Fix a basic bug (having to do with typedefs) in Sema::UsualArithmeticConversions().
...
This resuled in the following crash below.
Also modified the usual-float.c test case to capture this case.
[steve-naroffs-imac:clang/test/Sema] snaroff% ../../../../Debug/bin/clang usual-float.c
Assertion failed: (0 && "Sema::UsualArithmeticConversions(): illegal float comparison"), function UsualArithmeticConversions, file SemaExpr.cpp, line 960.
0 clang 0x001ef9b9 _ZN40_GLOBAL__N_Signals.cpp_00000000_4E6DAF8315PrintStackTraceEv + 45
1 clang 0x001efd5f _ZN40_GLOBAL__N_Signals.cpp_00000000_4E6DAF8313SignalHandlerEi + 323
2 libSystem.B.dylib 0x90c6297b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 libSystem.B.dylib 0x90cdb782 raise + 26
5 libSystem.B.dylib 0x90cead3f abort + 73
6 libSystem.B.dylib 0x90cdc923 __assert_rtn + 101
7 clang 0x00077316 _ZN5clang4Sema26UsualArithmeticConversionsERPNS_4ExprES3_b + 1004
8 clang 0x000803cf _ZN5clang4Sema27CheckMultiplyDivideOperandsERPNS_4ExprES3_NS_14SourceLocationEb + 181
9 clang 0x0007a8e8 _ZN5clang4Sema10ActOnBinOpENS_14SourceLocationENS_3tok9TokenKindEPvS4_ + 472
10 clang 0x000cf058 _ZN5clang6Parser26ParseRHSOfBinaryExpressionENS_6Action12ActionResultILj0EEEj + 1286
11 clang 0x000cf2de _ZN5clang6Parser25ParseAssignmentExpressionEv + 86
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43985 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-10 19:45:54 +00:00
Chris Lattner
b7489d8129
change source location to have two bits for macros, tracking
...
whether the location is the start and/or end of an expansion.
These are currently not set or used by anything.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43968 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-09 23:52:16 +00:00
Steve Naroff
f3473a7e48
Rewrite global variable initializers.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43947 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-09 15:20:18 +00:00
Chris Lattner
fab21b6d73
add a getAtOffset() member to simplify some code.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43905 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 20:51:02 +00:00
Chris Lattner
8b0c2f659d
Add a new RewriteRope data structure which is a smarter way to represent the text
...
backing a rewrite buffer than using an std::vector<char>. This class was hacked
together very quickly and needs to be cleaned up, but it seems to work. It speeds
up rewriting a a 7M file from 6.43s to 0.24s on my machine. The impl could also
be made to be a lot more algorithmically sound.
This produces identical output to using vector on this testcase, if it causes a
problems or bugs are encountered, it can be disabled by changing the
RewriteBuffer::Buffer typedef back.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43884 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 07:35:14 +00:00
Ted Kremenek
8c35a9b3b9
Added TypeSerialization.cpp and DeclSerialization.cpp to the XCode project.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43710 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 17:04:40 +00:00
Chris Lattner
770951b5bb
add support for vector type compatibility checking. Patch by Nate Begeman.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43604 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 05:03:41 +00:00
Steve Naroff
6c6a2dbb4d
Tweak RewriteInterfaceDecl() to generate a typedef (if one hasn't already been generated).
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43600 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 03:35:41 +00:00
Fariborz Jahanian
19d74e1494
More infrastructure to recognize objective-c's type qualifiers (in,inout, etc.)
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43580 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 21:59:43 +00:00
Steve Naroff
8ee529b567
Implement a more sensible strategy for ObjC built-in types (addressing a long standing FIXME in Sema::GetObjcIdType()).
...
This removes several gross hacks to work around the previous "lazy" behavior.
Two notes:
- MinimalActions still needs to be taught about the built-in types (This breaks one of the -noop test cases). I started this, then added a FIXME.
- I didn't convert Sema::GetObjcProtoType() yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43567 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 18:42:27 +00:00
Fariborz Jahanian
dea84f82b2
After Anders check-in, we can now encode 'Class' type.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43556 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 16:00:13 +00:00
Steve Naroff
9165ad378f
Add some plumbing to help cope with rewriting "id<p>", "Class<p>*".
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43543 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 04:38:33 +00:00
Fariborz Jahanian
8be9d0a9cd
Added new type and bitfield fields in some decl types in preparation for objective-c's type qualifiers.
...
Added initialization of Class/SEMA types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43534 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-31 00:12:35 +00:00
Steve Naroff
09b266eb2a
Stop pre-defining objc_msgSend/objc_getClass in the preprocessor. Instead, I generate these declaration on the fly when rewriting a message expression.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43529 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 23:14:51 +00:00
Fariborz Jahanian
c2939bc82c
Added type encoding for 'id' type.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43504 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 17:06:23 +00:00
Steve Naroff
2feac5e559
Remove a couple FIXME's for rewriting ObjC interfaces (which are now being rewritten properly).
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43494 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 03:43:13 +00:00
Fariborz Jahanian
33e1d64ab5
Encoding for objectiive-c methods.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43481 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 22:57:28 +00:00
Steve Naroff
60fcceeedb
This commit contains lot's of small tweaks to how we pass around and store SourceLocation's for interfaces/protocols/categories/implementations.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43475 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 21:38:07 +00:00
Anders Carlsson
e8c4953352
Address Chris's comments.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43445 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 06:33:42 +00:00
Chris Lattner
fe79595619
Implement *skeletal* support for representing GNU inline asm stmts in the AST,
...
resolving a crash on a .i file in PR1750. We now generate 49 errors on the
.i file in that bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43433 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 04:04:16 +00:00
Fariborz Jahanian
4d733d3288
Path to synthesize 'instance' size field of _objc_class metadata.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43409 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-26 23:09:28 +00:00
Steve Naroff
bef1185418
Start rewriting ObjC interfaces. As a start, we comment out all the methods. This involved refining how the parser/AST passes/manages SourceLocations for ObjcMethodDecl's.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43404 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-26 20:53:56 +00:00
Ted Kremenek
f152b2ee87
Added DeclSerialization.cpp to XCode project.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43362 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 21:39:10 +00:00
Fariborz Jahanian
ccd87b07a7
Refactored several meta data for reusability.
...
Changed the entire rewrite of metadata to write to std::string
object instead of stdout.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43360 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 20:55:25 +00:00
Chris Lattner
158ecb9767
Convert one type of metadata to use std::string instead of
...
printf as an example.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43346 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 17:07:24 +00:00
Ted Kremenek
a194bc6018
Added SourceLocation.cpp to XCode project.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43344 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 16:03:53 +00:00
Chris Lattner
27437caade
Add a new ChooseExpr::isConditionTrue method to unify
...
some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43322 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 00:29:32 +00:00
Fariborz Jahanian
2e6d935930
Refactord instance and class metadata emission. Refactored protocols metadata emission.
...
Implemented emission of category metadata,
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43308 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-24 19:23:36 +00:00
Steve Naroff
ebf2b56bce
Add some plumbing to rewrite message expressions (still under construction).
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43274 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 23:50:29 +00:00
Steve Naroff
7e15891fc8
- Add rewrite rule for @class.
...
- Add setter/getter to ObjcClassDecl.
- Predefined key runtime functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43257 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-23 20:20:08 +00:00
Fariborz Jahanian
e887c09395
This patch generates protocol metadata and all its sub-metadata.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43233 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-22 21:41:37 +00:00
Steve Naroff
806a4ebcf5
Fix the previous (short lived:-) FIXME.
...
I didn't realize that GCC considers this a hard error (I thought it was built-in).
Since it's not, we should simply emit an error.
[dylan:~/llvm/tools/clang] admin% cc -c trivial.m
trivial.m:6: error: cannot find interface declaration for 'NSConstantString'
[administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang trivial.m
trivial.m:6:16: error: cannot find interface declaration for 'NSConstantString'
NSString *s = @"123";
^
1 diagnostic generated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43157 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 23:53:51 +00:00
Ted Kremenek
6acaabc91e
Added StmtIterator.cpp and StmtIterator.h to the XCode project.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43139 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 18:22:01 +00:00
Steve Naroff
fd8b4a4b29
Fix the following bug...
...
unsigned char asso_values[] = { 34 };
int legal2() {
return asso_values[0];
}
The code that creates the new constant array type was operating on the original type.
As a result, the constant type being generated was "unsigned char [1][]" (which is wrong).
The fix is to operate on the element type - in this case, the correct type is "unsigned char [1]"
I added this case to array-init.c, which clearly didn't catch this bogosity...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43112 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 03:27:23 +00:00
Ted Kremenek
5a59d92fb0
Added Driver/SerializationTest.cpp to the XCode project.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43054 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 23:40:12 +00:00
Fariborz Jahanian
2a35fa9b5e
Fix location processing of @selector: the range should include the @ sign.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43051 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 23:21:02 +00:00
Chris Lattner
311ff02fae
Add a new Rewriter::getRangeSize method.
...
Rename SourceRange::Begin()/End() to getBegin()/getEnd() for
consistency with other code.
Start building the rewriter towards handling @encode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43047 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 22:36:42 +00:00
Fariborz Jahanian
3e7fd152aa
Patch to diagnose duplicate method implementations.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43046 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:52:23 +00:00
Chris Lattner
2c64b7b938
Push the rewriter forward a bit more. Now it rewrites
...
#import to #include's as a test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43041 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:07:07 +00:00
Fariborz Jahanian
b62f681340
Patch to implement AST generation for objective-c's @selector expression.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43038 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 20:40:23 +00:00
Steve Naroff
a1fe1176a4
Bad cast...need to use dyn_cast_or_null. Also changed Sema::InitBuiltinVaListType (which had the same bug).
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43023 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 00:00:18 +00:00
Fariborz Jahanian
a0818e3cd7
Patch to parse @selector expressions.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43022 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 23:39:13 +00:00
Steve Naroff
ec0550fa36
Move type compatibility predicates from Type to ASTContext. In addition, the predicates are now instance methods (they were previously static class methods on Type).
...
This allowed me to fix the following hack from this weekend...
// FIXME: Devise a way to do this without using strcmp.
// Would like to say..."return getAsStructureType() == IdStructType;", but
// we don't have a pointer to ASTContext.
bool Type::isObjcIdType() const {
if (const RecordType *RT = getAsStructureType())
return !strcmp(RT->getDecl()->getName(), "objc_object");
return false;
}
...which is now...
bool isObjcIdType(QualType T) const {
return T->getAsStructureType() == IdStructType;
}
Side notes:
- I had to remove a convenience function from the TypesCompatibleExpr class.
int typesAreCompatible() const {return Type::typesAreCompatible(Type1,Type2);}
Which required a couple clients get a little more verbose...
- Result = TCE->typesAreCompatible();
+ Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2());
Overall, I think this change also makes sense for a couple reasons...
1) Since ASTContext vends types, it makes sense for the type compatibility API to be there.
2) This allows the type compatibility predeciates to refer to data not strictly present in the AST (which I have found problematic on several occasions).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43009 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 20:41:53 +00:00
Anders Carlsson
ee98ac5a13
Add support for Pascal strings.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42974 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 02:50:23 +00:00
Chris Lattner
88d0ed0c58
Woo, tab deletion now works. Next lets see if we can
...
insert stuff.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42941 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-13 00:17:04 +00:00
Fariborz Jahanian
e7f64cc250
Check and diagnose that objective-c objects may not be statically allocated.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42936 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 22:10:42 +00:00