Commit Graph

12864 Commits

Author SHA1 Message Date
Ted Kremenek 407d81b2cd Add another test case found due to an analyzer regression.
llvm-svn: 70600
2009-05-01 23:35:18 +00:00
Daniel Dunbar 6d0eecad6c Make install target actually work, dependencies FTW.
llvm-svn: 70599
2009-05-01 23:34:58 +00:00
Douglas Gregor cf7b2afc62 When printing a source line as part of a diagnostic, the source line
might be wider than we're supposed to print. In this case, we try to
select the "important" subregion of the source line, which contains
everything that we want to show (e.g., with underlining and the caret
itself) and tries to also contain some of the context. 

From the fantastically long line in the test case, we get an error
message that slices down to this:

message-length.c:18:120: warning: comparison of distinct pointer types
      ('int *' and 'float *')
  a_func_to_call(ip == FloatPointer, ip[ALongIndexName], 
                 ~~ ^  ~~~~~~~~~~~~

There are a bunch of gee-it-sounds-good heuristics in here, which seem
to do well on the various simple tests I've thrown at it. However,
we're going to need to look at a bunch more diagnostics to tweak these
heuristics.

This is the second part of <rdar://problem/6711348>. Almost there! 

llvm-svn: 70597
2009-05-01 23:32:58 +00:00
Anders Carlsson 2bbb86b02e It's an error to call offsetof on a non-POD type.
llvm-svn: 70595
2009-05-01 23:20:30 +00:00
Daniel Dunbar c52d01f8d9 Add ONLY_MAN_DOCS variable to only install the man page, not the html
and ps documentation.

llvm-svn: 70589
2009-05-01 23:11:42 +00:00
Anders Carlsson aa10d656b5 Get rid of CXXDestroyExpr.
llvm-svn: 70586
2009-05-01 22:21:22 +00:00
Ted Kremenek 2c32773fa2 Add a new BFS GRWorkList and make it the default worklist model for
GRCoreEngine. This tends to result in shorter paths for pathological cases.

llvm-svn: 70585
2009-05-01 22:18:46 +00:00
Anders Carlsson f58c243830 Rename CXXExprWithCleanup to CXXExprWithTemporaries.
llvm-svn: 70584
2009-05-01 22:18:43 +00:00
Anders Carlsson 4ac533dc90 We can now call member functions where the base is a pointer.
llvm-svn: 70579
2009-05-01 21:55:16 +00:00
Douglas Gregor 4818553abd Implement -fmessage-length=N, which word-wraps diagnostics to N columns.
Also, put a line of whitespace between the diagnostic and the source
code/caret line when the start of the actual source code text lines up
(or nearly lines up) with the most recent line of the diagnostic. For
example, here it's okay for the last line of the diagnostic to be
(vertically) next to the source line, because there is horizontal
whitespace to separate them:

decl-expr-ambiguity.cpp:12:16: error: function-style cast to a builtin
      type can only take one argument
  typeof(int)(a,5)<<a;

However, here is a case where we need the vertical separation (since
there is no horizontal separation):

message-length.c:10:46: warning: incompatible pointer types initializing 'void
      (int, float, char, float)', expected 'int (*)(int, float, short,
      float)'

      int (*fp1)(int, float, short, float) = f;

This is part one of <rdar://problem/6711348>.

llvm-svn: 70578
2009-05-01 21:53:04 +00:00
Douglas Gregor 8d9c509975 Implement bit-field promotion rules for C99. Fixes PR3500.
llvm-svn: 70571
2009-05-01 20:41:21 +00:00
Eli Friedman 6630d6495f Add support for -Wno-format-zero-length.
llvm-svn: 70570
2009-05-01 20:41:13 +00:00
Fariborz Jahanian 07b7165b50 Check for method type conflict between declaration in
class/protocol and implementation which could be
an imm. implementation or down in the inheritance
hierarchy.

llvm-svn: 70568
2009-05-01 20:07:12 +00:00
Anders Carlsson b781bcdc30 Replace more release+static_cast with takeAs.
llvm-svn: 70567
2009-05-01 19:49:17 +00:00
Anders Carlsson 3cbc85985a Replace a bunch of static_cast + release with takeAs.
llvm-svn: 70566
2009-05-01 19:30:39 +00:00
Ted Kremenek 9c21f1d174 StoreManager::CastRegion:
- Don't layer TypedViewRegions on top of any region except
  SymbolicRegions and AllocaRegions.  This follows from my offline
  discussion within Zhongxing about how TypedViewRegions really only
  represent memory getting re-appropriated for a new purpose.

Fallout	from this change:
- Move test case from xfail_rdar_6440393.m to misc-ps-64.m
  (it now passes).

- test/Analysis/fields.c now fails for region store (crash).
  Marking XFAIL.

- test/Analysis/rdar-6441136-region.c now fails (only runs with region store).
  Marking XFAIL.

  Diagnosis: The analyzer now correctly identifies an early out-of-bounds memory
   access then the one flagged:

  rdar-6541136-region.c:17:3: warning: Load or store into an out-of-bound memory position.
    *p = 1;
    ^~

  Changing the line:
   char *p = (void*) &wonky[1];
  to
   char *p = (void*) &wonky[0];

  (which should delay the buffer overrun) causes region store to crash, probably
  because it expects a TypedViewRegion.

- test/Analysis/casts.c (region store) now fails (crash).
  Marking XFAIL.

llvm-svn: 70565
2009-05-01 19:22:20 +00:00
Ted Kremenek a11c607312 Basic Store: Always convert a non::LocAsInteger to a Loc when storing to a pointer.
llvm-svn: 70564
2009-05-01 19:04:28 +00:00
Ted Kremenek 0e3cc24e79 Update CMake file.
llvm-svn: 70563
2009-05-01 18:43:00 +00:00
Anders Carlsson bfdea0f136 Get rid of the implicit deref call when calling member functions where the base is a pointer.
llvm-svn: 70562
2009-05-01 18:34:30 +00:00
Ted Kremenek 5cfe43ddd3 Add function prototype for OSAtomicCompareAndSwap32Barrier.
llvm-svn: 70559
2009-05-01 17:37:31 +00:00
Ted Kremenek 38ce220817 Fix run line in failing test case (it was missing the '%s' for the
file name, thus causing the test case to hang).

llvm-svn: 70558
2009-05-01 17:29:33 +00:00
Chris Lattner a020b07634 teach -parse-noop about int128_t and friends.
llvm-svn: 70547
2009-05-01 16:33:20 +00:00
Ted Kremenek afbff15e64 BugReporter (extensive diagnostics): introduce the notion of a "dead"
location context.  This allows us to postpone the decision of whether
or not a context should add a control-flow piece to the diagnostics
when inspecting its subexpressions.

llvm-svn: 70545
2009-05-01 16:08:09 +00:00
Douglas Gregor f16a8a7443 Finish a thought in CheckVariableDeclaration's comment. No functionality change
llvm-svn: 70544
2009-05-01 15:47:09 +00:00
Douglas Gregor 72a57b89aa Add testcase that illustrates the problem from r69699 regarding tentative definitions of statics
llvm-svn: 70543
2009-05-01 15:45:53 +00:00
Ted Kremenek 29d0880e50 Remove #if 0'ed code.
llvm-svn: 70542
2009-05-01 15:19:33 +00:00
Ted Kremenek 3b201db3c0 Add failing static analyzer case (this crashes).
llvm-svn: 70532
2009-05-01 04:13:51 +00:00
Eli Friedman f4e3ad6500 PR4013 and PR4105: pointer-like types can only be cast to/from integers
and other pointer-like types.

llvm-svn: 70531
2009-05-01 02:23:58 +00:00
Chris Lattner 2ab6983e41 C/ObjC work well enough with clang for them not to be a gcc strength anymore.
llvm-svn: 70528
2009-05-01 01:42:13 +00:00
Chris Lattner 0936387c46 add word
llvm-svn: 70527
2009-05-01 01:40:42 +00:00
Chris Lattner 0cfae87d80 C/ObjC work well enough to claim support for them now.
llvm-svn: 70526
2009-05-01 01:40:17 +00:00
Mike Stump d898026e8a Don't assert when we think we need copy/dispose, but don't need them.
Radar 6838889

llvm-svn: 70525
2009-05-01 01:31:57 +00:00
Anders Carlsson b4e463287e Don't use indirect memory destinations for inline asm. Fixes 6841383.
llvm-svn: 70523
2009-05-01 00:16:04 +00:00
Anders Carlsson 5e965472b9 C++ destructors can have a single unnamed void parameter. Fixes <rdar://problem/6841210>.
llvm-svn: 70519
2009-04-30 23:18:11 +00:00
Fariborz Jahanian e29b4f0785 Remove a warning when this file is compiled optimized.
llvm-svn: 70518
2009-04-30 23:08:58 +00:00
Anders Carlsson a088693557 Rework the way we handle constructor decls to be less hacky and fix PR3948 completely.
llvm-svn: 70516
2009-04-30 22:41:11 +00:00
Fariborz Jahanian 68592fc9e1 Use of super class ivar to synthesize property is back to being error.
llvm-svn: 70514
2009-04-30 21:39:24 +00:00
Ted Kremenek 2ff8a79d27 retain/release checker: Hook up attributes 'objc_ownership_retain' and
'objc_ownership_release' to the effects on receivers.

llvm-svn: 70507
2009-04-30 20:00:31 +00:00
Sebastian Redl aae83b4596 Make a home for exception specs in the AST. Now Sema can hook them up.
llvm-svn: 70506
2009-04-30 19:20:55 +00:00
Ted Kremenek 2acb5adac9 Allow attributes 'objc_ownership_retain' and 'objc_ownership_release' to be
applied to ObjCMethodDecls, not just parameters. This allows one to specific
side-effects on the receiver of a message expression. No checker support yet.

llvm-svn: 70505
2009-04-30 19:18:03 +00:00
Ted Kremenek 290fbb1d42 Hook up Sema support for attributes on Objective-C method declarations that
appear between the return type and the selector. This is a separate code path
from regular attribute processing, as we only want to (a) accept only a specific
set of attributes in this place and (b) want to distinguish to clients the
context in which an attribute was added to an ObjCMethodDecl.

Currently, the attribute 'objc_ownership_returns' is the only attribute that
uses this new feature. Shortly I will add a warning for 'objc_ownership_returns'
to be placed at the end of a method declaration.

llvm-svn: 70504
2009-04-30 18:41:06 +00:00
Ted Kremenek 8c06515f2b Add parsing support in an Objective-C method declaration for attributes between
the return type and selector. Haven't hooked this up to Sema yet.

llvm-svn: 70501
2009-04-30 17:55:29 +00:00
Steve Naroff a80dd1cae1 Name the "return-type" DiagGroup and reference it in a few places.
llvm-svn: 70500
2009-04-30 17:53:16 +00:00
Douglas Gregor ef462e6bb0 Properly compute the alignment of typedefs that make use of the
"aligned" attribute. Previously, we were skipping over these
attributes when we jumped directly to the canonical type. Now,
ASTContext::getTypeInfo walks through typedefs and other
"non-canonical" types manually, looking for "aligned" attributes on
typedefs.

As part of this change, I moved the GNU-specific logic (such as
determining the alignment of void or of a function pointer) out of the
expression evaluator and into ASTContext::getTypeInfo.

llvm-svn: 70497
2009-04-30 17:32:17 +00:00
Fariborz Jahanian 18c435a17d API for message dispatch of methods returning floats
to match gcc's closely.

llvm-svn: 70493
2009-04-30 16:31:11 +00:00
Steve Naroff 62e0cb0a22 Warn about invalid return statements by default.
This fixes <rdar://problem/6839489> 10A345: Clang does not warm about mismatched returns (void return from a bool function)
 
Will implement -Wreturn-type, -Wno-return-type in another commit.

llvm-svn: 70492
2009-04-30 16:01:26 +00:00
Ted Kremenek 10e21109d7 Update checker build.
llvm-svn: 70489
2009-04-30 15:15:37 +00:00
Eli Friedman 902fddd1cf Fix for PR4108: be a bit looser with the casts that we accept in
constant initializers.

llvm-svn: 70483
2009-04-30 07:03:22 +00:00
Chris Lattner 8ca336a86a accept and ignore two new warning specifiers. -Wno-discard-qual seems easy
to hook up if someone was interested.

llvm-svn: 70482
2009-04-30 06:36:43 +00:00
Chris Lattner b822fad20f fix i128 to return in 2 64-bit registers (rax/rdx on x86-64)
llvm-svn: 70481
2009-04-30 06:22:07 +00:00
Chris Lattner 7d4f5c47ce only support int128_t on 64-bit and larger targets. 32-bit targets don't
have support for __divti3 and friends.

llvm-svn: 70480
2009-04-30 06:18:40 +00:00
Ted Kremenek b4e27a1838 Handle case in EvalReturn where we cache out in the ExplodedGraph.
llvm-svn: 70475
2009-04-30 05:51:50 +00:00
Ted Kremenek 497df9126f retain/release checker: Use the ObjCMethodDecl in the @implementation if no
matching ObjCMethodDecl exists in the @interface.

llvm-svn: 70474
2009-04-30 05:47:23 +00:00
Ted Kremenek b2a143fad6 retain/release checker: Resolve method decl in @interface after getting the
ObjCInterfaceDecl, not before.

llvm-svn: 70473
2009-04-30 05:41:14 +00:00
Chris Lattner 0a415ec50c int128_t is apparently 128-bit aligned on all 64-bit targets, and
not supported on 32-bit targets, so we can define it to be 128-bit
aligned there too :)

