Commit Graph

4142 Commits

Author SHA1 Message Date
Eli Friedman c96d4963eb Implement __is_empty. Patch by Sean Hunt.
llvm-svn: 79143
2009-08-15 21:55:26 +00:00
Eli Friedman da8d4def72 Don't perform integer promotions on the operand to a cast; this
simplifies the AST, and can matter in some rare cases involving 
casts to vector types. Patch by Enea Zaffanella.

llvm-svn: 79126
2009-08-15 19:02:19 +00:00
Fariborz Jahanian 0aed0225b4 Improved on ir-gen for synthesis of non-trivial default
constructor body whose class has non-static data-members which
required non-trivial construction.

llvm-svn: 79125
2009-08-15 18:55:17 +00:00
Eli Friedman b360412582 Make test more precise.
llvm-svn: 79074
2009-08-15 03:40:49 +00:00
Eli Friedman c0f6d44ef6 Make test a bit more precise.
llvm-svn: 79073
2009-08-15 03:35:55 +00:00
Eli Friedman 04fddf0d1f Fix for PR4721: adjust CodeGen and ASTContext so that we have a
consistent model for handling size expressions for VLAs.

The model is essentially as follows: VLA types own their associated
expression.  In some cases, we need to create multiple VLA types to 
represent a given VLA (for canonical types, or qualifiers on array types,
or type merging).  If we need to create multiple types based off of 
the same VLA declaration, we use the new refcounting functionality so they can 
all own the expression. The VLASizeMap in CodeGenFunction then uses the size
expression to identify the group of VLA types based off of the same original
declaration.

I'm not particularly attached to the VLA types owning the expression, 
but we're stuck with at least until someone comes up with a way 
to walk the VLA expressions for a declaration.

I did the parallel fix in ASTContext for DependentSizedArrayType, but I 
haven't really looked closely at it, so there might still be issues 
there.

I'll clean up the code duplication in ASTContext in a followup commit.

llvm-svn: 79071
2009-08-15 02:50:32 +00:00
John McCall deb8448690 Disable all recognition of main() in -ffreestanding. Addresses bug #4720.
llvm-svn: 79070
2009-08-15 02:09:25 +00:00
Ted Kremenek 08479ae7fe Change handling of attribute 'malloc' to only accept the attribute on function
declarations (and not function pointers). This is consistent with GCC. Accepting
this attribute on function pointers means that the attribute should be treated
as a type qualifier, which apparently is not what GCC does. We obviously can
change this later should we desire to enhance the 'malloc' attribute in this
way.

llvm-svn: 79060
2009-08-15 00:51:46 +00:00
Ted Kremenek 8d091dbe13 Add more attribute 'malloc' test cases involving function pointers.
llvm-svn: 79055
2009-08-14 22:06:01 +00:00
Ted Kremenek f22c410efa Per Eli Friedman's feedback, handle attribute 'malloc' being applied to
declarations of function pointers.

llvm-svn: 79053
2009-08-14 22:03:27 +00:00
Fariborz Jahanian 2e4a46b745 objc2's foreach statement's selector type can be
a block pointer too.

