summaryrefslogtreecommitdiffstats
path: root/clang/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Various improvements to Sema::ParseMemberReferenceExpr().Steve Naroff2007-07-261-23/+24
| | | | | | | | | | | - Added source range support to Diag's. - Used the new type predicate API to remove dealing with the canonical type explicitly. - Added Type::isRecordType(). - Removed some casts. - Removed a const qualifier from RecordType::getDecl(). llvm-svn: 40508
* - Fix commit in Parser.h (patch by Kevin Andre).Steve Naroff2007-07-251-4/+2
| | | | | | - Add comment and minor cleanup to yesterday's fix to ParseCallExpr(). llvm-svn: 40492
* Fix a couple of bugs, add some new cool stuff.Chris Lattner2007-07-251-0/+8
| | | | | | | | | | | | | | | 1. Fix a todo in Parser::ParseTag, to recover better. On code like that in test/Sema/decl-invalid.c it causes us to return a single error instead of multiple. 2. Fix an error in Sema::ParseDeclarator, where it would crash if the declarator didn't have an identifier. Instead, diagnose the problem. 3. Start adding infrastructure to track the range of locations covered by a declspec or declarator. This is mostly implemented for declspec, but could be improved, it is missing for declarator. Thanks to Neil for pointing out this crash. llvm-svn: 40482
* Fix Sema::ParseCallExpr()...it wasn't doing the default array/function ↵Steve Naroff2007-07-242-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | promotions on it's argument types. This resulted in the following errors when compiling promote_types_in_proto.c test... [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang test/Parser/promote_types_in_proto.c test/Parser/promote_types_in_proto.c:7:24: error: incompatible types passing 'char *[]' to function expecting 'char *const []' arrayPromotion(argv); ~~~~~~~~~~~~~~ ^~~~ test/Parser/promote_types_in_proto.c:8:27: error: incompatible types passing 'void (char *const [])' to function expecting 'void (char *const [])' functionPromotion(arrayPromotion); ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~ 2 diagnostics generated. When fixing this, noticed that both ParseCallExpr() and ParseReturnStmt() were prematurely comparing types for equivalence. This is incorrect (since the expr. promotions haven't been done yet). To fix this, I moved the check "down" to Sema::CheckAssignmentConstraints(). I also converted Type::isArrayType() to the modern API (since I needed it). Still more Type predicates to convert. llvm-svn: 40475
* implement ast building and trivial semantic analysis of stmt exprs.Chris Lattner2007-07-242-0/+26
| | | | | | This implements test/Sema/stmt_exprs.c llvm-svn: 40465
* correctly verify that default and case are in a switchstmt,Chris Lattner2007-07-231-13/+9
| | | | | | this fixes test/Sema/switch.c. llvm-svn: 40438
* Refactor switch analysis to make it possible to detect duplicate case valuesAnders Carlsson2007-07-222-18/+65
| | | | llvm-svn: 40388
* recover from void argument types more nicely.Chris Lattner2007-07-211-2/+3
| | | | llvm-svn: 40169
* better wording for an error, suggested by Neil.Chris Lattner2007-07-211-1/+1
| | | | llvm-svn: 40163
* Implement code generation for __func__, __FUNCTION__ and __PRETTY_FUNCTION__Anders Carlsson2007-07-212-5/+14
| | | | llvm-svn: 40162
* improve and simplify error recovery for calls, fix a crash when diagnosingChris Lattner2007-07-211-11/+12
| | | | | | invalid arguments. llvm-svn: 40161
* fix a warning on some compilersChris Lattner2007-07-211-0/+1
| | | | llvm-svn: 40139
* Fix off-by-one error when emitting diagnostics. Also, make diagnosticChris Lattner2007-07-211-2/+3
| | | | | | | | | | | | | | a bit nicer for people who pass lots of extra arguments to calls by selecting them all instead of just the first one: arg-duplicate.c:13:13: error: too many arguments to function f3 (1, 1, 2, 3, 4); // expected-error {{too many arguments to function}} ^~~~~~~ This implements test/Sema/arg-duplicate.c, thanks to Neil for pointing out this crash. llvm-svn: 40136
* move some casts up to the entry of the function for clarity.Chris Lattner2007-07-211-23/+23
| | | | llvm-svn: 40135
* Two fixes: Chris Lattner2007-07-211-18/+26
| | | | | | | | | | 1) fix a crash on test/Sema/default.c by making sure that the switch scope is non-null. 2) if there is an error sema'ing a default or case stmt, make sure to return the substmt up, so that the error recovery code has more acurate info to continue with. llvm-svn: 40134
* At one point there were going to be lexer and parser tokens.Chris Lattner2007-07-202-7/+7
| | | | | | | Since that point is now long gone, we should rename LexerToken to Token, as it is the only kind of token we have. llvm-svn: 40105
* Finish fixing crasher with compound literals.Steve Naroff2007-07-191-4/+5
| | | | | | | We still need to do sematic analysis (and implement initializers), however this should complete the parsing & ast building for compound literals. llvm-svn: 40067
* Work towards fixing crasher with compound literals...Steve Naroff2007-07-192-0/+29
| | | | | | | | | | | | | | | | Before this commit, we crashed in ParseBinOp... [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c SemaExpr.cpp:1298: failed assertion `(rhs != 0) && "ParseBinOp(): missing right expression"' With this commit, we still crash in the newly added action ParseCompoundLiteral (which is progress:-) [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c SemaExpr.cpp:478: failed assertion `(Op != 0) && "ParseCompoundLiteral(): missing expression"' The crash go away once the actions return AST nodes. I will do this in a separate commit. llvm-svn: 40032
* Fix a crasher that Neil reported: Sema::GetTypeForDeclarator should never Chris Lattner2007-07-191-16/+11
| | | | | | | return a null type. If there is an error parsing the type, pick a new type for error recovery purposes. llvm-svn: 40029
* First round of extended vector support. Here is an overview...Steve Naroff2007-07-182-9/+63
| | | | | | | | | | | - added ocu_vector_type attribute, Sema::HandleOCUVectorTypeAttribute(). - added new AST node, OCUVectorType, a subclass of VectorType. - added ASTContext::getOCUVectorType. - changed ASTContext::convertToVectorType() to ASTContext::getVectorType(). This is unrelated to extended vectors, however I was in the vicinity and it was on my todo list. Added a FIXME to Sema::HandleVectorTypeAttribute to deal with converting complex types. llvm-svn: 40007
* Cast to void is valid, patch by Benoit BoissinotChris Lattner2007-07-181-2/+3
| | | | llvm-svn: 40003
* Add initial switch stmt support, patch by Anders Carlsson!Chris Lattner2007-07-182-8/+34
| | | | llvm-svn: 39989
* Use the correct method for getting the ReferenceType from a QualType.Bill Wendling2007-07-171-2/+2
| | | | llvm-svn: 39960
* Change dyn_cast for reference types to be more like pointers and not need ↵Bill Wendling2007-07-171-4/+8
| | | | | | the canonical type. Also fix so that we're not expecting a return value from a void function llvm-svn: 39954
* Fix references:Bill Wendling2007-07-171-1/+5
| | | | | | | | According to the spec (C++ 5p6[expr]), we need to adjust "T&" to "T" before further analysis. We do this via the "implicit cast" thingy. llvm-svn: 39953
* Convert UsualArithmeticConversions to return "void". Now that we synthesize ↵Steve Naroff2007-07-172-58/+72
| | | | | | | | | | ImplicitCastExpr's, there is no compelling need to return the converted type. If both expression type's are arithmetic, then both types will always be the same. If they aren't (for pointer/int types, say), then the types will be different. The client is responsible for distinguishing... llvm-svn: 39947
* Implement semantic analysis for the cast operator.Steve Naroff2007-07-161-4/+16
| | | | llvm-svn: 39943
* Remove the 2 QualType references to method UsualArithmeticConversions. Last ↵Steve Naroff2007-07-162-29/+21
| | | | | | | | | | week, I added these to quickly fix a regression. Avoiding them entirely is a much cleaner solution. Clients of UsualArithmeticConversions should simply call getType() on the expression to get the converted type. In practice, only a small number of routines care about this. llvm-svn: 39934
* Change DefaultFunctionArrayConversions and UsualUnaryConversions to return ↵Steve Naroff2007-07-163-51/+64
| | | | | | | | | void. The caller needs to query the expression for the type. Since both these functions guarantee the expression contains a valid type, removed old/vacuous asserts (from code calling both of these routines). llvm-svn: 39930
* Fix a GCC warning:Chris Lattner2007-07-161-3/+5
| | | | | | | | SemaExpr.cpp:561: warning: dereferencing type-punned pointer will break strict-aliasing rules Patch by Benoit Boissinot! llvm-svn: 39928
* Now that isPointerType can return a pointer type, avoid stripping off typedefChris Lattner2007-07-161-3/+4
| | | | | | | | | | | | | | | | | | | information in the common case. On this invalid code: typedef float float4 __attribute__((vector_size(16))); typedef int int4 __attribute__((vector_size(16))); void test(float4 a, int4 *result, int i) { result[i] = a; } we now generate: t.c:5:15: error: incompatible types assigning 'float4' to 'int4' instead of: t.c:5:15: error: incompatible types assigning 'float4' to 'int __attribute__((vector_size(16)))' This implements test/Sema/typedef-retain.c llvm-svn: 39892
* Use the return value of isPointerType and isVectorType to significantly simplifyChris Lattner2007-07-161-36/+35
| | | | | | | ParseArraySubscriptExpr. Notably, the new code doesn't have to think about canonical types at all. llvm-svn: 39891
* rename variables to be more consistent. Always use LHS/RHS intead of T1/T2 ↵Chris Lattner2007-07-151-15/+12
| | | | | | sometimes. llvm-svn: 39889
* Refactor code so that isIntegerConstantExpr has an ASTContext available.Chris Lattner2007-07-153-13/+14
| | | | llvm-svn: 39884
* This is the final step/commit for implementing exlicit implicit casts. ↵Steve Naroff2007-07-151-22/+41
| | | | | | | | | | | | | Unlike the previous two checkins, which involved lot's of tedious refactoring, this checkin is nice and clean:-) - Hacked UsualUnaryConversions, UsualArithmeticConversions, and DefaultFunctionArrayConversion to create the AST node (using a helper function promoteExprToType). - Added a setType method to Expr. - Changed Expr::isIntegerConstantExpr to allow for the new node. llvm-svn: 39866
* A significant refactoring of the type size stuff to also Chris Lattner2007-07-142-6/+7
| | | | | | compute type alignment. This info is needed for struct layout. llvm-svn: 39850
* More changes related to implementing ImplicitCastExpr.Steve Naroff2007-07-133-57/+102
| | | | | | | | | | | | | | - Fixed a recent regression discovered by Keith Bauer (thanks!). The fix involved adding (back) two arguments to UsualArithmeticConversions. Without the reference arguments, no unary conversions were being passed back to the caller. This had the effect of turning off the UsualUnaryConversions. - Refactored CheckAssignmentConstraints into 3 functions. CheckAssignmentConstraints, CheckSingleAssignmentConstraints, and CheckCompoundAssignmentConstraints. - Changed the argument type of DefaultFunctionArrayConversion from QualType->Expr*&. - Removed a bunch of casts in routines I was working on (cleanup). - Fixed the visitor for ImplicitCastExpr (oops). llvm-svn: 39840
* Move getSize() out of type, into ASTContext, where it has target info, andChris Lattner2007-07-131-3/+2
| | | | | | where ASTContext can manage caches for struct layout, etc. llvm-svn: 39835
* Unspecified type specs default to int. This fixes a crashChris Lattner2007-07-131-0/+1
| | | | | | on test/Sema/implicit-int.c llvm-svn: 39833
* Removed some superfluous code. The getType() method and associatedSteve Naroff2007-07-131-11/+3
| | | | | | assert is now done in UsualUnaryConversions(). llvm-svn: 39818
* Add (explicit) AST support for implicit casts. This should simplify the Steve Naroff2007-07-133-97/+98
| | | | | | | | | | | | | | | | | | | code generator. Source translation tools can simply ignore this node. - Added a new Expr node, ImplicitCastExpr. - Changed UsualUnaryConversions/UsualArithmeticConversions to take references to Expr *'s. This will allow these routines to instantiate the new AST node and pass it back. - Changed all clients of UsualUnary/UsualArithmetic (lot's of diff's). - Changed some names in CheckConditionalOperands. Several variables where only distinguished by their case (e.g. Cond, cond). Yuck (what was I thinking). - Removed an old/crufty constructor in CastExpr (cleanup). This check-in does not actually create the new AST node. I wanted to separate the mechanical changes from the semantic changes. In addition, I need to coordinate with Chris, since the semantic change will break the code generator. llvm-svn: 39814
* Implement codegen for + and - with pointers. Patch contributed by Chris Lattner2007-07-132-4/+5
| | | | | | Keith Bauer. llvm-svn: 39793
* Two changes...Steve Naroff2007-07-121-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | - Teach all the integer/float predicates on Type about Vectors. - Disallow bitwise compliment on float vectors. For example... typedef float __attribute__(( vector_size(16) )) float4; float4 float4_return() { float4 xx; return ~xx; } ...now emits the following diagnostic... [administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang bug.c bug.c:8:12: error: invalid argument type to unary expression 'float4' return ~xx; ^ 1 diagnostic generated. llvm-svn: 39791
* remember the initializer for a variable in the AST and teach theChris Lattner2007-07-121-1/+6
| | | | | | pretty printer to print it. llvm-svn: 39770
* Fix a release build of clang.Chris Lattner2007-07-111-1/+1
| | | | llvm-svn: 39756
* Bug #:Steve Naroff2007-07-111-1/+0
| | | | | | | | Submitted by: Reviewed by: Remove reference to Attr.h... llvm-svn: 39730
* Bug #:Steve Naroff2007-07-101-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Two vector fixes: - Sema::CheckAssignmentConstraints() needs to compare the canonical type. - Expr::isLvalue() needs to disallow subscripting into a vector returned by a function. This follows the rules for struct returns (in C, at least...C++ is another story:-) Here is an example... float4 float4_return() { float4 xx; return xx; } void add_float4_void_return(float4 *a, float4 *b, float4 *result) { float f; float4_return()[1] = f; // now illegal } llvm-svn: 39728
* Bug #:Steve Naroff2007-07-101-15/+23
| | | | | | | | | | | | | Submitted by: Reviewed by: Support the following... 1. Type checking and codegen support for V[i] on vectors. Hacked Sema::ParseArraySubscriptExpr(). 2. Unary bitwise complement ("~") on vectors. Hacked Sema::ParseUnaryOp(). llvm-svn: 39723
* Bug #:Steve Naroff2007-07-091-2/+3
| | | | | | | | Submitted by: Reviewed by: Added primitive support for 32-bit floating point literals. llvm-svn: 39719
* Bug #:Steve Naroff2007-07-092-2/+31
| | | | | | | | | | | | | | | Submitted by: Reviewed by: Typechecking support for vectors... - Added CheckVectorOperands(). Called from CheckAdditionOperands, CheckMultiplyDivideOperands, CheckSubstractionOperands, and CheckBitwiseOperands. - Added diagnostic for converting vector values of different size. - Modified Type::isArithmeticType to include vectors. Sould be ready for Chris to add code generation. I will continue testing/refining. llvm-svn: 39717
OpenPOWER on IntegriCloud