Commit Graph

12864 Commits

Author SHA1 Message Date
Chris Lattner 83a3235a3e -Wformat should depend on format-extra-args so that -Wformat implies
the extra argument warnings, and -Wformat -Wno-format-extra-args
turns on -Wformat but not the extra-args warnings.

llvm-svn: 70363
2009-04-29 04:16:52 +00:00
Chris Lattner 941153afcd tweak warning options to be more like gcc:
1. All all variants of -Wformat*, make them imply -Wformat.  GCC warns 
   if you use -Wformatfoo without -Wformat.  We just make one imply the 
   other.
2. Make -Wformat-nonliteral default to off, like gcc.  It is an incredible
   nuisance.
3. Accept but currently ignore -Wformat-extra-args.

llvm-svn: 70362
2009-04-29 04:15:07 +00:00
Chris Lattner e3fa5aa91c minor code cleanup
llvm-svn: 70361
2009-04-29 04:12:34 +00:00
Zhongxing Xu 892a5f78eb Update test case.
llvm-svn: 70359
2009-04-29 02:37:26 +00:00
Zhongxing Xu 3ee3044bd7 As discussed with Ted offline, re-apply r70293.
llvm-svn: 70358
2009-04-29 02:30:09 +00:00
Zhongxing Xu c14f097f58 XFAIL the test case.
llvm-svn: 70356
2009-04-29 01:50:12 +00:00
Daniel Dunbar c1b1658751 Add incredibly bare bones docs/tools.
- Mirroring LLVM's docs/CommandGuide, a place to put .pod files which
   are used to generate man/html/etc documentation for tools provided
   as part of clang.

llvm-svn: 70355
2009-04-29 01:00:32 +00:00
Mike Stump d00bc1a275 Implement sema checking for noreturn.
llvm-svn: 70353
2009-04-29 00:43:21 +00:00
Ted Kremenek 7686ffaf07 retain/release checker: Refactor the guts of getClassMethodSummary to not depend
on ObjCMessageExpr. This will enable us to use it elsewhere. This should not
change any functionality.

llvm-svn: 70352
2009-04-29 00:42:39 +00:00
Ted Kremenek ebc6d91f4e Add regression test case provided by <rdar://problem/6833332>.
llvm-svn: 70350
2009-04-29 00:41:31 +00:00
Douglas Gregor 272842aa1c Enable PCH by default
llvm-svn: 70339
2009-04-28 22:44:02 +00:00
Douglas Gregor c1547eb338 Force driver's PTH test to use PTH
llvm-svn: 70338
2009-04-28 22:43:20 +00:00
Chris Lattner af6094eafc In -fdiagnostics-print-source-range-info mode, print a space before the
lines that clang extracts from the source code so that machine parsing can
easily ignore them.

llvm-svn: 70337
2009-04-28 22:33:16 +00:00
Ted Kremenek 869292d5b6 Implement ownership attribute 'objc_ownership_make_collectable'. This allows one
to add 'CFMakeCollectable' semantics to a method.

llvm-svn: 70336
2009-04-28 22:32:26 +00:00
Chris Lattner 865efd72b3 add support for -Wendif-labels, PR4101
llvm-svn: 70335
2009-04-28 22:19:16 +00:00
Douglas Gregor ce1a9c5a6b Make all PCH-incompatibility warnings into errors, and abort
compilation if the user requested a PCH file but no such PCH file
exists.

llvm-svn: 70332
2009-04-28 22:01:16 +00:00
Douglas Gregor 6f00bf8ceb Make the PCH reader use the diagnostics system for its complaints.
llvm-svn: 70330
2009-04-28 21:53:25 +00:00
Chris Lattner 8577f62622 Implement -Wfour-char-constants, which is an extension, not an extwarn,
and apparently not part of -Wall

llvm-svn: 70329
2009-04-28 21:51:46 +00:00
Ted Kremenek 89c3861061 Improve retain/release test cases for ownership attributes.
llvm-svn: 70327
2009-04-28 21:43:40 +00:00
Douglas Gregor b925652433 Optimize IdentifierInfo storage within the precompiled header. We've
now gotten back about 180k of the 500k we lost.

