Commit Graph

115 Commits

Author SHA1 Message Date
Ted Kremenek e9b83bbd68 Renamed all serialization "Materialize" methods to "Create" to conform with
the new serialization API.

llvm-svn: 44035
2007-11-13 00:25:37 +00:00
Steve Naroff 4d7b367652 Teach ASTContext::tagTypesAreCompatible() about the built-in ObjC types (Class and id), removing a bogus warning.
llvm-svn: 43809
2007-11-07 06:03:51 +00:00
Ted Kremenek 453ab7d126 Started work on new serialization approach within ASTContext to
serialize Type objects in the order they are serialized in the Types
vector.  We also now rely on the methods within ASTContext to unique
Type objects and handle the actual creation of Type objects (these are
now called by the deserialization code).  This approach solves some
hairy issues with ownership of objects and allows us to naturally
handle recursive types.

llvm-svn: 43787
2007-11-06 22:26:16 +00:00
Ted Kremenek 77068e17d4 Misc. serialization changes to ASTContext and Decls. Serialization
for ASTContext is still rapidly evolving.

llvm-svn: 43774
2007-11-06 19:51:47 +00:00
Ted Kremenek 58473ab478 For serialization of ASTContext, added special-casing of serialization
of type sets when emitting complex types and pointer types that are
also considered builtins.  These types are automatically created in
the ctor of ASTContext, and thus should not be serialized (was
producing an error during deserialization).

llvm-svn: 43733
2007-11-05 20:49:23 +00:00
Steve Naroff a397efd915 Implement rewrite rules for ObjC string constants.
llvm-svn: 43665
2007-11-03 11:27:19 +00:00
Devang Patel e11664a0ef Rename classes and collections that maintain record layout information.
Now, at AST level record info is maintained by ASTRecordLayout class.
Now, at code gen  level record info is maintained by CGRecordLayout class.

llvm-svn: 43619
2007-11-01 19:11:01 +00:00
Ted Kremenek 26a7f3fd56 Implemented serialization of QualTypes within ASTContext. Clarified
ownership model of some type pointers.  Added FIXMEs to serialization.

Added comments to ASTContext indicating which variables we are intentionally
*not* serializing.

llvm-svn: 43618
2007-11-01 18:11:32 +00:00
Fariborz Jahanian ac73ff8868 Remaining work to collect objective-c's type qualifiers and use them to encode
method types.

llvm-svn: 43617
2007-11-01 17:18:37 +00:00
Ted Kremenek 53155f379e Changed serialization/deserialization of BuiltinTypes to explicitly serialize
each type.  This ensures that the order in which the types are serialized
is clear and remains persistent.

llvm-svn: 43615
2007-11-01 17:10:34 +00:00
Chris Lattner b338a6b9f3 add support for vector type compatibility checking. Patch by Nate Begeman.
llvm-svn: 43604
2007-11-01 05:03:41 +00:00
Ted Kremenek 6aff871a84 Implemented more of serialization/deserialization for ASTContext. We now
(hypothetically) read in/write out most of the types.  Bugs likely exist.

llvm-svn: 43584
2007-10-31 22:44:07 +00:00
Ted Kremenek c55cd9a38a Adjusted QualType deserialization to reflect updated deserialization API.
We now serialize ivar references inside of ASTContext.

llvm-svn: 43571
2007-10-31 20:00:03 +00:00
Ted Kremenek 9cc9335bdf Implemented serialization of Variable Array Types (VLAs).
llvm-svn: 43561
2007-10-31 17:50:23 +00:00
Ted Kremenek fc581a9a89 Renamed ivar "ArrayTypes" in ASTContext to "ComplexArrayTypes".
Added skeleton code for serialization of ASTContext.

llvm-svn: 43558
2007-10-31 17:10:13 +00:00
Anders Carlsson f56a7aee2f Encode Class, SEL and Objective-C objects.
llvm-svn: 43540
2007-10-31 02:53:19 +00:00
Chris Lattner e0218997ab minor code cleanup
llvm-svn: 43512
2007-10-30 20:27:44 +00:00
Fariborz Jahanian 509d8d6fc6 Added type encoding for 'id' type.
llvm-svn: 43504
2007-10-30 17:06:23 +00:00
Ted Kremenek 9139310c76 Added vector to ASTContext to store references to "complete" VLA types
(VLAs with a specified size expresssion).  This vector owns the
references to these type objects.

