Commit Graph

29239 Commits

Author SHA1 Message Date
John Thompson 88903beaf5 Fixed some of the incompatibilities with gcc.
llvm-svn: 128228
2011-03-24 18:51:57 +00:00
Douglas Gregor d7d7e0d3df Minor fix in the injection of labels, since we want to look at the redeclaration context of each declaration in the identifier chain. Should fix Linux self-host
llvm-svn: 128210
2011-03-24 14:35:16 +00:00
John McCall 084e83dfe7 Insomniac refactoring: change how the parser allocates attributes so that
AttributeLists do not accumulate over the lifetime of parsing, but are
instead reused.  Also make the arguments array not require a separate
allocation, and make availability attributes store their stuff in
augmented memory, too.

llvm-svn: 128209
2011-03-24 11:26:52 +00:00
Douglas Gregor 33f352ca62 Fix the insertion of label declarations into the identifier chain in
the case where we only have a single identifier with that name in the
chain. Fixes PR9463 for real this time.

llvm-svn: 128208
2011-03-24 10:35:39 +00:00
Eli Friedman b4d3c99929 Make sure we aggressively attach nounwind (etc.) to calls to library
functions of the form __builtin_XXX.

llvm-svn: 128198
2011-03-24 05:09:45 +00:00
Ken Dyck 16ffcac1a2 Convert the BaseOffset member of BaseSubobject to CharUnits from bits. No
change in functionality intended.

llvm-svn: 128190
2011-03-24 01:21:01 +00:00
Anders Carlsson 98766db785 Add a new warning for exit-time destructors.
llvm-svn: 128188
2011-03-24 01:01:41 +00:00
Ted Kremenek 49c79790de Rework checker "packages" and groups to be more hierarchical.
llvm-svn: 128187
2011-03-24 00:28:47 +00:00
John McCall c23308ceea Call out ObjC parameter types as a different kind of declarator context
from a normal type-spec, just for completeness.