llvm-svn: 70326
2009-04-28 21:32:13 +00:00
Douglas Gregor 1d583f2838 Implement a minor space optimization for the PCH identifier table,
which eliminates the storage for IdentifierInfo in the "uninteresting
identifier" cases. Sadly, this only brought back 7k of the 500k we
lost :(

llvm-svn: 70325
2009-04-28 21:18:29 +00:00
Douglas Gregor cd07dd168d Fix a typo noticed by Gabor
llvm-svn: 70323
2009-04-28 21:06:13 +00:00
Douglas Gregor 1a949368e4 Replace a lame fprintf with a slightly-less lame diagnostic
llvm-svn: 70322
2009-04-28 20:36:16 +00:00
Douglas Gregor e6648fb79e Implement checking for macro definitions that occur on the command
line when using a PCH that were not provided when building the PCH
file. If those names were used as identifiers somewhere in the PCH
file, reject the PCH file.

llvm-svn: 70321
2009-04-28 20:33:11 +00:00
Douglas Gregor ab4df58193 Revert r70075 and r70078, which reorganized the PCH on-disk hash table
for identifiers to separate "interesting" from "uninteresting"
identifiers. However, to cope with compiler invocations where the
predefines buffers mismatch, we need to be able to search the complete
identifier table. Cocoa.h.pch is now about 500k larger that it used to
be :(

llvm-svn: 70320
2009-04-28 20:01:51 +00:00
Daniel Dunbar fb83baaf76 With -ccc-pch-is-pch, always treat precompiled inputs as PCH,
regardless of extension.
 - Otherwise we can't expect that just plugging in -ccc-pch-is-pch
   will work.

llvm-svn: 70318
2009-04-28 19:38:45 +00:00
Eli Friedman a38da57cd6 PR4097: add logic to Evaluate to handle pointer equality comparisons.
llvm-svn: 70317
2009-04-28 19:17:36 +00:00
Douglas Gregor c379c07240 Allow some differences between the predefines buffer used to build a
PCH file and the predefines buffer used when including the PCH
file. We (explicitly) detect conflicting macro definitions (rejecting
the PCH file) and about missing macro definitions (they'll be
automatically pulled from the PCH file anyway).

We're missing some checking to make sure that new macro definitions
won't have any impact on the PCH file itself (e.g., #define'ing an
identifier that the PCH file used).

llvm-svn: 70316
2009-04-28 18:58:38 +00:00
Chris Lattner 74c95e20af implement -Wmultichar
llvm-svn: 70315
2009-04-28 18:52:02 +00:00
Eli Friedman 5406f5430b Add some text to the user manual describing the current state of C
support in clang.

llvm-svn: 70314
2009-04-28 18:48:34 +00:00
Ted Kremenek ea62bf4e58 Revert 70293.
llvm-svn: 70313
2009-04-28 18:48:13 +00:00
Chris Lattner 0cd56890ef merge number.c into constants.c and start running it in -verify mode.
llvm-svn: 70310
2009-04-28 18:43:12 +00:00
Eli Friedman 4058a842e6 Fix a minor edge case in C89 mode related to the definition of a
"function designator".

(This causes a minor glitch in the 
diagnostics for C++ member pointers, but we weren't printing the 
right diagnostic there anyway.)

llvm-svn: 70307
2009-04-28 17:59:09 +00:00
Eli Friedman 9f1d66419d Fix additional issues pointed out in PR4088.
llvm-svn: 70305
2009-04-28 17:48:05 +00:00
Ted Kremenek ce6b865c21 ccc-analyzer: Don't automatically generate 'Parser Rejects' files anymore. The
frontend is far enough along that most discrepancies between Clang and GCC are
(at least for C and Objective-C) are intentional. We also now have codegen to
test the frontend.

llvm-svn: 70303
2009-04-28 17:37:44 +00:00
Ted Kremenek ed70968484 Update analyzer build.
llvm-svn: 70295
2009-04-28 14:32:50 +00:00
Zhongxing Xu 3c3fee0fb8 Add test case.
llvm-svn: 70294
2009-04-28 13:52:13 +00:00
Zhongxing Xu 6e304e6323 Now we can remove the 'blast-through' code.
llvm-svn: 70293
2009-04-28 13:49:42 +00:00
Douglas Gregor 76fe50c654 Improve compatibility with GCC regarding inline semantics in GNU89
mode and in the presence of __gnu_inline__ attributes. This should fix
both PR3989 and PR4069.

As part of this, we now keep track of all of the attributes attached
to each declaration even after we've performed declaration
merging. This fixes PR3264.

llvm-svn: 70292
2009-04-28 06:37:30 +00:00
Ted Kremenek 9bea0dc178 Extensive diagnostics: Do not add a location context for do...while statements.
llvm-svn: 70286
2009-04-28 04:28:12 +00:00
Ted Kremenek 61114bc558 BugReporter (extensive diagnostics): Clean up do...while control-flow edges, and
add "Looping back to the head of the loop" diagnostic for loops.

llvm-svn: 70285
2009-04-28 04:23:15 +00:00
Ted Kremenek cb37bb0f20 CFG: Add "loop back" block for do...while statements.
llvm-svn: 70284
2009-04-28 04:22:00 +00:00
Eli Friedman 6bba2adc95 Emit keyword extension warning in all modes, not just C99 mode.
llvm-svn: 70283
2009-04-28 03:59:15 +00:00
Eli Friedman 6131bfbf77 Remove unused LangOptions NoExtensions and Boolean.
llvm-svn: 70282
2009-04-28 03:28:55 +00:00
Eli Friedman 2b680b43e9 Simplify the scheme used for keywords, and change the classification
scheme to be more useful.

The new scheme introduces a set of categories that should be more 
readable, and also reflects what we want to consider as an extension 
more accurately.  Specifically, it makes the "what is a keyword" 
determination accurately reflect whether the keyword is a GNU or 
Microsoft extension.

I also introduced separate flags for keyword aliases; this is useful 
because the classification of the aliases is mostly unrelated to the 
classification of the original keyword.

This patch treats anything that's in the implementation 
namespace (prefixed with "__", or "_X" where "X" is any upper-case 
letter) as a keyword without marking it as an extension.  This is 
consistent with the standards in that an implementation is allowed to define 
arbitrary extensions in the implementation namespace without violating 
the standard. This gets rid of all the nasty "extension used" warnings 
for stuff like __attribute__ in -pedantic mode.  We still warn for 
extensions outside of the the implementation namespace, like typeof.
If someone wants to implement -Wextensions or something like that, we 
could add additional information to the keyword table.

This also removes processing for the unused "Boolean" language option; 
such an extension isn't supported on any other C implementation, so I 
don't see any point to adding it.

The changes to test/CodeGen/inline.c are required because previously, we 
weren't actually disabling the "inline" keyword in -std=c89 mode.

I'll remove Boolean and NoExtensions from LangOptions in a follow-up 
commit.

llvm-svn: 70281
2009-04-28 03:13:54 +00:00
Ted Kremenek 49936f76ec CFG: 'WhileStmts' needs an extra block to indicate the "loop back" path.
llvm-svn: 70280
2009-04-28 03:09:44 +00:00
Mike Stump 6ea352a750 We avoid the count of diagnostics when not generating carent
diagnostics to improve gcc compatibility; useful for dejagnu testing.

llvm-svn: 70278
2009-04-28 01:19:10 +00:00
Mike Stump d456c48568 Don't allow blocks to be declared as returning an array. Radar 6441502
llvm-svn: 70277
2009-04-28 01:10:27 +00:00
Ted Kremenek 902393b4b7 CFG:
- Add 'LoopTarget' pointer field to CFGBlock. This records if the block is used
  as the 'loop back' path back to the head of a loop.
- For ForStmt, encode the loop back target as the increment code.

llvm-svn: 70274
2009-04-28 00:51:56 +00:00
Eli Friedman 5d72d41189 Get rid of some useless uses of NoExtensions. The philosophy here is
that if we're going to print an extension warning anyway, 
there's no point to changing behavior based on NoExtensions: it will 
only make error recovery worse.

Note that this doesn't cause any behavior change because NoExtensions 
isn't used by the current front-end.  I'm still considering what to do about
the remaining use of NoExtensions in IdentifierTable.cpp.

llvm-svn: 70273
2009-04-28 00:51:18 +00:00
Eli Friedman f66a2e12a4 A couple more small changes which are probably required for Cygwin
builds to work (PR4088).

llvm-svn: 70269
2009-04-27 23:43:36 +00:00
Eli Friedman a90db0acd0 Attempt to fix reported build error on Cygwin, PR4088.
llvm-svn: 70268
2009-04-27 23:36:17 +00:00
Devang Patel df348f10b6 While generating debug info ignore unnamed fields.
llvm-svn: 70266
2009-04-27 22:40:36 +00:00
Douglas Gregor 7b71e63120 Add a header containing the Clang version; make the driver use this
Clang version value rather than hard-coding "1.0".

Add PCH and Clang version information into the PCH file. Reject PCH
files with the wrong version information.

llvm-svn: 70264
2009-04-27 22:23:34 +00:00
Chris Lattner 1d72888cfc fix test/PCH/method_pool.m
llvm-svn: 70263
2009-04-27 22:17:41 +00:00
Chris Lattner 8804f40321 -E, -Eonly and -parse-noop now work with PCH!
llvm-svn: 70259
2009-04-27 22:02:30 +00:00
Chris Lattner 8575daaa82 Teach PCH that ASTContext is optional. Move -parse-noop and -Eonly (so far)
processing to after PCH is loaded.  -Eonly and -parse-noop are close to working
with PCH now but are not quite there yet.

llvm-svn: 70257
2009-04-27 21:45:14 +00:00
Sebastian Redl 4c018663b2 Track down return statements in the handlers of a function-try-block of constructors. Meh ...
llvm-svn: 70256
2009-04-27 21:33:24 +00:00
Douglas Gregor 0bc1293584 Be more careful in our teardown of the PCHReader after deciding to
ignore a PCH file.

llvm-svn: 70251
2009-04-27 21:28:04 +00:00
Chris Lattner 1f1e1c7e39 unnest some code, decoupling fixit rewriting from ast stuff.
llvm-svn: 70250
2009-04-27 21:25:27 +00:00
Daniel Dunbar c6480e2634 Add -empty-input-only option, for timing.
- Forces input file to be empty to time startup/shutdown costs.

llvm-svn: 70249
2009-04-27 21:19:07 +00:00
Sebastian Redl 2f38ba57c8 Don't allow catch declarations to name an abstract class
llvm-svn: 70248
2009-04-27 21:03:30 +00:00
Sebastian Redl 4de47b445b Improve validation of C++ exception handling: diagnose throwing incomplete types and jumps into protected try-catch scopes.
llvm-svn: 70242
2009-04-27 20:27:31 +00:00
Douglas Gregor 61cac2b295 Add Sema::ExtVectorDecls and Sema::ObjCCategoryImpls to the PCH file. Since these vectors are very, very rarely used and, when used in headers, and even when used are relatively small, we load them eagerly.
llvm-svn: 70240
2009-04-27 20:06:05 +00:00
Ted Kremenek 84bfa2c2dc Add two new checker-specific attributes: 'objc_ownership_release' and
'objc_ownership_cfrelease'. These are the 'release' equivalents of
'objc_ownership_retain' and 'objc_ownership_cfretain' respectively.

llvm-svn: 70235
2009-04-27 19:36:56 +00:00
Ted Kremenek e6633567e0 Track objects in GC mode returned by 'alloc', 'new', etc. methods. These are
treated as "not owned" objects.

llvm-svn: 70232
2009-04-27 19:14:45 +00:00
Chris Lattner c4976c7377 make these be unsigned now that they are eagerly created.
llvm-svn: 70229
2009-04-27 19:03:22 +00:00
Chris Lattner 12d61d3253 shrink SOURCE_LOCATION_OFFSETS to use 4-byte entries instead of 8-byte
entries, shaving 100K off the PCH file for cocoa.

llvm-svn: 70228
2009-04-27 19:01:47 +00:00
Douglas Gregor 988e627f8c Fix a problem with the RUN line of one of the PCH tests
llvm-svn: 70227
2009-04-27 18:49:47 +00:00
Ted Kremenek 5fbe183ce0 Refactor HandleObjCOwnershipRetainAttr and HandleObjCOwnershipCFRetainAttr into
HandleObjCOwnershipParmAttr. No functionality change (hopefully).

llvm-svn: 70224
2009-04-27 18:41:18 +00:00
Douglas Gregor c504683237 Implement caching of stat() calls for precompiled headers, which is
essentially the same thing we do with pretokenized headers. stat()
caching improves performance of the Cocoa-prefixed "Hello, World" by
45%.

llvm-svn: 70223
2009-04-27 18:38:38 +00:00
Daniel Dunbar 01910a50c4 x86-32 ABI: Fix crash on return of structure with flexible array
member.

Also, spell bitfield more consistently as bit-field.

llvm-svn: 70220
2009-04-27 18:31:32 +00:00
Ted Kremenek ebbef7d0d3 Add new checker-specific attribute 'objc_ownership_cfretain'. This is the same
as 'objc_ownership_cfretain' except that the method acts like a CFRetain instead
of a [... retain] (important in GC modes). Checker support is wired up, but
currently only for Objective-C message expressions (not function calls).

llvm-svn: 70218
2009-04-27 18:27:22 +00:00
Sebastian Redl 21b349d5ea Fill in the C++ status table for exceptions
llvm-svn: 70217
2009-04-27 18:25:15 +00:00
Chris Lattner eeb0569b5a encode the type and decl offsets with 32-bits for entry instead
of 64 bits.  This cuts 400KB off the PCH file for cocoa (7.1 -> 
6.7MB):

Before:

	Record Histogram:
		  Count    # Bits   % Abv  Record Kind
		      1     14296          SOURCE_LOCATION_PRELOADS
		      1   1699598  100.00  SOURCE_LOCATION_OFFSETS
		      1   1870766  100.00  METHOD_POOL
		      1    212988  100.00  SELECTOR_OFFSETS
		      1        88          STATISTICS
		      1       106          SPECIAL_TYPES
		      1  18033788  100.00  IDENTIFIER_TABLE
		      1   1806428  100.00  IDENTIFIER_OFFSET
		      1       170  100.00  TARGET_TRIPLE
		      1       268          LANGUAGE_OPTIONS
		      1   5168252  100.00  DECL_OFFSET
		      1    952700  100.00  TYPE_OFFSET

After:

	Record Histogram:
		  Count    # Bits   % Abv  Record Kind
		      1     14296          SOURCE_LOCATION_PRELOADS
		      1   1699598  100.00  SOURCE_LOCATION_OFFSETS
		      1   1870766  100.00  METHOD_POOL
		      1    212988  100.00  SELECTOR_OFFSETS
		      1        88          STATISTICS
		      1       106          SPECIAL_TYPES
		      1  18033788  100.00  IDENTIFIER_TABLE
		      1   1806428  100.00  IDENTIFIER_OFFSET
		      1       170  100.00  TARGET_TRIPLE
		      1       268          LANGUAGE_OPTIONS
		      1   2584156  100.00  DECL_OFFSET
		      1    476380  100.00  TYPE_OFFSET

llvm-svn: 70216
2009-04-27 18:24:17 +00:00
Chris Lattner 258172e78d add an abbreviation for common PARM_VAR_DECL. All but 9 of the
parm var decls in leopard cocoa.h end up using this abbreviation,
which shrinks the bitcode file by about 50K: 7217736->7167120.

Before:
  Block ID #12 (DECLS_BLOCK):
      Num Instances: 1
         Total Size: 2.23595e+07b/2.79494e+06B/698736W
          % of file: 38.7233
      Num SubBlocks: 0
        Num Abbrevs: 0
        Num Records: 139387
      % Abbrev Recs: 0

After:
  Block ID #12 (DECLS_BLOCK):
      Num Instances: 1
         Total Size: 2.02405e+07b/2.53006e+06B/632516W
          % of file: 35.301
      Num SubBlocks: 0
        Num Abbrevs: 1
        Num Records: 139387
      % Abbrev Recs: 19.2902

llvm-svn: 70199
2009-04-27 07:35:58 +00:00
Chris Lattner 72405d6ec2 fix a couple more places that should be using the DeclCursor instead
of the normal stream cursor.

llvm-svn: 70198
2009-04-27 07:35:40 +00:00
Douglas Gregor 258ae54a5d Load most of the source manager's information lazily from the PCH
file. In particular, only eagerly load source location entries for
files and for the predefines buffer. Other buffers and
macro-instantiation source location entries are loaded lazily.

With the Cocoa-prefixed "Hello, World", we only load 815/26555 source
location entities. This halves the amount of user time we spend in
this "Hello, World" program with -fsyntax-only (down to .007s).

This optimization is part 1 of 2 for the source manager. This
eliminates most of the user time in loading a PCH file. We still spend
too much time initialize File structures (especially in the calls to
stat), so we need to either make the loading of source location
entries for files lazy or import the stat cache from the PTH
implementation.

llvm-svn: 70196
2009-04-27 06:38:32 +00:00
Chris Lattner 1f55182459 split expr/stmt writing out to PCHWriterStmt.cpp
llvm-svn: 70194
2009-04-27 06:20:01 +00:00
Chris Lattner 7099dbc5bc split decl writing out to its own PCHWriterDecl.cpp file.
llvm-svn: 70193
2009-04-27 06:16:06 +00:00
Chris Lattner 9df8a73328 unclone SavedStreamPosition
llvm-svn: 70192
2009-04-27 06:03:19 +00:00
Chris Lattner 8f63ab5385 move attribute reading to PCHReaderDecl.cpp, remove some
extraneous braces.

llvm-svn: 70191
2009-04-27 06:01:06 +00:00
Chris Lattner 1de76db762 read all decls (and attributes and stmts/exprs referenced by the decl)
from the DeclsCursor.

llvm-svn: 70190
2009-04-27 05:58:23 +00:00
Chris Lattner 9c28af0cc5 rename GetStmt -> GetDeclStmt to make it clear that the stmt read
is part of a decl.

llvm-svn: 70189
2009-04-27 05:46:25 +00:00
Chris Lattner f4262539fa change the interface to ReadStmt to force clients to pass a cursor in to read from.
llvm-svn: 70188
2009-04-27 05:41:06 +00:00
Chris Lattner 487412d4db split decl reading out to its own PCHReaderDecl.cpp file.
llvm-svn: 70187
2009-04-27 05:27:42 +00:00
Chris Lattner 92ba5ffdfe split stmt/expr deserialization out to PCHReaderStmt.cpp
llvm-svn: 70186
2009-04-27 05:14:47 +00:00
Chris Lattner 669e32f8c0 rdar://6827200 - [sema] reject statically allocated arrays of interface types
Upgrade "array of interface" warning to an error.  In addition to being a
terrible idea, this crashes codegen.

llvm-svn: 70178
2009-04-27 01:55:56 +00:00
Chris Lattner 9a84589671 Change our silencing of C typedef redefinition handling to what we had
before r69391: typedef redefinition is an error by default, but if
*either* the old or new definition are from a system header, we silence
it.

llvm-svn: 70177
2009-04-27 01:46:12 +00:00
Chris Lattner 6ab8142cb2 remove dead var
llvm-svn: 70174
2009-04-27 01:08:03 +00:00
Chris Lattner e78a6bec89 Set up DeclsCursor.
llvm-svn: 70173
2009-04-27 01:05:14 +00:00
Chris Lattner ccac3a611a add stmt/expr names to BlockInfo block.
llvm-svn: 70172
2009-04-27 00:49:53 +00:00
Chris Lattner 94b38c0ff2 fix a comment by starting stmts/exprs after types and decls.
llvm-svn: 70171
2009-04-27 00:44:11 +00:00
Chris Lattner 35cfb0544a make -Wtypedef-redefinition an extwarn instead of defaulting
to error, doing this breaks too many programs (e.g. Adium).

llvm-svn: 70170
2009-04-27 00:41:01 +00:00
Chris Lattner 6403198468 drop the _ID suffixes from block names.
llvm-svn: 70169
2009-04-27 00:40:25 +00:00
Douglas Gregor 060eaf6520 Turn PCH off by default, yet again. I'm happier about it this time, though
llvm-svn: 70168
2009-04-26 23:15:05 +00:00
Chris Lattner db397b6a32 add the decl names.
llvm-svn: 70167
2009-04-26 22:32:16 +00:00
Chris Lattner 28fa4e6055 make llvm-bcanalyzer dump out PCH files symbolically. We should probably
eventually get an option to turn this off, but it is nice for looking at 
statistics.  For example, the types block now prints:

  Block ID #11 (TYPES_BLOCK_ID):
      Num Instances: 1
         Total Size: 895100b/111888B/27971.9W
          % of file: 1.55801
      Num SubBlocks: 0
        Num Abbrevs: 0
        Num Records: 14899
      % Abbrev Recs: 0

        Code Histogram:
                5478    TYPE_FUNCTION_PROTO
                2683    TYPE_TYPEDEF
                2460    TYPE_POINTER
                2047    TYPE_ENUM
                1553    TYPE_RECORD
                283     TYPE_CONSTANT_ARRAY
                274     TYPE_OBJC_INTERFACE
                76      TYPE_INCOMPLETE_ARRAY
                10      TYPE_VECTOR
                9       TYPE_OBJC_QUALIFIED_ID
                5       TYPE_FUNCTION_NO_PROTO
                5       TYPE_EXT_QUAL
                3       TYPE_TYPEOF_EXPR

llvm-svn: 70166
2009-04-26 22:26:21 +00:00
Douglas Gregor 56930a4b81 Trying turning on PCH by default yet again. We might actually a chance at success now
llvm-svn: 70164
2009-04-26 22:21:26 +00:00
Douglas Gregor 70091b8f43 Some fixes for PCH (de-)serialization of Objective-C AST nodes:
- Deal with the Receiver/ClassInfo shared storage in ObjCMessageExpr
  - Implement PCH support for ImplicitParamDecl
  - Fix the handling of the body of an ObjCMethodDecl
  - Several cast -> cast_or_null fixes
  - Make Selector::getIdentifierInfoForSlot work for 1-argument, NULL
  selectors.
  - Make Selector::getAsString() work with NULL selectors.
  - Fix the names of VisitObjCAtCatchStmt and VisitObjCAtFinallyStmt
  in the PCH reader and writer; these were never getting called.

At this point, all of the pch-test tests pass for C and Objective-C.

llvm-svn: 70163
2009-04-26 22:20:50 +00:00
Eli Friedman 4e2ab55502 Add a bit more handling for declarations like "int a[*]".
llvm-svn: 70162
2009-04-26 21:57:51 +00:00
Sebastian Redl d98ecd615f The mysterious bug turns out to be an incredibly bone-headed mistake.
llvm-svn: 70160
2009-04-26 21:08:36 +00:00
Chris Lattner 9356acecff Adjust to LLVM API changes that went into r70157.
llvm-svn: 70158
2009-04-26 20:59:20 +00:00
Eli Friedman 64fc3c68e5 Fix for PR4079: make sure to construct the member expressions for
offsetof correctly in the presence of anonymous structs/unions.

This could definitely use some cleanup, but I don't really want to mess 
with the anonymous union/struct code.

llvm-svn: 70156
2009-04-26 20:50:44 +00:00
Sebastian Redl a7b98a772c Implement function-try-blocks. However, there's a very subtle bug that I can't track down.
llvm-svn: 70155
2009-04-26 20:35:05 +00:00
Eli Friedman 1c4a175aef Remove getIntegerConstantExprValue in favor of using EvaluateAsInt.
llvm-svn: 70145
2009-04-26 19:19:15 +00:00
Eli Friedman 5cdb8cc267 Minor code cleanup.
llvm-svn: 70144
2009-04-26 19:04:51 +00:00
Steve Naroff eda6d20792 Add PCH read/write support for ObjC statements.
llvm-svn: 70143
2009-04-26 18:52:16 +00:00
Chris Lattner 574428e4db implement PR4077: [Linux kernel] inscrutable error on inline asm input/output constraint mismatch
Before we emitted:

$ clang t.c -S -m64 
llvm: error: Unsupported asm: input constraint with a matching output constraint of incompatible type!

Now we produce:
$ clang t.c -S -m64 
t.c:5:40: error: unsupported inline asm: input with type 'unsigned long' matching output with type 'int'
  asm volatile("foo " : "=a" (a) :"0" (b));
                             ~~~      ~^~

llvm-svn: 70142
2009-04-26 18:22:24 +00:00
Chris Lattner 4c92b51089 in a tied operand, don't copy over the name or constraint string, just the flags.
llvm-svn: 70137
2009-04-26 18:05:25 +00:00
Chris Lattner c16d476b30 pull operands names "[foo]" into ConstraintInfo.
llvm-svn: 70136
2009-04-26 17:57:12 +00:00
Chris Lattner c3f4c7b1c5 pull the constraint string into the ConstraintInfo struct
instead of passing it around in addition to it.

llvm-svn: 70135
2009-04-26 17:19:08 +00:00
Steve Naroff 8d2b49aae3 Make sure we have a code in the node:-)
This fixes all the -emit-pch problems discovered by utils/pch-test.pl.

