Commit Graph

4023 Commits

Author SHA1 Message Date
Chris Lattner a4af543375 destroy should forward to base class.
llvm-svn: 65151
2009-02-20 20:42:28 +00:00
Chris Lattner d7ba858314 move the @implementation ivar list to being an ObjCList, which prevents
it from being leaked, among other things.

llvm-svn: 65150
2009-02-20 20:41:34 +00:00
Daniel Dunbar 2f3a3d9f7a Add some IRgen improvement notes.
llvm-svn: 65146
2009-02-20 19:34:45 +00:00
Daniel Dunbar 27032de34b Shorten; no functionality change.
llvm-svn: 65145
2009-02-20 19:34:33 +00:00
Daniel Dunbar 5006f4a5f0 Take advantage of noreturn attribute to add unreachable instruction &
clear insertion point. The rest of IRgen should theoretically take
advantage of this to avoid emitting dead code. Theory != Practice.

llvm-svn: 65141
2009-02-20 18:54:31 +00:00
Anders Carlsson c4c6031859 Always try to fold array sizes, and warn if we could fold something that isn't an ICE. This makes us compatible with GCC.
llvm-svn: 65140
2009-02-20 18:53:20 +00:00
Chris Lattner a499715c83 remove some more methods from objc decls, using the iterator
interfaces more consistently.

llvm-svn: 65138
2009-02-20 18:43:26 +00:00
Daniel Dunbar ce39954d5d Handle constant int -> ptr casts of lvalue results.
- PR3463 (again).

llvm-svn: 65133
2009-02-20 18:22:23 +00:00
Chris Lattner f5b77513b0 remove some slow O(n) methods.
llvm-svn: 65132
2009-02-20 18:18:36 +00:00
Chris Lattner ed89b3ff2f Change ObjCForwardProtocolDecl to use an ObjCList.
llvm-svn: 65131
2009-02-20 18:10:37 +00:00
Daniel Dunbar cdbb5e336d Set call attribute for direct calls (i.e. noreturn).
- Remove an unused variant of EmitCallExpr overload.

