Commit Graph

327 Commits

Author SHA1 Message Date
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
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
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 dff1930bf7 Fixed source range for all DeclaratorDecl's.
llvm-svn: 127225
2011-03-08 08:55:46 +00:00
John McCall 5fca7eaf85 Don't hard-code these constants, or at least don't hard-code them so hard.
llvm-svn: 126841
2011-03-02 12:29:23 +00:00
John McCall 80ee5963fd Pretty up the wrong-number-of-arguments-for-attribute diagnostic by
using a custom plural form.  Split out the range diagnostics as their
own message.

llvm-svn: 126840
2011-03-02 12:15:05 +00:00
John McCall 86bc21ffcf Provide an attribute, objc_method_family, to allow the inferred family
of an Objective-C method to be overridden on a case-by-case basis.  This
is a higher-level tool than ns_returns_retained &c.;  it lets users specify
that not only does a method have different retain/release semantics, but
that it semantically acts differently than one might assume from its name.
This in turn is quite useful to static analysis.

llvm-svn: 126839
2011-03-02 11:33:24 +00:00
Douglas Gregor 144548072d Use NestedNameSpecifierLoc within out-of-line variables, function, and
tag definitions. Also, add support for template instantiation of
NestedNameSpecifierLocs.

llvm-svn: 126470
2011-02-25 02:25:35 +00:00
Chris Lattner 190aa10fe6 rework processing of unavailable and deprecated attributes to avoid
unneeded allocation of an empty StringLiteral when these don't have
a message.

llvm-svn: 126364
2011-02-24 05:42:24 +00:00
Chris Lattner 0ddd0ae50e accept and ignore a few things for better OpenBSD compatibility,
patch by Amit Kulkarni!

llvm-svn: 125944
2011-02-18 17:05:55 +00:00
Chris Lattner cab02a60d2 Step #2/N of __label__ support: keep pushing LabelDecl forward,
making them be template instantiated in a more normal way and 
make them handle attributes like other decls.

This fixes the used/unused label handling stuff, making it use
the same infrastructure as other decls.

llvm-svn: 125771
2011-02-17 20:34:02 +00:00
John McCall c146582e60 When parsing an out-of-line member function declaration, we must delay
access-control diagnostics which arise from the portion of the declarator
following the scope specifier, just in case access is granted by
friending the individual method.  This can also happen with in-line
member function declarations of class templates due to templated-scope
friend declarations.

We were really playing fast-and-loose before with this sort of thing,
and it turned out to work because *most* friend functions are in file
scope.  Making us delay regardless of context exposed several bugs with
how we were manipulating delay.  I ended up needing a concept of a
context that's independent of the declarations in which it appears,
and then I actually had to make some things save contexts correctly,
but delay should be much cleaner now.

I also encapsulated all the delayed-diagnostics machinery in a single
subobject of Sema;  this is a pattern we might want to consider rolling
out to other components of Sema.

llvm-svn: 125485
2011-02-14 07:13:47 +00:00
Peter Collingbourne 7ce13fc940 OpenCL: add support for __kernel, kernel keywords and EXTENSION,
FP_CONTRACT pragmas.  Patch originally by ARM.

llvm-svn: 125475
2011-02-14 01:42:53 +00:00
John McCall 7a198cef04 When checking the 'weak' and 'weakref' attributes, look for non-external
linkage rather than the presence of the 'static' storage class specifier.
Fixes rdar://problem/8814626.

llvm-svn: 125126
2011-02-08 22:35:49 +00:00
Ted Kremenek d68ec818c3 Downgrade error about attribute 'iboutlet' and 'ibaction' being applied to anything but a instance method to a warning.
llvm-svn: 124858
2011-02-04 06:54:16 +00:00
Douglas Gregor c03a1083af Give OpaqueValueExpr a source location, because its source location
might be queried in places where we absolutely require a valid
location (e.g., for template instantiation). Fixes some major
brokenness in the use of __is_convertible_to.