llvm-svn: 70125
2009-04-26 14:11:39 +00:00
Sebastian Redl 07d6f79f1b Update StmtNodes.def with the new base class of CXXTemporaryObjectExpr
llvm-svn: 70122
2009-04-26 11:30:47 +00:00
Sebastian Redl f79d397081 Make reference class unification in conditional expressions check for validity of the conversion.
llvm-svn: 70121
2009-04-26 11:21:02 +00:00
Torok Edwin c26ed54e06 Add missing include. This fixes the build with gcc 4.3.3.
llvm-svn: 70115
2009-04-26 07:50:14 +00:00
Chris Lattner d9725f7041 change TargetInfo::ConstraintInfo to be a struct that contains
the enum along with some other data.

llvm-svn: 70114
2009-04-26 07:16:29 +00:00
Douglas Gregor 8bdbf3628f Turn off PCH by default, again
llvm-svn: 70113
2009-04-26 05:09:50 +00:00
Douglas Gregor 5b21e96c56 One more crazy try with PCH-by-default
llvm-svn: 70112
2009-04-26 03:59:49 +00:00
Douglas Gregor 2ef5dc4fc6 Make sure to pull in the target builtin records when initialize the AST context, even if we're not going to initialize the __builin_* identifiers
llvm-svn: 70111
2009-04-26 03:57:37 +00:00
Douglas Gregor 1d46a1f8a5 Simple little smoke-test script that tries to build PCH files and then
dump their contents for all of the compilable tests in Clang's
testsuite. All of the tests pass for C, but there are still many
failures for Objective-C.

llvm-svn: 70110
2009-04-26 03:52:11 +00:00
Douglas Gregor 1970d887ab When writing a PCH file, write multiple type and declaration blocks as
necessary and iterate until all types and declarations have been
written. This reduces the Cocoa.h PCH file size by about 4% (since we
don't write types we don't need), and fixes problems where writing a
declaration generates a new type.

This doesn't seem to have any impact on performance either way.

llvm-svn: 70109
2009-04-26 03:49:13 +00:00
Douglas Gregor 32887f0274 Add a new -ast-dump-full option that traverses the translation unit
declaration rather than printing through the HandleTopLevelDecl
action. Using this, one can deserialize an entire PCH file and dump
it.

llvm-svn: 70108
2009-04-26 02:02:08 +00:00
Chris Lattner 44b03a67f8 Split C++ statements out to their own file.
llvm-svn: 70107
2009-04-26 01:42:41 +00:00
Douglas Gregor 58d23997c8 Turn of PCH by default. I got the info I was looking for
llvm-svn: 70106
2009-04-26 01:34:47 +00:00
Chris Lattner f0b64d73a8 split ObjC and C++ Statements out into their own headers.
llvm-svn: 70105
2009-04-26 01:32:48 +00:00
Eli Friedman bd0e67362c Correct the order of the parameters to CheckAssignmentConstraints in
cleanup attribute checking.  The difference isn't normally visible, but it
can make a difference...

llvm-svn: 70104
2009-04-26 01:30:08 +00:00
Daniel Dunbar 885db54671 Make this code a little more generic.
llvm-svn: 70103
2009-04-26 01:28:51 +00:00
Daniel Dunbar 72a6090dc4 Driver: Add -std-default= option.
- This can be used to supply a default value for -std=; the idea is
   that this can be used in conjunction with CCC_ADD_ARGS or
   QA_OVERRIDE_GCC3_OPTIONS to change the default without having to
   modify the build system.

llvm-svn: 70102
2009-04-26 01:10:38 +00:00
Daniel Dunbar 3ba94d8778 Add option for AddAllArgsTranslated to control whether output argument
should be joined or separate.

llvm-svn: 70101
2009-04-26 01:07:52 +00:00
Chris Lattner 7ec71da215 implement PCH support for the rest of ExprObjC.h, including
the missing bits of ObjCMessageExpr.

llvm-svn: 70100
2009-04-26 00:44:05 +00:00
Douglas Gregor 06ccf7a463 Another shot at switching PCH on by default, now that we've cleaned up some bugs and improved performance. Will be reverted after Mr. Speedy gets done with it
llvm-svn: 70099
2009-04-26 00:37:38 +00:00
Anders Carlsson 6f5c15688d When calling the cleanup function specified by __attribute__((cleanup)), make sure to bitcast the argument so it has the same type as the first argument of the cleanup function. Fixes <rdar://problem/6827047>.
llvm-svn: 70098
2009-04-26 00:34:20 +00:00
Douglas Gregor eda6a89c4e Don't read all of the records in the PCH file's preprocessor block,
most of which are ignored. Instead, move the __COUNTER__ value out to
a PCH-level record (since it is handled eagerly) and move the header
file information into the SourceManager block (which is also,
currently, loaded eagerly).

This results in another 17% performance improvement in the
Cocoa-prefixed "Hello, World" with PCH.

