Commit Graph

3115 Commits

Author SHA1 Message Date
John McCall
2979fe01da After some discussion with Doug, we decided that it made a lot more sense
for __unknown_anytype resolution to destructively modify the AST.  So that's
what it does now, which significantly simplifies some of the implementation.
Normal member calls work pretty cleanly now, and I added support for
propagating unknown-ness through &.

llvm-svn: 129331
2011-04-12 00:42:48 +00:00
John McCall
2d2e870745 More __unknown_anytype work.
llvm-svn: 129269
2011-04-11 07:02:50 +00:00
Anders Carlsson
8a01a751c9 Remove CK_DynamicToNull.
llvm-svn: 129265
2011-04-11 02:03:26 +00:00
Anders Carlsson
267c0c930e Add CXXDynamicCastExpr::isAlwaysNull() which will be replacing the cast kind I added.
llvm-svn: 129263
2011-04-11 01:43:55 +00:00
Anders Carlsson
c602006638 As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind which
represents a dynamic cast where we know that the result is always null.

For example:

struct A {
  virtual ~A();
};
struct B final : A { };
struct C { };

bool f(B* b) {
  return dynamic_cast<C*>(b);
}

llvm-svn: 129256
2011-04-10 20:33:22 +00:00
Eli Friedman
c5b20b5283 PR8369: make __attribute((regparm(0))) work correctly. Original patch by
pageexec@freemail.hu, tweaks by me.

llvm-svn: 129206
2011-04-09 08:18:08 +00:00
Fariborz Jahanian
4806ff8af9 Warn for any kind of initialization if initializer does not
implement lhs's protocols. // rdar://9091389.
 

llvm-svn: 129142
2011-04-08 18:25:29 +00:00
John McCall
319963434c Basic, untested implementation for an "unknown any" type requested by LLDB.
The idea is that you can create a VarDecl with an unknown type, or a
FunctionDecl with an unknown return type, and it will still be valid to
access that object as long as you explicitly cast it at every use.  I'm
still going back and forth about how I want to test this effectively, but
I wanted to go ahead and provide a skeletal implementation for the LLDB
folks' benefit and because it also improves some diagnostic goodness for
placeholder expressions.

llvm-svn: 129065
2011-04-07 08:22:57 +00:00
Fariborz Jahanian
3b9819b4a2 Fix lookup for class messages sent to qualified-class
types such that protocols are seached first. Fixes
// rdar://9224670

llvm-svn: 129016
2011-04-06 18:40:08 +00:00
Peter Collingbourne
ba3e6667cc Do not use IR marker for LLVM intrinsics
llvm-svn: 129001
2011-04-06 12:29:09 +00:00
Chandler Carruth
f20ec92331 Apply a bug-fix patch from Marcin Kowalczyk to the source locations for
a couple of operator overloads which form interesting expressions in the
AST.

I added test cases for both bugs with the c-index-test's token
annotation feature. Also, thanks to John McCall for confirming that this
is the correct solution.

llvm-svn: 128768
2011-04-02 09:47:38 +00:00
Ted Kremenek
98a24e37c5 Begin reworking static analyzer support for C++ method calls. The current logic was divorced
from how we process ordinary function calls, had a tremendous about of redundancy, and relied
strictly on inlining behavior (which was incomplete) to provide semantics instead of falling
back to the conservative analysis we use for C functions.  This is a significant step into
making C++ analyzer support more useful.

llvm-svn: 128557
2011-03-30 17:41:19 +00:00
Fariborz Jahanian
071caefef2 More coherent diagnostic attempting to assign to a member of a const object returned
from an objective-c message: // rdar://9005189

llvm-svn: 128348
2011-03-26 19:48:30 +00:00
Benjamin Kramer
8aef596dec Make helpers static.
llvm-svn: 128339
2011-03-26 12:38:21 +00:00
Douglas Gregor
1baf38f5a6 On Mac OS X, the presence of an 'availability' attribute for that
platform implies default visibility. To achieve these, refactor our
lookup of explicit visibility so that we search for both an explicit
VisibilityAttr and an appropriate AvailabilityAttr, favoring the
VisibilityAttr if it is present.

llvm-svn: 128336
2011-03-26 12:10:19 +00:00
Douglas Gregor
7ab142b55a Extend the new 'availability' attribute with support for an
'unavailable' argument, which specifies that the declaration to which
the attribute appertains is unavailable on that platform.

llvm-svn: 128329
2011-03-26 03:35:55 +00:00
Eli Friedman
9faf2f902c Silly mistake in integer constant folding cleanup.
llvm-svn: 128297
2011-03-25 19:07:11 +00:00
Anders Carlsson
6fc2204dde Fix some clang warnings.
llvm-svn: 128272
2011-03-25 11:22:47 +00:00
Eli Friedman
8bfbe3a01a Switch constant evaluation of float casts over to cast kinds.
llvm-svn: 128251
2011-03-25 00:54:52 +00:00
Eli Friedman
c757de2326 Cleanup integral and vector constant evaluation of casts to use cast kinds.
llvm-svn: 128250
2011-03-25 00:43:55 +00:00
Chris Lattner
89d3b337b8 remove a dead variable.
llvm-svn: 128141
2011-03-23 04:03:30 +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
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
Ted Kremenek
022dbc1672 Simplify crash recovery cleanup registration.
llvm-svn: 128057
2011-03-22 01:15:19 +00:00
Ted Kremenek
f75d089679 Recover memory from RecordLayoutBuilders during crashes.
llvm-svn: 127931
2011-03-19 01:00:36 +00:00
Peter Collingbourne
599cb8e430 Add support for language-specific address spaces. On top of that,
add support for the OpenCL __private, __local, __constant and
__global address spaces, as well as the __read_only, _read_write and
__write_only image access specifiers.  Patch originally by ARM;
language-specific address space support by myself.

