Граф коммитов

71 Коммитов

Автор SHA1 Сообщение Дата
Gabor Greif 3513e138cc Change variable name to Tq (from TQ)
because silly gcc 3.4.6 barfs on this
construct.
Type.h defines an "enum TQ", which makes
the parser to err.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47438 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-21 17:40:55 +00:00
Chris Lattner f46699ce22 Alternate address spaces work:
rename QualType::getQualifiers to getCVRQualifiers.
Add some fixme's and clean up some code relevant to qualifiers.
Change ASQualType to contain a Type* instead of a QualType.  
Any CVR qualifiers should be on the outer qual type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-20 20:55:12 +00:00
Eli Friedman d3f2f79fed Implemnt isVariablyModifiedType correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47233 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-17 00:59:11 +00:00
Eli Friedman c5773c4b8c Split out incomplete arrays from VariableArrayType into
IncompleteArrayType.  This should make code dealing with both incomplete 
and variable length arrays much more readable, plus it allows properly 
making the distinction between isVariableArrayType() and 
isVariablyModifiedType().  The patch is a little big, but it's 
strightforward. so I don't think there should be any issues.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47165 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-15 18:16:39 +00:00
Eli Friedman 3c2b317004 Remove useless parameter from isConstantSizeType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47156 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-15 12:20:59 +00:00
Christopher Lamb ebb97e98c0 Add experimental support for address space qualified types. Address space
qualifiers use the __attribute__((address_space(id))) syntax.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46691 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-04 02:31:56 +00:00
Steve Naroff 9412d68131 Exclude vectors from Type::isScalar() predicate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46328 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-24 22:55:05 +00:00
Steve Naroff 5c06a69a3e Add a predicate/getter when checking for incomplete array types ("[]").
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46231 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-21 22:59:18 +00:00
Steve Naroff 494783a1f9 Simplify comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46103 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 23:56:32 +00:00
Steve Naroff 67c49e892b Type::isArithmeticType(): disallow incomplete enum decls.
Bug submitted by Eli.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46102 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-16 23:54:22 +00:00
Steve Naroff 02f62a9fed - Change Type::isComplexType() to exlude GCC's complex integer extension. In general, we will keep the lowest level Type predicates "pure" (i.e. true to the C99 spec).
- Modify Sema::UsualArithmeticConversions() to work with the new definition of Type::isComplexType().