llvm-svn: 70097
2009-04-26 00:07:37 +00:00
Eli Friedman ab2784f2c1 Fix for PR4074: allow subscripting non-lvalue arrays in C90 mode.
I wasn't originally going to use this approach, but cases like 
test/Sema/expr-comma.c make things difficult.

llvm-svn: 70096
2009-04-25 23:46:54 +00:00
Chris Lattner 0dedefe4f2 minor cleanups to ast-dump, use getBody(context).
llvm-svn: 70095
2009-04-25 23:31:28 +00:00
Douglas Gregor 99734e7669 Lazily load the controlling macros for all of the headers known in the
PCH file. In the Cocoa-prefixed "Hello, World" benchmark, this takes
us from reading 503 identifiers down to 37 and from 470 macros down to
4. It also results in an 8% performance improvement.

llvm-svn: 70094
2009-04-25 23:30:02 +00:00
Chris Lattner c06ce0f710 "This fixes message sends to super in a way that both works with real code and passes the test in the test suite. It also fixes a crash when using recent versions of GNU libobjc and compiling modules that do not contain any constant strings but do contain a declaration of the constant string class and possible some other corner cases (thanks to Pete French for providing me with a test case for that one)."
Patch by David Chisnall!

llvm-svn: 70093
2009-04-25 23:19:45 +00:00
Chris Lattner 003af24927 minor diagnostics improvements.
llvm-svn: 70092
2009-04-25 22:50:55 +00:00
Eli Friedman 50322773b7 Minor simplification.
llvm-svn: 70091
2009-04-25 22:44:54 +00:00
Eli Friedman 7524de1da2 Change isNullPointerConstant to be strict; hopefully this won't cause
any issues now that we have our own tgmath.h.

llvm-svn: 70090
2009-04-25 22:37:12 +00:00
Eli Friedman bb967cc98d Make VerifyIntegerConstantExpr print extension warnings for non-ICEs.
Overall, I'm not particularly happy with the current situation regarding 
constant expression diagnostics, but I plan to improve it at some point.

llvm-svn: 70089
2009-04-25 22:26:58 +00:00
Eli Friedman 37e663df63 Silence gcc warnings.
llvm-svn: 70086
2009-04-25 22:20:56 +00:00
Chris Lattner c71d08bc22 fix PR4073 by making designated initializer checking code use
VerifyIntegerConstantExpression instead of isIntegerConstantExpr.
This makes it ext-warn but tolerate things that fold to a constant
but that are not valid i-c-e's.

There must be a bug in the i-c-e computation though, because it
doesn't catch this case even with pedantic.

This also switches the later code to use EvaluateAsInt which is
simpler and handles everything that evaluate does.

llvm-svn: 70081
2009-04-25 21:59:05 +00:00
Douglas Gregor 95272494cb Optimize the loading of an identifier from a PCH file when given the
identifier's ID. In this case, we know where the identifier's entry is
located in the hash table (it starts right before the identifier
string itself), so skip the hash table lookup and read the entry
directly. The performance improvement here is, gain, hard to quantify,
but it's the right thing to do.

llvm-svn: 70078
2009-04-25 21:21:38 +00:00
Douglas Gregor 5287b4e8ec PCH optimization for the identifier table, where we separate
"interesting" identifiers (e.g., those where the IdentifierInfo has
some useful information) from "uninteresting" identifiers (where the
IdentifierInfo is just a name). This makes the hash table smaller (so
searching in it should be faster) and, when loading "uninteresting"
identifiers, we skip the lookup in the hash table.

PCH file size is slightly smaller than before (since we don't emit the
contents of the uninteresting IdentifierInfo structures). The
Cocoa.h-prefixed "Hello, World" doesn't show any speedup, although
we're getting to the point where system noise is a bit issue.

llvm-svn: 70075
2009-04-25 21:04:17 +00:00
Douglas Gregor 6b7bf5a771 Revert my changes that try to avoid creating StringMap entries for
identifiers. They don't yet work, but will inhibit future
optimizations.

llvm-svn: 70071
2009-04-25 20:26:24 +00:00
Douglas Gregor 518bd14f2d Start implementing the PTH IdentifierInfo-saving trick in PCH,
allocating IdentifierInfos with a pointer into the string data stored
in the PCH file rather than having an entry in the identifier table's
string map. However, we don't actually get these savings at the
moment, because we go through the IdentifierTable when loading
identifiers from the on-disk hash table.

This commit is for record-keeping purposes only. I'll be reverting
this change (and the PCH layout tweak that preceded it) because it
appears that implementing this optimization will collide with another,
future optimization to reduce the size of the on-disk hash table for
identifiers. That optimization is likely to provide more benefit (with
less voodoo).

llvm-svn: 70070
2009-04-25 20:21:25 +00:00
Chris Lattner a4185c543e fix PR4067: [Linux kernel] cannot aggregate codegen stmtexpr as lvalue
llvm-svn: 70067
2009-04-25 19:35:26 +00:00
Douglas Gregor b3e5f7a7ff Tweak the data layout for the on-disk hash table of identifiers in the PCH file so that the key layout matches that of the PTH key layout
llvm-svn: 70066
2009-04-25 19:25:49 +00:00
Ted Kremenek b62db80c83 Updated checker build.
llvm-svn: 70065
2009-04-25 19:12:36 +00:00
Chris Lattner a69b07636b remove a fixme that is already done.
llvm-svn: 70064
2009-04-25 19:11:05 +00:00
Douglas Gregor 0e14997758 Write the identifier offsets array into the PCH file as a blob, so
that the PCH reader does not have to decode the VBR encoding at PCH
load time.

Also, reduce the size of the identifier offsets from 64 bits down to
32 bits. The identifier table itself isn't going to grow to more than
4GB :)

Overall, this results in a 13% speedup in the Cocoa-prefixed "Hello,
World" benchmark.

llvm-svn: 70063
2009-04-25 19:10:14 +00:00
Chris Lattner b28fe9eae6 improve a diagnostic to make more sense.
llvm-svn: 70062
2009-04-25 18:52:45 +00:00
Chris Lattner 6d7ffe0283 accept an ignore the no_instrument_function attribute. Since we don't
support -pg, we never instrument :)

llvm-svn: 70061
2009-04-25 18:44:54 +00:00
Chris Lattner 49303b2dcb with the fixes for better invalid decl/type propagation, this code
is no longer needed: a function type and a function declarator are
always known to line up.

llvm-svn: 70060
2009-04-25 18:38:18 +00:00
Douglas Gregor 745ed14636 Write the declaration and type offset arrays into the bitstream as
blobs, so that we don't need to do any work to get these arrays into
memory at PCH load time.

This gives another 19% performance improvement to the Cocoa-prefixed
"Hello, World!".

llvm-svn: 70059
2009-04-25 18:35:21 +00:00
Douglas Gregor 95c13f53b3 Load the selector table lazily from the PCH file.
This results in a 10% speedup on the Cocoa-prefixed "Hello, World!",
all of which is (not surprisingly) user time. There was a tiny
reduction in the size of the PCH file for Cocoa.h, because certain
selectors aren't being written twice.

I'm using two new tricks here that I'd like to replicate elsewhere:
  (1) The selectors not used in the global method pool are packed into
  the blob after the global method pool's on-disk hash table and
  stored as keys, so that all selectors are in the same blob.
  (2) We record the offsets of each selector key when we write it into
  the global method pool (or after it, in the same blob). The offset
  table is written as a blob, so that we don't need to pack/unpack a
  SmallVector with its contents.

llvm-svn: 70055
2009-04-25 17:48:32 +00:00
Steve Naroff 62dccd01a2 Fix indexing error in PCHStmtReader::VisitArraySubscriptExpr().
llvm-svn: 70046
2009-04-25 15:19:54 +00:00
Steve Naroff eec4a0a7f1 Add PCH support for ObjCMessageExpr (needed to build Mail).
llvm-svn: 70044
2009-04-25 14:04:28 +00:00
Steve Naroff ac6e6f786b Fixup comment.
llvm-svn: 70040
2009-04-25 12:18:35 +00:00
Steve Naroff 4f2a71bcdb Fix a major bug in PCHReader::ReadSelectorBlock().
Also simplify some syntax in PCHWriter::WritePreprocessor(), suggested by Chris.

llvm-svn: 70039
2009-04-25 12:07:12 +00:00
Chris Lattner edfa8d4557 Change SemaType's "GetTypeForDeclarator" and "ConvertDeclSpecToType" to
always return a non-null QualType + error bit.  This fixes a bunch of 
cases that didn't check for null result (and could thus crash) and eliminates
some crappy code scattered throughout sema.

This also improves the diagnostics in the recursive struct case to eliminate
a bogus second error.  It also cleans up the case added to function.c by forming
a proper function type even though the declarator is erroneous, allowing the
parameter to be added to the function.  Before:

t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*P)
^
t.c:4:3: error: use of undeclared identifier 'P'
  P+1;
  ^

After:
t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*P)
^

llvm-svn: 70023
2009-04-25 08:47:54 +00:00
Chris Lattner b41df4f622 change a couple more c++ sema methods to be based on isinvalid bits.
llvm-svn: 70022
2009-04-25 08:35:12 +00:00
Chris Lattner 38378bf61f various "is invalid" cleanups for C++ ctors/dtors.
llvm-svn: 70021
2009-04-25 08:28:21 +00:00
Chris Lattner f6d1c9c7f0 This is a pretty big cleanup for how invalid decl/type are handle.
This gets rid of a bunch of random InvalidDecl bools in sema, changing
us to use the following approach:

1. When analyzing a declspec or declarator, if an error is found, we 
   set a bit in Declarator saying that it is invalid.
2. Once the Decl is created by sema, we immediately set the isInvalid
   bit on it from what is in the declarator.  From this point on, sema
   consistently looks at and sets the bit on the decl.

This gives a very clear separation of concerns and simplifies a bunch
of code.  In addition to this, this patch makes these changes:

1. it renames DeclSpec::getInvalidType() -> isInvalidType().
2. various "merge" functions no longer return bools: they just set the
   invalid bit on the dest decl if invalid.
3. The ActOnTypedefDeclarator/ActOnFunctionDeclarator/ActOnVariableDeclarator
   methods now set invalid on the decl returned instead of returning an
   invalid bit byref.
4. In SemaType, refering to a typedef that was invalid now propagates the
   bit into the resultant type.  Stuff declared with the invalid typedef
   will now be marked invalid.
5. Various methods like CheckVariableDeclaration now return void and set the
   invalid bit on the decl they check.


There are a few minor changes to tests with this, but the only major bad
result is test/SemaCXX/constructor-recovery.cpp.  I'll take a look at this
next.

llvm-svn: 70020
2009-04-25 08:06:05 +00:00
Douglas Gregor 25d85bcada Revert my PCH change. I'm happy now
llvm-svn: 70018
2009-04-25 07:18:06 +00:00
Douglas Gregor 9e17c07741 Temporarily try to build with PCH by default. Revert this change once
we see what trouble it causes.

llvm-svn: 70017
2009-04-25 06:28:32 +00:00
Chris Lattner 9af40c1e14 fix PR4049, a crash on invalid, by making sema install the right number of
parameters in a functiondecl, even if the decl is invalid and has a confusing
Declarator.  On the testcase, we now emit one beautiful diagnostic:

t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*)
^

GCC 4.0 produces:

t.c:2: error: syntax error before ‘f’
t.c: In function ‘f’:
t.c:2: error: parameter name omitted

