Commit Graph

4006 Commits

Author SHA1 Message Date
Douglas Gregor 5d68a20949 Extend the implicit declaration and checking against out-of-scope
external declarations to also support external variable
declarations. Unified the code for these two cases into two new
subroutines.

Note that we fail to diagnose cases like the one Neil pointed
out, where a visible non-external declaration hides an external
declaration by the same name. That will require some reshuffling of
name lookup.

llvm-svn: 65385
2009-02-24 19:23:27 +00:00
Ted Kremenek c52f9394ce retain/release checker:
- For autorelease pool tracking, keep information about the stack of pools
  separate from their contents. Also, keep track of the number of times an
  autorelease pool will send the "release" message to an object when the pool is
  destroyed.
- Update CFRefCount::Update to return a new state instead of a reference count
  binding. This will allow us to implement more complicated semantics with
  autorelease pools.

llvm-svn: 65384
2009-02-24 19:15:11 +00:00
Daniel Dunbar d4ecca135a Fix IRgen of constant expressions referring to external/static
variables.
 - PR3657.

llvm-svn: 65381
2009-02-24 18:41:57 +00:00
Daniel Dunbar 0b0dcd987d Some initial Obj-C zero cost EH support.
- Only handles cases with @try with no @catch blocks, and there are a
   number of problems with the implementation. Nevertheless, this is
   good enough to handled @synchronized correctly, and some other
   basic uses.

llvm-svn: 65378
2009-02-24 07:47:38 +00:00
Daniel Dunbar 36ae309434 Add a note about an IRgen optimization opportunity.
llvm-svn: 65376
2009-02-24 06:34:04 +00:00
Chris Lattner 59da739613 Fix PR3635 by handling ## magically
llvm-svn: 65374
2009-02-24 05:29:33 +00:00
Douglas Gregor de681d43eb In C, when we see a function declaration within a local scope, export
that declaration to global scope so that it can be found from other
scopes. This allows us to diagnose redeclaration errors for external
declarations across scopes. We also warn when name lookup finds such
an out-of-scope declaration. This is part of <rdar://problem/6127293>;
we'll also need to do the same thing for variables.

llvm-svn: 65373
2009-02-24 04:26:15 +00:00
Anders Carlsson 729a8202d0 Prevent accidental copying of CodeGenFunction and CodeGenModule.
llvm-svn: 65372
2009-02-24 04:21:31 +00:00
Anders Carlsson b9c9e1d16f Pass the CodeGenModule object to GenerateBlockFunction, instead of *this (which will call the copy constructor).
Also, since we're creating a new CodeGenFunction object for each block function, we don't need to clear the BreakContinueStack.

llvm-svn: 65371
2009-02-24 04:19:41 +00:00
Mike Stump 18e91257e4 Ensure that we can't break or continue out of a block.
llvm-svn: 65370
2009-02-24 02:59:30 +00:00
Ted Kremenek cce27f5502 Fix <rdar://problem/6611677>: Add basic transfer function support in the static
analyzer for array subscript expressions involving bases that are vectors. This
solution is probably a hack: it gets the lvalue of the vector instead of an
rvalue like all other types. This should be reviewed (big FIXME in
GRExprEngine).

llvm-svn: 65366
2009-02-24 02:23:11 +00:00
Daniel Dunbar 94ceb61574 Fix two @synchronized bugs found by inspection: the expression to sychronize on should only be evaluated once, and it is evaluated outside the cleanup scope.
Also, lift SyncEnter and SyncExit up in nervous anticipation of x86-64
zero cost EH.

llvm-svn: 65362
2009-02-24 01:43:46 +00:00
Douglas Gregor e62c0a45dd Improve merging of function declarations. Specifically:
- When we are declaring a function in local scope, we can merge with
    a visible declaration from an outer scope if that declaration
    refers to an entity with linkage. This behavior now works in C++
    and properly ignores entities without linkage.
  - Diagnose the use of "static" on a function declaration in local
    scope.
  - Diagnose the declaration of a static function after a non-static
    declaration of the same function.
  - Propagate the storage specifier to a function declaration from a
    prior declaration (PR3425)
  - Don't name-mangle "main"