llvm-svn: 70465
2009-04-30 02:55:13 +00:00
Chris Lattner f122cef4df initial support for __[u]int128_t, which should be basically
compatible with VC++ and GCC.  The codegen/mangling angle hasn't
been fully ironed out yet.  Note that we accept int128_t even in
32-bit mode, unlike gcc.

llvm-svn: 70464
2009-04-30 02:43:43 +00:00
Bill Wendling 50e41a4d86 Remove two unused options.
llvm-svn: 70457
2009-04-30 00:55:13 +00:00
Mike Stump e9efa80c00 Sema checking for incorrect placement of __block. Radar 6441502
llvm-svn: 70452
2009-04-30 00:19:40 +00:00
Bill Wendling 29405d836b Use the new code gen optimization enum instead of passing in the optimization
level. This is more expressive.

llvm-svn: 70451
2009-04-29 23:53:23 +00:00
Douglas Gregor d1a602c628 Make DISABLE_SMART_POINTERS work, again
llvm-svn: 70443
2009-04-29 23:37:31 +00:00
Fariborz Jahanian 334df667a3 Change to warning when property uses an ivar in super class
in an @synthesize diective, as it breaks few projects.

llvm-svn: 70441
2009-04-29 23:31:56 +00:00
Anders Carlsson 118b098cd9 Just because a declaration has the same name as its containing class doesn't mean that it's a constructor. Fixes rdar://problem/6815988.
llvm-svn: 70436
2009-04-29 23:19:39 +00:00
Douglas Gregor e5f93b1e58 Revert r70424. We don't need it
llvm-svn: 70432
2009-04-29 23:06:13 +00:00
Ted Kremenek 223a7d5445 retain/release checker: When determining whether an analyzed method can return
an owned object, consult its summary instead of inspecting the selector. This
picks up annotations, and is just more general.

