Commit Graph

692 Commits

Author SHA1 Message Date
Chris Lattner 5c11c41203 implement correct semantic analysis for shifts. For:
int test(int x, long long y) {
  return x << y;
}

we now realize the type of the shift is int, not long long.

This fixes a fixme from june.

llvm-svn: 44912
2007-12-12 05:47:28 +00:00
Chris Lattner e002fbea56 Add ObjC parser support for concatenated ObjC strings. Note that
this is passed to sema and ignored there, so the second part of the
string will not make it into the AST.  Passing to Fariborz to finish
Sema + AST construction.

llvm-svn: 44898
2007-12-12 01:04:12 +00:00
Chris Lattner f641255a86 simplify code now that isConstantExpr really does always
return a loc.

llvm-svn: 44890
2007-12-11 23:15:04 +00:00
Ted Kremenek d4e5fbacab Mega-patch: ripped SourceManager out of Diagnostic/DiagnosticClient. Now
SourceManager is passed by reference, allowing the SourceManager to be
associated with a specific translation unit, and not the entire execution
of the driver.

Modified all users of Diagnostics to comply with this new interface.

Integrated SourceManager as a member variable of TargetInfo. TargetInfo will
eventually be associated with a single translation unit (just like
SourceManager).

Made the SourceManager reference in ASTContext private. Provided accessor
getSourceManager() for clients to use instead. Modified clients to comply with
new interface.

llvm-svn: 44878
2007-12-11 21:27:55 +00:00
Fariborz Jahanian 3b5dca2533 For @optional unimplemented methods do not issue the warning.
llvm-svn: 44872
2007-12-11 19:10:26 +00:00
Steve Naroff 5cace62e66 Avoid the first person in a recently added comment.
llvm-svn: 44843
2007-12-11 03:38:03 +00:00
Steve Naroff c30dcf1251 Change err_undef_protocolref to warn_undef_protocolref (this is consistent with GCC).
llvm-svn: 44840
2007-12-11 02:44:30 +00:00
Steve Naroff f727faf2ed Explicitly set the string literal type from "char *" to "constant array of char".
At this point, I am fairly certain the front-end is correct. Unfortunately, the back-end is still unhappy.

That said, I've commented out the two lines in globalinit.c that are causing problems.

Chris, please have a look...thanks!

llvm-svn: 44823
2007-12-11 00:00:01 +00:00
Steve Naroff 91f78080e3 Add support for initializing char arrays from string literals.
Adapted from a patch by Anders Carlsson.

llvm-svn: 44816
2007-12-10 22:44:33 +00:00
Chris Lattner 4d62f42eba Implement correct semantic analysis of subtractions, implementing
C99 6.5.6.

llvm-svn: 44746
2007-12-09 21:53:25 +00:00
Fariborz Jahanian ff6a455c12 Implemented when static typing is combined with protocols and use as receiver
type.

llvm-svn: 44685
2007-12-07 21:21:21 +00:00
Steve Naroff 2c20c38ced Have Sema::CheckConstantInitList skip semantic analysis when the element type is a record (until we implement the FIXME). This removes a bogus error for the following code...
snarofflocal% cat bug.m

#import <Foundation/NSGeometry.h>

#define NUMHELICOPTERRECTS 5

static NSRect helicopterRects[NUMHELICOPTERRECTS] = {
    {{27, 0}, {18, 11}},	// Bottom
    {{0, 8}, {4, 11}},		// Tail
    {{0, 16}, {50, 1}},
    {{22, 5}, {18, 12}},	// Body
    {{0, 10}, {42, 3}}
};

llvm-svn: 44684
2007-12-07 21:12:53 +00:00
Steve Naroff 888f33cc44 Lookup methods in the global pool even when a statically typed object's class interface isn't in scope!
As the comment in the code indicates, I'm not fond of this. Nevertheless, gcc compat is a goal.

Here is the case I'm talking about...

#import <Foundation/Foundation.h>

@interface AnyClass : NSObject
- (NSRect)rect;
@end

@class Helicopter;

static void func(Helicopter *obj) {
  NSRect r = [obj rect];
}

...before this patch, we would warn/error. With this patch, everything "just works".