llvm-svn: 124465
2011-01-28 02:26:04 +00:00
Jeffrey Yasskin bbc4eea2c2 Revert r124217 because it didn't catch the actual error case it was trying to
catch:

  lock_guard(my_mutex);

declares a variable instead of creating a temporary.

llvm-svn: 124398
2011-01-27 19:17:54 +00:00
Jeffrey Yasskin 08a4f8f197 Add an attribute to forbid temporary instances of a type. This allows class
authors to write 

  class __attribute__((forbid_temporaries)) Name { ... };

when they want to force users to name all variables of the type. This protects
people from doing things like creating a scoped_lock that only lives for a
single statement instead of an entire scope.

The warning produced by this attribute can be disabled by
-Wno-forbid-temporaries.

llvm-svn: 124217
2011-01-25 20:08:12 +00:00
John McCall ed433937c2 Add the ns_consumes_self, ns_consumed, cf_consumed, and ns_returns_autoreleased
attributes for the benefit of the static analyzer.

llvm-svn: 124174
2011-01-25 03:31:58 +00:00
Anders Carlsson e30621b626 Get rid of [[hiding]], [[override]] and [[base_check]].
llvm-svn: 124087
2011-01-23 21:33:18 +00:00
Anders Carlsson 19588aa40b Get rid of the [[final]] C++0x attribute.
llvm-svn: 124083
2011-01-23 21:07:30 +00:00
Peter Collingbourne b331b267b1 Sema: support for processing non-inheritable declaration attributes early
llvm-svn: 123960
2011-01-21 02:08:45 +00:00
John McCall 3882ace207 Refactor the application of type attributes so that attributes from
the declaration-specifiers and on the declarator itself are moved
to the appropriate declarator chunk.  This permits a greatly
simplified model for how to apply these attributes, as well as
allowing a much more efficient query for the GC attribute.
Now all qualifier queries follow the same basic strategy of
"local qualifiers, local qualifiers on the canonical type,
then look through arrays".  This can be easily optimized by
changing the canonical qualified-array-type representation.

Do not process type attributes as decl attributes on declarations
with declarators.

When computing the type of a block, synthesize a prototype
function declarator chunk if the decl-spec type was not a
function.  This simplifies the logic for building block signatures.

Change the logic which inserts an objc_read_weak on a block
literal to only fire if the block has a __weak __block variable,
rather than if the return type of the block is __weak qualified,
which is not actually a sensible thing to ask.

llvm-svn: 122871
2011-01-05 12:14:39 +00:00
Peter Collingbourne 7293698ed3 Funciton -> Function
llvm-svn: 122709
2011-01-02 19:53:19 +00:00
Peter Collingbourne ed12ffb50f Unkown -> Unknown
llvm-svn: 122708
2011-01-02 19:53:12 +00:00
John McCall 53fa71476d Refactor how we collect attributes during parsing, and add slots for attributes
on array and function declarators.  This is pretty far from complete, and I'll
revisit it later if someone doesn't beat me to it.

llvm-svn: 122535
2010-12-24 02:08:15 +00:00
Fariborz Jahanian 7d6e11a192 Warn when message is sent to receiver of
unknown type and there is a possibility that
at runtime method is resolved to a deprecated or 
unavailable method.  Addreses // rdar://8769853

llvm-svn: 122294
2010-12-21 00:44:01 +00:00
Francois Pichet 7da1166da0 Validate Microsoft's uuid attribute string.
llvm-svn: 122220
2010-12-20 01:41:49 +00:00
Francois Pichet a83957a5c9 Add support for the Microsoft uuid attribute:
example:
struct __declspec(uuid("6d5140c1-7436-11ce-8034-00aa006009fa"))
test { };

llvm-svn: 122173
2010-12-19 06:50:37 +00:00
Douglas Gregor 1e2cdf5933 __attribute__((nonnull)) can apply to reference-to-pointer
parameters. Fixes <rdar://problem/8769025>.