llvm-svn: 65360
2009-02-24 01:23:02 +00:00
Ted Kremenek 29b8697393 Move PTHStatCache within the anonymous namespace.
llvm-svn: 65348
2009-02-23 23:27:54 +00:00
Ted Kremenek 2c2ec42322 Tidy up 'ExecutionContinues' to distinguish between jumping to the end of a 'method' or 'funciton'.
llvm-svn: 65346
2009-02-23 23:13:51 +00:00
Ted Kremenek 62b3879c5e Tidy up the path diagnostic generation logic in BugReporter and remove a case where an "Execution continues..." diagnostic could result in an empty message bubble.
llvm-svn: 65342
2009-02-23 22:44:26 +00:00
Chris Lattner d13b8b55ca fix rdar://6611778, a redefinition of an interface was causing an
assertion when the ivars and method list was reset into the existing
interface.  To fix this, mark decls as invalid when they are redefined,
and don't insert ivars/methods into invalid decls.

llvm-svn: 65340
2009-02-23 22:00:08 +00:00
Fariborz Jahanian 392124c78e We should not generate __weak write barrier on indirect reference
of a pointer to object; This patch does this odd behavior according to
gcc.

llvm-svn: 65334
2009-02-23 18:59:50 +00:00
Steve Naroff a94e52c687 - Generate error for protocol qualifiers on 'Class'.
- Generate error for protocol qualifiers on non-ObjC types.

llvm-svn: 65333
2009-02-23 18:53:24 +00:00
Steve Naroff 91362dd011 Revert http://llvm.org/viewvc/llvm-project?view=rev&revision=65244.
Remove support for "Class<P>". Will be making this an error.

llvm-svn: 65332
2009-02-23 18:36:16 +00:00
Chris Lattner e7a0a63a16 Add copy assignment operator, caught by doug.
llvm-svn: 65331
2009-02-23 18:17:44 +00:00
Ted Kremenek 50db3d0923 Add more boilerplate logic to more accurately reason about autorelease pools.
This doesn't change the current functionality, but better codifies the
autorelease pool stack itself.

llvm-svn: 65328
2009-02-23 17:45:03 +00:00
Daniel Dunbar 1234749853 Add low level support for generating invoke instead of calls.
- No functionality change.

llvm-svn: 65325
2009-02-23 17:26:39 +00:00
Ted Kremenek 726fd5cbf5 Fix 80 col. violations.
llvm-svn: 65322
2009-02-23 16:54:00 +00:00
Ted Kremenek 82157a17c1 Per Chris L.'s suggestion, use getAsFunctionType() instead of getDesguaredType(). Constify some pointers along the way.
llvm-svn: 65321
2009-02-23 16:51:39 +00:00
Steve Naroff 59bf35e44a Remove isSuperExpr(), which ignores any casts on 'super'.
I don't think casting super makes any sense (since it won't effect method lookup).
Will discuss with other offline and decide what to do.

