Commit Graph

5972 Commits

Author SHA1 Message Date
John McCall c07a0c7e48 Change the representation of GNU ?: expressions to use a different expression
class and to bind the shared value using OpaqueValueExpr.  This fixes an
unnoticed problem with deserialization of these expressions where the
deserialized form would lose the vital pointer-equality trait;  or rather,
it fixes it because this patch also does the right thing for deserializing
OVEs.

Change OVEs to not be a "temporary object" in the sense that copy elision is
permitted.

This new representation is not totally unawkward to work with, but I think
that's really part and parcel with the semantics we're modelling here.  In
particular, it's much easier to fix things like the copy elision bug and to
make the CFG look right.

I've tried to update the analyzer to deal with this in at least some          
obvious cases, and I think we get a much better CFG out, but the printing
of OpaqueValueExprs probably needs some work.

llvm-svn: 125744
2011-02-17 10:25:35 +00:00
NAKAMURA Takumi 31ea2f14bc Triple::MinGW64 is deprecated and removed. We can use Triple::MinGW32 instead.
No one uses *-mingw64. mingw-w64 is represented as {i686|x86_64}-w64-mingw32.

llvm-svn: 125742
2011-02-17 08:51:38 +00:00
NAKAMURA Takumi 029d74b264 Fix whitespace.
llvm-svn: 125741
2011-02-17 08:50:50 +00:00
Chandler Carruth 712563bba4 Implement -Wenum-compare, which warns when comparing two enums of
different types. We omit the warning when the enum types are anonymous.
Unlike GCC, this warning does not distinguish between C++ and C/ObjC for
controling whether it is on by default, it is always on by default.

Original patch contributed by Richard Trieu (@ Google), I fixed some
style issues, and cleaned it up for submission.

llvm-svn: 125739
2011-02-17 08:37:06 +00:00
Chris Lattner c8e630e4db Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt.  There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself.  This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.

llvm-svn: 125733
2011-02-17 07:39:24 +00:00
Douglas Gregor 0e5d72f164 I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.

llvm-svn: 125718
2011-02-17 03:19:26 +00:00
Matt Beaumont-Gay 956fc1cb81 Fix PR9025 and add a diagnostic (and sometimes a fixit) for an overloaded
function name used as the base of a member expression. Early feedback from
Chandler Carruth, and code review from Nick Lewycky.

llvm-svn: 125714
2011-02-17 02:54:17 +00:00
Fariborz Jahanian 05d389f407 Improve diagnostics when property names an object type of
a forward class. // rdar://8851803

llvm-svn: 125699
2011-02-17 01:26:14 +00:00
Douglas Gregor 669a25aec3 Implement code completion results for the Objective-C Key-Value Coding
(KVC) and Key-Value Observing (KVO) protocols.

llvm-svn: 125696
2011-02-17 00:22:45 +00:00
Ted Kremenek 197fcd4418 Fix assertion failure in -Warray-bounds on template parameters used as arrays.
llvm-svn: 125693
2011-02-16 23:39:09 +00:00
John McCall 1bf5846abf Save a copy expression for non-trivial copy constructions of catch variables.
llvm-svn: 125661
2011-02-16 08:02:54 +00:00
Ted Kremenek 108b2d56bf Tweak -Warray-bounds diagnostics based on feedback from Chandler.
llvm-svn: 125649
2011-02-16 04:01:44 +00:00
Ted Kremenek 64699befcd Add trivial buffer overflow checking in Sema.
llvm-svn: 125640
2011-02-16 01:57:07 +00:00
Douglas Gregor 042465709f When searching for visible declarations (e.g., for code completion),
be sure to look at all of the Objective-C class declarations within a
@class. Fixes <rdar://problem/8876207>.

llvm-svn: 125635
2011-02-16 01:39:26 +00:00
Douglas Gregor b5f1e46d30 When trying to provide a code completion item for a call to "super" in
Objective-C, also look in the categories and class extensions of our
superclasses. Fixes <rdar://problem/8853540>.

