Commit Graph

15101 Commits

Author SHA1 Message Date
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
Anders Carlsson ed1674d971 Add a CastInfo struct that will be used for cast information when constructing cast expressions. Right now it only stores the cast kind, but in the future it might store conversion functions and constructors.
llvm-svn: 78599
2009-08-10 21:30:22 +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 9d3405ceab minor refactoring. No change otherwise.
llvm-svn: 78582
2009-08-10 18:46:38 +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
Mike Stump 68f0d31f25 Add walking bases in reverse order.
llvm-svn: 78578
2009-08-10 18:21:22 +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 71f22e738a Use LLVM's new error handler API to report back end errors using Diagnostic.
For example,
--
ddunbar@giles:Frontend$ clang -c backend-errors.c
fatal error: error in backend: Global variable 'a' has an invalid section specifier
      'I AM, not, legal': mach-o section specifier uses an unknown section type.
--
compare to:
--
ddunbar@giles:Frontend$ gcc -c backend-errors.c
/var/folders/DQ/DQ8GT3++HESEzT1obWBynE+++TI/-Tmp-//cc45w2pq.s:2:Expected comma after segment-name
/var/folders/DQ/DQ8GT3++HESEzT1obWBynE+++TI/-Tmp-//cc45w2pq.s:2:Rest of line ignored. 1st junk character valued 77 (M).
--

Yay!

I am not tied to my wording choice, we could also go with "uncoverable error"
for the prefix, or just leave it off entirely.

llvm-svn: 78554
2009-08-10 03:40:28 +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
Benjamin Kramer b57e5d2f4f Older GCCs don't have vector::data().
llvm-svn: 78519
2009-08-08 23:43:26 +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
Anders Carlsson 28a5fa29f3 Take #pragma pack into account when laying out structs. Fixes rdar://problem/7095436.
llvm-svn: 78490
2009-08-08 19:38:24 +00:00
Fariborz Jahanian f6bda5d61e Refactoring of copy ctor ir-gen. No change in functionality.
llvm-svn: 78489
2009-08-08 19:31:03 +00:00
Ryan Flynn 2f08571e4d PR4700 - remove shift by 0 warning
llvm-svn: 78488
2009-08-08 19:18:23 +00:00
Anders Carlsson 68e0b68289 Introduce a new PragmaPack attribute, and use it for #pragma pack. The PackedAttr now only represents __attribute__((packed)).
This is necessary because #pragma pack and __attribute__((packed)) have different semantics. No functionality change yet, but this lays the groundwork for fixing a record layout bug.

llvm-svn: 78483
2009-08-08 18:23:56 +00:00
Anders Carlsson 453878bed4 Assert that the LLVM type has the same size as the RecordDecl size.
llvm-svn: 78481
2009-08-08 18:01:57 +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 b26ab816a2 Factor some code to get the "function level" DeclContext out into a separate function.
llvm-svn: 78478
2009-08-08 17:45:02 +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
Edward O'Callaghan c69169d175 Patch should implement packed enums - PR4098. Credit to Anders Johnsen.
llvm-svn: 78471
2009-08-08 14:36:57 +00:00
Anders Carlsson c5c57c3b86 Get rid of Stmt::Clone now that we can reference count statements instead.
llvm-svn: 78452
2009-08-08 02:50:17 +00:00
Douglas Gregor 2c742024ff Introduce reference counting for statements and expressions, using it
to allow sharing of nodes. Simplifies some aspects of template
instantiation, and fixes both PR3444 and <rdar://problem/6757457>.

llvm-svn: 78450
2009-08-08 01:41:12 +00:00
Fariborz Jahanian 7c3d7f6c59 Remove use of uninitized variable.
llvm-svn: 78448
2009-08-08 00:59:58 +00:00
Fariborz Jahanian 59b3259284 Synthesize copying of non-static data members with
non-trivial copy constructors.

llvm-svn: 78445
2009-08-08 00:15:41 +00:00
Fariborz Jahanian b68df0bc42 Synthesized copy constructor now generates code for
copying non-virtual base classes which have non-trivial
constructor. Work in progress.

llvm-svn: 78436
2009-08-07 23:51:33 +00:00
Anders Carlsson 8fc489da2a Add a CK_ArrayToPointerDecay cast kind.
llvm-svn: 78434
2009-08-07 23:48:20 +00:00
Anders Carlsson ec143777ba Add CK_ToUnion and use it for aggregate expression codegen.
llvm-svn: 78429
2009-08-07 23:22:37 +00:00
Anders Carlsson f10e414e4e More CastKind work.
llvm-svn: 78415
2009-08-07 22:21:05 +00:00
John McCall c7e8e795fa Just add global scope to the associated namespaces set instead of tracking it
separately.  Add the framework (currently unfed) for finding friend declarations
during argument-dependent lookup.

llvm-svn: 78414
2009-08-07 22:18:02 +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
Mike Stump d9687fded6 Add rbegin and rend for virtual bases, might come in handy some day.
llvm-svn: 78412
2009-08-07 21:44:39 +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
Ted Kremenek d99f2866ac Constify some pointers. No functionality change.
llvm-svn: 78407
2009-08-07 20:55:20 +00:00
Fariborz Jahanian 40134e71be More synthesis of copy constructors. Work in progress.
llvm-svn: 78402
2009-08-07 20:22:40 +00:00
Mike Stump a4d94b1a95 Fix typo.
llvm-svn: 78401
2009-08-07 20:14:05 +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
Anders Carlsson 4f4aab2aeb Use the correct cast kind as suggested by Doug.
llvm-svn: 78395
2009-08-07 18:45:49 +00:00
Mike Stump b93185d05a Fix some const_cast issues. This is the beginning of the rabbit hole.
llvm-svn: 78393
2009-08-07 18:05:12 +00:00
Ryan Flynn f53fab87d8 PR3333: warn when shifting by invalid amount
llvm-svn: 78385
2009-08-07 16:20:20 +00:00
Douglas Gregor e26a285c8f Separate Stmt::Destroy into the entrypoint for destroying a statement
or expression (Destroy) from the virtual function used to actually
destroy a given expression (DoDestroy). 

llvm-svn: 78375
2009-08-07 06:08:38 +00:00