llvm-svn: 79050
2009-08-14 21:53:27 +00:00
Ted Kremenek 026d201eca This test case does not need to include 'stdlib.h'.
llvm-svn: 79042
2009-08-14 20:53:10 +00:00
Ted Kremenek 527042b5a9 Improve Sema's handling of attribute 'malloc' to reject the attribute when
attaching to Objective-C methods (which mirrors GCC's behavior) and to allow the
return type of the function to be an Objective-C pointer or Block pointer (which
GCC also accepts).

Along the way, add 'const' to some of the pointer arguments of various utility
functions...

llvm-svn: 79040
2009-08-14 20:49:40 +00:00
Fariborz Jahanian 42af5ba7b7 ir-gen for generation of trvial copy constructor
call.

llvm-svn: 79034
2009-08-14 20:11:43 +00:00
Fariborz Jahanian 83b000c713 Fixed a regression in deciding when to issue warning on properties which
implement NSCopying protocol in GC mode.

llvm-svn: 79008
2009-08-14 18:06:25 +00:00
Shantonu Sen 4a7b937c4b PR4715
-Wno-error disables WarningsAsErrors instead of
mistakenly being treated like -Werror

llvm-svn: 78987
2009-08-14 04:07:15 +00:00
John McCall 58de35804b Support friend declarations in templates and test that argdep lookup
still works.

llvm-svn: 78979
2009-08-14 02:03:10 +00:00
Mike Stump 5aa7855e3a Testcase for a recent checkin.
llvm-svn: 78974
2009-08-14 01:50:51 +00:00
Mike Stump c4b7afed0f Testcase for recent checkin.
llvm-svn: 78973
2009-08-14 01:48:56 +00:00
Mike Stump 7ba9c8752c Testcase for a recent checkin.
llvm-svn: 78972
2009-08-14 01:46:56 +00:00
Fariborz Jahanian 92b3f47de2 Fixed a bug in ir-gen for copy assignment synthesis.
Fixed a bug when evaluating those copy-assignments
which need by lazily syntheized. A test case
for these.

llvm-svn: 78965
2009-08-14 00:01:54 +00:00
Mike Stump 9a1090a399 Add testcase for recent work.
llvm-svn: 78959
2009-08-13 23:33:29 +00:00
Mike Stump c2f591b1e6 Refine vtable layout for virtual bases and keep better track of
primaries.  WIP.

llvm-svn: 78950
2009-08-13 22:53:07 +00:00
Fariborz Jahanian 3d693b22df Adds testing of copy assignment of anonymous union
data members.

llvm-svn: 78943
2009-08-13 21:47:21 +00:00
Fariborz Jahanian 89d01eb3e4 More complete test for my previous patch.
llvm-svn: 78941
2009-08-13 21:38:50 +00:00
Fariborz Jahanian 4985b33fd7 Patch to force synthesis of copy assignment operator
function in the order according to c++03. ir-gen 
for copy assignment in the trivial case and the first
test case.

llvm-svn: 78938
2009-08-13 21:09:41 +00:00
Daniel Dunbar e5515289fa Update test
llvm-svn: 78877
2009-08-13 01:27:45 +00:00
Mike Stump 6bb66bbd06 Refine virtual base layout. WIP.
llvm-svn: 78873
2009-08-13 00:34:14 +00:00
Mike Stump 6f3793b406 Refine primary vbase selection ordering. WIP.
llvm-svn: 78844
2009-08-12 21:50:08 +00:00
Mike Stump 9deb22b850 Improve the secondary vtables to not include vbase offsets. WIP.
llvm-svn: 78831
2009-08-12 18:50:26 +00:00
Fariborz Jahanian 887cd6a8eb error on property of objc interface type instead of crashing
llvm-svn: 78826
2009-08-12 18:17:53 +00:00
Fariborz Jahanian 853d21a18a Warn on use of property dot syntax when unused.
llvm-svn: 78760
2009-08-12 00:45:33 +00:00
Dan Gohman 43b4484f87 Use the inbounds variant of getelementptr for common pointer arithmetic.
llvm-svn: 78756
2009-08-12 00:33:55 +00:00
Benjamin Kramer b3788a24c6 Rename macro to avoid a name clash on FreeBSD.
llvm-svn: 78741
2009-08-11 22:46:25 +00:00
Fariborz Jahanian 3f8917abf6 Patch to warn if a property which is 'assign' by default
may not implement NSCopying protocol in -fobjc-gc[-only] mode.

llvm-svn: 78726
2009-08-11 22:02:25 +00:00
Chris Lattner 66a388b859 merge two tests.
llvm-svn: 78705
2009-08-11 20:08:52 +00:00
Chris Lattner f1c9797ffa Fix rdar://7126285: don't warn on unused ObjC property access
that uses "dot syntax" since it might have a side effect.

llvm-svn: 78704
2009-08-11 20:08:03 +00:00
Fariborz Jahanian b2197042b8 ir-gen support for anonymous union data member
copying in copy constructors and used in
default constructor's initializer list.

llvm-svn: 78700
2009-08-11 18:49:54 +00:00
Daniel Dunbar d362857f4c Update test case.
llvm-svn: 78699
2009-08-11 18:37:40 +00:00
John McCall d1e9d835f3 Argument-dependent lookup for friend declarations. Add a new decl type,
FriendFunctionDecl, and create instances as appropriate.

The design of FriendFunctionDecl is still somewhat up in the air;  you can
befriend arbitrary types of functions --- methods, constructors, etc. ---
and it's not clear that this representation captures that very well.
We'll have a better picture when we start consuming this data in access
control.

llvm-svn: 78653
2009-08-11 06:59:38 +00:00
Mike Stump 78696a70bf Implement more of the inductive case for vtable layout involving
virtual base primaries and improve the layout of classes with virtual
bases.  WIP.

Hey, I've decided I want a change to FileCheck, I need to ensure that
the group is together, nothing in between.  Can we change it to check
the match line is from the line immediately following the last matched
line, if the source for the matched line is immediately after the
source for the previously matched line?

// CHECK: 1
// CHECK: 2
// CHECK: 3

// CHECK: 4
// CHECK: 5
// CHECK: 6

would require 1 2 and 3 to be continuous in the output, and 4 5 and 6
to be continuous.

llvm-svn: 78638
2009-08-11 04:03:59 +00:00
Nate Begeman 5ec4b318e3 Take 2 on AltiVec-style vector initializers.
Fixes PR4704 problems

Addresses Eli's patch feedback re: ugly cast code

Updates all postfix operators to remove ParenListExprs.  While this is awful,
no better solution (say, in the parser) is obvious to me.  Better solutions
welcome.

llvm-svn: 78621
2009-08-10 23:49:36 +00:00
Chris Lattner 30ba674391 fix a couple of problems with section attributes:
1. Passing something that isn't a string used to cause:
   "argument to annotate attribute was not a string literal"
  make it say "section attribute" instead.

2. Fix the location of the above message to point to the
   bad argument instead of the section token.

3. Implement rdar://4341926, by diagnosing invalid section
   specifiers in the frontend rather than letting them slip all
   the way to the assembler (a QoI win).

An example of #3 is that we used to produce something like this:

/var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Expected comma after segment-name
/var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Rest of line ignored. 1st junk character valued 46 (.).

Daniel improved clang to use llvm_report_error, so now we got:

$ clang t.c -c
fatal error: error in backend: Global variable 'x' has an invalid section specifier 'sadf': mach-o section specifier
      requires a segment and section separated by a comma.

with no loc info.  Now we get:

$ clang t.c -fsyntax-only
t.c:4:30: error: argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment
      and section separated by a comma
int x __attribute__((section("sadf")));
                             ^

which is nice :)