llvm-svn: 121864
2010-12-15 15:41:46 +00:00
Abramo Bagnara 6d8106386c Added missing IgnoreParens().
llvm-svn: 121795
2010-12-14 22:11:44 +00:00
Peter Collingbourne 827301e659 Basic, Sema: add support for CUDA launch_bounds attribute
llvm-svn: 121654
2010-12-12 23:03:07 +00:00
Peter Collingbourne e8cfaf4258 Sema: diagnose kernel functions with non-void return type
llvm-svn: 121653
2010-12-12 23:02:57 +00:00
Rafael Espindola 0017c5fa92 Fix PR8720 by printing an error message with a substring that the gcc testsuite searches for.
llvm-svn: 121137
2010-12-07 15:23:23 +00:00
Argyrios Kyrtzidis 7ddcb80efe Remove a fixme which was fixed in a previous commit.
llvm-svn: 121029
2010-12-06 19:36:50 +00:00
Argyrios Kyrtzidis e88168ae6e Use Sema's MarkDeclarationReferenced, which takes care of templates, instead of calling Decl's setUsed directly.
Thanks to John for the hint!

llvm-svn: 121014
2010-12-06 17:51:53 +00:00
Argyrios Kyrtzidis 7b608976b1 Use the source location of the parameter, when it makes sense, for diagnostics in HandleCleanupAttr.
llvm-svn: 121013
2010-12-06 17:51:50 +00:00
Argyrios Kyrtzidis 86a26b8e35 Mark functions referenced by 'cleanup' attribute as used. Fixes rdar://8728293
llvm-svn: 120872
2010-12-04 01:12:11 +00:00
Eric Christopher 515d87ff95 Add some warning messages about invalid use of common/nocommon attributes.
llvm-svn: 120799
2010-12-03 06:58:14 +00:00
Eric Christopher 8a2ee390be Add support for the common and nocommon attributes.
rdar://8560647

llvm-svn: 120650
2010-12-02 02:45:55 +00:00
Eric Christopher bc638a83e0 80-col fixups.
llvm-svn: 120613
2010-12-01 22:13:54 +00:00
Peter Collingbourne 6ab610ce57 Basic, Sema: add support for CUDA location attributes
llvm-svn: 120545
2010-12-01 03:15:31 +00:00
Peter Collingbourne e57e9ef9b7 Remove static_casts from SemaDeclAttr.cpp
llvm-svn: 120053
2010-11-23 20:45:58 +00:00
Dan Gohman f41b525161 Drop the warning about __attribute__((may_alias)) being used
on a non-type declaration, as GCC permits it on variables too.
This fixes PR8635.

llvm-svn: 119517
2010-11-17 17:21:47 +00:00
Dan Gohman bbb7d62546 Front-end support for __attribute__((may_alias)). This is not
yet hooked up to anything yet.

llvm-svn: 119407
2010-11-17 00:03:07 +00:00
Chandler Carruth 743682bb9f Re-work the handling of implicit 'this' arguments and silly GCC-style attribute
argument indexes. This handles the offsets in a consistent manner for all of
the attributes which I saw working with these concepts. I've also added tests
for the attribute that motivated this: nonnull.

I consolidated the tests for format attributes into one file, and fleshed them
out a bit to trigger more of the warning cases. Also improved the quality of
some of the diagnostics that occur with invalid argument indices.

The only really questionable change here is supporting the implicit this
argument for the ownership attribute. I'm not sure it's really a sensible
concept there, but implemented the logic for consistency.

llvm-svn: 119339
2010-11-16 08:35:43 +00:00
John McCall 29600e160e Kill off the remaining places which generate CK_Unknown casts.
llvm-svn: 119326
2010-11-16 02:32:08 +00:00
Bob Wilson 118baf7611 Add support for "neon_vector_type" and "neon_polyvector_type" attributes
to create the special Neon vector types.  These are intended to be used in
Clang's version of <arm_neon.h> to define special Neon vector types that will
be mangled according to ARM's ABI.

llvm-svn: 119301
2010-11-16 00:32:24 +00:00
John McCall 8cb679e4e1 Assorted work leading towards the elimination of CK_Unknown.
llvm-svn: 119138
2010-11-15 09:13:47 +00:00