Commit Graph

69 Commits

Author SHA1 Message Date
Douglas Gregor 2daae31e9a Argiris Kirtzidis's fix for handling empty IdDeclInfo's in IdentifierResolver::AddDecl
llvm-svn: 49631
2008-04-14 00:26:07 +00:00
Argyrios Kyrtzidis 25f54c72ac Move IdDeclInfoMap class in an anonymous namespace. Suggestion by Chris Lattner.
llvm-svn: 49628
2008-04-14 00:09:21 +00:00
Douglas Gregor 556877c1e6 This patch adds very basic support for parsing and type-checking class
inheritance in C++. It'll parse the base-specifier list, e.g.,

 class D : public B1, virtual public B2 { };

and do some of the simpler semantic checks (B1 and B2 are classes;
they aren't unions or incomplete types, etc).

llvm-svn: 49623
2008-04-13 21:30:24 +00:00
Douglas Gregor 83a586ec19 Introduce support for finding class and enum names via ordinary name lookup in C++
llvm-svn: 49621
2008-04-13 21:07:44 +00:00
Chris Lattner 861a226586 This patch is just the easy part of the class names patch, which
allows the parsing of "class" in addition to "struct" and "union" to
declare a record.  So this patch allows:

 class C { };
 class C c1;

But it does not contain the lookup bits, so this won't work yet:

 C c2;

Patch by Doug Gregor!

llvm-svn: 49613
2008-04-13 18:59:07 +00:00
Chris Lattner b0d3844fb8 Default argument cleanups and minor improvements, patch by
Doug Gregor!

llvm-svn: 49598
2008-04-12 23:52:44 +00:00
Argyrios Kyrtzidis 740525a6b7 Use std::list's push_back instead of resize to add an element.
llvm-svn: 49582
2008-04-12 12:38:58 +00:00
Argyrios Kyrtzidis dfd52220d7 Fixed comments.
Moved IdDeclInfo class to anonymous namespace.
Replaced array with a std::vector.

llvm-svn: 49570
2008-04-12 01:50:47 +00:00
Argyrios Kyrtzidis b8a4920d62 Added PushOnScopeChains method to Sema, that adds a decl to both the IdResolver and the Scope.
llvm-svn: 49567
2008-04-12 00:47:19 +00:00
Fariborz Jahanian 4572b45574 AST generation for objc2's property declarations.
llvm-svn: 49565
2008-04-11 23:40:25 +00:00
Steve Naroff 5a4611cdda Add class and super class location info to ObjCInterfaceDecl...
llvm-svn: 49553
2008-04-11 19:35:35 +00:00
Fariborz Jahanian 963767476c Minor changes per Chris L's review.
llvm-svn: 49539
2008-04-11 16:55:42 +00:00
Chris Lattner 9950c80c83 two new files for previous patch, by Argiris Kirtzidis
llvm-svn: 49521
2008-04-11 07:06:57 +00:00
Chris Lattner c5c95b52a8 Switch sema to maintaining its own scope chain information for variable
shadowing, instead of threading it through the AST.  This patch contributed
by Argiris Kirtzidis!

llvm-svn: 49520
2008-04-11 07:00:53 +00:00
Fariborz Jahanian de615836f3 Patch for:
1) objc ivar processing is split out of ActOnField into its own ActOnIvar method.
2) the new objc ivar action takes visibility info directly, eliminating 
  AllVisibilities in ParseObjCClassInstanceVariables.

llvm-svn: 49506
2008-04-10 23:32:45 +00:00
Chris Lattner 0e91b41902 typedef void T;
void f(T);

is only invalid in C++ mode, not C89 mode.

llvm-svn: 49460
2008-04-10 02:26:16 +00:00
Chris Lattner 58258246ec Several improvements from Doug Gregor related to default
argument handling.  I'll fix up the c89 (void) thing next.

llvm-svn: 49459
2008-04-10 02:22:51 +00:00
Chris Lattner 199abbcb26 Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!

llvm-svn: 49370
2008-04-08 05:04:30 +00:00
Chris Lattner aa9c7aed0f Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!

llvm-svn: 49369
2008-04-08 04:40:51 +00:00
Chris Lattner 7460fd297d simplify reference handling.
llvm-svn: 49325
2008-04-07 06:52:53 +00:00
Chris Lattner ec646834e7 simplify compatibility testing for tag types.
llvm-svn: 49323
2008-04-07 06:49:41 +00:00
Chris Lattner 2a3569b5d9 move ObjCQualifiedIdTypesAreCompatible out of ASTContext into Sema.
While it is similar to the other compatibility predicates in ASTContext,
it is not used by them and is different.