llvm-svn: 125628
2011-02-16 00:51:18 +00:00
Fariborz Jahanian 6fd9435f6d Check for deprecated implementation unconditionally.
Warning and its note will be ignored in default case.

llvm-svn: 125621
2011-02-16 00:30:31 +00:00
Fariborz Jahanian 0c87d36d9d Fix typo (per Chris's comment).
llvm-svn: 125619
2011-02-16 00:14:11 +00:00
John McCall 9743e8d84e Handle delayed access in local declarations. PR9229.
llvm-svn: 125609
2011-02-15 22:51:53 +00:00
Douglas Gregor 24bbc46208 Teach code completion to cope with block types written without a
prototype, e.g., ^() rather than ^(void). Fixes
<rdar://problem/8875712>.

llvm-svn: 125608
2011-02-15 22:37:09 +00:00
Douglas Gregor f34a6f0fef Implement a special code-completion pattern for "IBAction". Fixes
<rdar://problem/8767704>.

llvm-svn: 125604
2011-02-15 22:19:42 +00:00
Douglas Gregor 8003924d10 When code-completing within a list of declaration specifiers,
separately handle the case of a local declaration-specifier list,
including all types in the set of options. Fixes
<rdar://problem/8790735> and <rdar://problem/8662831>.

llvm-svn: 125594
2011-02-15 20:33:25 +00:00
Peter Collingbourne e87167b7d8 OpenCL: semantic analysis support for cl_khr_fp64 extension
llvm-svn: 125588
2011-02-15 19:46:23 +00:00
Fariborz Jahanian d724a109cf Refactoring of code to issue warning on implemented
deprecated class and methods in objective-c.

llvm-svn: 125573
2011-02-15 17:49:58 +00:00
John McCall 25849cab8b Return a declaration to the parser when creating a field in C++ so that
the parser will complete the declarator with a valid decl and thus trigger
delayed diagnostics for it.  It certainly looks like we were intentionally
returning null here, but I couldn't find any good reason for it, and there
wasn't a comment, so farewell to all that.

llvm-svn: 125556
2011-02-15 07:12:36 +00:00
Fariborz Jahanian d33ab8c635 Warn if method for a deprecated method is implemented.
Warn if class for a deprecated class is implemented.
Warn if category for a deprecated class is implemented.
All under control of -Wdeprecated-implementations.
// rdar://8973810.

llvm-svn: 125545
2011-02-15 00:59:30 +00:00
John McCall fe9cf0abb7 Don't crash on hierarchy static_casts which appear in variable initializers.
PR9221.

llvm-svn: 125532
2011-02-14 23:21:33 +00:00
John McCall 2957e3ef49 Change the context correctly when instantiating a static data member definition.
llvm-svn: 125517
2011-02-14 20:37:25 +00:00
John McCall 909acf8209 Provide overload diagnostics when explicit casts involving class types fail.
PR8626.

llvm-svn: 125506
2011-02-14 18:34:10 +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
Peter Collingbourne 564c0fa47a Move support for "#pragma STDC FP_CONTRACT" to Parser; add Sema actions
llvm-svn: 125474
2011-02-14 01:42:35 +00:00
Fariborz Jahanian 12834e19c1 Use hasSameType in one more, hopefully, last place.
llvm-svn: 125468
2011-02-13 20:11:42 +00:00
Fariborz Jahanian 4de45dc6a7 Some refactoring and using more modern APIs for
implementation of co/contra-variance objc++
block pointers. // rdar://8979379.

llvm-svn: 125467
2011-02-13 20:01:48 +00:00
John McCall 8322c3a197 Give some convenient idiomatic accessors to Stmt::child_range and
Stmt::const_child_range, then make a bunch of places use them instead
of the individual iterator accessors.

llvm-svn: 125450
2011-02-13 04:07:26 +00:00
Fariborz Jahanian 42455ea935 Implement objective-c++'s block pointer type matching involving
types which are contravariance in argument types and covariance
in return types. // rdar://8979379.

llvm-svn: 125445
2011-02-12 19:07:46 +00:00
Peter Collingbourne de32b20bdd Reject forbidden storage class specifiers in OpenCL. Patch by George Russell!
llvm-svn: 125399
2011-02-11 19:59:54 +00:00
Daniel Dunbar 7c2dc3667f Fix think-o I committed without testing, shameful.
llvm-svn: 125299
2011-02-10 18:29:28 +00:00
Daniel Dunbar 66d8483170 Fix a gcc Wuninitialized false positive.
llvm-svn: 125298
2011-02-10 18:24:25 +00:00
Argyrios Kyrtzidis 7dd856a76b For -Woverloaded-virtual take into account canonical methods. Fixes rdar://8979966 & http://llvm.org/PR9182.
llvm-svn: 125296
2011-02-10 18:13:41 +00:00
NAKAMURA Takumi 98dd73d66c CMake: LLVM_NO_RTTI must be obsolete now!
llvm-svn: 125275
2011-02-10 09:15:32 +00:00
Fariborz Jahanian ca3566fc20 Fix scoping of method declarations and issue
warning when same parameter name used multiple times.
// rdar://8877730

llvm-svn: 125229
2011-02-09 22:20:01 +00:00
Peter Collingbourne 41f8546233 AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actions
llvm-svn: 125217
2011-02-09 21:07:24 +00:00
Peter Collingbourne 9e2c81f00a AST, Sema, Serialization: keep track of cudaConfigureCall
llvm-svn: 125216
2011-02-09 21:04:32 +00:00
John McCall bd06678921 Remove vtables from the Stmt hierarchy; this was pretty easy as
there were only three virtual methods of any significance.

The primary way to grab child iterators now is with
  Stmt::child_range children();
  Stmt::const_child_range children() const;
where a child_range is just a std::pair of iterators suitable for
being llvm::tie'd to some locals.  I've left the old child_begin()
and child_end() accessors in place, but it's probably a substantial
penalty to grab the iterators individually now, since the
switch-based dispatch is kindof inherently slower than vtable
dispatch.  Grabbing them together is probably a slight win over the
status quo, although of course we could've achieved that with vtables, too.

I also reclassified SwitchCase (correctly) as an abstract Stmt
class, which (as the first such class that wasn't an Expr subclass)
required some fiddling in a few places.

There are somewhat gross metaprogramming hooks in place to ensure
that new statements/expressions continue to implement
getSourceRange() and children().  I had to work around a recent clang
bug;  dgregor actually fixed it already, but I didn't want to
introduce a selfhosting dependency on ToT.

llvm-svn: 125183
2011-02-09 08:16:59 +00:00
John McCall f4cd4f94d9 NonTypeTemplateParmDecl is just a DeclaratorDecl, not a VarDecl.
Also, reorganize and make very explicit the logic for determining
the value kind and type of a referenced declaration.

llvm-svn: 125150
2011-02-09 01:13:10 +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
Argyrios Kyrtzidis 898fdbf82d In Sema::CheckShadow, get the DeclContext from the variable that we are checking
instead from the Scope; Inner scopes in bodies don't have DeclContexts associated with them.

Fixes http://llvm.org/PR9160 & rdar://problem/8966163.

llvm-svn: 125097
2011-02-08 18:21:25 +00:00
Fariborz Jahanian 87967425f9 Support for objextive-c++ use of property-dot syntax as receiver
in liu of a class method getter. 
// rdar://8962253

llvm-svn: 125094
2011-02-08 18:05:59 +00:00
Douglas Gregor a57a66e8d0 Sema::MaybeBindToTemporary() shouldn't treat any expression returning
a glvalue as a temporary. Previously, we were enumerating all of the
cases that coul return glvalues and might be called with
Sema::MaybeBindToTemporary(), but that was gross and we missed the
Objective-C property reference case.

llvm-svn: 125070
2011-02-08 02:14:35 +00:00
John McCall 653dac4b0a dgregor accidentally killed this assert, but on investigation, it can fire
on invalid code and we don't really care, so kill it harder.

llvm-svn: 125068
2011-02-08 01:59:10 +00:00