llvm-svn: 128185
2011-03-23 23:43:04 +00:00
David Chisnall 76803410c2 Fixed type error in last commit (forgot that now that selectors are not
accessed via the indirect pointer, they don't need to be pointers to pointers).

Finished moving the message lookup code into separate subclasses for each
runtime.  Also performed a few smallish related tidies.

We're now bitcasting the result of the message lookup functions, rather than
casting the lookup functions themselves, so the messages.m test needed updating
to reflect this.

llvm-svn: 128180
2011-03-23 22:52:06 +00:00
Ted Kremenek dcc4c38970 Fix CFG-construction bug when run from AnalysisBasedWarnings::IssueWarnings() where block-level expressions that need
to be recorded in the Stmt*->CFGBlock* map were not always done so.  Fixes <rdar://problem/9171946>.

llvm-svn: 128170
2011-03-23 21:33:21 +00:00
Douglas Gregor 336a15e041 Unbreak test
llvm-svn: 128168
2011-03-23 21:19:43 +00:00
Fariborz Jahanian 16f92ce539 Support for Transparent unions used as overloadable
function parameter. // rdar:// 9129552
and PR9406.

llvm-svn: 128159
2011-03-23 19:50:54 +00:00
Marshall Clow e7deac8cdc Add a test for !ptr-to-member (should fail)
llvm-svn: 128158
2011-03-23 19:44:36 +00:00
Andrew Trick 4a3ee93447 Revert r128156 because of CodeGenObjC/messages.m and Coverage/codegen-gnu.m.
llvm-svn: 128157
2011-03-23 19:43:59 +00:00
David Chisnall f1a38cf32d Remove the redundant loads / stores to globals that we were generating for selectors (GNU runtimes).
llvm-svn: 128156
2011-03-23 18:39:12 +00:00
David Chisnall d7972f5bf8 Initial work on refactoring GNU runtime code (long overdue - it's quite obvious
that I hadn't used C++ for several years before writing most of this code).
Still lots more to do.  This set of changes includes:

- Remove the distinction between typed and untyped selectors.  More accurately
  reflect what the runtime does, by using typed selectors everywhere, with an
  empty type field if the types are unknown.  Now we just store a small list of
  types for each selector (in theory, this should always be exactly one, but
  this constraint was not enforced back in 1986 when it should have been).

- Add some consistency to how runtime functions are created.  These are all
  generated via the LazyRuntimeFunction class (which might be useful outside
  CGObjCGNU - feel free to move it into a header if it is).  This function
  stores the types of a function, looks it up the first time it's used, and
  caches the result.  This means that we're now not wasting time constructing
  the llvm::FunctionType every time some of the functions are looked up, but
  also not inserting references to runtime functions into the module if they're
  not actually used.

- Started separating out the fragile and non-fragile ABI behaviours into two
  subclasses of CGObjCGNU: CGObjCGCC for the legacy GCC runtime ABI and
  CGObjCGNUstep for the new GNUstep ABI.  Not all of the differences in
  behaviour are factored out yet, but they will be in future commits.

- Removed all of the CodeGen:: things: we've been using namespace CodeGen in
  this file for ages, so having explicit namespace specifiers is just a bit
  confusing.

- Added a few more comments.

- Used llvm::StringRef instead of std::string in a few places.

- Finally got around to storing the module path in the module structure.  The
  ABI says that the compiler should do this, although it's not used in the
  runtime or exposed outside the runtime, so it's pretty useless.  

Still to do:

- We currently have two code paths for generating try blocks, one for ObjC and
  one for ObjC++.  Not only are these substantially similar, they are also very
  similar to the CGObjCMac version.  These need factoring out into a single
  parameterised implementation, either in CGObjCRuntime or CodeGenFunction.
  The EmitObjCXXTryStmt() function was added so that the changes to fix a bug
  in time for the 2.9 release would be self-contained and reduce the chances of
  breaking anything else, but these should be done properly as soon as
  possible.

- Split up some large functions (e.g. GenerateClass()) into smaller functions
  for generating the various data structures.

- The method lookup code into the two subclasses, removing the conditionals in
  the message send functions.

- Add doxygen comments on the remaining undocumented functions.

- We seem to be generating global pointer variables for selectors, then storing
  a pointer to the selector, then generating a load of this pointer (and then a
  load of the real selector later) every time a static selector is used.  I can
  only assume I was asleep or drunk when I did this - we should just be
  referencing the selectors directly in the selector array.

llvm-svn: 128152
2011-03-23 16:36:54 +00:00
Devang Patel 945b8aed2a Update type cache when a type is completed.
Radar 9168773

llvm-svn: 128150
2011-03-23 16:29:39 +00:00
Douglas Gregor 899b68fdf5 Teach DelayedDiagnostic to copy its string, rather than hope that the
string itself lives longer than the DelayedDiagnostic. Fixes a recent
use-after-free regression due to my availability attribute work. 

llvm-svn: 128148
2011-03-23 15:13:44 +00:00
Douglas Gregor d71149a453 Ignore weak_import on Objective-C property and method declarations on
all platforms, not just darwin. Fixes the regression in this test case.

llvm-svn: 128147
2011-03-23 13:27:51 +00:00
Chris Lattner ce6c42f65f switch a few Driver APIs to use llvm::ArrayRef, cleaning up code.
llvm-svn: 128142
2011-03-23 04:04:01 +00:00
Chris Lattner 89d3b337b8 remove a dead variable.
llvm-svn: 128141
2011-03-23 04:03:30 +00:00
Ted Kremenek 1ba9bbc149 Fix crash in clang_getInstantiationLoc() when SourceManager::getInstantiationLoc() can return a SourceLocatin with an invalid
FileID on invalid code.  Fixes <rdar://problem/9164623>.

llvm-svn: 128139
2011-03-23 02:16:44 +00:00
Ted Kremenek d6f4ad1579 std::vector::data() is not portable to VS. Use a gross hack instead.
llvm-svn: 128138
2011-03-23 02:16:41 +00:00
Ken Dyck 3fb4c8920d Convert OffsetFromNearestVBast parameter of InitializeVTablePointer(s) to
CharUnits. No change in functionality intended.

llvm-svn: 128129
2011-03-23 01:04:18 +00:00
Douglas Gregor 20b2ebd785 Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,

  void foo()
  __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));

says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:

  - If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
    will result in a deprecation warning, as if we had placed
    attribute((deprecated)) on it (but with a better diagnostic)
  - If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
    will result in an "unavailable" warning (in C)/error (in C++), as
    if we had placed attribute((unavailable)) on it
  - If we choose a deployment target prior to 10.2, foo() is
    weak-imported (if it is a kind of entity that can be weak
    imported), as if we had placed the weak_import attribute on it.

Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.

The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.

Addresses <rdar://problem/6690412>.

As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.

llvm-svn: 128127
2011-03-23 00:50:03 +00:00
Ken Dyck cfc332cc43 Convert NonVirtual parameter of ApplyNonVirtualAndVirtualOffset() to
CharUnits. No change in functionality intended.

llvm-svn: 128126
2011-03-23 00:45:26 +00:00
John McCall 92d627e1b0 Fix an error with the declaration of block parameters that depend
on previous block parameters that crept in as part of my captures
work a month or so ago.

llvm-svn: 128121
2011-03-22 23:15:50 +00:00
John McCall aa01737782 Warn about unused declaration-specifiers on tag declarations.
llvm-svn: 128118
2011-03-22 23:00:04 +00:00
Eli Friedman 015d6288d4 Make the definition of "long double" consistent for llvm::Triple::Win32 for
both 32-bit and 64-bit targets.