and GCC 4.2:

t.c:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘f’

llvm-svn: 70016
2009-04-25 06:12:16 +00:00
Chris Lattner 47c0d00c3f rename getNumParmVarDeclsFromType back to getNumParams(),
remove a special case that was apparently for typeof() and
generalize the code in SemaDecl that handles typedefs to 
handle any sugar type (including typedef, typeof, etc).
Improve comment to make it more clear what is going on.

llvm-svn: 70015
2009-04-25 06:03:53 +00:00
Chris Lattner dfd637f204 add a new helper function to FunctionDecl instead of it being
static in Decl.cpp.

llvm-svn: 70014
2009-04-25 05:56:45 +00:00
Chris Lattner ae4ee5be22 in:
typedef void foo(void);

We get a typedef for a functiontypeproto with no arguments, not
one with one argument and type void.  This means the code being
removed in SemaDecl is dead.

llvm-svn: 70013
2009-04-25 05:51:56 +00:00
Daniel Dunbar 68f1d8ed0c Driver: -mkernel disables default use of unwind tables (although I
don't yet understand where this is happening in llvm-gcc).

llvm-svn: 70012
2009-04-25 05:49:54 +00:00
Chris Lattner 3f863f6827 set NewFD->setInvalidDecl() in one place, sharing code and ensuring that
functions with prototypes get the bit.

llvm-svn: 70011
2009-04-25 05:44:12 +00:00
Daniel Dunbar 11892e951d Driver: -mkernel and -fapple-kext imply -mno-red-zone.
llvm-svn: 70010
2009-04-25 05:33:23 +00:00
Daniel Dunbar ef2ffbc390 Fix pointer addressing and array subscripting of Objective-C interface
types.
 - I broke this in the switch to representing interfaces with opaque
   types.

 - <rdar://problem/6822660> clang crashes on subscript of interface in
   32-bit mode

llvm-svn: 70009
2009-04-25 05:08:32 +00:00
Ted Kremenek e75de95408 Hook up attribute 'objc_ownership_retain' to the analyzer. This attribute allows
users to specify that a method's argument is visibly retained (reference count
incremented).

llvm-svn: 70008
2009-04-25 01:21:50 +00:00
Douglas Gregor f005eac566 Make sure that the consumer sees all interested decls. This fixes Preview
llvm-svn: 70007
2009-04-25 00:41:30 +00:00
Ted Kremenek 2cfd264636 Add new checker-specific attribute 'objc_ownership_retain'. This isn't hooked up
to the checker yet, but essentially it allows a user to specify that an
Objective-C method or C function increments the reference count of a passed
object.

llvm-svn: 70005
2009-04-25 00:17:17 +00:00
Chris Lattner 12bdebbbf7 reject explicit pointer arithmetic on interface pointers in 64-bit objc ABI
llvm-svn: 70004
2009-04-24 23:50:08 +00:00
Douglas Gregor c62a133a38 When we de-serialize an Objective-C protocol, hand it to the AST consumer so that we can create metadata
llvm-svn: 70003
2009-04-24 23:42:14 +00:00
Ted Kremenek b97d093e16 Hook up __attribute__((objc_ownership_returns)) to the retain/release checker.
llvm-svn: 70002
2009-04-24 23:32:32 +00:00
Ted Kremenek 44e662cd4f Add new checker-specific attribute 'objc_ownership_returns'. This isn't hooked
up to the checker yet, but essentially it allows a user to specify that an
Objective-C method or C function returns an owned an Objective-C object.

llvm-svn: 70001
2009-04-24 23:09:54 +00:00
Anders Carlsson defc644e06 Add CXXExprWithCleanup
llvm-svn: 70000
2009-04-24 22:47:04 +00:00
Chris Lattner cd2a8c5864 fix the sizeof error recovery issue (sizeof-interface.m:attributeRuns)
by correctly propagating the fact that the type was invalid up to the
attributeRuns decl, then returning an ExprError when attributeRuns is
formed (like we do for normal declrefexprs).

llvm-svn: 69998
2009-04-24 22:30:50 +00:00
Douglas Gregor 9a1899ba42 Fix a pasto in the lookup of instance methods in the global pool
llvm-svn: 69996
2009-04-24 22:23:41 +00:00
Douglas Gregor 6525578397 Once the protocol list has been loaded from the PCH file, add it to
the Objective-C interface.

llvm-svn: 69993
2009-04-24 22:01:00 +00:00
Ted Kremenek 6a966b2486 Fix the same false positive reported in PR 2542 and <rdar://problem/6793409>
involving an NSAnimation object delegating its release to a delegate method.

llvm-svn: 69992
2009-04-24 21:56:17 +00:00
Douglas Gregor 4647cfac32 Fix two small but very nasty bugs in the PCH writer for method pools:
(1) Make sure to pad on-disk hash tables with 4 bytes, not 2, since
  the reader assumes that bucket data is aligned on 4-byte
  boundaries. 
  (2) Don't emit the number of factory methods twice. This was
  throwing off the data counts and therefore causing lookups to
  fail. I've added asserts so that this class of error cannot happen
  again.

llvm-svn: 69991
2009-04-24 21:49:02 +00:00
Douglas Gregor c78d34699f PCH support for the global method pool (= instance and factory method
pools, combined). The methods in the global method pool are lazily
loaded from an on-disk hash table when Sema looks into its version of
the hash tables.

llvm-svn: 69989
2009-04-24 21:10:55 +00:00
Fariborz Jahanian 969bc68195 Minor refactoring. No intended change in behavior.
llvm-svn: 69988
2009-04-24 21:07:43 +00:00
Steve Naroff 3fa455a1aa Add PCH support for #import.
llvm-svn: 69987
2009-04-24 20:03:17 +00:00
Ted Kremenek 53c5b7e0bd Minor refactoring: pass selector to getCommonMethodSummary(). No functionality
change.

llvm-svn: 69985
2009-04-24 18:19:07 +00:00
Ted Kremenek 6e86cafca3 retain/release checker: more hacks to workaround false positives cause by
delegates. When a reference counted object is passed as to a 'void*' argument to
a method stop tracking the reference count.

llvm-svn: 69984
2009-04-24 18:00:17 +00:00
Ted Kremenek 21895e0b89 Sentence case bug name.
llvm-svn: 69983
2009-04-24 17:51:19 +00:00
Ted Kremenek 8a5ad39a46 retain/release checker:
- Fix summary lookup for class methods to now use the (optional)
  ObjCInterfaceDecl associated with a message expression. This removes a
  long-standing FIXME.
- Partial fix for <rdar://problem/6062730> by stop tracking objects that
  are passed to [NSObject performSelector].  These methods are often used
  for delegates, which the analyzer doesn't reason about well yet.

llvm-svn: 69982
2009-04-24 17:50:11 +00:00
Anders Carlsson 95c56ebfb5 Make CXXTemporaryObjectExpr inherit from CXXConstructExpr.
llvm-svn: 69981
2009-04-24 17:34:38 +00:00
Fariborz Jahanian 1dcb32260a Avoid issuing spurious errors as side-effect of diagnosing
application of sizeof on an interface.

llvm-svn: 69980
2009-04-24 17:34:33 +00:00
Fariborz Jahanian ce567657fd Minor refactoring. No change in functionality.
llvm-svn: 69979
2009-04-24 17:15:27 +00:00
Steve Naroff b87eeaeadf Use cast_or_null instead of ternary operator (suggested by Doug).
llvm-svn: 69975
2009-04-24 16:59:10 +00:00
Fariborz Jahanian a123b64218 Some code clean up of objc2's bitmap layout.
llvm-svn: 69970
2009-04-24 16:17:09 +00:00
Steve Naroff 54b6db1763 Allow the next catoregory slot to be null.
llvm-svn: 69969
2009-04-24 16:08:42 +00:00
Chris Lattner 40493eb6eb fix rdar://6816766 - Crash with function-like macro test at end of directive.
llvm-svn: 69964
2009-04-24 07:15:46 +00:00
Chris Lattner 469fdc6af3 simplification and speedup
llvm-svn: 69963
2009-04-24 07:15:22 +00:00
Anders Carlsson 643e0a40db Fix assert.
llvm-svn: 69961
2009-04-24 06:06:07 +00:00
Anders Carlsson b17a2c3d8f CXXTempVarDecls aren't looked up. Fixes tests.
llvm-svn: 69960
2009-04-24 06:02:55 +00:00
Anders Carlsson a861067029 Add an ASTContext parameter to CXXTemporaryObjectExpr.
llvm-svn: 69959
2009-04-24 05:44:25 +00:00
Anders Carlsson 56c5bd8d23 Add a VarDecl parameter to the CXXTemporaryObjectExpr constructor. It's unused for now, so no functionality change yet. Also, create CXXTempVarDecls to pass to the CXXTemporaryObjectExpr ctor.
llvm-svn: 69957
2009-04-24 05:23:13 +00:00
Anders Carlsson e500faf8c8 Create a CXXConstructExpr instead of a CXXTemporaryObjectExpr in InitializeVarWithConstructor.
llvm-svn: 69956
2009-04-24 05:16:06 +00:00
Douglas Gregor 1011c9a827 Make sure that ObjCCompatibleAlias and ObjCImplementation decls are considered NamedDecls
llvm-svn: 69955
2009-04-24 05:15:35 +00:00
Anders Carlsson 32ebd29b99 Make the CXXConstructExpr public and add a StmtClass to it. No functionality change.
llvm-svn: 69954
2009-04-24 05:04:04 +00:00
Anders Carlsson c5e0337eb2 Move the CXXConstructExpr before the CXXTemporaryObjectExpr so that the temporary object expr can inherit from the construct expr. No functionality change.
llvm-svn: 69953
2009-04-24 04:57:02 +00:00
Daniel Dunbar c1b1b4b2c9 Don't run dsymutil when making a fat executable direct source.
- Otherwise, we will end up with stray .dSYM files which don't get
   lipo'ed or removed.

 - Ideally we would run dsymutil on the result, but we don't have the
   infrastructure for that yet. Note that gcc doesn't handle this case
   either.

 - <rdar://problem/6809621> [driver] clang leaves .dSYM files lying
   around in tmp.

llvm-svn: 69951
2009-04-24 03:03:52 +00:00
Douglas Gregor 38feed810f Eliminate Sema::ObjCAliasDecls. This is based on Steve's fix, but also
updates name lookup so that we see through @compatibility_alias
declarations to their underlying interfaces.

llvm-svn: 69950
2009-04-24 02:57:34 +00:00
Sanjiv Gupta 4742515771 Clang part of r69947. Reverting back 69574 as it is no longer needed.
llvm-svn: 69949
2009-04-24 02:40:57 +00:00
Daniel Dunbar 449354c761 Add a test case for a somewhat obscure scenario.
llvm-svn: 69947
2009-04-24 02:38:10 +00:00
Douglas Gregor ac3531247f Fix Objective-C crashes
llvm-svn: 69945
2009-04-24 02:15:36 +00:00
Daniel Dunbar a2666fefd8 We don't accept this test anymore in a non-fragile ABI.
llvm-svn: 69944
2009-04-24 02:11:35 +00:00
Chris Lattner 62975a788e Fix rdar://6821047 - clang crashes on subscript of interface in 64-bit mode
Several changes here:
1. We change Type::isIncompleteType to realize that forward declared 
   interfaces are incomplete.  This eliminate special case code for this
   from the sizeof path, and starts us rejecting P[4] when P is a pointer
   to an incomplete interface.