llvm-svn: 78586
2009-08-10 19:03:04 +00:00
Chris Lattner 2375952a47 these tests include section specifiers that aren't valid on the
mac, use an explicit triple.

llvm-svn: 78583
2009-08-10 18:56:44 +00:00
Fariborz Jahanian 7cc52cf09f ir-gen for generating copying of scalar data members in
a synthesized copy constructor.

llvm-svn: 78580
2009-08-10 18:34:26 +00:00
Fariborz Jahanian 2a26e351fc Fixed a ir-gen bug in synthesizing copy constructors.
llvm-svn: 78570
2009-08-10 17:20:45 +00:00
Daniel Dunbar 481fe50903 Revert r78535, it is causing a number of failures to build projects.
--- Reverse-merging r78535 into '.':
D    test/Sema/altivec-init.c
U    include/clang/Basic/DiagnosticSemaKinds.td
U    include/clang/AST/Expr.h
U    include/clang/AST/StmtNodes.def
U    include/clang/Parse/Parser.h
U    include/clang/Parse/Action.h
U    tools/clang-cc/clang-cc.cpp
U    lib/Frontend/PrintParserCallbacks.cpp
U    lib/CodeGen/CGExprScalar.cpp
U    lib/Sema/SemaInit.cpp
U    lib/Sema/Sema.h
U    lib/Sema/SemaExpr.cpp
U    lib/Sema/SemaTemplateInstantiateExpr.cpp
U    lib/AST/StmtProfile.cpp
U    lib/AST/Expr.cpp
U    lib/AST/StmtPrinter.cpp
U    lib/Parse/ParseExpr.cpp
U    lib/Parse/ParseExprCXX.cpp