llvm-svn: 70429
2009-04-29 23:03:22 +00:00
Douglas Gregor 424ac21318 Add PCH version to the -v output
llvm-svn: 70424
2009-04-29 22:47:43 +00:00
Fariborz Jahanian 4b4ef86369 Undid setting of the flag for msg_Send for 32bit code gen.
It seems to effect code gen. Add a FIXME instead.

llvm-svn: 70423
2009-04-29 22:47:27 +00:00
Ted Kremenek d6bef2edab Format cleanup. No functionality change.
llvm-svn: 70420
2009-04-29 22:25:52 +00:00
Douglas Gregor 0cfbdab0cf Implement semantic analysis for transparent unions. This is largely
based on a patch from Anders Johnsen. CodeGen support is incomplete,
in that we do not properly coerce to the first field's type.

llvm-svn: 70419
2009-04-29 22:16:16 +00:00
Mike Stump a74841e22c Remove extra line.
llvm-svn: 70418
2009-04-29 22:11:32 +00:00
Ted Kremenek 9f08b842e1 Fix null dereference.
llvm-svn: 70417
2009-04-29 22:05:03 +00:00
Ted Kremenek 47187c6ad2 BugReporter/PathDiagnostics:
- Add an (optional) short description for BugReports for clients that want
  to distinguish between long and short descriptions for bugs