2. Explicitly reject P[4] when P points to an interface in non-fragile ABI
   mode.
3. Switch the sizeof(interface) diagnostic back to an error instead of a 
   warning in non-fragile abi mode.

llvm-svn: 69943
2009-04-24 00:30:45 +00:00
Douglas Gregor ac345a3990 Eliminate Sema::ObjCInterfaceDecls
llvm-svn: 69942
2009-04-24 00:16:12 +00:00
Douglas Gregor 79947a24e6 Eliminate Sema::ObjCImplementations, relying instead on name lookup. What's good for uniformity is good for PCH (or is it the other way around?).
As part of this, make ObjCImplDecl inherit from NamedDecl (since
ObjCImplementationDecls now need to have names so that they can be
found). This brings ObjCImplDecl very, very close to
ObjCContainerDecl; we may be able to merge them soon.

llvm-svn: 69941
2009-04-24 00:11:27 +00:00
Ted Kremenek 9099126795 Update checker build.
llvm-svn: 69940
2009-04-23 23:42:21 +00:00
Douglas Gregor de9f17e943 Eliminate Sema::ObjCProtocols. Instead, we place ObjCProtocolDecls in
their own namespace (IDNS_Protocol) and use the normal name-lookup
routines to find them. Aside from the simplification this provides
(one less DenseMap!), it means that protocols will be lazily
deserialized from PCH files.

Make the code size of the selector table block match the code size of
the type and decl blocks.

llvm-svn: 69939
2009-04-23 23:18:26 +00:00
Daniel Dunbar 838cbe19b7 Call ld, not collect2.
- <rdar://problem/6517382> [driver] call ld directly

llvm-svn: 69938
2009-04-23 23:17:23 +00:00
Ted Kremenek 60746a0a83 Refactor common logic in getMethodSummary() and getClassMethodSummary(). No
functionality change.

llvm-svn: 69936
2009-04-23 23:08:22 +00:00
Douglas Gregor f6c2a27e16 PCH support for categories in Objective-C interfaces.
llvm-svn: 69933
2009-04-23 22:34:55 +00:00
Douglas Gregor 512b077803 PCH support for all of the predefined Objective-C types, such as id,
SEL, Class, Protocol, CFConstantString, and
__objcFastEnumerationState. With this, we can now run the Objective-C
methods and properties PCH tests.

llvm-svn: 69932
2009-04-23 22:29:11 +00:00
Ted Kremenek 37467813c5 Further cleanups to isTrackedObjectType().
llvm-svn: 69929
2009-04-23 22:11:07 +00:00
Fariborz Jahanian 6f0f25b0d8 Diagnose if an implementation implements a forward class
declaration (and avoid issuing bogus error later on).

llvm-svn: 69928
2009-04-23 21:49:04 +00:00
Ted Kremenek 0a1f9c423f retain/release checker: Don't call isTrackedObject() with the canonical type.
This was preventing the checker from tracking return objects referenced by 'id'.

llvm-svn: 69922
2009-04-23 21:25:57 +00:00
Ted Kremenek d6ed5b7376 Temporarily remove expected warnings.
llvm-svn: 69917
2009-04-23 20:03:52 +00:00
Ted Kremenek b2f419dc88 retain/release checker: For class methods, only treat return values that are
object references as tracked objects.