llvm-svn: 65130
2009-02-20 18:06:48 +00:00
Chris Lattner 9ee23b7f1a move the interace list of @class to use ObjCList.
llvm-svn: 65129
2009-02-20 18:04:31 +00:00
Steve Naroff 17b2f5d728 Fix <rdar://problem/6586239> bitfield constraints not enforced (for ObjC)
llvm-svn: 65128
2009-02-20 17:57:11 +00:00
Chris Lattner a11480defa remove a dead list.
llvm-svn: 65127
2009-02-20 17:53:35 +00:00
Chris Lattner d0b80c8c75 add support for amd64-*, patch by Brooks Davis!
llvm-svn: 65124
2009-02-20 17:04:14 +00:00
Chris Lattner 90669d0500 switch ObjCMethodDecl's parameter list from being explicitly managed to an ObjCList.
llvm-svn: 65114
2009-02-20 06:23:21 +00:00
Chris Lattner fa62dc3483 switch the interface ivar list from being explicitly managed to using ObjCList.
llvm-svn: 65113
2009-02-20 06:10:45 +00:00
Chris Lattner 8d10c11606 move more objc destruction out of dtors into Destroy.
llvm-svn: 65112
2009-02-20 06:03:09 +00:00
Chris Lattner 55c8d39695 move some objc decl destruction out of dtors into Destroy method.
llvm-svn: 65111
2009-02-20 05:54:35 +00:00
Zhongxing Xu 617bc3d02e Add an example in comments.
llvm-svn: 65110
2009-02-20 05:19:30 +00:00
Eli Friedman cf7cbe7441 A few small tweaks to isConstantInitializer. (No test because this
isn't getting used by Sema or CodeGen at the moment...)

llvm-svn: 65107
2009-02-20 02:36:22 +00:00
Eli Friedman 0b8337c30b Add support for * (unary dereference) operator to ExprConstant.
llvm-svn: 65105
2009-02-20 01:57:15 +00:00
Chris Lattner caae716837 optimize the 'StoredDeclsMap' for the common case where there is
exactly one decl with a specific name in a specific context.  This
avoids a bunch of malloc traffic and shrinks StoredDeclsMap to hold
one pointer instead of 3 words (for a std::vector).

This speeds up -fsyntax-only on cocoa.h with PTH by ~7.3%.

llvm-svn: 65103
2009-02-20 01:44:05 +00:00
Eli Friedman ce98257691 Suppress constant initializer checking when the declaration isn't valid.
This prevents emitting diagnostics which are almost certainly useless.

(Note that the test is checking that we emit only one diagnostic.)

llvm-svn: 65101
2009-02-20 01:34:21 +00:00
Eli Friedman 719ed1a9ab Initialize the Init variable to something reasonable when we emit an
error, so we don't crash.

llvm-svn: 65099
2009-02-20 01:18:21 +00:00
Eli Friedman 742421e2e7 ExprConstant handling for a couple more cases of pointer-to-int casts
from the testsuite.

llvm-svn: 65098
2009-02-20 01:15:07 +00:00
Fariborz Jahanian c86fb5ecb4 More objc gc's ir-gen fixes.
llvm-svn: 65097
2009-02-20 01:14:43 +00:00
Chris Lattner 29578f3f41 make the redeclaration case faster for the common instance of a redeclaration
where there is exactly one existing declaration.  This is common.

this speeds up clang about 3% on cocoa.h for me 0.165 -> 0.160s

llvm-svn: 65096
2009-02-20 01:10:07 +00:00
Chris Lattner 33f219d1a9 80 cols
llvm-svn: 65095
2009-02-20 00:56:18 +00:00
Chris Lattner 24e24d51a1 slight code simplifications.
llvm-svn: 65094
2009-02-20 00:55:03 +00:00
Mike Stump 2a9baebae1 Deox and Capitolize.
llvm-svn: 65093
2009-02-20 00:45:51 +00:00
Chris Lattner 464ceb4ec8 map source ranges through macro expansions. Before:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

(no ranges on the second diagnostics)

After:

t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                         ~~~ ^ ~~~

(ranges!)

llvm-svn: 65090
2009-02-20 00:25:28 +00:00
Mike Stump f5a5c4fa11 Fix spacing.
llvm-svn: 65089
2009-02-20 00:19:45 +00:00
Chris Lattner 1973d84625 refactor, pass ranges down instead of the whole
DiagnosticInfo.

llvm-svn: 65088
2009-02-20 00:18:51 +00:00
Ted Kremenek c537a6d3f1 Fix crash from <rdar://problem/6562655>: 'init' method only return a receiver alias if the return type is a location.
llvm-svn: 65084
2009-02-20 00:05:35 +00:00
Chris Lattner cf868c458c replace a dirty hack with a clean solution. Too bad we can't
use Blocks for our callbacks ;-)

llvm-svn: 65083
2009-02-19 23:53:20 +00:00
Ted Kremenek 68abaa984d retain/release checker: Generate an intermediate simulation node for "leak"
transitions and then generate a subsequent node that removes the dead symbol
bindings. This should drastically improve caching in the simulation graph when
retain-counted objects are being tracked.

llvm-svn: 65082
2009-02-19 23:47:02 +00:00
Chris Lattner 810d330cd3 Fix a long standard problem with clang retaining "too much" sugar
information about types.  We often print diagnostics where we say 
"foo_t" is bad, but the user doesn't know how foo_t is declared 
(because it is a typedef).  Fix this by expanding sugar when present
in a diagnostic (and not one of a few special cases, like vectors).

Before:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)')
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

After:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

llvm-svn: 65081
2009-02-19 23:45:49 +00:00
Ted Kremenek 513f0b147e Added a new method to GRStmtNodeBuilder to build nodes using an arbitrary
PostStmt program point. This allows clients to pass in PostStmtCustom program
points.

llvm-svn: 65080
2009-02-19 23:45:28 +00:00
Chris Lattner a8bac26e2c pretty printing vector types should print the element type, not just the attribute.
llvm-svn: 65078
2009-02-19 23:42:29 +00:00
Fariborz Jahanian 0f466c746f More objc's gc ir-gen stuff.
llvm-svn: 65077
2009-02-19 23:36:06 +00:00
Chris Lattner ae0197e134 GetTypeForDeclarator can return null on error now, handle this.
llvm-svn: 65076
2009-02-19 23:13:55 +00:00
Daniel Dunbar 1c8560d93e Extend Evaluate() to fold (int) <pointer type>.
- PR3463, PR3398, <rdar://problem/6553401> crash on relocatable
   symbol addresses as constants in static locals.

 - There are many more scenarious we could handle (like arithmetic on
   such an int) but this is the main use case.