- Make the bug report for VLA less obscene for Plist diagnostics by using
  the short description

llvm-svn: 70415
2009-04-29 21:58:13 +00:00
Fariborz Jahanian bff0167a0b use of an ivar specified on a property @synthesize
and found in super class triggers a diagnostics.

llvm-svn: 70414
2009-04-29 21:45:02 +00:00
Mike Stump 56ed2eab9e Fixup Sema and CodeGen for block literal attributes when the return
type and argument types are missing, and let return type deduction
happen before we give errors for returning from a noreturn block.
Radar 6441502

llvm-svn: 70413
2009-04-29 21:40:37 +00:00
Ted Kremenek 53cce5c195 Reformat long line. No functionality change.
llvm-svn: 70412
2009-04-29 21:31:59 +00:00
Evan Cheng a97709b66f Match addPassesToEmitFile API change.
llvm-svn: 70409
2009-04-29 21:02:33 +00:00
Fariborz Jahanian e55f8660be Export lazy references of .objc_class_name of class names
referenced in a category implementation meta-data
(Next objc 32bit abi).

llvm-svn: 70407
2009-04-29 20:40:05 +00:00
Eli Friedman 8b171f6516 Minor simplification; also silences gcc warning.
llvm-svn: 70406
2009-04-29 20:29:43 +00:00
Fariborz Jahanian e27b929809 Type of msgSend message dispatch API is a vararg.
llvm-svn: 70404
2009-04-29 19:14:43 +00:00
Mike Stump 88788feddd Sema and CodeGen support for attributes on blocks. Radar 6441502
llvm-svn: 70403
2009-04-29 19:03:13 +00:00
Ted Kremenek 6bd78709f2 retain/release checker: Hoist code for bug reports above transfer function logic
(those diffs are just code moving) and move the logic for "return of owned
object" leak reporting to EvalReturnStmt.

