Commit Graph

3894 Commits

Author SHA1 Message Date
Daniel Dunbar 6bdd19a7e2 Change these tests to not depend as much on the name of the input.
llvm-svn: 77057
2009-07-25 09:01:12 +00:00
John McCall 02dee0a46a Semantic checking for main().
Fix some invalid main() methods in the test suite that were nicely
exposed by the new checks.

llvm-svn: 77047
2009-07-25 04:36:53 +00:00
Douglas Gregor a6ef8f0813 Template instantiation for static data members that are defined out-of-line.
Note that this also fixes a bug that affects non-template code, where we 
were not treating out-of-line static data members are "file-scope" variables,
and therefore not checking their initializers.

llvm-svn: 77002
2009-07-24 20:34:43 +00:00
Fariborz Jahanian 4dcc53f312 Fixes broken test by accident.
llvm-svn: 77001
2009-07-24 20:33:35 +00:00
Fariborz Jahanian a5c335527d More Sema check for constructor's member initializer along
with type conversion to fix ir-gen crash.

llvm-svn: 77000
2009-07-24 20:28:49 +00:00
Steve Naroff e87026a08f Allow front-end 'isa' access on object's of type 'id'.
Enhance test case to cover 'isa' access on interface types (clang produces an error, GCC produces a warning).

Still need back-end CodeGen for ObjCIsaExpr.

llvm-svn: 76979
2009-07-24 17:54:45 +00:00
Anders Carlsson e2c6baf629 Don't use getLLVMFieldNo for bitfields when constructing the ivar layout maps for GC.
llvm-svn: 76978
2009-07-24 17:23:54 +00:00
Mike Stump 8e79f99b16 Implement new warning for functions declared 'noreturn' when they fall off the end.
llvm-svn: 76932
2009-07-24 02:49:01 +00:00
Douglas Gregor 79f83eda84 This patch fixes the implementations of the __has_trivial_destructor
and __has_trivial_constructor builtin pseudo-functions and
additionally implements __has_trivial_copy and __has_trivial_assign,
from John McCall!

llvm-svn: 76916
2009-07-23 23:49:00 +00:00
Daniel Dunbar 91ade14197 Output UTF-16 string literals independent of host byte order.
- Steve, can you take a look at this? It seems like this code should live
   elsewhere, and there is a FIXME about having Sema validates the UTF-8 to
   UTF-16 conversion.

llvm-svn: 76915
2009-07-23 23:41:22 +00:00
Fariborz Jahanian ca2f085a4e Diagnose when base classes and members to be intialized
with constructors don't have a matching constructor.

llvm-svn: 76913
2009-07-23 23:32:59 +00:00
Ted Kremenek 6610c0326b Implement: <rdar://problem/6335715> rule request: gets() buffer overflow
llvm-svn: 76905
2009-07-23 22:29:41 +00:00
Ted Kremenek 9c49762776 Refine checking and diagnostics for use of floating point variable as a counter.
This implements <rdar://problem/6336718> and checks for CERT secure coding
advisory FLP30-C.

llvm-svn: 76900
2009-07-23 21:34:35 +00:00
Anders Carlsson 516e5e7835 Correct a thinko in bitfield layout code. Fixes PR4611.
llvm-svn: 76898
2009-07-23 21:16:33 +00:00
Daniel Dunbar 07b749230c Switch the driver back to always using clang-cc by default (for C++, and
regardless of the architecture).
 - This is a good default for development & testing; for example without this
   any tests using 'clang' in the test suite will fail on PowerPC, since the
   driver will avoid using clang.

 - We don't want to actually ship something built this way, but that should be
   handled via some sort of configuration file.

llvm-svn: 76886
2009-07-23 17:48:59 +00:00
Anders Carlsson d78fc89fcb We don't need to keep track of the packed alignment, just whether the struct is packed or not. Fixes PR4610.
llvm-svn: 76884
2009-07-23 17:24:40 +00:00
Daniel Dunbar 34169976d0 Fix test case, which has a control-reaches-end-of-non-void warning that was
being masked by previous bug.