llvm-svn: 128110
2011-03-22 21:25:11 +00:00
David Chisnall 067f0ed468 Simplify Mac runtime selection - it's the factory function's job to select which class to produce, not CodeGenModule's.
llvm-svn: 128109
2011-03-22 21:21:24 +00:00
Ted Kremenek 600b54c1e7 Hopefully fix VS build by not using std::vector::data().
llvm-svn: 128105
2011-03-22 20:16:19 +00:00
David Chisnall 08a45257de Make the property accessor functions that take a ptrdiff_t actually take a ptrdiff_t instead of a long (should have no impact on any sane platforms, but win64 is not sane).
llvm-svn: 128104
2011-03-22 20:03:13 +00:00
David Chisnall 6a566d2c1e Make the ivar offset always be a ptrdiff_t, because stuff in CGObjC.cpp expects this. Actually, it expects a long, but that's a bug that will be fixed in the next commit...
llvm-svn: 128102
2011-03-22 19:57:51 +00:00
Nick Lewycky d2348d8d3f Fix typo in comment.
llvm-svn: 128088
2011-03-22 17:35:47 +00:00
Daniel Dunbar 12100e2c7f Frontend: Add a more explicit -backend-option flag for passing backend command
line options, instead of leveraging the blanket -mllvm option.
 - This allows using the frontend itself without requiring the backend have
   those options available (i.e., if the target wasn't built).

llvm-svn: 128087
2011-03-22 16:48:17 +00:00
Benjamin Kramer ce276e3822 Don't clear OverloadCandidateSets on destruction, it has no effect anymore.
And clearing a SmallPtrSet can be an expensive operation.

llvm-svn: 128081
2011-03-22 09:46:54 +00:00
John McCall 30cd20a316 Apply Jonathan Sauer's proposed solution to PR9519. Thanks!
llvm-svn: 128075
2011-03-22 07:16:37 +00:00
John McCall 6a4fa52b37 The emission of an Objective-C++'s class .cxx_destruct method should be
conditioned on whether it has any destructible ivars, not on whether
it has any non-trivial class-object initializers.

llvm-svn: 128074
2011-03-22 07:05:39 +00:00
John McCall 8f9a42971e Fix a test case and teach ClearLinkageCache() to clear the linkage of
a function template decl's pattern, which was suddenly exposed by my
last patch.

llvm-svn: 128073
2011-03-22 06:58:49 +00:00
John McCall 290b32b90f File-scope static functions need to be mangled with 'L' so that
they don't collide with file-scope extern functions from the same
translation unit.  This is basically a matter of applying the same
logic to FunctionDecls as we were previously applying to VarDecls.

llvm-svn: 128072
2011-03-22 06:34:45 +00:00
Ken Dyck 6aa767c18e Convert Offset variable in GetAddressOfDirectBaseInCompleteClass() to
CharUnits. No change in functionality intended.

llvm-svn: 128060
2011-03-22 01:21:15 +00:00
Ted Kremenek 022a4904fa Rework crash recovery cleanup in ASTUnit and CIndex to recover more memory during a Sema crash (we have just a handful of leaks left)
and to use the simplified cleanup registration API.

llvm-svn: 128059
2011-03-22 01:15:24 +00:00
Ted Kremenek 288fb9dc6e Remove crash recovery cleanups from TypeLocBuilder. They were a bit error prone, only hit in rare cases.
llvm-svn: 128058
2011-03-22 01:15:21 +00:00
Ted Kremenek 022dbc1672 Simplify crash recovery cleanup registration.
llvm-svn: 128057
2011-03-22 01:15:19 +00:00
Ted Kremenek 4c9d46b310 Migrate 'PrettySTackTraceParserEntry' object out of Parser, and have it constructed within ParseAST. This avoids double crashes
during crash recovery.

llvm-svn: 128056
2011-03-22 01:15:17 +00:00
Ken Dyck a1a4ae34d0 Change return value of ComputeNonVirtualBaseClassOffset() to CharUnits. No
change in functionality intended.

llvm-svn: 128050
2011-03-22 00:53:26 +00:00
Ken Dyck 664569965f Eliminate some literal '8's in FillInNullDataMemberPointers() by switching
to CharUnits. No change in functionality intended.

llvm-svn: 128047
2011-03-22 00:24:31 +00:00
Matt Beaumont-Gay a282bc6a00 Output to tempfile
llvm-svn: 128043
2011-03-22 00:19:31 +00:00
Bob Wilson 87ba1d329a Another cortex-m0 patch from James Orr.
llvm-svn: 128029
2011-03-21 21:55:25 +00:00