llvm-svn: 78551
2009-08-10 03:01:36 +00:00
Ryan Flynn e64ffc277c warn, as gcc does, if __attribute__((malloc)) applied to function returning non-pointer type
llvm-svn: 78542
2009-08-09 22:36:29 +00:00
Ryan Flynn 1f1fdc070e map previously ignored __attribute((malloc)) to noalias attribute of llvm function's return
llvm-svn: 78541
2009-08-09 20:07:29 +00:00
Anders Carlsson f48123b413 Improve handling of member pointers.
llvm-svn: 78536
2009-08-09 18:26:27 +00:00
Nate Begeman a96114ed08 AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);
In addition to being defined by the AltiVec PIM, this is also the vector
initializer syntax used by OpenCL, so that vector literals are compatible
with macro arguments.

llvm-svn: 78535
2009-08-09 17:55:44 +00:00
Fariborz Jahanian 24f38969d5 ir-gen for initialization, in synthesize copy constructor,
of base/field which have trivial copy constructor.

llvm-svn: 78516
2009-08-08 23:32:22 +00:00
Anders Carlsson b8be93fc92 Add support for global initializers.
llvm-svn: 78515
2009-08-08 23:24:23 +00:00
Anders Carlsson f40886acca Refactor some code and implement support for global destructors for static variables.
llvm-svn: 78507
2009-08-08 21:45:14 +00:00
Anders Carlsson 2c101b3cd1 Use CastExpr::CK_ArrayToPointerDecay and fix an assert.
llvm-svn: 78502
2009-08-08 21:04:35 +00:00
Anders Carlsson e139f868b7 Add tests.
llvm-svn: 78491
2009-08-08 19:43:14 +00:00
Ryan Flynn 2f08571e4d PR4700 - remove shift by 0 warning
llvm-svn: 78488
2009-08-08 19:18:23 +00:00
Anders Carlsson 5fd7dad784 getFunctionLevelDeclContext needs to get the previous DeclContext if EnterDeclaratorContext has been called. Fixes PR4694. (Doug, please review)
llvm-svn: 78480
2009-08-08 17:48:49 +00:00
Anders Carlsson 21776b75ce Make sure to diagnose use of declarations in the case where we create an implicit CXXThisExpr.
llvm-svn: 78474
2009-08-08 16:55:18 +00:00
Daniel Dunbar d3a114fe2d Update test case; I don't really understand why packed enums changed this, but
the new havior is better so...

llvm-svn: 78473
2009-08-08 15:47:00 +00:00
Mike Stump 16644668cd Add vbase offsets to the vtable. Wow, having an rbegin was so
fortuitous.  WIP.