llvm-svn: 65074
2009-02-19 22:24:01 +00:00
Daniel Dunbar cf04aa1a02 Simplify, no functionality change.
llvm-svn: 65073
2009-02-19 22:16:29 +00:00
Ted Kremenek e76eb060c7 Fix another PTH warning that should not be a note.
llvm-svn: 65072
2009-02-19 22:14:49 +00:00
Ted Kremenek 36b005db45 Make PTH warnings actual warnings instead of 'notes'.
llvm-svn: 65071
2009-02-19 22:13:40 +00:00
Mike Stump a67033294a Add enough checking to ensure that non-constant block literals don't
appear to be constant.  I'll probably redo this and throw it all away
later once we have codegen for BlockDeclRefExprs.

llvm-svn: 65070
2009-02-19 22:01:56 +00:00
Daniel Dunbar 18e1444f82 Remove IRgen constant emission assumption that LValue APValue results
only occur for pointer types; they are also possible for integer types
now.
 - No intended functionality change, IntExprEvaluate doesn't return
   LValue results yet.

llvm-svn: 65066
2009-02-19 21:44:24 +00:00
Daniel Dunbar ca097adca8 Change IntExprEvaluator to operate on an APValue not an APSInt.
- Prep for handling lvalues, no intended functionality change.

llvm-svn: 65063
2009-02-19 20:17:33 +00:00
Daniel Dunbar 96f8677e11 Arguments to unordered comparison builtins may need implicit casts.
- <rdar://problem/6094103> sema fails to promote type arguments to __builtin_isgreater (and friends)

llvm-svn: 65059
2009-02-19 19:28:43 +00:00
Anders Carlsson f96954ca30 Add irgen support for the noinline attribute.
llvm-svn: 65056
2009-02-19 19:22:11 +00:00
Anders Carlsson 880971241b Add sema support for the noinline attribute.
llvm-svn: 65055
2009-02-19 19:16:48 +00:00
Daniel Dunbar e3c92bc672 Add another IntExprEvaluator::Success overload to suck up remained of
manual setting of the Result.

 - Idiom now enforces that result will always have correct width and
   type; this exposed three new bugs:

    o Enum constant decl value can have different width than type
      (PR3173).

    o EvaluateInteger should not run an IntExprEvaluator over
      non-integral expressions.

    o FloatExprEvaluate was not handling casts correctly (it was
      evaluating the cast in the IntExprEvaluator!).

llvm-svn: 65053
2009-02-19 18:37:50 +00:00
Chris Lattner 91668def8b fix PR3609, emit:
t.c:1:10: error: missing terminating '>' character
#include <stdio.h
         ^

instead of:

t.c:1:10: error: missing terminating " character
#include <stdio.h
         ^

llvm-svn: 65052
2009-02-19 18:29:56 +00:00
Fariborz Jahanian 3114e94e10 Generate the conservative objc gc's API for now.
llvm-svn: 65051
2009-02-19 18:29:24 +00:00
Ted Kremenek deafc5c601 retain/release checker: Fix crasher when the leak site is the same expression that allocates an object.
llvm-svn: 65047
2009-02-19 18:18:48 +00:00
Chris Lattner 780b46fd50 Fix PR3619 by properly considering size modifiers and type quals when
uniquing array types.

llvm-svn: 65046
2009-02-19 17:31:02 +00:00
Zhongxing Xu 69aac369c3 only track integer and pointer values for now.
llvm-svn: 65041
2009-02-19 09:56:08 +00:00
Daniel Dunbar 8aafc89db8 Add IntExprEvaluator::Success method.
- Handles assignment to Result with appropriate type.

 - Simplifies & encapsulates most direct handling of the Result value;
   prep for allowing IntExprEvaluator to deal with LValue APValues.

 - No intended functionality change.

llvm-svn: 65038
2009-02-19 09:06:44 +00:00
Zhongxing Xu f74ab25e22 Convert the offset to signed before making an ElementRegion with it. It seems
that this problem arises from time to time. We should find a fundamental 
solution for it.

llvm-svn: 65035
2009-02-19 08:37:16 +00:00
Daniel Dunbar f0acf7bd4c Don't emit K&R unprototyped function definitions as varargs.
- <rdar://problem/6584606> clang/x86-64 - too many reg saves

llvm-svn: 65032
2009-02-19 07:15:39 +00:00
Daniel Dunbar 5c275a94fb Add Type::getAsFunctionNoProto
llvm-svn: 65031
2009-02-19 07:11:26 +00:00
Chris Lattner 124bb197a7 only do one DenseMap lookup instead of two (one to find out if there is
already an entry and one to insert).