llvm-svn: 70399
2009-04-29 18:50:19 +00:00
Daniel Dunbar 44e7122151 Make sure to pass the same options to the static analyzer as the
compiler.
 - Code generation options may still affect the language...

llvm-svn: 70393
2009-04-29 18:32:25 +00:00
Chris Lattner 156ed6c015 accept and ignore two new warning options. PR410[45]
llvm-svn: 70392
2009-04-29 18:15:38 +00:00
Eli Friedman ba94471e6e PR4103: improve source location information for members of the current
class.  This isn't perfect, but it's a big improvement over not having 
any location information.

llvm-svn: 70390
2009-04-29 17:56:47 +00:00
Sebastian Redl 2b9cacbffa Have the parser communicate the exception specification to the action.
llvm-svn: 70389
2009-04-29 17:30:04 +00:00
Ted Kremenek 99fe1695c7 Add version of getMethodSummary() that can be used to query the summary for the
method currently being analyzed.

llvm-svn: 70388
2009-04-29 17:17:48 +00:00
Ted Kremenek 387243067a Rename getMethodSummary() -> getInstanceMethodSummary().
llvm-svn: 70387
2009-04-29 17:09:14 +00:00
Steve Naroff d98037132f Integrate 3 months of ObjC rewriter fixes (from the Apple/objective-rewrite branch).
llvm-svn: 70385
2009-04-29 16:37:50 +00:00
Eli Friedman debdc1d732 PR4103: Silence bogus unused expression warning.
llvm-svn: 70384
2009-04-29 16:35:53 +00:00
Ted Kremenek bcf597d2e5 Add test case for transfer function logic for OSCompareAndSwap32Barrier.
llvm-svn: 70383
2009-04-29 16:03:59 +00:00
Ted Kremenek 3941d22a98 Add corner case logic to BasicStoreManager and GRSimpleVals::EvalBinOp to enable
reasoning about OSCompareAndSwap32Barrier/OSCompareAndSwap64Barrier. Essentially
the address of reference to a region (pointer-to-pointer) can be casted to
(int32_t*), and we need to handle the logic to convert the involved locations
back and forth from nonloc::LocAsInteger, nonloc::ConcreteInt, to Loc and
loc::ConcreteInt respectively. This adds some potentially suspect logic to
BasicStoreManager that allows the analyzer to reason about abuses of the C type
system. This should probably be refined, be ported over to RegionStoreManager,
and extended with "path-sensitive type checking" to flag bugs in clearly
incoherent code.

