summaryrefslogtreecommitdiffstats
path: root/clang/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* Bug #:Steve Naroff2007-07-101-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-091-1/+5
| | | | | | | | | | | | | | | 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
* Bug #:Steve Naroff2007-07-062-0/+67
| | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: - Finished semantic analysis for vectors, added some diagnostics. - Added AST for vectors (instantiation, installation into the decl). - Fixed bug in ParseArraySubscriptExpr()...this crasher was introduced by me when we added the range support. - Turned pedantic off by default. Since vectors are gcc extensions, having pedantic on by default was annoying. Turning it off by default is also consistent with gcc (but this wasn't my primary motivation). - Tweaked some comments and diagnostics. Note: The type checking code is still under construction (for vectors). This will be my next check-in. llvm-svn: 39715
* add a method to get more precise arrow positioning for expressions. RenameChris Lattner2007-06-271-2/+2
| | | | | | some ivars to more obvious names, eliminating some comments. llvm-svn: 39685
* implement the rest of Expr::hasLocalSideEffectChris Lattner2007-06-271-10/+14
| | | | llvm-svn: 39684
* First cut at warning about expressions whose results are ignored. For example,Chris Lattner2007-06-271-4/+59
| | | | | | | | | | | | | | | | | | | this produces: warn.c:4:3: warning: expression result unused X == Y; ^~~~~~ warn.c:5:3: warning: expression result unused (void)X; ^~~~~~~ warn.c:11:3: warning: expression result unused A == foo(1, 2); ^~~~~~~~~~~~~~ warn.c:13:3: warning: expression result unused foo(1,2)+foo(4,3); ^~~~~~~~~~~~~~~~~ llvm-svn: 39682
* Split complex types out from being members of BuiltinType to being their ownChris Lattner2007-06-222-38/+59
| | | | | | types. llvm-svn: 39672
* Finally bite the bullet and make the major change: split the clang namespaceChris Lattner2007-06-159-25/+15
| | | | | | | | | | | | | out of the llvm namespace. This makes the clang namespace be a sibling of llvm instead of being a child. The good thing about this is that it makes many things unambiguous. The bad things is that many things in the llvm namespace (notably data structures like smallvector) now require an llvm:: qualifier. IMO, libsystem and libsupport should be split out of llvm into their own namespace in the future, which will fix this issue. llvm-svn: 39659
* Implement support for formal arguments. We can now compile this:Chris Lattner2007-06-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | int test(int X, short Y, float Z) { return (int)(X*Y+Z); } to: define i32 @test(i32 %X, i16 %Y, float %Z) { entry: %promote = sext i16 %Y to i32 ; <i32> [#uses=1] %mul = mul i32 %promote, %X ; <i32> [#uses=1] %promote3 = sitofp i32 %mul to float ; <float> [#uses=1] %add = add float %promote3, %Z ; <float> [#uses=1] %conv = fptosi float %add to i32 ; <i32> [#uses=1] ret i32 %conv } with: $ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis llvm-svn: 39652
* Pretty print if/else/elseif chains nicer, like this:Chris Lattner2007-06-111-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | void printutf8(unsigned int X) { if (X <= 127) printf("%c", (char)X); else if (X <= 2047) printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1))); else if (X <= 65535) printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63)); else printf("UNKNOWN %d\n", X); instead of: if (X <= 127) printf("%c", (char)X); else if (X <= 2047) printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1))); else if (X <= 65535) printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63)); else printf("UNKNOWN %d\n", X); llvm-svn: 39648
* Enums are integer constant exprs, return their values.Chris Lattner2007-06-111-4/+1
| | | | llvm-svn: 39645
* Implement capturing of enum values and chaining of enums together.Chris Lattner2007-06-112-15/+3
| | | | llvm-svn: 39644
* Bug #:Steve Naroff2007-06-091-7/+0
| | | | | | | | | | Submitted by: Reviewed by: Lot's of attribute scaffolding. Modernized ParseArraySubscriptExpr...call DefaultFunctionArrayConversion (which simplified the logic considerably) and upgrade Diags to use the range support. llvm-svn: 39628
* Finally break down and chain together decls that are defined with common ↵Chris Lattner2007-06-091-3/+5
| | | | | | | | | | | declspecs, like: int X, Y, Z; This is required for the code gen to get to all of the declarations in a DeclStmt, and should simplify some other code. llvm-svn: 39623
* fix assertion on out-of-range shiftChris Lattner2007-06-081-2/+6
| | | | llvm-svn: 39618
* Fix bugs in isIntegerConstantExpr handling character and enum literalsChris Lattner2007-06-081-2/+2
| | | | llvm-svn: 39617
* implement a fixme, fixing test/Sema/i-c-e1.cChris Lattner2007-06-081-11/+4
| | | | llvm-svn: 39610
* Various improvements to the tree printer, including printing decls in for ↵Chris Lattner2007-06-051-25/+39
| | | | | | stmts prettier etc llvm-svn: 39592
* add another fixmeChris Lattner2007-06-051-0/+1
| | | | llvm-svn: 39588
* Rename Sema::isConstantArrayType -> VerifyConstantArrayType. Make sure toChris Lattner2007-06-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | check canonical types in a few places. Tighten up VerifyConstantArrayType to diagnose more errors, now that we can evaluate i-c-e's. Add some fixmes about poor diagnostics. We now correctly typecheck this example: void s(void) { typedef int a[(int) +1.0]; static a b; // invalid, static VLA static int c[(int) +1.0]; // invalid, static VLA } void t(void) { typedef int a[(int)1.0]; static a b; // valid, constant size } void u() { static int X[-1]; static int Y[0]; } producing: static-vla.c:3:12: error: variable length array declared outside of any function static a b; // invalid, static VLA ^ static-vla.c:5:14: error: variable length array declared outside of any function static int c[(int) +1.0]; // invalid, static VLA ^ ~~~~~~~~~~ static-vla.c:15:14: error: array size is negative static int X[-1]; ^ ~~ static-vla.c:16:14: warning: zero size arrays are an extension static int Y[0]; ^ ~ llvm-svn: 39587
* simplify Type::isConstantSizeType based on knowledge that it is only calledChris Lattner2007-06-051-5/+3
| | | | | | on complete types. llvm-svn: 39586
* Change Expr::isIntegerConstantExpr in two ways:Chris Lattner2007-06-051-52/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Compute and return the value of the i-c-e if the expression is one. 2. Use this computation to correctly track whether subexprs are being evaluated, and use this to guide diagnostics appropriately. This allows us to correctly handle all the cases in: void bar() { int foo(); switch (1) { case 1 ? 0 : foo(): // bad case 0 ? 0 : foo(): // bad case 0 ? 1/0 : 14 : // ok case 1 ? 1/0 : 14 : // bad ; } switch (1) { case 1 ? 2: (2, 3): // ok case 0 ? 2: (2, 3): // invalid comma. ; } } This code has numerous todo items. Specifically, we need to: 1. Pass in target info, so we know the size of the integers we are producing. 2. Model type sizes and alignments correctly, so we can eval sizeof/alignof 3. Handle promotions (need to talk to steve about this). 4. Return an enum that can be used to better diagnose problems with i-c-e's. instead of just saying "this isn't valid" we should be able to say why. 5. Various other miscellanea, like handling enums and character literals properly. llvm-svn: 39585
* Nothing currently wants to know if something is a constantexpr. SimplifyChris Lattner2007-06-051-14/+12
| | | | | | | isConstantExpr into just isIntegerConstantExpr in preparation for other changes. llvm-svn: 39584
* fix two checks that should be integer-constant-exprs not just c-e's.Chris Lattner2007-06-051-1/+1
| | | | llvm-svn: 39583
* fix a predicate I just brokeChris Lattner2007-06-031-1/+1
| | | | llvm-svn: 39578
* Type::isSignedInteger() and isUnsignedInteger() did not properly account forChris Lattner2007-06-032-21/+32
| | | | | | | | | | 'char', which varies based on the target. Instead of spreading target knowledge throughout the compiler, bifurcate char into Char_S and Char_U, and have ASTContext create the right one based on the target, when it starts up. llvm-svn: 39577
* Submitted by: Bill WendlingBill Wendling2007-06-021-0/+19
| | | | | | | | | Reviewed by: Chris Lattner - Added a method to determine if two types, where at least one is a reference, are compatible. That is you can assign the RHS to the LHS. llvm-svn: 39566
* trivial simplificationChris Lattner2007-06-021-2/+1
| | | | llvm-svn: 39563
* Pretty print storage classes for vardecls.Chris Lattner2007-06-021-1/+14
| | | | llvm-svn: 39556
* Modify Expr::isConstantExpr and friends take a pointer to a SourceLoc insteadChris Lattner2007-06-022-20/+20
| | | | | | of one by reference, making it optional. llvm-svn: 39552
* Generalize this to support printing any valuedecl, e.g. function definitions.Chris Lattner2007-06-021-6/+8
| | | | | | | | | | | We now print: extern void blah(); as: void (blah)(); Strange, but ok :) llvm-svn: 39549
* Bug #:Steve Naroff2007-06-012-12/+27
| | | | | | | | Submitted by: Reviewed by: Add implemention file for GCC attributes llvm-svn: 39542
* Bug #:Steve Naroff2007-06-011-0/+10
| | | | | | | | | | | | | | | Submitted by: Reviewed by: Implement support for GCC __attribute__. - Implement "TODO" in Parser::ParseAttributes. Changed the return type from void to Parser::DeclTy. Changed all call sites to accept the return value. - Added Action::ParseAttribute and Sema::ParseAttribute to return an appropriate AST node. Added new node AttributeDecl to Decl.h. Still to do...hook up to the Decl... llvm-svn: 39539
* more minor improvements to pretty printer.Chris Lattner2007-05-311-24/+5
| | | | llvm-svn: 39538
* add some ;'sChris Lattner2007-05-311-5/+5
| | | | llvm-svn: 39537
* fix a small printer bug, to emit:Chris Lattner2007-05-311-0/+1
| | | | | | | | | | | | | | | | | | | | | | | a = b; { int c; c = a + b; int d; d++; } int e; instead of: a = b; { int c; c = a + b; int d; d++; } int e; llvm-svn: 39535
* pretty print exprs in stmt contexts with a trailing semicolon.Chris Lattner2007-05-301-1/+1
| | | | llvm-svn: 39531
* Bug #:Steve Naroff2007-05-301-1/+2
| | | | | | | | | | | | Submitted by: Reviewed by: - ParseForStatement(): Put back a test/assignment. My removal of ParseExprStmt() was a bit over zealous:-(thanks to Chris for pointing it out) - Add assert to VisitDeclStmt(). - Removed an out-of-date FIXME - Added some curlies for a couple multi-line calls to Diag(). llvm-svn: 39528
* Don't print billions of spaces for a label with no indent.Chris Lattner2007-05-291-1/+1
| | | | llvm-svn: 39521
* Bug #:Steve Naroff2007-05-291-0/+12
| | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Implement some FIXME's that stand in the way of fully typechecking "for" statements. This involved: - Adding a DeclStmt AST node (with statement visitor). The DeclStmt printer is preliminary. - Added a ParseDeclStmt action, called from Parser::ParseForStatement() and Parser::ParseStatementOrDeclaration(). DID NOT add to Parser::ParseIdentifierStatement()...probably could have, however didn't really understand the context of this rule (will speak with Chris). - Removed ParseExprStmt (and it's clients)...it was vestigial. llvm-svn: 39518
* implement full sema support for the GCC address-of-label extension.Chris Lattner2007-05-282-22/+38
| | | | llvm-svn: 39510
* Change GotoStmt's to have a pointer to the LabelStmt instead of a pointer toChris Lattner2007-05-281-1/+1
| | | | | | | | | | | | | | | | | the label identifier. Handle fwd references etc. This allows us to detect uses of undefined labels and label redefinitions, such as: t.c:2:12: error: redefinition of label 'abc' abc: ; abc: ^ t.c:2:3: error: previous definition is here abc: ; abc: ^ t.c:12:12: error: use of undeclared label 'hijl' goto hijl; ^ llvm-svn: 39509
* Null pointers in the ast are no longer considered to be the null stmt.Chris Lattner2007-05-281-1/+1
| | | | llvm-svn: 39507
* add a NullStmt ast node.Chris Lattner2007-05-281-0/+4
| | | | llvm-svn: 39505
* Bug #:Steve Naroff2007-05-271-21/+33
| | | | | | | | | | | | | | | | Submitted by: Reviewed by: - Added type checking to Sema::ParseReturnStmt (still under construction). - Improved Expr::isLvalue() and Expr::isModifiableLvalue() to return more info. Used the info in Sema::CheckAssignmentOperands() to produce more descriptive diagnostics. Added FIXME to other clients of isLvalue()/etc. - Added a SourceLocation slot to MemberExpr...changed the implementation of getSourceRange(). - Added getResultType() helper to FunctionDecl. - Changed many Diag calls to use the SourceRange support (now that it's a big hit...we better milk it:-). llvm-svn: 39501
* Bug #:Bill Wendling2007-05-271-7/+5
| | | | | | | | | Submitted by: Bill Wendling Reviewed by: - Can do just a 'cast<>()' because we're checking that it's Tagged. llvm-svn: 39500
* Bug #:Bill Wendling2007-05-271-7/+9
| | | | | | | | | | Submitted by: Bill Wendling Reviewed by: Steve Naroff - Steve suggested avoiding the dyn_cast by using the "Tagged" type class and having the "default" just return false. llvm-svn: 39499
* Bug #:Bill Wendling2007-05-271-2/+15
| | | | | | | | | | | Submitted by: Bill Wendling Reviewed by: Chris Lattner - Rework the isDerivedType method so that if a language doesn't support references, it won't have to pay the price for them. This inlines the checks for derived types and turns it into a switch statement instead. llvm-svn: 39498
* Bug #:Bill Wendling2007-05-272-7/+53
| | | | | | | | | | | Submitted by: Bill Wendling Reviewed by: Chris Lattner - Initial support for C++ references. Adding to the AST and Parser. Skeletal support added in the semantic analysis portion. Full semantic analysis is to be done soon. llvm-svn: 39496
* Accept parenthesized expressions like ((void*)0) and (void*)(0) as null pointerChris Lattner2007-05-241-24/+29
| | | | | | constants. llvm-svn: 39493
OpenPOWER on IntegriCloud