llvm-svn: 65030
2009-02-19 07:05:16 +00:00
Chris Lattner 74c04eb99e minor simplification.
llvm-svn: 65029
2009-02-19 07:02:09 +00:00
Chris Lattner dfd6b3d190 use early exit to reduce indentation.
llvm-svn: 65028
2009-02-19 07:00:44 +00:00
Chris Lattner 06ef388a61 fix a bug introduced in my previous patch: moving clang headers to the
"after" group instead of the system group makes it so #include <limits.h>
picks up the *system* limits.h file before clang's.  This causes a failure
on linux and is definitely not what we want.

llvm-svn: 65026
2009-02-19 06:48:28 +00:00
Chris Lattner ab68faf9f0 fix warning in no-assert mode.
llvm-svn: 65024
2009-02-19 06:41:13 +00:00
Anders Carlsson 0756c97dae Emit the correct diagnostics when we constant fold an array size to a negative value.
llvm-svn: 65023
2009-02-19 06:30:50 +00:00
Chris Lattner b5d8416b90 don't new[] an empty array when an AttributeList has
zero expression arguments.  This eliminates 2579 1-byte
mallocs when parsing Cocoa.h.

llvm-svn: 65022
2009-02-19 06:25:12 +00:00
Daniel Dunbar b2f4cdb233 Emission of global variable initialializer was broken in rare
situation where a tentative decl was emitted *after* the actual
initialization. This occurs in some rare situations with static decls.
 - PR3613.

 - I'm not particularly happy with this fix, but I don't see a simpler
   or more elegant solution yet.

llvm-svn: 65018
2009-02-19 05:36:41 +00:00
Anders Carlsson ef56fbaa39 Handle the GNU void* and function pointer arithmetic extensions for constant expressions as well.
llvm-svn: 65013
2009-02-19 04:55:58 +00:00
Chris Lattner 45d26bd00d PR3614: "ignoring nonexistent directory" should print the -isysroot
mapped path, not the requested path.

llvm-svn: 65009
2009-02-19 04:48:57 +00:00
Chris Lattner ec5a332e46 fix another typo gabor noticed
llvm-svn: 65006
2009-02-19 04:44:58 +00:00
Ted Kremenek 66d9edc346 Implemented simple check in <rdar://problem/6600344>: When the receiver of a
message expression is nil and the return type is struct then the returned value
is undefined or potentially garbage.

llvm-svn: 65003
2009-02-19 04:06:22 +00:00
Mike Stump 4e1f26aad0 Fit 80col and fix indentation.
llvm-svn: 65000
2009-02-19 03:04:26 +00:00
Mike Stump 82191d0413 Fix spacing.
llvm-svn: 64998
2009-02-19 02:54:59 +00:00
Mike Stump 5d2534ada7 More codegen for blocks. The type of block literals should be better.
The size calculation is improved.

llvm-svn: 64994
2009-02-19 01:01:04 +00:00
Douglas Gregor 0f3dd9a86b Provide a proper source location when building an implicit dereference. Fixes PR3600
llvm-svn: 64993
2009-02-19 00:52:42 +00:00
Fariborz Jahanian 83e3eea5fc Some code simplification. ir gen for gc'able array
of objects in objc.

llvm-svn: 64992
2009-02-19 00:48:05 +00:00
Howard Hinnant 9c788c081c testing (reverted)
llvm-svn: 64991
2009-02-19 00:27:58 +00:00
Howard Hinnant 2d12fbdc2e testing
llvm-svn: 64990
2009-02-19 00:25:33 +00:00
Fariborz Jahanian d29fecd746 Couple of helpers for objc's gc attributes.
No change in functionality.

llvm-svn: 64989
2009-02-19 00:22:47 +00:00
Douglas Gregor 5f361c9f1e Address Chris's comments regarding C++ name mangling.
llvm-svn: 64984
2009-02-18 23:53:56 +00:00
Ted Kremenek 84e7c1e2ff retain/release checker: Place the leak diagnostic after the last statement that
references the tracked object.