llvm-svn: 44682
2007-12-07 20:41:14 +00:00
Steve Naroff b2f8ff153d Rewrite 'super' within a class method. This required some minor tweaks to the front-end.
llvm-svn: 44673
2007-12-07 03:50:46 +00:00
Fariborz Jahanian 2bbd03a755 Patch to implement "Protocol" as a built-in type declared as
"@class Protocol;"

llvm-svn: 44670
2007-12-07 00:18:54 +00:00
Anders Carlsson 10c6110fca Add workaround to get test/Parser/compound_literal.c working again.
llvm-svn: 44666
2007-12-06 20:10:20 +00:00
Fariborz Jahanian 227c0d13bc On Steve's suggestion, moved handling of use of undeclared method in a message
to rewriter (my previous patch).

llvm-svn: 44665
2007-12-06 19:49:56 +00:00
Fariborz Jahanian c277f6f351 A missing method in a messaging expression issues a warning, clients must not
crash because of this.

llvm-svn: 44648
2007-12-06 01:37:55 +00:00
Fariborz Jahanian b31a2f2a47 Patch to prevent crash on use of objc2 syntax.
llvm-svn: 44617
2007-12-05 18:16:33 +00:00
Anders Carlsson 2c1ec6d5f7 Add sema checking for compound literal expressions.
llvm-svn: 44605
2007-12-05 07:24:19 +00:00
Anders Carlsson cbdb6f5b5d Revert DidWarn change - It won't catch all cases anyway and GCC warns for every excess element. Maybe later we can add back the limit and make it smarter.
llvm-svn: 44603
2007-12-05 04:57:06 +00:00
Steve Naroff 2644aaf537 Recognize CompoundLiteralExpr's as valid lvalue's.
Also updated a FIXME in Sema::CheckInitializer()...

llvm-svn: 44602
2007-12-05 04:00:10 +00:00
Fariborz Jahanian 1f606a999e Simplified setting up Method's scope before generating AST for its nody.
llvm-svn: 44576
2007-12-04 19:20:11 +00:00
Anders Carlsson 5dd106b212 Handle initializing vector elements correctly. Emit just one warning if there are excess initializers, instead of one per initializer.
llvm-svn: 44525
2007-12-03 01:01:28 +00:00
Chris Lattner 310369fb84 restore these lines, which fixes some regtest failures.
llvm-svn: 44516
2007-12-02 07:50:03 +00:00
Chris Lattner 9724ce12f9 improve VC++ compatibility, patch by Cédric Venet.
llvm-svn: 44496
2007-12-02 00:47:03 +00:00
Anders Carlsson 3b754452eb Initialize CurMethodDecl to 0.
llvm-svn: 44463
2007-11-30 20:01:38 +00:00
Anders Carlsson 801c5c7467 GCC has an extension where the left hand side of the ? : operator can be omitted. Handle this in a few more places.
llvm-svn: 44462
2007-11-30 19:04:31 +00:00
Anders Carlsson e1af1d20ef Support lax vector conversions.
llvm-svn: 44449
2007-11-30 04:21:22 +00:00
Steve Naroff 205ec3d07a Yesterday, I simplified how we stream top-level decls.
After a discussion with Ted, we both came to the conclusion that adding a "HandleTopLevelDeclaration" hook to ASConsumer is far more elegant. The default implementation of HandleTopLevelDeclaration will be responsible for iterating over the ScopedDecl (which has a chain of the decls:-).

TODO: Once Ted adds HandleTopLevelDeclaration, make sure TagDecls are chainged appropriately...
llvm-svn: 44445
2007-11-29 23:05:20 +00:00
Christopher Lamb 2ed9afd777 Update the initializer's type, in addition to the decl, if we've changed the type of the decl based on it.
llvm-svn: 44440
2007-11-29 19:09:19 +00:00
Ted Kremenek eda40e273e Enhanced implementation of -Wfloat-equal to check for comparisons against
floating-point literals that are represented exactly by the APFloat in
FloatingLiteral. For such literals, we do not emit a warning since such checks are
often performed in real code to see if a variable has changed from its original
value. This heuristic clearly can lead to false negatives, but the hope is it will
significantly reduce false positives to help make the compiler flag more useful.

llvm-svn: 44424
2007-11-29 00:59:04 +00:00
Ted Kremenek 3a2c950401 Added "isExact" field to FloatingLiteral. This flag indicates whether or not
the APFloat representing the parsed literal can represent the literal value
exactly.  This is useful when performing various semantic checks on the code,
and issuing appropriate warnings to users.