In addition, greatly simplify ObjCQualifiedIdTypesAreCompatible and
fix some canonical type bugs.  Also, simplify my Type::getAsObjC* methods.

llvm-svn: 49313
2008-04-07 05:30:13 +00:00
Chris Lattner d4bacd68bf simplify max type computation by making it return an integer (like
getFloatingTypeOrder) instead of a type.  Fix a fixme.

llvm-svn: 49297
2008-04-06 23:55:33 +00:00
Chris Lattner b90739d556 minor simplifications/cleanups to type comparisons.
llvm-svn: 49296
2008-04-06 23:38:49 +00:00
Chris Lattner fc4379f916 remove the Decl::getCanonicalType() method.
llvm-svn: 49295
2008-04-06 23:10:54 +00:00
Chris Lattner 76a00cf3ff Start switching clients over from CT.getCanonicalType() to Context.getCanonicalType(CT) for PR2189.
While I'm at it, clean up a bit of maxIntegerType.

llvm-svn: 49292
2008-04-06 22:59:24 +00:00
Chris Lattner 784903e4c1 move a semantic check out of the parser into sema.
llvm-svn: 49273
2008-04-06 07:49:57 +00:00
Chris Lattner 0a5ff0d34a This patch contains these changes:
-Renamed ContextDecl -> DeclContext
-Removed DeclContext pointer from FieldDecl
-EnumDecl inherits from DeclContext, instead of TagDecl

Patch by Argiris Kirtzidis!

llvm-svn: 49261
2008-04-06 04:47:34 +00:00
Chris Lattner 9d51f2b9d4 Fix handling of implicit int, resolving PR2012 and reverting (and
subsuming) my patch for PR1999.

llvm-svn: 49251
2008-04-05 06:32:51 +00:00
Steve Naroff 3913ea4bfb Add explicit support for diagnosing implicit function decls.
Without this, the diagnostic is very confusing. The diag is now consistent with gcc as well.

llvm-svn: 49214
2008-04-04 14:32:09 +00:00
Chris Lattner c5ffed4a66 Introduce ContextDecl, patch by Argiris Kirtzidis!
-Added ContextDecl (no TranslationUnitDecl)
-ScopedDecl class has a ContextDecl member
-FieldDecl class has a ContextDecl member, so that a Field or a ObjCIvar can be traced back to their RecordDecl/ObjCInterfaceDecl easily
-FunctionDecl, ObjCMethodDecl, TagDecl, ObjCInterfaceDecl inherit from ContextDecl. With TagDecl as ContextDecl, enum constants have a EnumDecl as their context.
-Moved Decl class to a "DeclBase.h" along with ContextDecl class
-CurContext is handled by Sema

llvm-svn: 49208
2008-04-04 06:12:32 +00:00
Nate Begeman 002e4bd158 Ignore qualifiers when checking vector operands, just like scalar operands.
This prevents things like 
a += b[0]; where a is a float4 and b is a float4 * (address_space 1)

llvm-svn: 49199
2008-04-04 01:30:25 +00:00
Chris Lattner 3a0702e631 Fix a bug where we didn't check the RHS for null, we checked
the LHS for null twice.

llvm-svn: 49138
2008-04-03 05:07:25 +00:00
Steve Naroff 778927532d Change ObjCInterfaceDecl to inherit from NamedDecl (not TypeDecl). While ObjCInterfaceDecl is arguably a TypeDecl, it isn't a ScopedDecl. Since TypeDecl's are scoped, it makes sense to simply treat them as NamedDecl's. I could have fiddled a bit more with the hierarchy (in terms of creating a non-scoped TypeDecl), however this probably isn't worth the effort.
I also finished unifying access to scope decl change by converting Sema::getObjCInterfaceDecl() to use Sema::LookupDecl(). This is much cleaner now:-)

llvm-svn: 49107
2008-04-02 18:30:49 +00:00
Chris Lattner 182f660d8d simplify some code by using PointerLikeType.
llvm-svn: 49101
2008-04-02 17:45:06 +00:00
Chris Lattner db5f1fa3d8 add a common base class "PointerLikeType" for PointerType and ReferenceType,
allowing them to be treated the same in some contexts.  A suggestion for a
better name is welcome :)