llvm-svn: 127915
2011-03-18 22:38:29 +00:00
Abramo Bagnara
60804e1604 Fixed inconsistency when adding TemplateParameterListsInfo.
llvm-svn: 127876
2011-03-18 15:16:37 +00:00
Abramo Bagnara
9875a3ce70 Use ElaboratedType also for C.
llvm-svn: 127755
2011-03-16 20:16:18 +00:00
Peter Collingbourne
7d8a0b52d4 Support for printing/dumping static asserts
llvm-svn: 127744
2011-03-16 18:37:27 +00:00
Abramo Bagnara
22f8cd7117 Added missing methods to get Designators source range.
llvm-svn: 127735
2011-03-16 15:08:46 +00:00
Fariborz Jahanian
90186f8a3e Block return type of the initialized must be
be more speciaclized than that of the initializer,
when matching protocol qualifier list.
// rdar:// 9118343.

llvm-svn: 127585
2011-03-14 16:07:00 +00:00
Sebastian Redl
31ad754c96 Instead of storing an ASTContext* in FunctionProtoTypes with computed noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall.
llvm-svn: 127568
2011-03-13 17:09:40 +00:00
Sebastian Redl
fa453cfdc3 Propagate the new exception information to FunctionProtoType.
Change the interface to expose the new information and deal with the enormous fallout.
Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications.
Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support.

llvm-svn: 127537
2011-03-12 11:50:43 +00:00
Peter Collingbourne
e190dee7a5 Add support for the OpenCL vec_step operator, by generalising and
extending the existing support for sizeof and alignof.  Original
patch by Guy Benyei.

llvm-svn: 127475
2011-03-11 19:24:49 +00:00
Ken Dyck
dbc0191181 Overload IntExprEvaluator::Success() with a function that takes a CharUnits
parameter to tidy up the places where the expression is a size.

llvm-svn: 127454
2011-03-11 02:13:43 +00:00
Ken Dyck
a1a2e8decb Instead of round up sizes to '8', round them up to the alignment of the char
type.

llvm-svn: 127391
2011-03-10 02:00:35 +00:00
Ken Dyck
e73807538a Round up the non-virtual size to the next char instead of rounding down.
llvm-svn: 127390
2011-03-10 01:53:59 +00:00
Abramo Bagnara
29c2d46786 Fixed InnerLocStart.
llvm-svn: 127330
2011-03-09 14:09:51 +00:00
Douglas Gregor
f2f0806f71 Teach libclang's token-annotation logic about context-sensitive
keywords for Objective-C+ and C++0x. 

llvm-svn: 127253
2011-03-08 17:10:18 +00:00
Abramo Bagnara
ea94788cf4 Fixed source range for StaticAssertDecl and LinkageSpecDecl. Fixed source range for declarations using postfix types.
llvm-svn: 127251
2011-03-08 16:41:52 +00:00
Abramo Bagnara
b5545be14b Fixed NamespaceDecl source range.
llvm-svn: 127242
2011-03-08 12:38:20 +00:00
Abramo Bagnara
20c9e24241 Fixed bitfields source range.
llvm-svn: 127237
2011-03-08 11:07:11 +00:00
Abramo Bagnara
dff1930bf7 Fixed source range for all DeclaratorDecl's.
llvm-svn: 127225
2011-03-08 08:55:46 +00:00
John McCall
75f9498a7c The conditional needs to be pushed before the branch. Make the test less
trivial to check this.  Adjust for style.

llvm-svn: 127151
2011-03-07 03:12:35 +00:00
Abramo Bagnara
5022863fd8 Completed source ranges fixes for all classes inheriting from TypeDecl.
llvm-svn: 127120
2011-03-06 16:09:14 +00:00
Abramo Bagnara
b3185b00c5 Fixed TypedefDecl and TemplateTypeParameter source range.
llvm-svn: 127119
2011-03-06 15:48:19 +00:00
Sebastian Redl
7c6c9e971c Reinstate r127112, "Propagate new-style exception spec information to ExtProtoInfo.", this time with the missing header.
llvm-svn: 127118
2011-03-06 10:52:04 +00:00
NAKAMURA Takumi
c92335a87c Revert r127112, "Propagate new-style exception spec information to ExtProtoInfo."
It seems missing "clang/Basic/ExceptionSpecificationType.h".

llvm-svn: 127115
2011-03-06 00:17:36 +00:00
Sebastian Redl
69d37125a9 Propagate new-style exception spec information to ExtProtoInfo.
llvm-svn: 127112
2011-03-05 22:42:26 +00:00