llvm-svn: 64980
2009-02-18 23:28:26 +00:00
Chris Lattner 1b2cd9aca9 fariborz already fixed this.
llvm-svn: 64975
2009-02-18 23:00:57 +00:00
Ted Kremenek 6692f45829 Remove unused variable.
llvm-svn: 64974
2009-02-18 22:59:38 +00:00
Ted Kremenek 75a96ed40a Remove logic for computing 'display hint'.
llvm-svn: 64973
2009-02-18 22:59:04 +00:00
Chris Lattner 6805ac6ab0 minor name changes, no functionality change.
llvm-svn: 64972
2009-02-18 22:58:38 +00:00
Ted Kremenek 551747fe3a More fun with retain checker diagnostics:
- Fix some grammar.
- Fix a bug where a "reference count incremented" diagnostic would not be shown
  if the previous typestate was "Released" (only happens in GC mode).

llvm-svn: 64971
2009-02-18 22:57:22 +00:00
Chris Lattner d60183d29f fix some subtle bugs handling the mix of cvr qualifiers, addr spaces,
and gc attrs.  Add an assert to check that we never 
get ExtQualType(ExtQualType(T)).

llvm-svn: 64970
2009-02-18 22:53:11 +00:00
Daniel Dunbar a228a67637 Add anti-FIXME.
llvm-svn: 64969
2009-02-18 22:52:09 +00:00
Daniel Dunbar 8cdb9dae45 i386 ABI: Offset computation in va_arg was incorrect for sizeof(Ty)>4.
We are down to only failing gcc.dg/compat/vector-[12] (8 tests total).

llvm-svn: 64967
2009-02-18 22:28:45 +00:00
Douglas Gregor ac3865c387 Remove pointless backslash
llvm-svn: 64965
2009-02-18 22:24:55 +00:00
Douglas Gregor 1cba5fe1d1 Downgrade the "excess elements in initializer" errors to warnings *in
C*. They're required errors in C++.

llvm-svn: 64964
2009-02-18 22:23:55 +00:00
Daniel Dunbar e60ec0abca x86_64 ABI: Fix thinko in computation of bound for "passed in SSE regs" test.
Two more gcc/x86_64 failures down.

llvm-svn: 64963
2009-02-18 22:19:44 +00:00
Ted Kremenek a790c8dcac Fix diagnostics bugs when computing ranges for the retain/release checker.
llvm-svn: 64962
2009-02-18 22:17:20 +00:00
Chris Lattner d7cfc246f6 rip out __builtin_overload
llvm-svn: 64961
2009-02-18 22:14:55 +00:00
Ted Kremenek ea3a9e270c HTMLDiagnostics: Always display diagnostics *below* the line in question.
llvm-svn: 64959
2009-02-18 22:10:00 +00:00
Daniel Dunbar e3bba6e3d0 x86_64 ABI: "is passed in regs" computation for va_arg was broken for
things passed in mixed registers.

This knocks out 8 x86_64 failures.

llvm-svn: 64958
2009-02-18 22:05:01 +00:00
Douglas Gregor 222e5e4ad2 Return true on errors, return true on errors, return true on errors
llvm-svn: 64957
2009-02-18 22:00:45 +00:00
Ted Kremenek 1045289881 retain/release checker: We now emit fancy diagnostics telling users about the
semantics of CFMakeCollectable and friends.

llvm-svn: 64956
2009-02-18 21:57:45 +00:00
Douglas Gregor 171c45ab0c Downgrade complaints about calling unavailable functions to a warning
(as GCC does), except when we've performed overload resolution and
found an unavailable function: in this case, we actually error.

Merge the checking of unavailable functions with the checking for
deprecated functions. This unifies a bit of code, and makes sure that
we're checking for unavailable functions in the right places. Also,
this check can cause an error. We may, eventually, want an option to
make "unavailable" warnings into errors.

Implement much of the logic needed for C++0x deleted functions, which
are effectively the same as "unavailable" functions (but always cause
an error when referenced). However, we don't have the syntax to
specify deleted functions yet :)

llvm-svn: 64955
2009-02-18 21:56:37 +00:00
Fariborz Jahanian 9620769901 Some refactoring and simplificaiotn of objc's gc
ir gen.

llvm-svn: 64954
2009-02-18 21:49:28 +00:00
Mike Stump 8dbf1dbdb8 Codegen for int (^bp)(int) = 0;
llvm-svn: 64951
2009-02-18 21:44:49 +00:00
Daniel Dunbar aac5bf19a5 __attribute__((aligned)) was being ignored!
This knocks out another 8 gcc/compat/i386 & x86_64 failures.

