Commit Graph

1830 Commits

Author SHA1 Message Date
Ted Kremenek 2edaf4e973 Remove superfluous null pointer check. The pointer is used prior to this check.
llvm-svn: 175807
2013-02-21 22:10:49 +00:00
Ted Kremenek c6ebda167f Teach serialized diagnostics about notes without locations.
Along the way, improve a diagnostic for "previous declaration here" for implicit parameters.

Fixes <rdar://problem/13211384>.

llvm-svn: 175802
2013-02-21 21:40:44 +00:00
Joey Gouly 7d00f00f1d Add support to Sema and CodeGen for floating point vector types in OpenCL.
llvm-svn: 175734
2013-02-21 11:49:56 +00:00
David Blaikie 3a3c4e0f84 Avoid implicit conversions of Optional<T> to bool.
This is a precursor to making Optional<T>'s operator bool 'explicit' when
building Clang & LLVM as C++11.

llvm-svn: 175722
2013-02-21 06:05:05 +00:00
David Blaikie 6adc78e0df Replace TypeLoc llvm::cast support to be well-defined.
The TypeLoc hierarchy used the llvm::cast machinery to perform undefined
behavior by casting pointers/references to TypeLoc objects to derived types
and then using the derived copy constructors (or even returning pointers to
derived types that actually point to the original TypeLoc object).

Some context is in this thread:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html
Though it's spread over a few months which can be hard to read in the mail
archive.

llvm-svn: 175462
2013-02-18 22:06:02 +00:00
Fariborz Jahanian 223ca5c9ab Prevent crash on multiple user errors (which I cannot reproduce in
a small test case). // rdar://13178483.

llvm-svn: 175450
2013-02-18 17:22:23 +00:00
Benjamin Kramer 25c0510690 Sema: Unnest early exit and remove an unnecessary bad cast.
cast<ObjCObjectPointerType> doesn't look through sugar, getAs does.
Fixes PR15257.

llvm-svn: 175272
2013-02-15 15:17:50 +00:00
Fariborz Jahanian a934a022af objective-C: When implementing custom accessor method for
a property, the -Wdirect-ivar-access should not warn when 
accessing the property's synthesized instance variable.
// rdar://13142820

llvm-svn: 175195
2013-02-14 19:07:19 +00:00
Nick Lewycky b7444cd11e When marking derived classes' virtual methods ODR-used in order to trigger
instantiation in order to permit devirtualization later in codegen, skip over
pure functions since those can't be devirtualization targets.

llvm-svn: 175116
2013-02-14 00:55:17 +00:00
Nick Lewycky a096b14d1d The meat of this patch is in BuildCXXMemberCalLExpr where we make it use
MarkMemberReferenced instead of marking functions referenced directly. An audit
of callers to MarkFunctionReferenced and DiagnoseUseOfDecl also caused a few
other changes:
 * don't mark functions odr-used when considering them for an initialization
   sequence. Do mark them referenced though.
 * the function nominated by the cleanup attribute should be diagnosed.
 * operator new/delete should be diagnosed when building a 'new' expression.

llvm-svn: 174951
2013-02-12 08:08:54 +00:00
John McCall 587b348504 Perform placeholder conversions on the controller of a _Generic
expression.

llvm-svn: 174930
2013-02-12 02:08:12 +00:00
John McCall 6ced97aaae Diagnose loads of 'half' l-values in OpenCL.
Patch by Joey Gouly!

llvm-svn: 174928
2013-02-12 01:29:43 +00:00
Nick Lewycky 192542ce38 Test for virtual instead of pure here. It has the exact same effect, and John
claims it will improve performance.

llvm-svn: 174341
2013-02-05 06:20:31 +00:00
Richard Smith 9ca910111c PR15095: Use more correct source locations for the InitListExpr we fake up for
vector initialization. Patch by John Stratton!

llvm-svn: 174339
2013-02-05 05:55:57 +00:00
Richard Smith 6b21696ee8 Add some missing diagnostics for C++11 narrowing conversions.
llvm-svn: 174337
2013-02-05 05:52:24 +00:00
Richard Smith c084bd2888 PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".

For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".

For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.

llvm-svn: 174262
2013-02-02 02:14:45 +00:00
Nick Lewycky 45b5052834 This patch makes "&Cls::purevfn" not an odr use. This isn't what the standard
says, but that's a defect (to be filed). "Cls::purevfn()" is still an odr use.