llvm-svn: 78413
2009-08-07 21:54:03 +00:00
Ted Kremenek 0e8e1fde25 Fix: <rdar://problem/7075531> static analyzer wrongly detects unused ivars used in blocks
llvm-svn: 78409
2009-08-07 21:13:23 +00:00
Mike Stump c266c6d797 Add ability to generate vcall offsets for primary virtual base.
llvm-svn: 78396
2009-08-07 19:00:50 +00:00
Ryan Flynn f53fab87d8 PR3333: warn when shifting by invalid amount
llvm-svn: 78385
2009-08-07 16:20:20 +00:00
Mike Stump 7c32eab164 Add support for vcall generation for vtables for virtual bases. WIP.
llvm-svn: 78357
2009-08-06 23:48:32 +00:00
Ted Kremenek 040e3b91da Fix a few more false positives involving RegionStore and unions, but this time
with array accesses. In the process, refactor some common logic in
RetrieveElement() and RetrieveField() into RetrieveFieldOrElementCommon().

llvm-svn: 78349
2009-08-06 22:33:36 +00:00
Mike Stump e6b39f5ca3 Almost forgot to turn on 32-bit test.
llvm-svn: 78346
2009-08-06 22:02:55 +00:00
Mike Stump 52aee0f3d9 Testcase for recent checkin.
llvm-svn: 78344
2009-08-06 21:53:24 +00:00
Mike Stump 3e62d00271 Also generate the rtti field for virtual bases for vtables. Turn on
rtti so we can properly test it.  Refactor code a little.  Still a
work in progress.