llvm-svn: 70382
2009-04-29 16:03:27 +00:00
Ted Kremenek e034868a36 MemRegion pretty-printing: Convert DeclName to a string to print out the actual
name of the tracked function.

llvm-svn: 70381
2009-04-29 15:37:24 +00:00
Zhongxing Xu f985648e83 SymbolicRegions may also be live roots.
llvm-svn: 70380
2009-04-29 09:24:35 +00:00
Zhongxing Xu 12233fd97e Added comments to test case.
llvm-svn: 70374
2009-04-29 05:59:48 +00:00
Chris Lattner 11a827471e fix PR4021, array and functions decay in the receiver position of an objc message send.
llvm-svn: 70373
2009-04-29 05:48:32 +00:00
Chris Lattner 0f94c5a741 Fix PR4092 by improving error recovery in two ways:
1. In a struct field redefinition, don't mark the struct erroneous.  The
   field is erroneous, but the struct is otherwise well formed.
2. Don't emit diagnostics about functions that are known to be broken already.

Either fix is sufficient to silence the second diagnostic in the example,
but the combination is better :)

llvm-svn: 70371
2009-04-29 05:12:23 +00:00
Ted Kremenek 0b50fb1de1 retain/release checker: Refactor getMethodSummary() to not depend on ObjCMessageExpr.
llvm-svn: 70369
2009-04-29 05:04:30 +00:00
Chris Lattner cc5d1c2e4e implement -Wformat-security properly, which is enabled by default.
This enables one specific class of non-literal format warnings.

llvm-svn: 70368
2009-04-29 04:59:47 +00:00
Chris Lattner e009a881ea code simplification, no functionality change.
llvm-svn: 70367
2009-04-29 04:49:34 +00:00
Chris Lattner e525dc3c66 add a bunch of individual warnings to -Wformat (which is
on by default).

llvm-svn: 70365
2009-04-29 04:41:16 +00:00
Chris Lattner fd4a4d1f8a Wire up -Wformat=2 and -Wformat-extra-args
llvm-svn: 70364
2009-04-29 04:31:58 +00:00
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