llvm-svn: 43502
2007-10-30 16:41:53 +00:00
Anders Carlsson df4cc6160f Handle function types.
llvm-svn: 43485
2007-10-30 00:06:20 +00:00
Ted Kremenek 843ebedde4 VariableArrayTypes (VLAs) without a size expression are now uniqued
and inserted into a FoldingSet owned by ASTContext.

llvm-svn: 43482
2007-10-29 23:37:31 +00:00
Fariborz Jahanian 797f24cd7e Encoding for objectiive-c methods.
llvm-svn: 43481
2007-10-29 22:57:28 +00:00
Anders Carlsson 18acd44514 Address Chris's comments.
llvm-svn: 43445
2007-10-29 06:33:42 +00:00
Anders Carlsson 0f1cacd049 Fix logic error.
llvm-svn: 43443
2007-10-29 05:58:43 +00:00
Anders Carlsson d849982e84 Add (partial) support for @encode.
llvm-svn: 43439
2007-10-29 05:01:08 +00:00
Fariborz Jahanian a32aaefadc Implementation of AST for @protocol expression.
llvm-svn: 43075
2007-10-17 16:58:11 +00:00
Fariborz Jahanian 4bef462a3e Patch to implement AST generation for objective-c's @selector expression.
llvm-svn: 43038
2007-10-16 20:40:23 +00:00
Steve Naroff f73b784a5e Change the type of ObjCStringLiteral from "struct __builtin_CFString *" to "NSConstantString *".
This makes the typecheck much happier. Without this change, the type checker would have to special case "struct __builtin_CFString *". This change does assume the interface for NSConstantString is declared in the translation unit.

I left ASTContext::getCFConstantStringType() around for now (with a comment that says it is currently unused).

llvm-svn: 43021
2007-10-15 23:35:17 +00:00
Steve Naroff 32e44c0032 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).

llvm-svn: 43009
2007-10-15 20:41:53 +00:00
Steve Naroff 66e9f331ba Added ASTContext::setObjcIdType/getObjcIdType(), set by Sema.
Also noticed ASTContext::BuiltinVaListType wasn't being initialized to the null type (so I set it).

llvm-svn: 42983
2007-10-15 14:41:52 +00:00
Chris Lattner f709a1495d slightly simplify interface
llvm-svn: 42858
2007-10-11 03:36:41 +00:00
Anders Carlsson 87c149bf51 Add __builtin_va_start to the list of builtins, make __builtin_va_list available to builtin functions.
llvm-svn: 42857
2007-10-11 01:00:40 +00:00
Fariborz Jahanian 70e8f1024a Patch to create protocol conforming class types.
llvm-svn: 42856
2007-10-11 00:55:41 +00:00
Steve Naroff c62adb6d1a Make sure methods with no return type default to "id".
This fixes a crasher in Sema::MatchTwoMethodDeclarations(), identified by selector-overload.m (just added).

Added Action::ActOnTranslationUnitScope() and renamed Action::PopScope to ActOnPopScope.

Added a Translation Unit Scope instance variable to Sema (will be very useful to ObjC-related actions, since ObjC declarations are always file-scoped).

llvm-svn: 42817
2007-10-09 22:01:59 +00:00
Chris Lattner c330d008f4 remove unneeded #include
llvm-svn: 42731
2007-10-07 08:59:27 +00:00
Chris Lattner ef6b136781 move IdentifierTable.h from liblex to libbasic.
llvm-svn: 42730
2007-10-07 08:58:51 +00:00
Steve Naroff 67391b8a54 Move ObjC decls to DeclObjC.h, a new AST header.
Update clients and add to project file.

llvm-svn: 42494
2007-10-01 19:00:59 +00:00
Chris Lattner ec0a6d9be5 Use APFloat for the representation of FP immediates, ask the target
for *which* apfloat to use for a particular type.

llvm-svn: 42234
2007-09-22 18:29:59 +00:00
Steve Naroff 2cd263ff71 Remove SelectorTable/SelectorInfo, simply store all selectors in the central IdentifierTable.
Rationale:

We currently have a separate table to unique ObjC selectors. Since I don't need all the instance data in IdentifierInfo, I thought this would save space (and make more sense conceptually).

It turns out the cost of having duplicate entries for unary selectors (i.e. names without colons) outweighs the cost difference between the IdentifierInfo & SelectorInfo structures. Here is the data:

Two tables:

*** Selector/Identifier Stats:
# Selectors/Identifiers: 51635 
Bytes allocated:         1999824

One table:

*** Identifier Table Stats:
# Identifiers:   49500
Bytes allocated: 1990316

llvm-svn: 42139
2007-09-19 16:18:46 +00:00
Steve Naroff 73d534a2e0 Add support for ObjC keyword selectors.
- Add SelectorInfo/SelectorTable classes, modeled after IdentifierInfo/IdentifierTable.
- Add SelectorTable instance to ASTContext, created lazily through ASTContext::getSelectorInfo().
- Add SelectorInfo slot to ObjcMethodDecl.
- Add helper function to derive a SelectorInfo from ObjcKeywordInfo.

Misc: Got the Decl stats stuff up and running again...it was missing support for ObjC AST's.
llvm-svn: 42023
2007-09-17 14:16:13 +00:00
Chris Lattner 793d10ca38 fix some warnings, patch by Justin Handville
llvm-svn: 42010
2007-09-16 19:23:47 +00:00
Steve Naroff 1d4b5eaeab Now that the dust has settled on the Decl refactoring, I noticed FieldDecl didn't need NextDeclarator. As a result, I'm removing it.
Removing both slots (NextDeclarator/Next) end up reducing the size of fields/ivars by 40%.

llvm-svn: 41948
2007-09-14 02:20:46 +00:00
Gabor Greif 412af03cee get rid of ugly "warning: no newline at end of file"
warnings that some compilers diagnose

llvm-svn: 41847
2007-09-11 15:32:40 +00:00
Steve Naroff 09bf815f89 The goal of this commit is to get just enough Sema support to recognize Objective-C classes
as types. That said, the AST nodes ObjcInterfaceDecl, ObjcInterfaceType, and ObjcClassDecl are *very*
preliminary.

The good news is we no longer need -parse-noop (aka MinimalActions) to parse cocoa.m.

llvm-svn: 41752
2007-09-06 21:24:23 +00:00
Steve Naroff cadebd086f Fix a comment.
llvm-svn: 41618
2007-08-30 18:14:25 +00:00
Steve Naroff 90dfdd5774 Polish yesterday's Array/ConstantArray/VariableArray rewrite, removing a couple FIXME's.
Refactored Array/VariableArray, moving SizeModifier/IndexTypeQuals back up to Array. These
attributes are not specific to VLA's. Most of them are specific to array parameter types.

llvm-svn: 41616
2007-08-30 18:10:14 +00:00
Steve Naroff 5c13180a27 Fix the following redefinition errors submitted by Keith Bauer...
[dylan:~/llvm/tools/clang] admin% cat tentative_decls.c 
// incorrectly generates redefinition error
extern int array[3];
int array[3];

// incorrectly generates a redefinition error
extern void nup(int a[3]);
void nup(int a[3]) {}

It turns out that this exposed a fairly major flaw in the type system,
array types were never getting uniqued! This is because all array types
contained an expression, which aren't unique.

To solve this, we now have 2 array types, ConstantArrayType and
VariableArrayType. ConstantArrayType's are unique, VAT's aren't.

This is a fairly extensive set of fundamental changes. Fortunately,
all the tests pass. Nevertheless, there may be some collateral damage:-)
If so, let me know!

llvm-svn: 41592
2007-08-30 01:06:46 +00:00
Chris Lattner 1c1f932433 Change EnumDecl to store its corresponding integer type
directly in it.  Remove TargetInfo::getEnumPolicy, as there is only
one policy that we support right now.

llvm-svn: 41548
2007-08-28 18:24:31 +00:00
Chris Lattner 8f63b9d534 constify some stuff
llvm-svn: 41503
2007-08-27 17:56:57 +00:00
Chris Lattner a9e7961a44 implement sizeof(enum x), patch inspired by Keith Bauer.
llvm-svn: 41500
2007-08-27 17:38:00 +00:00