llvm-svn: 78343
2009-08-06 21:49:36 +00:00
Ted Kremenek 2f6eb14af4 Fix a couple false positive "uninitialized value" warnings with RegionStore
involving reasoning about unions (which we don't handle yet).

llvm-svn: 78342
2009-08-06 21:43:54 +00:00
John McCall 93343b9466 Permit a class to friend its members in C++0x, without restriction.
Permit a class to friend its class members in C++ 98, as long as extensions
are enabled (and even when they aren't, only give an extwarn about it).

llvm-svn: 78332
2009-08-06 20:49:32 +00:00
Mike Stump 2d8d655922 Layout the primary base first in the vtable.
llvm-svn: 78327
2009-08-06 18:05:22 +00:00
Fariborz Jahanian 11a8e95a1a After reporting ill-formed copy constructor(12.8.p3)
don't recurs and crash.

llvm-svn: 78323
2009-08-06 17:22:51 +00:00
Douglas Gregor 15acfb9f50 When we encounter a dependent type that was parsed before we know that
we were going to enter into the scope of a class template or class
template partial specialization, rebuild that type so that it can
refer to members of the current instantiation, as in code like

  template<typename T>
  struct X {
    typedef T* pointer;
    pointer data();
  };

  template<typename T>
  typename X<T>::pointer X<T>::data() { ... }

Without rebuilding the return type of this out-of-line definition, the
canonical return type of the out-of-line definition (a TypenameType)
will not match the canonical return type of the declaration (the
canonical type of T*).

llvm-svn: 78316
2009-08-06 16:20:37 +00:00
Mike Stump c255f3581a More layout for virtual tables for virtual bases. Still in progress.
llvm-svn: 78314
2009-08-06 15:50:11 +00:00
Mike Stump a60f1fc54b Let's remember we want better codegen for these.
llvm-svn: 78310
2009-08-06 14:16:19 +00:00
Mike Stump 04df9b1d5e Testcase for a recent checkin for vbase layout ordering. I hate to
optimize and check for non-optimal code, but until the frontend is as
powerful as fold...

llvm-svn: 78309
2009-08-06 14:12:47 +00:00
Mike Stump 6b2556f829 Layout virtual bases. Work in progress.
llvm-svn: 78308
2009-08-06 13:41:24 +00:00
Douglas Gregor 71dc50915a Implement transformation of template names within the generic tree
transform, then use the result for template instantiation. The generic
transformation fixes a few issues:

  - It copes better with template template parameters and member
  templates (when they're implemented). 
  - The logic used to replace template template parameters with their
  arguments is now centralized in TransformDecl, so that it will apply
  for other declaration-instantiation steps.
  - The error-recovery strategy is normalized now, so that any error
  results in a NULL TemplateName.

llvm-svn: 78292
2009-08-06 06:41:21 +00:00
Ted Kremenek f368fa6728 Update test case.
llvm-svn: 78290
2009-08-06 06:26:40 +00:00
Douglas Gregor d806156d54 Support nested-name-specifiers for C++ member access expressions, e.g.,
this->Base::foo

from James Porter!

llvm-svn: 78278
2009-08-06 03:17:00 +00:00
Ryan Flynn aa5e5fd2f4 add support for FreeBSD's format(printf0,x,y) attribute; allows null format string.
llvm-svn: 78276
2009-08-06 03:00:50 +00:00
John McCall 07e91c04ba First pass at friend semantics.
llvm-svn: 78274
2009-08-06 02:15:43 +00:00
Fariborz Jahanian eb869768f9 Patch to optimize away copy constructor call when
appropriate.

llvm-svn: 78267
2009-08-06 01:02:49 +00:00
John McCall 9de556c8b6 AlisdairM pointed out that this will likely be relaxed in C++0x, so let's
make a note of it in the test case.

llvm-svn: 78266
2009-08-06 00:50:46 +00:00
Mike Stump 2509480813 Fixup object layout when we have a primary base (it goes first). Start preping for
virtual base layout.

llvm-svn: 78265
2009-08-06 00:38:46 +00:00
John McCall 13c5a27c9a Add a test for invalid uses of non-static members from nested classes, just
because I was thinking about it.

llvm-svn: 78262
2009-08-05 23:56:26 +00:00
Mike Stump 6d368129c5 Add another test for a recent checkin.
llvm-svn: 78253
2009-08-05 22:48:36 +00:00
Mike Stump d8fe7b2792 Calculate the primary base class better and use that when laying down
the vtable.  Still a work in progress.

llvm-svn: 78252
2009-08-05 22:37:18 +00:00
Fariborz Jahanian 01aabafee0 A blank line to separate the two blocks(per Mike comment).
llvm-svn: 78248
2009-08-05 21:52:02 +00:00
Fariborz Jahanian daeb7d51d4 Modified test case to use FileCheck.
llvm-svn: 78231
2009-08-05 19:24:33 +00:00
Douglas Gregor f9bd4ecea2 Fix canonical type construction for function types with the noreturn
attribute. Fixes PR4865.

llvm-svn: 78224
2009-08-05 19:03:35 +00:00
Fariborz Jahanian d460cb4356 Handle destruction of temporaries used in default argument
construction of constructor calls.

llvm-svn: 78222
2009-08-05 18:17:32 +00:00
Fariborz Jahanian aa890bf2f3 Patch to improve ir-gen for constructors with default argument
expressions and a test case.

llvm-svn: 78213
2009-08-05 17:03:54 +00:00
Ted Kremenek 68c1f010d2 Fix a bug in RegionStoreSubRegionManager::add() where multiple subregions wouldn't correctly get registered in the SubRegion map.
llvm-svn: 78162
2009-08-05 05:31:02 +00:00
Chris Lattner f49573d1ee weak globals that are const should get weak_odr linkage.
add a fixme about C++ const.

llvm-svn: 78159
2009-08-05 05:20:29 +00:00
Chris Lattner c0693bc2ea rdar://7119244 - globals with an explicit section specified don't get
common linkage.

llvm-svn: 78158
2009-08-05 04:56:58 +00:00
Zhongxing Xu 13ee441874 Add test case.
llvm-svn: 78150
2009-08-05 03:45:09 +00:00
Mike Stump 9beac787c1 vtable building for simple inheritance. Still in progress.
llvm-svn: 78110
2009-08-04 21:58:42 +00:00
Mike Stump f5fc72eea9 Test cases for some recent work.
llvm-svn: 78100
2009-08-04 20:37:29 +00:00