Also fixes a bug that caused us to not mark the function referenced just
because we didn't want to mark it odr used.

llvm-svn: 174242
2013-02-02 00:25:55 +00:00
Fariborz Jahanian 4dca1d3d81 objc: Provide correct fixit instruction when two mismatched
nsstringis are compared without. // rdar://12716301

llvm-svn: 174214
2013-02-01 20:04:49 +00:00
Bill Schmidt eb03ae268e Fix PR14881 by implementing conversion rules between int and complex int.
Prior to the patch, Clang does not properly promote types when a complex
integer operand is combined with an integer via a binary operator, or when
one is assigned to the other in either order.  This patch detects when
promotion is needed (and permissible) and generates the necessary code.

The test assmes no target has the same size operands for "char" and
"long long," and that no target performs arithmetic on char operands without
extending them to a larger format first.  If there are any targets for
which this is not the case, they should be XFAILed.

llvm-svn: 174181
2013-02-01 15:34:29 +00:00
Nick Lewycky 9c7eb1d887 Add a new -Wundefined-inline warning for inline functions which are used but not
defined. Fixes PR14993!

llvm-svn: 174158
2013-02-01 08:13:20 +00:00
Nick Lewycky 60bd4be17a Fix grammar in comment.
llvm-svn: 174033
2013-01-31 03:15:20 +00:00
Nick Lewycky 35d2359b1c Fix ODR-use of a MemberExpr to check before marking a pure function used. Remove
a workaround for this bug from the -Wundefined-internals warning.

llvm-svn: 174020
2013-01-31 01:34:31 +00:00
Ted Kremenek f2ca8ec2b9 Hoist retrieval of Expr* into caller. No functionality change.
Just makes the code a little cleaner, and easier to reason about.

llvm-svn: 173953
2013-01-30 19:10:21 +00:00
Tim Northover da16507111 Also promote fp16 types to double when they're anonymous variadic arguments.
__fp16 isn't covered by the standard, but this resolves the oddity that float
gets promoted when passed variadically, but not the smaller type. This is
required by the AArch64 ABI, and a sane action elsewhere.

llvm-svn: 173918
2013-01-30 09:46:55 +00:00
Richard Smith be8229c8c0 Micro cleanup: use an array of const char, rather than an array of char, as the
type of the string literal implicitly used for a raw user-defined literal call.
No test; this has no semantic impact.

llvm-svn: 173309
2013-01-23 23:38:20 +00:00
Joey Gouly dd7f4566b1 Add a new LangOpt NativeHalfType. This option allows for native half/fp16
operations (as opposed to storage only half/fp16).

Also add some semantic checks for OpenCL half types.

llvm-svn: 173254
2013-01-23 11:56:20 +00:00
Richard Smith c406cb7364 Add -Wunsequenced (with compatibility alias -Wsequence-point) to warn on
expressions which have undefined behavior due to multiple unsequenced
modifications or an unsequenced modification and use of a variable.

llvm-svn: 172690
2013-01-17 01:17:56 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Fariborz Jahanian 14da440018 put back diagnostics when flexible members are captured
in lambdas.

llvm-svn: 171921
2013-01-09 00:09:15 +00:00
Fariborz Jahanian 5eae4adf23 Fix typo (again).
llvm-svn: 171917
2013-01-08 23:48:48 +00:00
Fariborz Jahanian 7a83f04094 Remove lambda from my last patch.
llvm-svn: 171915
2013-01-08 23:40:08 +00:00
Fariborz Jahanian b68f7b2a77 Fixes typo in comment.
llvm-svn: 171913
2013-01-08 23:21:22 +00:00
Fariborz Jahanian a716a34527 objectiveC blocks: It is impractical to capture
struct variables with flexiable array members in
blocks (and lambdas). Issue error instead of
crashing in IRGen. // rdar://12655829

llvm-svn: 171912
2013-01-08 23:17:51 +00:00
Rafael Espindola f26d5391ab Move loop variable update.
Thanks to Dmitri Gribenko for the suggestion.

llvm-svn: 171889
2013-01-08 19:58:34 +00:00
Rafael Espindola 820fa707b1 Mark all subsequent decls used.
In the source

  static void f();
  static void f();
  template<typename T>
  static void g() {
    f();
  }
  static void f() {
  }
  void h() {
    g<int>();
  }

the call to f refers to the second decl, but it is only marked used at the end
of the translation unit during instantiation, after the third f decl has been
linked in.