llvm-svn: 76858
2009-07-23 05:06:51 +00:00
Anders Carlsson 718a89a501 Use arrays as union padding. Also, since the resulting struct will always contain a single element and either a single i8 element or an array of i8s, there's no reason to use a packed struct.
llvm-svn: 76854
2009-07-23 04:50:01 +00:00
Steve Naroff 8e6aee5821 Remove a bunch of FIXME's related to ObjC type checking.
- Move Sema::ObjCQualifiedIdTypesAreCompatible(), Sema::QualifiedIdConformsQualifiedId(), and a couple helper functions to ASTContext.
- Change ASTContext::canAssignObjCInterfaces() to use ASTContext:: ObjCQualifiedIdTypesAreCompatible(). 
- Tweak several test cases to accommodate the new/improved type checking.

llvm-svn: 76830
2009-07-23 01:01:38 +00:00
Fariborz Jahanian 0228bc1a41 Add constructor used to initialize base/member in
CXXBaseOrMemberInitializer AST node. Needed by
its clients to do the initialization.

llvm-svn: 76826
2009-07-23 00:42:24 +00:00
Mike Stump 33979f75a0 Add warning for falling off the end of a function that should return a
value.  This is on by default, and controlled by -Wreturn-type (-Wmost
-Wall).  I believe there should be very few false positives, though
the most interesting case would be:

  int() { bar(); }

when bar does:

  bar() { while (1) ; }

Here, we assume functions return, unless they are marked with the
noreturn attribute.  I can envision a fixit note for functions that
never return normally that don't have a noreturn attribute to add a
noreturn attribute.

If anyone spots other false positives, let me know!

llvm-svn: 76821
2009-07-22 23:56:57 +00:00
Douglas Gregor e93e46c690 Implement support for out-of-line definitions of the class members of class
templates, e.g.,

  template<typename T>
  struct Outer {
    struct Inner;
  };

  template<typename T>
  struct Outer<T>::Inner {
    // ...
  };

Implementing this feature required some extensions to ActOnTag, which
now takes a set of template parameter lists, and is the precursor to
removing the ActOnClassTemplate function from the parser Action
interface. The reason for this approach is simple: the parser cannot
tell the difference between a class template definition and the
definition of a member of a class template; both have template
parameter lists, and semantic analysis determines what that template
parameter list means.

There is still some cleanup to do with ActOnTag and
ActOnClassTemplate. This commit provides the basic functionality we
need, however.

llvm-svn: 76820
2009-07-22 23:48:44 +00:00
Mike Stump 8dd1b6bd10 Improve CFG support for C++ throw expressions.
llvm-svn: 76814
2009-07-22 22:56:04 +00:00
Mike Stump 24cbfc370b Prep for new warning.
llvm-svn: 76813
2009-07-22 22:55:09 +00:00
Eli Friedman 6aea57560f Slight code reorganization to allow instantiating post-inc/dec.
llvm-svn: 76807
2009-07-22 22:25:00 +00:00
Ted Kremenek 915c351496 Migrate the path-sensitive checking of 'nonnull' arguments over to the new
'Checker' interface. An updated test case illustrates that after calling a
function with the 'nonnull' attribute we now register the fact that the passed
pointer must be non-null. This retention of information was not possible with
the previously used GRSimpleAPICheck interface.

llvm-svn: 76797
2009-07-22 21:46:56 +00:00
Eli Friedman 3af2a77717 Fix the parsing of default arguments for inline member function
definitions.

I'm not very familiar with this code, so please review.

llvm-svn: 76796
2009-07-22 21:45:50 +00:00
Douglas Gregor d6605dbbc0 Fix the problems with template argument deduction and array types for
real. It turns out that we need to actually move all of the qualifiers
up to the array type itself, then recanonicalize the deduced template
argument type.

llvm-svn: 76788
2009-07-22 21:30:48 +00:00
Douglas Gregor 7ac44f4cfb Canonicalize the types produced by template argument deduction.
llvm-svn: 76777
2009-07-22 20:25:36 +00:00
Douglas Gregor b3a1fdc363 Slighty more testing for template argument deduction with array arguments
llvm-svn: 76774
2009-07-22 20:07:21 +00:00
Douglas Gregor 6045482792 Improve template argument deduction for array types, so that a parameter
const T