llvm-svn: 64947
2009-02-18 20:06:09 +00:00
Daniel Dunbar b1c22fe9b7 Add Type::isSpecificBuiltinType as a shortcut.
llvm-svn: 64946
2009-02-18 19:59:32 +00:00
Daniel Dunbar 216f64379f Simplify.
llvm-svn: 64944
2009-02-18 19:45:21 +00:00
Chris Lattner 3dd56f96c3 final string diagnostic issue (that I know about):
we used to not account for escapes in strings with
string concat.  Before:

t.m:5:20: warning: field width should have type 'int', but argument has type 'unsigned int'
  printf("\n\n" "\n\n%*d", (unsigned) 1, 1);
                   ^       ~~~~~~~~~~~~

after:

t.m:5:23: warning: field width should have type 'int', but argument has type 'unsigned int'
  printf("\n\n" "\n\n%*d", (unsigned) 1, 1);
                      ^    ~~~~~~~~~~~~

llvm-svn: 64941
2009-02-18 19:26:42 +00:00
Chris Lattner ddb7191920 Next step toward making string diagnostics correct: handle
escapes in the string for subtoken positioning.  This gives
us working examples like:

t.m:5:16: warning: field width should have type 'int', but argument has type 'unsigned int'
  printf("\n\n%*d", (unsigned) 1, 1);
               ^    ~~~~~~~~~~~~

where before the caret pointed two spaces to the left.

llvm-svn: 64940
2009-02-18 19:21:10 +00:00
Chris Lattner 57a09cfcbc update comment.
llvm-svn: 64939
2009-02-18 18:56:29 +00:00
Ted Kremenek f68490a3f7 retain/release checker: Distinguish in the function summaries between
retain/releases performed via [... release] and CFRetain(). The former are
no-ops in GC. The checker already handled this, but now we emit nice diagnostics
to the user telling them that these are no-ops.

llvm-svn: 64937
2009-02-18 18:54:33 +00:00
Chris Lattner ec396b5114 Fix some issues handling sub-token locations that come from macro expansions.
We now emit:

t.m:6:15: warning: field width should have type 'int', but argument has type 'unsigned int'
  printf(STR, (unsigned) 1, 1);
         ^    ~~~~~~~~~~~~
t.m:3:18: note: instantiated from:
#define STR "abc%*ddef"
                 ^

which has the correct location in the string literal in the note line.

llvm-svn: 64936
2009-02-18 18:52:52 +00:00
Fariborz Jahanian 9959eee95d Start generating gc'able code using the new
objc gc type attributes.

llvm-svn: 64935
2009-02-18 18:52:41 +00:00
Chris Lattner 24eb28bcf8 tidy up
llvm-svn: 64934
2009-02-18 18:50:45 +00:00
Chris Lattner 259971431d only get the spelling of a token to get its length if
it needs cleaning.

llvm-svn: 64932
2009-02-18 18:40:20 +00:00
Chris Lattner f638b97fe0 use the full spelling of a string literal token so that trigraphs
and escaped newlines don't throw off the offset computation.

On this testcase:
  printf("abc\
def"
         "%*d", (unsigned) 1, 1);

Before:
t.m:5:5: warning: field width should have type 'int', but argument has type 'unsigned int'
def"
    ^

after:
t.m:6:12: warning: field width should have type 'int', but argument has type 'unsigned int'
         "%*d", (unsigned) 1, 1);
           ^    ~~~~~~~~~~~~

llvm-svn: 64930
2009-02-18 18:34:12 +00:00
Fariborz Jahanian d35c792ebb Make warn-weak-field.m test pass again.
llvm-svn: 64927
2009-02-18 18:14:41 +00:00
Fariborz Jahanian 257eac6d0c Cleanup objc's gc attributes code no longer needed.
This make warn-weak-field.m to fail (subject of
a followup patch). 
attr-objc-gc.m no passes.

llvm-svn: 64925
2009-02-18 17:52:36 +00:00
Chris Lattner a26fb347a0 Start improving diagnostics that relate to subcharacters of string literals.
First step, handle diagnostics in StringLiteral's that are due to token pasting.

For example, we now handle:
  id str2 = @"foo" 
            "bar"
           @"baz"
           " b\0larg";  // expected-warning {{literal contains NUL character}}

Correctly:

test/SemaObjC/exprs.m:17:15: warning: CFString literal contains NUL character
           " b\0larg";  // expected-warning {{literal contains NUL character}}
           ~~~^~~~~~~

There are several other related issues still to be done.