llvm-svn: 44423
2007-11-29 00:56:49 +00:00
Steve Naroff 197616c3a8 Several fixes/simplifications surrounding how we stream top-level decl AST's.
The following code...

typedef struct cssm_data {} CSSM_DATA, *CSSM_DATA_PTR;

struct Y { int A; };

struct X { int A; } D; 

struct X E, F;

...now produces the following output...

> ../../Debug/bin/clang xx.c -ast-print
Read top-level tag decl: 'cssm_data'
typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data *CSSM_DATA_PTR;
Read top-level tag decl: 'Y'
Read top-level tag decl: 'X'
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'F'

...which is much more accurate than the previous -ast-print output...

typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data CSSM_DATA;
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'E'

llvm-svn: 44421
2007-11-28 22:54:11 +00:00
Chris Lattner db2a6ef881 Fix a bug checking for 'int foo(void)' that didn't look through typedefs of void.
Bug pointed out by Michael Zolda, thanks!

llvm-svn: 44408
2007-11-28 18:51:29 +00:00
Chris Lattner 1a6bb70ad0 Set loc earlier in CheckSingleInitializer to avoid emitting a
diagnostic without a location.  This produces:

simpleTest.c:2:18: error: initializer element is not constant
int *myPointer = &(myArray[2]);
                 ^~~~~~~~~~~~~

instead of:

error: initializer element is not constant
llvm-svn: 44375
2007-11-27 21:21:35 +00:00
Steve Naroff 0ee0b0ab8c Move the null pointer constant check from Sema::CheckSingleInitializer/ActOnCallExpr/CheckMessageArgumentTypes/ActOnReturnStmt to Sema::CheckSingleAssignmentConstraints. This makes sure all null pointer assignments are considered compatible.
Thanks to Seo Sanghyeon for the bug, follow-through, and patch!

llvm-svn: 44366
2007-11-27 17:58:44 +00:00
Chris Lattner db3467f8d4 handle __vector_size__ like vector_size
llvm-svn: 44358
2007-11-27 07:28:18 +00:00
Anders Carlsson 24c59958f4 Add comment to CheckVectorCast.h
llvm-svn: 44356
2007-11-27 07:16:40 +00:00
Anders Carlsson de71adff60 Report errors for invalid casts from/to vectors.
llvm-svn: 44350
2007-11-27 05:51:55 +00:00
Anders Carlsson f511f646a4 Add more semantic analysis for inline asm statements.
llvm-svn: 44349
2007-11-27 04:11:28 +00:00
Chris Lattner 2ab40a6207 Fix sema support for the gnu ?: expression with a
missing middle expression, and fix a codegen bug where
we didn't correctly promote the condition to the right 
result type.  This fixes PR1824.

llvm-svn: 44322
2007-11-26 01:40:58 +00:00
Ted Kremenek 43fb8b0799 Moved logic for -Wfloat-equal to SemaChecking.cpp.
Moved utility functions IgnoreParen and friends to be static inline functions
defined in SemaUtil.h.

Added SemaUtil.h to Xcode project.

llvm-svn: 44312
2007-11-25 00:58:00 +00:00
Anders Carlsson 290aa8560b Check that the clobber registers are valid.
llvm-svn: 44311
2007-11-25 00:25:21 +00:00
Anders Carlsson 660bdd1c87 Keep track of whether the asm is volatile or not.
llvm-svn: 44297
2007-11-23 23:12:25 +00:00
Anders Carlsson 80a5ea3552 Check asm input and output expressions.
llvm-svn: 44289
2007-11-23 19:43:50 +00:00
Anders Carlsson 94ea8aab34 Store output and input operands as well as clobber information in the AsmStmt. Ted, could you please review the serialization/deserialization code?
llvm-svn: 44266
2007-11-22 01:36:19 +00:00
Anders Carlsson 81a5a69682 Store inline asm code in the AST.
llvm-svn: 44255
2007-11-20 19:21:03 +00:00
Chris Lattner 5c3f1541a7 Improve function decl merging, patch by Oliver Hunt!
llvm-svn: 44253
2007-11-20 19:04:50 +00:00
Steve Naroff 14f5f79bb6 Now that we are passing back "free standing decls", make sure -ast-dump works like -ast-print.
Also added a cast to be safe...

llvm-svn: 44209
2007-11-17 21:37:36 +00:00