This is a nice cleanup and also fixes a bug submitted by Eli (which I've added to the test suite).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46005 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 19:36:10 +00:00
Steve Naroff 4cdec1c3ca Rework commit r45976, which was incorrect.
- Add Type::isComplexIntegerType(), Type::getAsComplexIntegerType().
- Don't inlude complex types with Type::isIntegerType(), which is too general.
- Use the new predicates in Sema::UsualArithmeticConversions() to recognize/convert the types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45992 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15 01:41:59 +00:00
Steve Naroff 3f0c5adc2f Teach Type::isIntegerType() about GCC's __complex__ integer extensions...
Bug submitted by Eli.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45976 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-14 21:38:57 +00:00
Ted Kremenek a526c5c67e Substituted all instances of the string "Objc" for "ObjC". This fixes
some naming inconsistencies in the names of classes pertaining to Objective-C
support in clang.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45715 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-07 19:49:32 +00:00
Chris Lattner 0bc735ffcf Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45410 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 19:59:25 +00:00
Fariborz Jahanian d58fabf7ed Refactoring work. ObjcQualifiedIdType is now derived from 'Type'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45174 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 21:33:44 +00:00
Chris Lattner 9bfa73c5ab remove the loc argument to Type::isConstantSizeType, which isn't useful.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45155 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 07:18:16 +00:00
Chris Lattner d52a457814 Fix PR1863: an assertion due to not setting a location on return from
this method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45153 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-18 07:03:30 +00:00
Fariborz Jahanian c569249ca0 Patch to implemented objective-c's dynamic object pointer qualified with
the protocol list (id<P,...> types).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45121 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-17 21:03:50 +00:00
Fariborz Jahanian 06cef25d0b Patch to make ObjcQualifiedInterfaceType inherit ObjcInterfaceType
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45014 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-13 20:47:42 +00:00
Chris Lattner 39caea9615 make it more clear what 'foo' is
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44653 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-06 04:20:07 +00:00
Seo Sanghyeon 2de3b3a4ac Fix isStructureType and isUnionType to ignore typedefs, as stated
in the header. Patch by Cédric Venet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44519 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-02 16:57:27 +00:00
Chris Lattner 7ee261c8e7 handle __vector_size__ like vector_size
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44358 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-27 07:28:18 +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
Chris Lattner dea6146dee Fix a major bug in the Type::getAs*Type methods: they didn't strip off
typeof(type) and typeof(expr) correctly.  Now provide a single point of
contact (Type::getDesugaredType) for doing the shallow stripping we need.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43432 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 03:41:11 +00:00
Anders Carlsson c67ad5f299 Add BuiltinType::Char_S to Type::isCharType
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43428 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 02:52:18 +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
Steve Naroff 7e219e47de Added ASTContext::setObjcIdType/getObjcIdType(), set by Sema.
Also noticed ASTContext::BuiltinVaListType wasn't being initialized to the null type (so I set it).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42983 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 14:41:52 +00:00
Steve Naroff 954ea17353 Teach the type checker about "id". This removes the following bogus warning...
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.m
t.m:29:18: warning: incompatible pointer types assigning 'id' to 'NSString *'
    resultString = [[NSString alloc] initWithFormat:0 arguments:0];
    ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42975 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 03:14:16 +00:00
Steve Naroff ff1afdb4f5 - Teach ObjcInterfaceDecl::lookupInstance/ClassMethod to look through protocols.
- Start looking up methods in the global method pools (for "id").
- Start integrating interface types into the type system.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42971 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 23:13:51 +00:00
Fariborz Jahanian dfbcce2b55 Implemented parsing of objctive-c protocol conforming type used in
an identifier statement. Fixed up pretty priting to print this type 
correctly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42866 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 18:08:47 +00:00
Fariborz Jahanian 4b6c9051c6 Patch to create protocol conforming class types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42856 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 00:55:41 +00:00
Chris Lattner c7229c338c move IdentifierTable.h from liblex to libbasic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42730 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-07 08:58:51 +00:00
Steve Naroff 980e508ca7 Move ObjC decls to DeclObjC.h, a new AST header.
Update clients and add to project file.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42494 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-01 19:00:59 +00:00
Steve Naroff 3536b443bc 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41752 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-06 21:24:23 +00:00
Steve Naroff d7444aac1a Removed Sema::VerifyConstantArrayType(). With the new Array/ConstantArray/VariableArray nodes, this
routine was causing more trouble than it was worth. Anders/Chris noticed that it could return an error code
without emiting a diagnostic (which results in an silent invalid decl, which should *never* happen). In addition,
this routine didn't work well for typedefs and field decls. Lastly, it didn't consider that initializers aren't
in place yet.

Added Type::getAsConstantArrayType(), Type::getAsVariableArrayType(), Type::getAsVariablyModifiedType(),
and Type::isVariablyModifiedType();

Modified Sema::ParseDeclarator() and Sema::ParseField() to use the new predicates. Also added a FIXME for
the initializer omission. Also added a missing test for "static" @ file scope.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41647 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-31 17:20:07 +00:00
Steve Naroff 6b91cd9af1 Diff is self small & self explanatory...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41621 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 18:45:57 +00:00
Steve Naroff c9406125e2 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41616 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 18:10:14 +00:00
Chris Lattner 729a213122 fix a bug that is causing CodeGen/complex.c to be grumpy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41603 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 06:19:11 +00:00
Steve Naroff fb22d96692 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!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41592 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 01:06:46 +00:00
Chris Lattner d5bbce4382 Teach Type::is[un]SignedIntegerType about enum decls. This allows the code generator
to emit signed comparisons when needed for enum decl references.  This implements
test/CodeGen/enum.c.  I think enums should be good now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41572 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29 17:48:46 +00:00
Steve Naroff 77878cc5aa Add Type::getAsBuiltinType() and Type::builtinTypesAreCompatible().
Modified Type::typesAreCompatible() to use the above.

This fixes the following bug submitted by Keith Bauer (thanks!).

int equal(char *a, const char *b)
{
    return a == b;
}

Also tweaked Sema::CheckCompareOperands() to ignore the qualifiers when
comparing two pointer types (though it doesn't relate directly to this bug).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41476 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27 04:08:11 +00:00
Chris Lattner c6fb90a724 add getAsComplexType() for consistency
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41229 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 16:54:08 +00:00
Chris Lattner 6000dace22 add a new AST dumper interface (E->dump()). This dumps out
the AST in a structural, non-pretty, form useful for understanding
the AST.  It isn't quite done yet, but is already somewhat useful.

For this example:

int test(short X, long long Y) {
  return X < ((100));
}

we get (with -parse-ast-dump):

int test(short X, long long Y)
(CompoundStmt 0x2905ce0
  (ReturnStmt 0x2905cd0
    (BinaryOperator 0x2905cb0 '<'
      (ImplicitCastExpr 0x2905ca0
        (DeclRefExpr 0x2905c20 Decl='X' 0x2905bb0))
      (ParenExpr 0x2905c80
        (ParenExpr 0x2905c60
          (IntegerLiteral 0x2905c40 100))))))




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40954 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-08 22:51:59 +00:00
Steve Naroff 13b7c5ff42 Finish implementing __builtin_classify_type()...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40951 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-08 22:15:55 +00:00
Steve Naroff 1bfd5cc290 Remove a space from "typeof" printing. It was causing the following error...
[dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check typeof.c 
Warnings expected but not seen:
  Line 21: incompatible types assigning 'typeof(*pi) const' to 'int *'
Warnings seen but not expected:
  Line 21: incompatible types assigning 'typeof(*pi)  const' to 'int *'

Also corrected a typo from my previous commit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40832 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-05 03:24:45 +00:00
Steve Naroff 363bcff47d - Finish hooking up support for __builtin_types_compatible_p().
- Fix type printing code for recently added TypeOfExpr/TypeOfType.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40700 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 23:45:51 +00:00
Steve Naroff 8d1a3b8ca1 Two typeof() related changes...
- Changed the name of ASTContext::getTypeOfType(Expr*)->getTypeOfExpr().
- Remove FIXME for TypeOfExpr::getAsStringInternal(). This will work fine for printing the AST. It isn't ideal
for error diagnostics (since it's more natural to display the expressions type). 

One "random" (or at least delayed:-) change...

- Changed all "ext_typecheck_*" diagnostics from EXTENSION->WARNING. Reason: Since -pedantic is now
off (by default), these diagnostics were never being emitted (which is bad). With this change, clang will
emit the warning all the time. The only downside (wrt GCC compatibility) is -pedantic-errors will not turn
this diagnostics into errors (a "feature" of making tagging them with EXTENSION). When/if this becomes
an issue, we can revisit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40676 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 17:20:42 +00:00
Chris Lattner 611c1fff19 move trivial type predicates inline.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40651 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 21:13:58 +00:00
Chris Lattner c8629630ce split the rest of the type predicates into pure predicates:
there is now an isXXXType and a getAsXXXType


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40646 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 19:29:30 +00:00