llvm-svn: 64924
2009-02-18 17:49:48 +00:00
Douglas Gregor 220cac5e89 Update Parser::ParseTypeName to return a TypeResult, which also tells
us whether there was an error in trying to parse a type-name (type-id
in C++). This allows propagation of errors further in the compiler,
suppressing more bogus error messages.

llvm-svn: 64922
2009-02-18 17:45:20 +00:00
Ted Kremenek ab89bc8ca1 Revise comment. Comparing pointer values in 'Range' wasn't the performance issue I thought it was, but it is still worth ordering Range objects by their APSInt values.
llvm-svn: 64921
2009-02-18 17:42:44 +00:00
Douglas Gregor c5c0488338 Add an unavailable __tg_promote function to attract incorrect uses of type-generic macros, rom Howard Hinnant.
llvm-svn: 64919
2009-02-18 17:23:05 +00:00
Chris Lattner 1fa74d9509 nothing says "ted was here" like a random url dropped in a header :)
llvm-svn: 64903
2009-02-18 07:09:44 +00:00
Douglas Gregor 94349fd8cb Allow "overloadable" functions in C to be declared as variadic without
any named parameters, e.g., this is accepted in C:

  void f(...) __attribute__((overloadable));

although this would be rejected:

  void f(...);

To do this, moved the checking of the "ellipsis without any named
arguments" condition from the parser into Sema (where it belongs anyway).

llvm-svn: 64902
2009-02-18 07:07:28 +00:00
Chris Lattner 112c2a914f teach child iterators to walk into the child string of an ObjCStringLiteral,
so it shows up in -ast-dump.

llvm-svn: 64901
2009-02-18 06:53:08 +00:00
Chris Lattner 163ffd22c3 fix the ownership issues and location tracking in
Sema::ParseObjCStringLiteral.

llvm-svn: 64900
2009-02-18 06:48:40 +00:00
Chris Lattner f83b5afb7b privatize all of the string literal memory allocation/creation
stuff behind a private static function.

llvm-svn: 64898
2009-02-18 06:40:38 +00:00
Douglas Gregor b2809a0a1b Don't allow calls to functions marked "unavailable". There's more work
to do in this area, since there are other places that reference
FunctionDecls.

Don't allow "overloadable" functions (in C) to be declared without a
prototype.

llvm-svn: 64897
2009-02-18 06:34:51 +00:00
Chris Lattner d7670d9a96 add some comments describing what is happening here.
llvm-svn: 64896
2009-02-18 06:13:04 +00:00
Chris Lattner fffd6a7e38 simplify the code used to compute the type of an objc string. This makes
it faster in the common case when NSConstantString is around.

llvm-svn: 64895
2009-02-18 06:06:56 +00:00
Chris Lattner 6436fb6acb rename CheckBuiltinCFStringArgument -> CheckObjCString
llvm-svn: 64894
2009-02-18 06:01:06 +00:00
Chris Lattner d3b5d5d1df simplify some code.
llvm-svn: 64893
2009-02-18 05:56:09 +00:00
Chris Lattner 630970ddb8 change the StringLiteral AST node to track all of the SourceLocations of
the various PPTokens that are pasted together to make it.  In the course
of working on this, I discovered ParseObjCStringLiteral which needs some
work.  I'll tackle it next.

llvm-svn: 64892
2009-02-18 05:49:11 +00:00
Ted Kremenek c2c0bdb880 Fix performance bug in RangeConstraintManager (that I introduced):
When comparing if one Range is "less" than another, compare the actual APSInt
  numeric values instead of their pointer addresses. This ensures that the
  ImmutableSet in RangeSet always has a consistent ordering between Ranges. This
  is critical for generating the same digest/hash for the contents of the sets.
  This was a serious performance bug because it would often cause state caching
  to be disabled along complicated paths.
  
Along the way:
 - Put Range and RangeSet in the "anonymous namespace" and mark them hidden

llvm-svn: 64890
2009-02-18 05:22:01 +00:00
Fariborz Jahanian e27e934d45 Representation of objc gc's attribute using ExtQualType.
Note that one test attr-objc-gc.m fails. I will fix this
after removing these attributes from the Decl nodes.

llvm-svn: 64889
2009-02-18 05:09:49 +00:00
Chris Lattner 2c4866057d fix rdar://6597252: two exactly identical pointer types are always
compatible, even if they are weird implicit objc pointer types like
Class.