With this patch we mark all subsequent decls used, so that it is easy to check
if a symbol is used or not.

llvm-svn: 171888
2013-01-08 19:43:34 +00:00
Ted Kremenek a046169000 Don't warn about undefined varargs argument behavior in unreachable code.
Fixes <rdar://problem/12322000>.

llvm-svn: 171831
2013-01-08 01:50:40 +00:00
David Tweed 042e0883cb Scalar shifts in the OpenCL specification (as of v. 1.2) are defined to be
with respect to the lower "left-hand-side bitwidth" bits, even when negative);
see OpenCL spec 6.3j. This patch both implements this behaviour in the code
generator and "constant folding" bits of Sema, and also prevents tests
to detect undefinedness in terms of the weaker C99 or C++ specifications
from being applied. 

llvm-svn: 171755
2013-01-07 16:43:27 +00:00
Richard Smith 89645bc888 s/CXX0X/CXX11/g, except for __GNU_EXPERIMENTAL_CXX0X__, and update a few nearby 'C++0x' comments.
llvm-svn: 171372
2013-01-02 12:01:23 +00:00
Richard Smith 2bf7fdb723 s/CPlusPlus0x/CPlusPlus11/g
llvm-svn: 171367
2013-01-02 11:42:31 +00:00
Richard Smith de1a487402 Improve diagnostic wording for when an implicitly-deleted special member
function is selected by overload resolution.

llvm-svn: 171190
2012-12-28 12:23:24 +00:00
Ted Kremenek 6487335f43 Tweak Sema::CheckLiteralKind() to also include block literals
This simplifies some diagnostic logic in checkUnsafeAssignLiteral(),
hopefully making it less error prone.

llvm-svn: 170945
2012-12-21 22:46:35 +00:00
Ted Kremenek 44c2a2a26e Change checkUnsafeAssignLiteral() to use the new Sema::CheckLiteralKind().
Along the way, fix a bug in CheckLiteralKind(), previously in diagnoseObjCLiteralComparison, where we didn't ignore parentheses
in boxed expressions for purpose of classification.

In other words, both @42 and @(42) should be classified as numeric
literals.

llvm-svn: 170931
2012-12-21 21:59:39 +00:00
Ted Kremenek 01a33f82d2 Hoist logic for classifying Objective-C literals into Sema (proper) for use with other diagnostics.
No immediate (intended) functionality change.

llvm-svn: 170930
2012-12-21 21:59:36 +00:00
Roman Divacky 241f45118b Remove duplicate includes.
llvm-svn: 170903
2012-12-21 17:07:08 +00:00
Richard Smith 38a549bc42 Fix regression in r170489: when instantiating a direct initializer which is a
CXXScalarValueInitExpr (or an ImplicitValueInitExpr), strip it back down to an
empty pair of parentheses so that the initialization code can tell that we're
performing value-initialization.

llvm-svn: 170867
2012-12-21 08:13:35 +00:00
Benjamin Kramer 6928cf7826 Sema: Don't emit a warning when __func__ is used in a lambda outside of a function.
Fixes PR14518.

llvm-svn: 169510
2012-12-06 15:42:21 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Douglas Gregor c401755f46 Fix the determination of whether a capture refers to an enclosing
scope when dealing with nested blocks. Fixes <rdar://problem/12778708>.

llvm-svn: 169065
2012-12-01 01:01:09 +00:00
Rafael Espindola 8778c28022 Merge function types in C.
Among other differences, GCC accepts

  typedef int IA[];
  typedef int A10[10];
  static A10 *f(void);
  static IA  *f(void);
  void g(void) {
    (void)sizeof(*f());
  }

but clang used to reject it with:

  invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []')

The intention of c99's 6.2.7 seems to be that we should use the composite type
and accept as gcc does.

Doing the type merging required some extra fixes:
  * Use the type from the function type in initializations, even if an parameter
    is available.
  * Fix the merging of the noreturn attribute in function types.
  * Make CodeGen  handle the fact that an parameter type can be different from
    the corresponding type in the function type.

llvm-svn: 168895
2012-11-29 16:09:03 +00:00
Richard Smith e6a56db2e6 Reject uses of __int128 on platforms that don't support it. Also move the ugly
'getPointerWidth(0) >= 64' test to be a method on TargetInfo, ready to be
properly cleaned up.

llvm-svn: 168856
2012-11-29 05:41:51 +00:00