llvm-svn: 65317
2009-02-23 15:40:48 +00:00
Eli Friedman 3ae5911042 A few small improvements to Evaluate for stuff I noted in FIXMEs.
llvm-svn: 65305
2009-02-23 04:23:56 +00:00
Ted Kremenek e73f282213 retain/release checker: For now don't track the retain count of NSWindow objects (opt for false negatives).
llvm-svn: 65304
2009-02-23 02:51:29 +00:00
Ted Kremenek 5485a2f70b Remove typo.
llvm-svn: 65302
2009-02-23 02:42:56 +00:00
Ted Kremenek 7d4fc5bcdc '[NSAutoreleasePool addObject:]' has an 'autorelease' effect, not a DoNothing effect.
llvm-svn: 65301
2009-02-23 02:31:16 +00:00
Steve Naroff 77170dcb14 Sema::ActOnInstanceMessage(): Tighen up the lookup rules for handling messages to 'Class'. Also improve "super" handling.
llvm-svn: 65300
2009-02-23 02:25:40 +00:00
Steve Naroff d2c44d224c Minor cleanup, replace bool with qual_empty().
llvm-svn: 65293
2009-02-22 19:41:00 +00:00
Steve Naroff c4173fa704 Contains the following (related to problems found while investigting <rdar://problem/6497631> Message lookup is sometimes different than gcc's).
- Implement instance/class overloading in ObjCContainerDecl (removing a FIXME). This involved hacking NamedDecl::declarationReplaces(), which took awhile to figure out (didn't realize replace was the default).
- Changed Sema::ActOnInstanceMessage() to remove redundant warnings when dealing with protocols. For now, I've omitted the "protocol" term in the diagnostic. It simplifies the code flow and wan't always 100% accurate (e.g. "Foo<Prot>" looks in the class interface, not just the protocol).
- Changed several test cases to jive with the above changes.

llvm-svn: 65292
2009-02-22 19:35:57 +00:00
Anders Carlsson e14282e274 Make sure to reset the DidCallStackSave variable before emitting a compound statement. Fixes PR3649.
llvm-svn: 65291
2009-02-22 18:44:21 +00:00
Fariborz Jahanian 0773533b27 More objc gc work. Match gcc's treatment of ivar access
true a local pointer to objective-c object in generating
write barriers.

llvm-svn: 65290
2009-02-22 18:40:18 +00:00
Mike Stump e8b2d066ea Copy some clenaups from Eli to code that I copied. :-)
llvm-svn: 65286
2009-02-22 13:55:31 +00:00
Mike Stump 624497c29a Cleanp code with some recent suggestions.
llvm-svn: 65285
2009-02-22 13:27:11 +00:00
Eli Friedman c2b5017a72 A bit of Evaluate cleanup. Also, a full audit of what's missing that
someone would reasonably expect Evaluate to handle for C/ObjC.

llvm-svn: 65284
2009-02-22 11:46:18 +00:00
Daniel Dunbar bb525c3c7f x86_64 ABI: Actually, we can always pass things we want to pass in
memory using Indirect; this was a holdover from when CGCall wasn't as
robust.

llvm-svn: 65278
2009-02-22 08:17:51 +00:00
Ted Kremenek 35251f3d92 Fix regression in naming convention derivation: a method only follows the copy 'rule' if it doesn't already start with 'init', etc.
llvm-svn: 65269
2009-02-22 07:32:24 +00:00
Eli Friedman 825fe7565e Eliminate a bunch of code which should be dead.
llvm-svn: 65267
2009-02-22 07:29:04 +00:00
Daniel Dunbar 075d642e24 x86_64 ABI: Make sure to pass vectors that we want to pass in memory
as byval. Otherwise LLVM will have its own opinion about where to put
things.

We now pass all gcc dg.compat tests on x86_64.

llvm-svn: 65266
2009-02-22 07:22:25 +00:00
Eli Friedman 7bfab36877 Throw the switch to exclusively use Evaluate (along with the small
helper isConstantInitializer) to check whether an initializer is 
constant.  This passes tests, but it's possible that it'll cause 
regressions with real-world code.

Future work:
1. The diagnostics obtained this way are lower quality at the moment; 
some work both here and in Evaluate is needed for accurate diagnostics.
2. We probably need some extra code when we're in -pedantic mode so we 
can strictly enforce the rules in C99 6.6p7.
3. Dead code cleanup (this should wait until after 2, because we might 
want to re-use some of the code).

llvm-svn: 65265
2009-02-22 06:45:27 +00:00
Daniel Dunbar c64c481d18 x86_64 ABI: Pass 32-bit vectors as Integer to match gcc. We don't care
about these much but <2 x i16> shows up in the gcc test suite.

llvm-svn: 65264
2009-02-22 04:48:22 +00:00
Daniel Dunbar f25afad9e5 x86_64 ABI: Classify <1 x i64> as INTEGER (match gcc not llvm-gcc).
Also, make sure to pass <1 x i64> as i64 (not <1 x i64>, which doesn't
quite work yet in the backend).

llvm-svn: 65262
2009-02-22 04:16:10 +00:00
Eli Friedman f837924faf Enhance Evaluate to handle ObjC qualified id and class types; as far as
I know, these follow the exact same rules as pointers, so I just made 
them use the same codepath.  Someone more familiar with ObjC should 
double-check this, though.

llvm-svn: 65261
2009-02-22 04:02:33 +00:00
Eli Friedman 3f8c01a110 Fix for PR3433: map __alignof__ to preferred alignment. (This was
partially done in r65258.)

llvm-svn: 65260
2009-02-22 03:31:23 +00:00
Eli Friedman 34ef305759 Last part of PR3254: use the same alignment computation in Sema and
CodeGen.  I'm not sure whether this actually makes any visible 
difference, but it's better to be consistent anyway.

llvm-svn: 65259
2009-02-22 03:23:43 +00:00
Eli Friedman 19a546c15b Improvements to ASTContext::getDeclAlignInBytes; fixes the testcase in
PR3254 and part of PR3433.

The isICE changes are necessary to keep the computed results 
consistent with Evaluate.

llvm-svn: 65258
2009-02-22 02:56:25 +00:00
Steve Naroff 10cbe66f17 Remove debugging statement.
llvm-svn: 65257
2009-02-22 02:19:47 +00:00