llvm-svn: 64885
2009-02-18 04:38:20 +00:00
Chris Lattner 432cff5bf4 rename some variables, no functionality change.
llvm-svn: 64884
2009-02-18 04:28:32 +00:00
Ted Kremenek 48d1645179 Hooked up the necessary machinery to allow the retain/release checker reference
back to the summary used when evaluating the statement associated with a
simulation node. This is now being used to help improve the checker's
diagnostics. To get things started, the checker now emits a path diagnostic
indicating that 'autorelease' is a no-op in GC mode.

Some of these changes are exposing further grossness in the interface between
BugReporter and the ExplodedGraph::Trim facilities. These really need to be
cleaned up one day.

llvm-svn: 64881
2009-02-18 03:48:14 +00:00
Daniel Dunbar 617e89231d x86_64 ABI: Two bug fixes.
1. Return of _Complex long double used wrong type.

2. va_arg of types passed in two SSE registers didn't account for
extra space in register save area.

Down to 18 failures on gcc/compat/x86_64. Combined 32/64 results are:
--
		=== gcc Summary ===

# of expected passes		1292
# of unexpected failures	34
# of unsupported tests		2
--

llvm-svn: 64880
2009-02-18 03:44:19 +00:00
Ted Kremenek d84fff6524 retain/release checker: Record the summary used to generate a given node.
llvm-svn: 64876
2009-02-18 02:00:25 +00:00
Daniel Dunbar 4750e63486 isICE was evaluating ?: incorrectly with missing-gcc-LHS extension.
Add assert to isICE that, on success, result must be the same as
EvaluateAsInt()... this enforces a minimum level of sanity.

llvm-svn: 64865
2009-02-18 00:47:45 +00:00
Daniel Dunbar 62347a0c55 Convert isIntegerConstantExpr to use ASTContext::MakeIntValue.
- This idiom ensures that the result will have the right width and
   type.

 - Tested on most of x86_64/llvm-test to satisfy my paranoia.

 - This fixes at least the following bugs:
   o UnaryTypeTraitExpr wasn't setting the width correctly.
   o Arithmetic on _Bool wasn't setting the width correctly.

   And probably a number more.

llvm-svn: 64864
2009-02-18 00:32:53 +00:00
Chris Lattner 970f245439 stop searching GCC install directories for standard C headers (but
keep searching for C++ headers when in C++ mode).  In theory clang
should be able to find all of its own headers now.  If not, the
CPATH or C_INCLUDE_PATH environment variables can be specified to
add a include path.

llvm-svn: 64862
2009-02-18 00:25:15 +00:00
Ted Kremenek fa1840b25e Add panic function.
llvm-svn: 64852
2009-02-17 23:27:17 +00:00
Mike Stump eecd39f2d7 Avoid getNameAsCString when the decl doesn't have a name.
Build of the parm list with the iterator, not end().

llvm-svn: 64851
2009-02-17 23:25:52 +00:00
Daniel Dunbar 491812cd76 Rename UnaryTypeTraitExpr::Evaluate to EvaluateTrait to not collide
with Expr::Evaluate().

llvm-svn: 64850
2009-02-17 23:20:26 +00:00
Chris Lattner 976fdefe2f gcc spells it "warn_unused_result" (already supported) not "warnunusedresult"
llvm-svn: 64849
2009-02-17 23:20:10 +00:00
Douglas Gregor 67a6564091 Implement basic parsing and semantic analysis for explicit
specialization of class templates, e.g.,

  template<typename T> class X;

  template<> class X<int> { /* blah */ };

Each specialization is a different *Decl node (naturally), and can
have different members. We keep track of forward declarations and
definitions as for other class/struct/union types.

This is only the basic framework: we still have to deal with checking
the template headers properly, improving recovery when there are
failures, handling nested name specifiers, etc.

llvm-svn: 64848
2009-02-17 23:15:12 +00:00
Ted Kremenek 2620a06fe7 Attribute 'iboutlet' can be applied to Objective-C property declarations.
llvm-svn: 64831
2009-02-17 22:20:20 +00:00
Daniel Dunbar 43a5d9e409 Eek! getDeclAlign sometimes returned alignment in bits.
- Renamed to getDeclAlignInBytes since most other query functions
   work in bits.

 - Fun to track down as isIntegerConstantExpr was getting it right,
   but Evaluate() was getting it wrong. Maybe we should assert they
   compute the same thing when they succeed?

llvm-svn: 64828
2009-02-17 22:16:19 +00:00