llvm-svn: 49100
2008-04-02 17:35:06 +00:00
Chris Lattner b1f7398b1c properly handle array decay in objc message exprs.
llvm-svn: 49098
2008-04-02 17:17:33 +00:00
Steve Naroff 2fc93f5c43 Two changes to Sema::LookupDecl() interface.
(1) Remove IdLoc (it's never used). 
(2) Add a bool to enable/disable lazy builtin creaation (defaults to true).

This enables us to use LookupDecl() in Sema::isTypeName(), which is also part of this commit.

To make this work, I changed isTypeName() to be a non-const member function. I'm not happy with this, however I fiddled with making LookupDecl() and friends const and it got ugly pretty quickly. We can certainly add it back if/when someone has time to fiddle with it. For now, I thought this simplification was more important than retaining the const-ness. 

llvm-svn: 49087
2008-04-02 14:35:35 +00:00
Chris Lattner b3a176da9f Various parts of the standard require something to be an "incomplete or
object type".  Add a predicate that checks exactly this, as it is equivalent
to checking ot see if the type is *not* a function type, which is faster
to check.

llvm-svn: 49082
2008-04-02 06:59:01 +00:00
Chris Lattner daaa8ba77e 1) Enforce C99 6.7.3p2: "Types other than pointer types derived from
object or incomplete types shall not be restrict-qualified."

2) Warn about qualifiers on function types: C99 6.7.3p8: "If the 
specification of a function type includes any type qualifiers, the 
behavior is undefined."

3) Implement restrict on C++ references.

4) fix some locations for various C++ reference diagnostics.

llvm-svn: 49081
2008-04-02 06:50:17 +00:00
Chris Lattner a21ad8058a Fix several bugs in array -> pointer decomposition.
First, we got several CVR propagation cases wrong, which Eli pointed
out in PR2039.

Second, we didn't propagate address space qualifiers correctly, leading
to incorrect lowering of code in CodeGen/address-space.c.

Third, we didn't uniformly propagate the specifier in the array to the
pointer ("int[restrict 4]" -> "int *restrict").

This adds an ASTContext::getArrayDecayedType member that handles the 
non-trivial logic for this seemingly simple operation.

llvm-svn: 49078
2008-04-02 05:18:44 +00:00
Chris Lattner 24d5bfe0b2 rename some variables, fix 80 col violation. No
functionality change.

llvm-svn: 49072
2008-04-02 04:24:33 +00:00
Chris Lattner 81cb9e8637 Fix PR2017 and silence some bogus errors.
llvm-svn: 49068
2008-04-02 01:05:10 +00:00
Steve Naroff 9b94b17806 Fix a comment typo and add a couple suggestions from Chris.
llvm-svn: 49066
2008-04-02 00:39:51 +00:00
Steve Naroff 257520b1b4 Fairly large "cleaup" related to changing ObjCCompatibleAliasDecl superclass (to inherit from NamedDecl, instead of ScopedDecl).
- Added a DenseMap to associate an IdentifierInfo with the ObjCCompatibleAliasDecl.
- Renamed LookupScopedDecl->LookupDecl and changed it's return type to Decl. Also added lookup for ObjCCompatibleAliasDecl's.
- Removed Sema::LookupInterfaceDecl(). Converted clients to used LookupDecl().
- Some minor indentation changes.

Will deal with ObjCInterfaceDecl and getObjCInterfaceDecl() in a separate commit...

llvm-svn: 49058
2008-04-01 23:04:06 +00:00
Chris Lattner 59a2594f3f rename Decl::CompatibleAlias -> ObjCCompatibleAlias.
Fix objc ivar lookup.  Ivar lookup should occur between lookup
of method-local values and lookup of globals.  Emulate this with
some logic in the handling of Sema::ActOnIdentifierExpr.

Two todo's left:
 1) sema shouldn't turn a bare reference to an ivar into "self->ivar"
    in the AST.  This is a hack.
 2) The new ScopedDecl::isDefinedOutsideFunctionOrMethod method does
    not correctly handle typedefs and enum constants yet.

llvm-svn: 48972
2008-03-31 00:36:02 +00:00
Steve Naroff 0de4199ca0 Make sure Sema::ActOnClassMessage() correctly diagnoses "super".
llvm-svn: 48924
2008-03-28 21:37:05 +00:00
Steve Naroff c06ee808d7 Alloc redeclaration of typedefs within ExternCSystemHeaderDir's AND SystemHeaderDir's.
llvm-svn: 48841
2008-03-26 21:27:00 +00:00
Nuno Lopes 623207d603 allow the format attribute to be specified in function pointer prototypes
# this is my first commit here, so please be gentle :)

llvm-svn: 48807
2008-03-25 23:01:48 +00:00
Nate Begeman c506c78117 Extend QualType::getAddressSpace to do the right thing for array types, and in
the future, RecordTypes.

llvm-svn: 48784
2008-03-25 18:36:32 +00:00