can be matched with, e.g.,

  volatile int [5]

llvm-svn: 76773
2009-07-22 20:02:25 +00:00
Mike Stump af6ab88979 Prep for new warning.
llvm-svn: 76772
2009-07-22 20:02:03 +00:00
Douglas Gregor 8a27391190 "This patch implements the restrictions on union members detailed in
[class.union]p1", from John McCall!

llvm-svn: 76766
2009-07-22 18:25:24 +00:00
Douglas Gregor b09f3d82cc Implement parsing and semantic analysis for out-of-line definitions of static
data members of class templates. We don't instantiate the definitions yet,
however.

llvm-svn: 76756
2009-07-22 17:18:37 +00:00
Steve Naroff 3de6b70730 Fix a couple recent ABI regressions noticed during code review (fallout from the ObjC type system rewrite).
It's unfortunate that the mangling includes the low-level structs. Nevertheless, we need this for binary compatibility with GCC.

llvm-svn: 76755
2009-07-22 17:14:51 +00:00
Steve Naroff 51d4f79ffa Fix <rdar://problem/6770276> Support Class<Proto> syntax.
llvm-svn: 76741
2009-07-22 16:07:01 +00:00
Douglas Gregor a3a4dd5d03 Test template instantiation for member functions of class templates defined
out of line.

llvm-svn: 76740
2009-07-22 15:45:39 +00:00
Eli Friedman 5ac69057c0 Make vectorized floating-point comparisons work without crashing.
llvm-svn: 76726
2009-07-22 06:07:16 +00:00
Ted Kremenek b2d0409d50 Fix a crasher in StoreManager::InvalidateRegion() caused by using the
'cast type' of a region to invalidate its binding.  This only occurs
when using RegionStoreManager, as it records the cast type.  I'm
currently considering removing the notion of a cast type (see
comments in code).

llvm-svn: 76719
2009-07-22 04:23:20 +00:00
Mon P Wang acedf7768f Preserve address space information through member accesses, e.g.,
__attribute__((address_space(1))) struct {int arr[ 3 ]; }  *p1;
   ... = p1->arr[2];  // load from address space 1

llvm-svn: 76717
2009-07-22 03:08:17 +00:00
Mike Stump 753d120975 Prep for new warning.
llvm-svn: 76709
2009-07-22 00:43:08 +00:00
Douglas Gregor 168190d822 Complain if we're entering the context of a dependent nested-name-specifier but
cannot match that nested-name-specifier to a class template or class template
partial specialization.

llvm-svn: 76704
2009-07-22 00:28:09 +00:00
Douglas Gregor d8d297c0ac Basic parsing and semantic analysis for out-of-line definitions of the
member functions of class templates, e.g.,

  template<typename T> 
  struct X {
    void f(T);
  };

  template<typename T> X<T>::f(T) { /* ... */ }

llvm-svn: 76692
2009-07-21 23:53:31 +00:00
Mike Stump 93a7ed1fc7 Revert this, we can now avoid error cascades better.
llvm-svn: 76691
2009-07-21 23:52:50 +00:00
Mike Stump 5c1acd1f33 Revert this, was a bug in my new warning code, not the test case.
llvm-svn: 76690
2009-07-21 23:50:15 +00:00
Mike Stump 0ab3c3deac Revert this, we have a better way to do this.
llvm-svn: 76687
2009-07-21 23:47:12 +00:00
Mike Stump d8679446a3 Revert this, we have a better way to handle this.
llvm-svn: 76685
2009-07-21 23:45:39 +00:00
Mike Stump d7b9282e48 Revert recent change, I now have a better way to solve this (thanks Chris).
llvm-svn: 76681
2009-07-21 23:41:23 +00:00
Mike Stump bdbe099dd2 Prep for new warning.
llvm-svn: 76670
2009-07-21 22:54:02 +00:00
Ted Kremenek c1986570ed Remove stale comment and fix RUN line.
llvm-svn: 76656
2009-07-21 21:48:25 +00:00