llvm-svn: 69915
2009-04-23 20:02:30 +00:00
Chris Lattner 310c921944 accept and ignore -Wconversion
llvm-svn: 69914
2009-04-23 19:54:39 +00:00
Ted Kremenek f27110fc27 Per discussions with Ken Ferry and Paul Marks (<rdar://problem/6815234>) greatly
extend the number of objects tracked by the retain/release checker by assuming
that all class and instance methods should follow Cocoa object "getter" and
"alloc/new" conventions.

llvm-svn: 69908
2009-04-23 19:11:35 +00:00
Douglas Gregor 89c8e000cf Fix handling of C99 "extern inline" semantics when dealing with
multiple declarations of the function. Should fix PR3989 and
<rdar://problem/6818429>.

llvm-svn: 69905
2009-04-23 18:22:55 +00:00
Devang Patel a6acb390e7 Handle corner case where clang-cc is invoked directly to compile preprocessed source file without -main-file-name. In this case, CDDebugInfo is not able identify correct main source file becase SM.isFromMainFile() returns true for locations from header files as well as locations from main source file.
This patch takes conservative approach by not emitting more then one compile unit with isMain bit set.

llvm-svn: 69902
2009-04-23 18:09:16 +00:00
Ted Kremenek 9c03f68206 Fix PR 4033: the analyzer shouldn't crash on computed gotos involving symbolic
target addresses.

llvm-svn: 69900
2009-04-23 17:49:43 +00:00
Steve Naroff 0ee66aa32d Remove @compatibility_alias regression.
llvm-svn: 69899
2009-04-23 17:46:47 +00:00
Ted Kremenek 3ebc5057ac BugReporter (extensive diagnostics): Recursively adjust the referred expression
when popping location contexts.

llvm-svn: 69898
2009-04-23 16:44:22 +00:00
Chris Lattner d87f6e55ee Fix rdar://6819438 - -Wmissing-noreturn not recognised by clang,
by accepting and ignoring it for now.

llvm-svn: 69897
2009-04-23 16:38:59 +00:00
Fariborz Jahanian 80672fce8f Removed bunch of FIXMEs no longer needed.
llvm-svn: 69896
2009-04-23 16:27:20 +00:00
Ted Kremenek e60809c31d BugReporter (extensive diagnostics): Ignore parentheses when added control-flow
pieces for location contexts.

llvm-svn: 69895
2009-04-23 16:19:29 +00:00
Steve Naroff 0cbba990d7 More PushOnScopeChain() FIXME's.
llvm-svn: 69894
2009-04-23 16:00:56 +00:00
Steve Naroff 3c301dc573 Sema::ActOnStartClassInterface(): Use PushOnScopeChains().
This enables class recognition to work with PCH. I believe this means we can remove Sema::ObjCInterfaceDecls and it's usage within Sema::LookupName(). Will investigate.

llvm-svn: 69891
2009-04-23 15:15:40 +00:00
Steve Naroff 2ddea05bca Add PCH read/write support for Objective-C Selectors.
Note: This support is non-lazy. Once we get "Cocoa.h" humming, we can optimize this.
llvm-svn: 69884
2009-04-23 10:39:46 +00:00
Daniel Dunbar f0a8344bac Mark IMAGE_INFO as constant on x86_64-darwin.
- This shouldn't change anything, we never actually access it, but
   this is consistent with llvm-gcc (and 32-bit)

llvm-svn: 69880
2009-04-23 08:03:21 +00:00
Chris Lattner 324f80b12a fix a problem producing debug info with global blocks.
llvm-svn: 69875
2009-04-23 07:18:56 +00:00
Daniel Dunbar 4645707034 Add implicit definition of objc_msgSend.
- As with malloc and friends, this is important where the return type
   on a 64-bit platform would otherwise end up discarding the upper
   32-bits.

llvm-svn: 69874
2009-04-23 07:00:09 +00:00
Chris Lattner 7b0344f656 implement debug info for _Complex.
llvm-svn: 69873
2009-04-23 06:13:01 +00:00
Chris Lattner 28ec0cf86c the logic for computing __func__ and friends is really broken:
the type assigned by sema (and is visible with sizeof(__func__) for
example) has nothing to do with what codegen ends up producing.
We should eventually add a method on PredefinedExpr to handle this.
In the meantime, just set up some framework and add some fixme's.

llvm-svn: 69872
2009-04-23 05:30:27 +00:00
Chris Lattner f718110ae5 remove some gone files
llvm-svn: 69871
2009-04-23 05:29:03 +00:00
Daniel Dunbar dec9e1ec5e Don't build error/warning/assertion detection in the testing script.
- This wasn't actually all that useful and isn't worth the extra
   (hard)code.

llvm-svn: 69869
2009-04-23 05:03:44 +00:00
Chris Lattner 0dc102624f some arm triples have weird characters in them, just fuzzy match
on armv* to be more compatible

llvm-svn: 69864
2009-04-23 04:22:04 +00:00
Chris Lattner 16ce381f37 Silence warnings about common forms of -Wstrict-aliasing etc.
llvm-svn: 69861
2009-04-23 04:12:10 +00:00
Douglas Gregor 515b505c3e PCH (de-)serialization of the protocols in an ObjCInterfaceDecl
llvm-svn: 69860
2009-04-23 03:59:07 +00:00
Douglas Gregor 0ebb9964f9 Add the PCH reader stub for ObjCCompatibleAliasDecl
llvm-svn: 69859
2009-04-23 03:51:49 +00:00
Douglas Gregor 49e72fb870 PCH support for ObjCPropertyImplDecl
llvm-svn: 69858
2009-04-23 03:43:53 +00:00
Douglas Gregor 5f66205233 The ivars in an ObjCImplementationDecl are now stored in the
DeclContext rather than in a separate list. This makes PCH
(de-)serialization trivial, so that ivars can be loaded lazily.

llvm-svn: 69857
2009-04-23 03:23:08 +00:00
Douglas Gregor 510fd8dff1 PCH support for ObjCCategoryImplDecl (which can't be tested now).
llvm-svn: 69856
2009-04-23 02:53:57 +00:00
Douglas Gregor 9a13efd5b2 PCH (de-)serialization for ObjCImplDecl. This can't be tested yet.
llvm-svn: 69855
2009-04-23 02:42:49 +00:00
Anders Carlsson 0781ce7cce Add a CXXConstructExpr that represents an implicit call to a C++ constructor. I think CXXTemporaryObjectExpr is going to become a subclass of CXXConstructExpr, since CXXTemporaryObjectExpr represents a syntactic temporary, for example T()
llvm-svn: 69854
2009-04-23 02:32:43 +00:00
Daniel Dunbar 22b0ada8cf Use std::sort instead of qsort.
- Notably, there was a memory error here, SkipIvars does not have to
   be the same size as IvarsInfo.

 - Fariborz, please check.

llvm-svn: 69850
2009-04-23 01:29:05 +00:00
Douglas Gregor 29bd76fd04 Eliminate the three SmallVectors in ObjCImplDecl (for instance
methods, class methods, and property implementations) and instead
place all of these entities into the DeclContext.

This eliminates more linear walks when looking for class or instance
methods and should make PCH (de-)serialization of ObjCDecls trivial
(and lazy).

llvm-svn: 69849
2009-04-23 01:02:12 +00:00
Douglas Gregor 85e110828e PCH support for Objective-C property declarations (UNTESTED!)
llvm-svn: 69843
2009-04-22 23:20:34 +00:00
Fariborz Jahanian 6df69867c3 ivar layout bitmap is alive!
llvm-svn: 69838
2009-04-22 23:00:43 +00:00
Douglas Gregor a57c3abf37 Add PCH statistics for the number/percent of lexical/visible declcontexts read
llvm-svn: 69835
2009-04-22 22:34:57 +00:00
Ted Kremenek 63e29cc99c Add PathDiagnosticRange to PathDiagnostics. These simply wrap SourceRange and
indicate whether or not the range represents an absolute range or should be
extended by lexing to the end of the token.

llvm-svn: 69834
2009-04-22 22:26:10 +00:00
Douglas Gregor acfc76cc63 Support locally-declared external declarations in PCH files
llvm-svn: 69833
2009-04-22 22:18:58 +00:00
Douglas Gregor 2e43ab535b Clean up and de-XFAIL-ify PCH test for external definitions
llvm-svn: 69831
2009-04-22 22:09:39 +00:00
Chris Lattner 91cb0eea67 remove obsolete tests.
llvm-svn: 69830
2009-04-22 22:06:26 +00:00
Douglas Gregor d4df8657b4 Support tentative definitions in precompiled headers. This isn't likely
to happen (ever), but at least we'll do the right thing when it does.

llvm-svn: 69829
2009-04-22 22:02:47 +00:00
Douglas Gregor 48db39dc90 Remove the serialization code that predates precompiled
headers. Future approaches to (de-)serializing ASTs will be based on
the PCH infrastructure.

llvm-svn: 69828
2009-04-22 21:45:53 +00:00
Douglas Gregor 7cd60f7be3 Eliminate some FIXMEs in the PCH reader that were either already fixed or aren't actually things to fix
llvm-svn: 69827
2009-04-22 21:15:06 +00:00
Douglas Gregor fedd428d04 Eliminate Sema::KnownFunctionIDs, so that Sema doesn't end up pulling
in a bunch of declarations from the PCH file. We're down to loading
very few declarations in Carbon-prefixed "Hello, World!":

*** PCH Statistics:
  6/20693 types read (0.028995%)
  7/59230 declarations read (0.011818%)
  50/44914 identifiers read (0.111324%)
  0/32954 statements read (0.000000%)
  5/6187 macros read (0.080815%)

llvm-svn: 69825
2009-04-22 20:56:09 +00:00
Ted Kremenek 48b7875e55 BugReporter (extensive diagnostics): Use correct location for location contexts.
llvm-svn: 69824
2009-04-22 20:51:59 +00:00
Ted Kremenek fb05406cef BugReporter (extensive diagnostics): always add an edge if there is no location
context.

llvm-svn: 69823
2009-04-22 20:36:26 +00:00
Eli Friedman d3a5a9d7fa Add handling for complex->int, int->complex float, and float->complex
int.  Note that constant int->complex float and float->complex int casts
were being miscompiled.

llvm-svn: 69821
2009-04-22 19:23:09 +00:00
Douglas Gregor b985eebcdf Minimize the number and kind of "external definitions" that the PCH
file needs to store. CodeGen needs to see these definitions (via
HandleTopLevelDecl), otherwise it won't be able to generate code for
them. 

This patch notifies the consumer (e.g., CodeGen) about function
definitions and variable definitions when the corresponding
declarations are deserialized. Hence, we don't eagerly deserialize the
declarations for every variable or function that has a definition in
the PCH file. This gives another 5% speedup for the Carbon-prefixed
"Hello, World!", and brings our PCH statistics down to something far
more reasonable:

*** PCH Statistics:
  13/20693 types read (0.062823%)
  17/59230 declarations read (0.028702%)
  54/44914 identifiers read (0.120230%)
  0/32954 statements read (0.000000%)
  5/6187 macros read (0.080815%)

llvm-svn: 69820
2009-04-22 19:09:20 +00:00
Chris Lattner 63660175f8 Add missing dependency, patch by Jason Haslam!
llvm-svn: 69819
2009-04-22 18:59:57 +00:00
Douglas Gregor 4621c6ae15 Lazy loading of builtins for precompiled headers.
PCH files now contain complete information about builtins, including
any declarations that have been synthesized as part of building the
PCH file. When using a PCH file, we do not initialize builtins at all;
when needed, they'll be found in the PCH file.

This optimization translations into a 9% speedup for "Hello, World!"
with Carbon.h as a prefix header and roughly a 5% speedup for 403.gcc
with its prefix header. We're also reading less of the PCH file for
"Hello, World!":

*** PCH Statistics:
  286/20693 types read (1.382110%)
  1630/59230 declarations read (2.751984%)
  764/44914 identifiers read (1.701029%)
  1/32954 statements read (0.003035%)
  5/6187 macros read (0.080815%)

down from

*** PCH Statistics:
  411/20693 types read (1.986179%)
  2553/59230 declarations read (4.310316%)
  1093/44646 identifiers read (2.448148%)
  1/32954 statements read (0.003035%)
  21/6187 macros read (0.339421%)

llvm-svn: 69815
2009-04-22 18:49:13 +00:00
Ted Kremenek 6c867a1460 BugReporter (extensive diagnostics):
- Remove stale assertion that was breaking the test suite.
- When popping location contexts, only add a control-flow piece for fileID
  locations.

llvm-svn: 69814
2009-04-22 18:37:42 +00:00
Ted Kremenek 0752a5dff3 BugReporter (extensive diagnostic algorithm): The initial control-flow edge now
starts from the first character of the first statement.

llvm-svn: 69813
2009-04-22 18:16:20 +00:00
Ted Kremenek 22579c4c8f PathDiagnosticLocation: ranges for terminators now only include the first
character instead of the entire range for the IfStmt, ForStmt, etc. We may
gradually refine these ranges later, but basically terminator ranges just refer
to the first keyword.

llvm-svn: 69812
2009-04-22 18:03:00 +00:00
Daniel Dunbar e4f25b706b Reapply r69771, with updates & fixes:
Rework the shadow struct that is layed out for Objective-C classes.

 - Superclasses are now always laid out in their shadow structure at
   the first field.

 - Prior to this, the entire class heirarchy was flattened into a
   single structure which meant that alignment, padding, and bitfields
   were incorrect (the ASTRecordLayout was correct however, which
   meant our debug info didn't coincide with ivar offsets, for
   example).

 - This is still very suboptimal (for example, ivar are looked up
   recursively, but I believe the ivar layout itself is now at least
   close to correct.

 - <rdar://problem/6773388> error: objc[29823]: layout bitmap sliding
   backwards

llvm-svn: 69811
2009-04-22 17:43:55 +00:00
Douglas Gregor 3d48e3d6f5 Remove some debugging output from the PCH reader
llvm-svn: 69803
2009-04-22 14:18:52 +00:00
Ted Kremenek 9ebfe91dea ccc-analyzer: Don't create preprocessed files about the ignored 'cdecl' attribute. We know Clang doesn't support it yet.
llvm-svn: 69802
2009-04-22 13:42:27 +00:00
Daniel Dunbar 202f3dc5b3 Remove lookupFieldDeclFromIvar from ObjCIvarDecl interface.
- This is only used by CGObjCRuntime now.

llvm-svn: 69800
2009-04-22 12:00:04 +00:00
Daniel Dunbar 24579842a5 Simplify addRecordToClass, it is not legal to call it on a forward
declaration now.

llvm-svn: 69799
2009-04-22 10:56:29 +00:00
Daniel Dunbar 7d4e1c5e4a Don't convert interface types (to structs) as part of CodeGenTypes.
- This has pros and cons, but for now the pros seem to significantly
   outway the con.

The con is that we will always need to cast in the runtime
implementation to a struct type, if we wish to access an interface
directly.

The pros are:
 - Avoid the cost of generating types which are used. Most
   manipulation of Objective-C objects is done through messages, and
   only the implementation of a class will directly access
   memory. Previously, we would convert the type even if it only
   appear as a function parameter, for example.

 - We don't need to worry about incomplete types, and
   UpdateCompletedType for interfaces is gone.

 - It becomes easier to narrow the interface to the shadow struct for
   Objective-C interfaces (so it can be eliminated).

Currently the runtimes still use the CodeGenTypes machinery to
generate the LLVM structure they need via ConvertTagDecl, but this can
eventually be replaced.

llvm-svn: 69797
2009-04-22 10:28:39 +00:00
Daniel Dunbar 7b4dfc8b78 Add CGObjCRuntime::GetConcreteClassStruct to encapsulate access to the
underlying llvm::StructType for an interface.

llvm-svn: 69796
2009-04-22 09:39:34 +00:00
Daniel Dunbar 66cb01313b Add another workaround for -include.
- If we don't find a file looking relative to the current working
   directory, fall back to header search. This is closer to what would
   happen if the lookup was starting from right directory in the first
   place (except it will find files in the directory of the main
   source file, which I *think* should not be found).

 - PR3992.

llvm-svn: 69794
2009-04-22 08:53:01 +00:00
Daniel Dunbar 83a66f78d2 Simplify.
llvm-svn: 69793
2009-04-22 08:50:59 +00:00
Daniel Dunbar 725dc2c5bb Emit meta data using the Ivar, not a looked up FieldDecl.
llvm-svn: 69790
2009-04-22 08:22:17 +00:00
Daniel Dunbar 89623deca1 Use ComputeIvarBaseOffset instead of looking up by hand.
llvm-svn: 69789
2009-04-22 08:20:31 +00:00
Daniel Dunbar 9fd114d577 Merge ivar access amongst the three runtimes.
- For now, this means we are always doing the address computations by
   hand instead of constructing a proper GEP. Right now, however, this
   is less important than having fewer entry points to dealing with
   Objective-C interface layout.

llvm-svn: 69787
2009-04-22 07:32:20 +00:00
Daniel Dunbar 6067720a41 Make sure this test runs on all 3 Objective-C implementations.
llvm-svn: 69786
2009-04-22 07:28:06 +00:00
Chris Lattner 43e6f8c08b implement debug info support for id<proto> and interface<proto>
llvm-svn: 69784
2009-04-22 06:58:56 +00:00
Chris Lattner ad8f750f71 ObjCQualifiedClass is dead, remove it.
llvm-svn: 69783
2009-04-22 06:50:37 +00:00
Chris Lattner 587cbe1ef2 deserialization support for qualified interfaces
llvm-svn: 69782
2009-04-22 06:45:28 +00:00
Chris Lattner 6e054afc9e pch support for protocol qualified id's.
llvm-svn: 69781
2009-04-22 06:40:03 +00:00
Chris Lattner 8f0734972b add three new objc expression types. @selector doesn't work because we have no
way to serialize selectors yet.

llvm-svn: 69780
2009-04-22 06:29:42 +00:00
Chris Lattner 19cea4eeb4 implement serialization support for @encode,
fix a couple of bugs in reader support for ObjCInterfaceDecl,
and add support for reading ObjCInterfaceType.

llvm-svn: 69779
2009-04-22 05:57:30 +00:00
Chris Lattner 01146a5fa9 rename methods.* -> objc_methods.*
llvm-svn: 69778
2009-04-22 05:31:53 +00:00
Chris Lattner dc00437fa0 change implicit int warnings to point to the identifier, not the
start of the declspec.  The fixit still goes there, and we underline
the declspec.  This helps when the start of the declspec came from a
macro that expanded from a system header.  For example, we now produce:

t.c:2:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
static x;
~~~~~~ ^

llvm-svn: 69777
2009-04-22 05:27:59 +00:00
Ted Kremenek 9dae596dc1 Update checker build.
llvm-svn: 69776
2009-04-22 05:13:56 +00:00
Daniel Dunbar 722f424178 Make ObjCInterfaceDecl's const in some more places.
llvm-svn: 69775
2009-04-22 05:08:15 +00:00
Douglas Gregor f89771cb87 Reorganize built-in initialization to separate the creation of target builtins from marking IdentifierInfos as builtins. No functionality change
llvm-svn: 69774
2009-04-22 04:56:28 +00:00
Daniel Dunbar 658ba85820 Revert r69771, I missed some (obvious) details. :/
llvm-svn: 69773
2009-04-22 04:39:47 +00:00
Daniel Dunbar aefc2b9be3 Mark another TypeForDecl const and make getObjCInterfaceType's argument const.
llvm-svn: 69772
2009-04-22 04:34:53 +00:00
Daniel Dunbar 25b81ef847 Rework the shadow struct that is layed out for Objective-C classes.
- Superclasses are now always laid out their shadow structure at the
   first field.

 - Prior to this, the entire class heirarchy was flattened into a
   single structure which meant that alignment, padding, and bitfields
   weren't packed correctly (the ASTRecordLayout was correct however,
   which meant our debug info didn't coincide with ivar offsets, for
   example).

 - This is still very suboptimal, but I believe the ivar layout itself
   is now at least close to correct.

 - <rdar://problem/6773388> error: objc[29823]: layout bitmap sliding
   backwards

llvm-svn: 69771
2009-04-22 03:45:12 +00:00
Chris Lattner ed462a8d44 Fix rdar://6814950 - stdint.h isn't "-pedantic -std=c89" clean,
by marking the predefines buffer as a system header.  The problem 
with stdint is that it was getting problems like this:

/Volumes/Projects/cvs/llvm/Debug/lib/clang/1.0/include/stdint.h:43:9: warning: 'long long' is an extension when C99 mode is not enabled
typedef __INT64_TYPE__ int64_t;
        ^
<built-in>:73:29: note: instantiated from:
#define __INT64_TYPE__ long long
                            ^

We correctly silence warnings in system headers, but only if the 
spelling location of the token came from the system header.  This is
designed so that if you use a system macro in your code that you don't
get punished for its definition.  This is all cool except that the 
predefines buffer wasn't considered a system header.

llvm-svn: 69770
2009-04-22 03:42:19 +00:00
Chris Lattner 2dfdb3ea94 move 64-bit abi functions to lazy model, everything is lazy now, yay.
llvm-svn: 69767
2009-04-22 02:53:24 +00:00
Chris Lattner ce8754edac remove the last of the non-lazy objc runtime functions for the 32-bit ABI,
7 left for 64-bit ABI.

llvm-svn: 69766
2009-04-22 02:44:54 +00:00
Chris Lattner 0a696a42fe number of non-lazy runtime functions from 9 -> 4.
llvm-svn: 69765
2009-04-22 02:38:11 +00:00
Chris Lattner 095ac38f1c make message send functions lazy, we're down from 14 non-lazy functions to 9.
llvm-svn: 69764
2009-04-22 02:32:31 +00:00
Chris Lattner c6406dbf7f move more EH stuff to being lazily created. An empty .m file now
produces just 14 dead "declares" in llvm ir instead of 19.

llvm-svn: 69763
2009-04-22 02:26:14 +00:00
Chris Lattner a7c00b4c4c make try/catch objc runtime functions be lazily generated.
rdar://6809612

llvm-svn: 69762
2009-04-22 02:15:23 +00:00
Chris Lattner d27f8d8c9f rename test
llvm-svn: 69761
2009-04-22 00:59:27 +00:00
Chris Lattner 934074cd5f Fix a problem with objc foreach loop. It turns out that objc mode changes
for scoping to match C99 even when in C89 mode.  This patch fixes this 
(eliminating a "redefinition of thisKey" error), and also prevents non-sensical
diagnostics in -pedantic mode like this:

t.m:7:8: warning: variable declaration in for loop is a C99-specific feature
  for (id thisKey in keys) ;
       ^

llvm-svn: 69760
2009-04-22 00:54:41 +00:00
Douglas Gregor 3ddc876758 Test PCH support for VLAs
llvm-svn: 69758
2009-04-22 00:21:21 +00:00
Douglas Gregor 13d247f7ec Eliminate a FIXME in one of the PCH test cases
llvm-svn: 69757
2009-04-22 00:17:41 +00:00
Chris Lattner f8dc07369a Fix some mishandling of the attr(gnu_inline) mode when used with
extern.  Previously we would warn about it and ignore the attribute.
This is incorrect, it should be handled as a c89 "extern inline" 
function.  Many thanks to Matthieu Castet for pointing this out and
beating me over the head until I got it.

PR3988: extern inline function are not externally visible
llvm-svn: 69756
2009-04-22 00:03:30 +00:00
Douglas Gregor c3366a555b Lazy deserialization of macro definitions for precompiled headers.
This optimization improves performance on the Carbon-prefixed "Hello,
World!" example by 57%. For reference, we're now about 2.25x faster
than GCC PCH. We're also pulling in far less of the PCH file:

*** PCH Statistics:
  411/20693 types read (1.986179%)
  2553/59230 declarations read (4.310316%)
  1093/44646 identifiers read (2.448148%)
  1/32954 statements read (0.003035%)
  21/6187 macros read (0.339421%)

llvm-svn: 69755
2009-04-21 23:56:24 +00:00
Ted Kremenek fe95afd0bc Fix crash reported in PR 3991. The analyzer doesn't reason about ObjCKVCExpr.
llvm-svn: 69754
2009-04-21 23:53:32 +00:00
Steve Naroff dd9aba001d Update Xcode project with recently added files.
llvm-svn: 69753
2009-04-21 23:46:12 +00:00
Ted Kremenek eff7c6a2d6 This patch is largely due to Zhongxing Xu. I've simply applied it because of
some refactoring I did recently to StoreManager.

StoreManager::CastRegion: Handle casts to void* by stripping TypedViewRegions.

llvm-svn: 69751
2009-04-21 23:31:46 +00:00
Chris Lattner ca515ccb49 apply Eli's patch to fix PR4008, with a testcase. Thanks Eli!
llvm-svn: 69750
2009-04-21 23:28:41 +00:00
Mike Stump 3cfd5614e7 Resolve merge conflict better.
llvm-svn: 69748
2009-04-21 23:03:34 +00:00
Chris Lattner 2f343dd5c8 fix PR4026: Clang can't codegen __func__ without implicit cast
llvm-svn: 69747
2009-04-21 23:00:09 +00:00
Mike Stump d79b5a85b0 Tighten up blocks type checking. This was discussed back in the
r56595 timeframe, but left undone.  Radar 6812711

llvm-svn: 69745
2009-04-21 22:51:42 +00:00
Douglas Gregor 195e9c5d18 Lazy deserialization of identifiers in PCH files fixed a problem with
name lookup of structures declared within other structures.

llvm-svn: 69744
2009-04-21 22:48:38 +00:00
Chris Lattner 41b8694777 Fix rdar://6814047, a crash on invalid in blocks code I noticed when
working on the previous fix.

llvm-svn: 69742
2009-04-21 22:38:46 +00:00
Ted Kremenek 35f875c136 Fix: <rdar://problem/6777209> false Dereference of null pointer in loop: pointer increment/decrement preserves non-nullness
When the StoreManager doesn't reason well about pointer-arithmetic, propagate
the non-nullness constraint on a pointer value when performing pointer
arithmetic uisng ++/--.

llvm-svn: 69741
2009-04-21 22:38:05 +00:00
Ted Kremenek 1a1b62c168 Tweak pretty-printing of constraints.
llvm-svn: 69740
2009-04-21 22:37:11 +00:00
Douglas Gregor b475a5ca95 Don't bother writing a visible-declarations record for the translation
unit into the PCH file, since we won't be performing name lookup into
it anyway. Reduces the size of the Carbon.h PCH file by ~200k.

llvm-svn: 69739
2009-04-21 22:32:33 +00:00
Chris Lattner 497d7b0c8a fix marking of nested blocks with the "hasBlockDeclRefExprs" to
mark exactly the blocks which have references that are "live through".
This fixes a rejects valid: 
rdar://6808730 - [sema] [blocks] block rejected at global scope

llvm-svn: 69738
2009-04-21 22:26:47 +00:00
Douglas Gregor a868bbd392 Lazy deserialization of the declaration chains associated with
identifiers from a precompiled header.

This patch changes the primary name lookup method for entities within
a precompiled header. Previously, we would load all of the names of
declarations at translation unit scope into a large DenseMap (inside
the TranslationUnitDecl's DeclContext), and then perform a special
"last resort" lookup into this DeclContext when we knew there was a
PCH file (see Sema::LookupName). Now, when we see an identifier named
for the first time, we load all of the declarations with that name
that are visible from the translation unit into the IdentifierInfo's
chain of declarations. Thus, the explicit "look into the translation
unit's DeclContext" code is gone, and Sema effectively uses the same
IdentifierInfo-based name lookup mechanism whether we are using a PCH
file or not. 

This approach should help PCH scale with the size of the input program
rather than the size of the PCH file. The "Hello, World!" application
with Carbon.h as a PCH file now loads 20% of the identifiers in the
PCH file rather than 85% of the identifiers. 

90% of the 20% of identifiers loaded are actually loaded when we
deserialize the preprocessor state. The next step is to make the
preprocessor load macros lazily, which should drastically reduce the
number of types, declarations, and identifiers loaded for "Hello,
World".

llvm-svn: 69737
2009-04-21 22:25:48 +00:00
Chris Lattner 1f9183c7ca this is a warning now, return a well formed ast.
llvm-svn: 69731
2009-04-21 22:00:54 +00:00
Ted Kremenek 2d495a6f43 Refactor 'BasicStoreManager::CastRegion' and 'RegionStoreManager::CastRegion'
into StoreManager::CastRegion. Both methods were practically identical, and this
is core logic that is common to all StoreManagers since it defines the basic
invariants of the abstract memory model.

llvm-svn: 69730
2009-04-21 21:51:34 +00:00
Chris Lattner 6750113d54 force a 32-bit triple.
llvm-svn: 69729
2009-04-21 21:42:41 +00:00
Daniel Dunbar d1148a7f72 Make sure to mark the interface as completed when we see an
@implementation that closes a @class delcaration.
 - I don't know how to make a test case for this, but this strengthens
   the invariants that hold internally. The functionality change here
   is the edit to SemaDeclObjC.cpp.

llvm-svn: 69728
2009-04-21 21:41:56 +00:00
Daniel Dunbar d361c345c6 Force triple (test case fails for platforms with the non-fragile ABI).
llvm-svn: 69727
2009-04-21 21:17:29 +00:00
Daniel Dunbar 46285d8084 We no longer accept @defs with the non-fragile ABI.
llvm-svn: 69721
2009-04-21 21:16:23 +00:00
Chris Lattner a8c92540dd temporarily downgrade to a warning.
llvm-svn: 69720
2009-04-21 21:14:41 +00:00
Ted Kremenek 01c9af18c9 Plist diagnostics: Remove deprecated single-point locations in control-flow
pieces.

llvm-svn: 69719
2009-04-21 21:03:00 +00:00
Fariborz Jahanian ece1b2b0e1 Patch to diagnose use of objc's @defs in nonfragile abi.
llvm-svn: 69710
2009-04-21 20:28:41 +00:00
Ted Kremenek a8e8bc24b3 Added over-release test case.
llvm-svn: 69703
2009-04-21 20:01:03 +00:00
Ted Kremenek 9bb660c3f4 Recommit 69694 but this time also include the header changes (sorry for breaking
the build).

llvm-svn: 69702
2009-04-21 19:56:58 +00:00
Chris Lattner 37920f5359 reject sizeof(itf) when itf is a forward declared interface, or when
in non-fragile abi mode.  rdar://6811884

llvm-svn: 69701
2009-04-21 19:55:16 +00:00
Douglas Gregor fa9ab53d95 Fix emission of static tentative definitions referenced from other static functions
llvm-svn: 69699
2009-04-21 19:28:58 +00:00