Commit Graph

2863 Commits

Author SHA1 Message Date
Ted Kremenek 5054663daa Fix: <rdar://problem/6776949> Branch condition evaluates to an uninitialized value (argc is guaranteed to be >= 1)
The analyzer now adds the precondition that the first argument of 'main' is > 0.

llvm-svn: 68757
2009-04-10 00:59:50 +00:00
Ted Kremenek 40f4ee74fd Implement attribute "analyzer_noreturn" (<rdar://problem/6777003>). This allows
clients of the analyzer to designate custom assertion routines as "noreturn"
functions from the analyzer's perspective but not the compiler's.

llvm-svn: 68746
2009-04-10 00:01:14 +00:00
Douglas Gregor ef84c4b434 Implementation of pre-compiled headers (PCH) based on lazy
de-serialization of abstract syntax trees.

PCH support serializes the contents of the abstract syntax tree (AST)
to a bitstream. When the PCH file is read, declarations are serialized
as-needed. For example, a declaration of a variable "x" will be
deserialized only when its VarDecl can be found by a client, e.g.,
based on name lookup for "x" or traversing the entire contents of the
owner of "x".

This commit provides the framework for serialization and (lazy)
deserialization, along with support for variable and typedef
declarations (along with several kinds of types). More
declarations/types, along with important auxiliary structures (source
manager, preprocessor, etc.), will follow.

llvm-svn: 68732
2009-04-09 22:27:44 +00:00
Anders Carlsson 39b2e130f0 Add @encode support for complex types.
llvm-svn: 68729
2009-04-09 21:55:45 +00:00
Daniel Dunbar b041085c17 Add more builtin definitions, including strcmp.
- PR3964.

llvm-svn: 68710
2009-04-09 16:42:50 +00:00
Ted Kremenek f9f9420303 GRExprEngine: Don't try to reason about the size of 'void' for the return type
of messages sent to nil.

llvm-svn: 68683
2009-04-09 05:45:56 +00:00
Daniel Dunbar d067f7fbef Driver: Split out CPP specific options for clang so that we don't end
up adding them twice when running with -no-integrated-cpp or
-save-temps.
 - <rdar://problem/6766636> -save-temps falls over with prefix headers

llvm-svn: 68660
2009-04-08 23:54:23 +00:00
Steve Naroff b47acdb2e5 Fix <rdar://problem/6770998> make cast of super illegal (again:-)
llvm-svn: 68659
2009-04-08 23:52:26 +00:00
Daniel Dunbar 6eaebd0934 Force triple for these tests.
llvm-svn: 68651
2009-04-08 23:02:51 +00:00
Chris Lattner e01d82b81f finish the implementation of -imacros. The driver still needs to be hooked up.
llvm-svn: 68640
2009-04-08 20:53:24 +00:00
Anders Carlsson 03a409feda We weren't generating correct code for calls to variadic member functions.
llvm-svn: 68635
2009-04-08 20:31:57 +00:00
Fariborz Jahanian fc58ca4af6 Fixed a problem using property syntax on a 'super'
used as receiver.

llvm-svn: 68631
2009-04-08 19:50:10 +00:00
Ted Kremenek 5451c60f5a Enhance analyzer reasoning about sending messages to nil. A nil receiver returns 0 for scalars of size <= sizeof(void*).
llvm-svn: 68629
2009-04-08 18:51:08 +00:00
Daniel Dunbar 17ddaa677e More fixes to builtin preprocessor defines.
- Add -static-define option driver can use when __STATIC__ should be
   defined (instead of __DYNAMIC__).

 - Don't set __OPTIMIZE_SIZE__ on Os, __OPTIMIZE_SIZE__ is tied to Oz.

 - Set __NO_INLINE__ following GCC 4.2.

 - Set __GNU_GNU_INLINE__ or __GNU_STDC_INLINE__ following GCC 4.2.

 - Set __EXCEPTIONS for Objective-C NonFragile ABI.

 - Set __STRICT_ANSI__ for standard conforming modes.

 - I added a clang style test case in utils for this, but its not
   particularly portable and I don't think it belongs in the test
   suite.

llvm-svn: 68621
2009-04-08 18:03:55 +00:00
Steve Naroff ea4c780da1 Sema::CheckConditionalOperands(): Soften pointer/integer mismatch from error->warning.
Fixes <rdar://problem/6762239> [sema] gcc incompatibility; error on incompatible operand types in ?:.

llvm-svn: 68617
2009-04-08 17:05:15 +00:00
Douglas Gregor b53c0c29c0 -Wmissing-prototypes shouldn't complain about main() missing a prototype.
Fixes <rdar://problem/6759522>

llvm-svn: 68611
2009-04-08 15:21:36 +00:00
Daniel Dunbar 8f28d01126 Implementation definition of interfaces with __objc_exception attribute.
- Complete <rdar://problem/6635883> Support __objc_exception__
   attribute

llvm-svn: 68591
2009-04-08 04:21:03 +00:00
Ted Kremenek 605fee8445 New static analyzer check by Nikita Zhuk!
"The attached patch generates warnings of cases where an ObjC message is sent to
a nil object and the size of return type of that message is larger than the size
of void pointer. This may result in undefined return values as described in PR
2718.  The patch also includes test cases."

llvm-svn: 68585
2009-04-08 03:07:17 +00:00
Daniel Dunbar ab7b2f5623 Set __PIC__ (more) correctly.
- Add -pic-level clang-cc option to specify the value for the define,
   updated driver to pass this.

 - Added __pic__

 - Added OBJC_ZEROCOST_EXCEPTIONS define while I was here (to match gcc).

llvm-svn: 68584
2009-04-08 03:03:23 +00:00
Anders Carlsson a60cbcdfe6 Don't assume that a block always has a FunctionProtoType. Fixes rdar://6768379.
llvm-svn: 68583
2009-04-08 02:55:55 +00:00
Daniel Dunbar d4510f2223 Driver: Fix forwarding of -fpascal-strings.
llvm-svn: 68570
2009-04-07 23:51:44 +00:00
Steve Naroff 65a0089eb7 Fix <rdar://problem/6764172> [sema] crash on invalid.
llvm-svn: 68568
2009-04-07 22:56:58 +00:00
Daniel Dunbar ea10ab668f Visibility attributes should only be set on definition.
llvm-svn: 68561
2009-04-07 22:36:33 +00:00
Daniel Dunbar c44b4ccca8 Driver: Fix forwarding of -{std,ansi,trigraphs} when there are
multiple instances of an option.

Also, removed direct -ansi support from clang-cc.

llvm-svn: 68558
2009-04-07 22:13:21 +00:00
Fariborz Jahanian 9ecb84bb21 Now that we have __weak defined as attribute in all modes,
we must not issue gc-specific errors in non-gc mode.

llvm-svn: 68551
2009-04-07 21:25:06 +00:00
Daniel Dunbar d18049ab1d Driver: Manually translate a number of -f with no- variants options to
clang.
 - We will eventually want some more driver infrastructre for this
   probably.

 - For now, the clang-cc interface stays relatively the same, but we
   don't accept multiple instances anymore, or the [no-] variants
   directly.

llvm-svn: 68550
2009-04-07 21:16:11 +00:00
Fariborz Jahanian 57eb2e021e Propagte -fvisibility to objc2's class symbols.
llvm-svn: 68543
2009-04-07 20:26:30 +00:00
Eli Friedman 574c745370 Diagnose uses of function specifiers on declarations which don't declare
functions.  Fixes PR3941.

llvm-svn: 68541
2009-04-07 19:37:57 +00:00
Fariborz Jahanian 69ba935743 Fixes method name lookup when method appears in
the base implementations (and not in
current implementation).

llvm-svn: 68527
2009-04-07 18:28:06 +00:00
Anders Carlsson e871d05e26 Fix broken test case. I have no idea why this ever worked.
llvm-svn: 68526
2009-04-07 18:21:53 +00:00
Daniel Dunbar b2a7c062aa Driver: Fix a parsing bug where some options were matched
incorrectly. I'm blanking on the smartest way to write this search,
but we should just do the right thing when we move to TableGen.
 - <rdar://problem/6761194> [driver] -Wextra-tokens isn't parsed
   correctly

llvm-svn: 68525
2009-04-07 18:21:47 +00:00
Daniel Dunbar 88056a97f2 Use %s in test, not hard coded name.
llvm-svn: 68521
2009-04-07 17:09:43 +00:00
Douglas Gregor 40a8e0fbce XFAIL a failing test
llvm-svn: 68519
2009-04-07 16:32:03 +00:00
Steve Naroff ebc790d4d8 Tweak Sema::ActOnInstanceMessage() to look for a class method when dealing with qualified id's. This change is motivated by our desire to not support the "Class<foo>" idiom. Note that the change makes perfect sense (since all ObjC classes are also id/instances).
This allow us to document a simple migration path...change "Class <foo>" to "id <foo>".

This effects: 
- <rdar://problem/6761939> TASK: File source change radars for "qualified Class" errors
- <rdar://problem/6761864> Protocol qualified Class is unsupported

llvm-svn: 68517
2009-04-07 15:07:57 +00:00
Steve Naroff d338d08f49 Fix typo in newly added test case.
llvm-svn: 68515
2009-04-07 14:22:40 +00:00
Steve Naroff 54e5945297 Change the type of ObjC @ string constants (from NSConstantString->NSString).
This fixes <rdar://problem/6757102> clang type for @"xxx" is "NSConstantString *" (GCC type is "NSString *").

llvm-svn: 68514
2009-04-07 14:18:33 +00:00
Daniel Dunbar d7beeea228 Handle use side of __objc_exception__ attribute; when using an
exception with this attribute we don't need to emit a weak definition
for the exception type information.

llvm-svn: 68513
2009-04-07 06:43:45 +00:00
Chris Lattner 91c941ecfd *everyone* knows that __weak is not defined on linux :)
llvm-svn: 68512
2009-04-07 06:05:28 +00:00
Chris Lattner 0f98a286a3 implement rdar://6762183. I'm not sure if it is more insane that
GCC ignores macro definitions after \n's or that real code depends
on this.

llvm-svn: 68511
2009-04-07 06:02:44 +00:00
Daniel Dunbar 15894b791b Various fixes to symbols used for Obj-C x86_64 metadata.
- Changed method names to match gcc (categories names still aren't
   mangled in).

 - Expose correct name for class and metadata symbols (although
   -fvisibility=hidden isn't yet correct).

 - Remove several things from llvm.used that didn't need to be there
   (I suspect this can still be trimmed).

 - Don't use asm-prefix extension for _objc_empty_{cache,vtable} (not
   needed).

 - Hide EH type class info with -fvisibility=hidden

 - Change setGlobal[Option]Visibility to not change the visibility of
   functions with internal linkage.

llvm-svn: 68510
2009-04-07 05:48:37 +00:00
Ted Kremenek 25db1f3ff1 Add test case.
llvm-svn: 68505
2009-04-07 05:33:18 +00:00
Daniel Dunbar 5718a2b4a1 Fix test (triple wasn't passed correctly, the driver doesn't accept
-mtriple).

llvm-svn: 68484
2009-04-07 02:31:44 +00:00
Daniel Dunbar 4fab57ddea Implement __sync_{add,sub,and,or,xor}_and_fetch and
__sync_bool_compare_and_swap.
 - <rdar://problem/6762223> [sema/irgen] support
   __sync_bool_compare_and_swap and __sync_add_and_fetch

llvm-svn: 68482
2009-04-07 00:55:51 +00:00
Fariborz Jahanian 54d569c51d Warn instead of error on duplicate protocol definitions.
Be kind to so many projects which are doing this (and be
like gcc).

llvm-svn: 68474
2009-04-06 23:43:32 +00:00
Steve Naroff 837dc03222 Make casting 'super' a deprecated warning (instead of a hard error).
This will simplify clang adoption, and is probably better "etiquette" (since gcc has always accepted this idiom without warning). Once we are over the adoption hurdle, we can turn this into an error.

llvm-svn: 68468
2009-04-06 22:07:54 +00:00
Douglas Gregor 7a5bc76b81 Fixed the Fix-It hints for comparison against a string literal. Thanks, Chris!
llvm-svn: 68454
2009-04-06 18:45:53 +00:00
Fariborz Jahanian bc3c77b881 Fixed visibility issues related to objc2's synthesized
ivars.

llvm-svn: 68453
2009-04-06 18:30:00 +00:00
Anders Carlsson 65cb90efc1 Define __OPTIMIZE__ and __OPTIMIZE_SIZE__ if the -O[12] and -Os flags are passed to the compiler.
llvm-svn: 68450
2009-04-06 17:37:10 +00:00
Chris Lattner a8d2dbd181 Daniel convinced me that accepting "const va_list" arguments to va_arg is
a really really bad idea.  Now that we emit an error about the unpromoted
type, users should be able to understand what is going on.

llvm-svn: 68447
2009-04-06 17:07:34 +00:00
Fariborz Jahanian 15e3a5c4b8 writable property in a category of class's superclass
makes the property writable in the current class.
 

llvm-svn: 68446
2009-04-06 16:59:10 +00:00
Chris Lattner dcceee734c Fix a couple of cases where Constant* pointers can dangle in
ObjCNonFragileABITypesHelper by converting them to dynamic
getters.  This fixes a crash on rdar://6757213.  The others
should be converted over as well.

llvm-svn: 68445
2009-04-06 16:53:45 +00:00
Chris Lattner 56382aa890 in va_arg diagnostics, print out the unpromoted type. This makes the
diagnostic use the va_list typedef more often, see the difference in the 
changed testcase.

llvm-svn: 68441
2009-04-05 15:49:53 +00:00
Zhongxing Xu 01a5beb8cd Apply a patch which adds 'OriginalParmVar' to the DeclContextPrinter by Jon
Simons.

llvm-svn: 68436
2009-04-05 02:04:38 +00:00
Chris Lattner 3f5cd77db2 Add a warning for questionable va_args usage.
llvm-svn: 68435
2009-04-05 00:59:53 +00:00
Chris Lattner 9e658eccab GCC compatibility: gcc allows applying va_args to const
va_lists for some reason.  This fixes rdar://6726818

llvm-svn: 68434
2009-04-05 00:52:59 +00:00
Chris Lattner ecdaf40c9e fix rdar://6757323, where an escaped newline in a // comment
was causing the char after the newline to get eaten.

llvm-svn: 68430
2009-04-05 00:26:41 +00:00
Anders Carlsson 468fa6366b Add some basic support for generating C++ member functions.
llvm-svn: 68425
2009-04-04 20:47:02 +00:00
Daniel Dunbar f89733cfb8 Driver: Handle properly calling dsymutil when source input is
preceeded by a linker input flag.
 - <rdar://problem/6757236> clang should make a dSYM when going
   straight from source to binary

 - This still matches gcc, but the right way to solve this would be to
   detect the situation we care about (we are compiling from source
   and linking in one step), instead of looking at the suffix of the
   input file. The Tool doesn't quite have enough information to do
   this yet, however.

 - Also, find the suffix correctly.

llvm-svn: 68417
2009-04-04 00:55:30 +00:00
Anton Korobeynikov 18e831dcc9 Testcase for regparm codegen
llvm-svn: 68415
2009-04-04 00:49:38 +00:00
Fariborz Jahanian 2705859981 Real corener case of a method declared in a protocol
used in a class which declares a property of the same
name. This should not result in an unimplemented
method warning.

llvm-svn: 68409
2009-04-03 21:51:32 +00:00
Chris Lattner 01b8ef2ac4 improve the string literal comparison warning to not call @encode's "string literals".
llvm-svn: 68407
2009-04-03 21:11:28 +00:00
Ted Kremenek 751e7e3833 retain/release checker: don't track NSPanel until we have better reasoning about
the subtle ownership issues of such objects.

llvm-svn: 68397
2009-04-03 19:02:51 +00:00
Chris Lattner 3a4e43107b add fixit advice to an archiac ObjC issue.
llvm-svn: 68395
2009-04-03 18:38:42 +00:00
Anders Carlsson 16b1461c21 Ignore plus operands when looking up the operand number from a named operand. This matches llvm-gcc and fixes PR3908.
llvm-svn: 68371
2009-04-03 05:57:08 +00:00
Fariborz Jahanian befc9dfbff Implement -fvisibility.
llvm-svn: 68369
2009-04-03 03:28:57 +00:00
Steve Naroff 3e90e33356 Tweak test (now that http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090330/015001.html is fixed).
llvm-svn: 68364
2009-04-03 01:25:18 +00:00
Daniel Dunbar fd6cfcffa2 Add target hook for setting symbol prefix and section of unicode
string literals.

llvm-svn: 68363
2009-04-03 00:57:44 +00:00
Mike Stump 898840f98c Move the rest of the fixit tests to the FixIt area.
llvm-svn: 68349
2009-04-02 23:44:32 +00:00
Mike Stump 5230b85fc1 Update wording.
llvm-svn: 68347
2009-04-02 23:42:13 +00:00
Douglas Gregor 9c0d38a7a0 Add a new command-line option "-fixit-at=file:line:column" that only
applies fix-its to error messages that occur at that specific location
in the program. 

llvm-svn: 68342
2009-04-02 19:05:20 +00:00
Fariborz Jahanian 38a5c9650e Fix up lookup rules for properties declared in
objc's continuation class.

llvm-svn: 68339
2009-04-02 18:44:20 +00:00
Steve Naroff d5ca2d0165 Fix http://llvm.org/bugs/show_bug.cgi?id=3907.
llvm-svn: 68338
2009-04-02 18:37:59 +00:00
Mike Stump d3e3885f2d Remove -ftrapu.
llvm-svn: 68330
2009-04-02 18:15:54 +00:00
Ted Kremenek 701fc10087 Add a few more analyzer test cases.
llvm-svn: 68326
2009-04-02 17:25:00 +00:00
Douglas Gregor 68bc53967e Move the fix-it tests into their own subdirectory
llvm-svn: 68325
2009-04-02 17:19:13 +00:00
Anders Carlsson 4eca109941 Implement mangling of declarations inside functions.
llvm-svn: 68321
2009-04-02 16:24:45 +00:00
Anders Carlsson f2125a02db Mangle VarDecls correctly.
llvm-svn: 68320
2009-04-02 16:05:20 +00:00
Douglas Gregor d8e97def58 When calling a function without a prototype for which we have a
definition, warn if there are too many/too few function call
arguments.

llvm-svn: 68318
2009-04-02 15:37:10 +00:00
Anders Carlsson cbaeb9e633 Emit code for linkage specifications.
llvm-svn: 68300
2009-04-02 05:55:18 +00:00
Douglas Gregor 3b3e0b3c1e Make darned sure that the -fixit tests are testing what we want them to test
llvm-svn: 68289
2009-04-02 04:59:27 +00:00
Douglas Gregor 7e70204613 Update comments in fixit tests
llvm-svn: 68279
2009-04-02 03:20:30 +00:00
Ted Kremenek 9335fecc2a Update expected warning in test case.
llvm-svn: 68276
2009-04-02 02:52:13 +00:00
Mike Stump 0be8875ea4 A code modification hint for files that don't end in a newline.
Eventually, would be nice to be able to run these modifications even
when we don't want the warning or errors for the actual diagnostic.

llvm-svn: 68272
2009-04-02 02:29:42 +00:00
Mike Stump 36c36ebc8b Oops, almost forgot the testcases.
llvm-svn: 68270
2009-04-02 01:14:26 +00:00
Douglas Gregor 578dae57ca Introduce a "-fixit" mode to clang-cc that applies code-modification hints.
llvm-svn: 68268
2009-04-02 01:08:08 +00:00
Mike Stump 21c81fdce4 We no longer expect an warning as this is now valid.
llvm-svn: 68263
2009-04-02 00:04:12 +00:00
Douglas Gregor 170512fa78 Add some more code modification hints
llvm-svn: 68261
2009-04-01 23:51:29 +00:00
Fariborz Jahanian e4fd640147 Fix a bug in declaration of property in continuation
class which was exposed by implementation of 
objc2's nonfragile abi code gen.

llvm-svn: 68259
2009-04-01 23:23:53 +00:00
Douglas Gregor e3e01a20d0 Add code modification hints to various parsing-related diagnostics.
Plus, reword a extension warnings to avoid talking about "ISO C" when
the extension might also be available in C++ or C++0x. 

llvm-svn: 68257
2009-04-01 22:41:11 +00:00
Douglas Gregor fe3d7d0880 Make parsing a semantic analysis a little more robust following Sema
failures that involve malformed types, e.g., "typename X::foo" where
"foo" isn't a type, or "std::vector<void>" that doens't instantiate
properly.

Similarly, be a bit smarter in our handling of ambiguities that occur
in Sema::getTypeName, to eliminate duplicate error messages about
ambiguous name lookup.

This eliminates two XFAILs in test/SemaCXX, one of which was crying
out to us, trying to tell us that we were producing repeated error
messages.

llvm-svn: 68251
2009-04-01 21:51:26 +00:00
Steve Naroff 0f55fd9f33 Update test case and comment.
llvm-svn: 68247
2009-04-01 21:27:56 +00:00
Steve Naroff 8d816d6cb5 CodeGenModule::GetAddrOfConstantCFString():
- Finish up support for converting UTF8->UTF16 to support ObjC @"string" constants.

Remove warning from CheckObjCString.

As the FIXME in the test case indicates, I still have a bug to work out (apparently with \u handling).

llvm-svn: 68245
2009-04-01 21:16:31 +00:00
Fariborz Jahanian 78be1651e2 Nonfragile ivar synthesis with property is in a continuation
class.

llvm-svn: 68234
2009-04-01 19:37:34 +00:00
Daniel Dunbar 7fdda1d695 Split PTH tests from carbon.c into separate test.
llvm-svn: 68223
2009-04-01 18:25:32 +00:00
Daniel Dunbar 9ff631039c Forgot to remove trailing &&
llvm-svn: 68220
2009-04-01 18:11:41 +00:00
Daniel Dunbar f46945b274 Ted & I crossed paths here, these tests are in cocoa-pth.m now.
llvm-svn: 68215
2009-04-01 16:59:39 +00:00
Fariborz Jahanian 95c802cc03 Removed the test case, as Chris did have a test case in the patch.
llvm-svn: 68214
2009-04-01 16:53:37 +00:00
Fariborz Jahanian df3a9f92b3 Test case for Chris's patch:
http://llvm.org/viewvc/llvm-project?view=rev&revision=68177

llvm-svn: 68213
2009-04-01 16:51:23 +00:00
Douglas Gregor 7c15b9c9a0 Add testcase for -Wmissing-prototypes
llvm-svn: 68212
2009-04-01 16:38:48 +00:00
Douglas Gregor 2e0757f319 Give Type::getDesugaredType a "for-display" mode that can apply more
heuristics to determine when it's useful to desugar a type for display
to the user. Introduce two C++-specific heuristics:

  - For a qualified type (like "foo::bar"), only produce a new
    desugred type if desugaring the qualified type ("bar", in this
    case) produces something interesting. For example, if "foo::bar"
    refers to a class named "bar", don't desugar. However, if
    "foo::bar" refers to a typedef of something else, desugar to that
    something else. This gives some useful desugaring such as
    "foo::bar (aka 'int')".
  - Don't desugar class template specialization types like
    "basic_string<char>" down to their underlying "class
    basic_string<char, char_traits<char>, allocator<char>>, etc.";
    it's better just to leave such types alone. 

Update diagnostics.html with some discussion and examples of type
preservation in C++, showing qualified names and class template
specialization types.

llvm-svn: 68207
2009-04-01 15:47:24 +00:00
Daniel Dunbar f524eff37d Add cocoa-pth.c test case, this got lost in shuffling PTH test cases.
llvm-svn: 68205
2009-04-01 15:36:37 +00:00
Ted Kremenek 455de13de1 Re-enable PTH testing for cocoa.h and carbon.h. This tests that PTH works on
real-world header files and these tests have caught serious bugs in the past.

llvm-svn: 68204
2009-04-01 15:28:20 +00:00
Daniel Dunbar e80bd1897c x86-32 Darwin ABI: Handle small structures correctly.
- Small structures are returned in a register if: 
    1. They fit nicely in a  register.
    2. All fields fit nicely in a register.
   (more or less)

 - We now pass the first 5000 ABITests if unions are disabled.

 - <rdar://problem/6497882> [irgen] x86-32 ABI compatibility with
   small structs

llvm-svn: 68197
2009-04-01 07:45:00 +00:00
Daniel Dunbar 58e2971bb0 x86-32 Darwin ABI: Single element arrays can be part of "single
element structures", which have different ABI rules.
 - Current return-arguments-32 status is: 1 out of 1000 failures (-7)

 - Also, vectors inside "single element structs" require special
   handling.

llvm-svn: 68196
2009-04-01 07:08:38 +00:00
Ted Kremenek 8b0dba358a Fix: <rdar://problem/6740387>. Sending nil to an object that returns a struct
should only be an error if that value is consumed. This fix was largely
accomplished by moving 'isConsumedExpr' back to ParentMap.

llvm-svn: 68195
2009-04-01 06:52:48 +00:00
Daniel Dunbar cd76e673eb x86-32 Darwin ABI: Handle direct return of vectors.
- Current return-arguments-32 status is: 8 out of 1000 failures (-7)

llvm-svn: 68192
2009-04-01 06:13:08 +00:00
Daniel Dunbar 386ef885bb Pull clang-cc code for generating PTH files based on the input type.
- <rdar://problem/6741594> [pth] don't abuse -x to drive pth
   generation

 - Simpler, and fixes PR3915.

Cleanup test cases for PTH:
 - Update to use -emit-pth

 - Removed PTH test of carbon.c and cocoa.mm; these didn't actually
   verify anything, and since PTH is token based the extra coverage
   (over cocoa.m) isn't particularly helpful.

 - Split PTH tests in cocoa.m to cocoa-pth.m, solely to increase
   available parallelism when running tests.

Ted, could you update the PTH test cases (include-pth.c and
cocoa-pth.m) to have some sort of positive check that the PTH is
getting used? "# of PTH cache hits" or "tokens read from PTH cache"
statistics would work great. :)

llvm-svn: 68189
2009-04-01 05:09:09 +00:00
Daniel Dunbar f77e292a0f Fix a subtle bug where the cleanup scope entries had a dangling block reference
- <rdar://problem/6732143> Crash when generating @synchronize for
   zero-cost exception

 - Thanks to Anders for helping track down the problem.

llvm-svn: 68186
2009-04-01 04:37:47 +00:00
Daniel Dunbar ae8bca038d Tweak/cleanup darwin::Link a bit, add several FIXMES, and improve test
case.

llvm-svn: 68182
2009-04-01 03:17:40 +00:00
Eli Friedman 1c3fb22cad Fix pascal string support; testcase from mailing list message.
llvm-svn: 68181
2009-04-01 03:17:08 +00:00
Eli Friedman 84ae509ac3 Fix test failure on Linux by forcing the triple to OS X.
llvm-svn: 68179
2009-04-01 02:55:21 +00:00
Chris Lattner d18136a644 fix the two xfails I added with a previous patch by making ObjC interface
types get completed when their definition is seen if previously laid out by
the code generator.

llvm-svn: 68177
2009-04-01 02:36:43 +00:00
Mike Stump cafa0a9746 Fix block comparisons. Radar 6732116.
llvm-svn: 68171
2009-04-01 01:17:39 +00:00
Anders Carlsson 237f349073 Implement code generation of namespaces and add mangling tests.
llvm-svn: 68170
2009-04-01 00:58:25 +00:00
Douglas Gregor dce2b62b70 Parsing, semantic analysis, and template instantiation for typename
specifiers that terminate in a simple-template-id, e.g.,

  typename MetaFun::template apply<T1, T2>

Also, implement template instantiation for dependent
nested-name-specifiers that involve unresolved identifiers, e.g.,

  typename T::type::type

llvm-svn: 68166
2009-04-01 00:28:59 +00:00
Anders Carlsson 7a6f8b9281 Fix a mangling bug where functions with no arguments weren't getting the 'v' parameter specifier.
llvm-svn: 68162
2009-04-01 00:15:23 +00:00
Daniel Dunbar 08b216abf1 Add Target hooks for IRgen of [cf]string literals.
- Notably, set section on cfstring literal string data (for now, this
   is done everywhere because it matches what we were already doing
   for the CFString data itself)

 - <rdar://problem/6599098> [irgen] linker requires objc string data
   to go into cstring

llvm-svn: 68160
2009-03-31 23:42:16 +00:00
Chris Lattner f41e87f4cd Change UsedArray to be a vector of WeakVH to fix a dangling pointer problem that occurs when
attribute(used) and asm renaming are used together.

llvm-svn: 68155
2009-03-31 22:37:52 +00:00
Douglas Gregor 7ef46d9ae2 Improve the dependent nested-name-specifier test a bit
llvm-svn: 68136
2009-03-31 20:07:16 +00:00
Daniel Dunbar 35579146aa x86_32 Darwin ABI: Treat empty unions like empty structures.
- Current return-arguments-32 status: 15/1000 failures

llvm-svn: 68132
2009-03-31 19:01:39 +00:00
Douglas Gregor aa59489b18 Implement template instantiation for template names, including both
template template parameters and dependent template names. For
example, the oft-mentioned

  typename MetaFun::template apply<T1, T2>::type

can now be instantiated, with the appropriate name lookup for "apply".

llvm-svn: 68128
2009-03-31 18:38:02 +00:00
Fariborz Jahanian 63a224ad59 ir-gen support for nonfragile abi's synthesized ivars.
llvm-svn: 68122
2009-03-31 18:11:23 +00:00
Daniel Dunbar d640be24fd (LLVM up) Update to use llvm::sys::getHostTriple().
- Always pass -triple to clang-cc (-arch will be removed).

 - clang-cc doesn't play guess work with the target triple anymore.

llvm-svn: 68119
2009-03-31 17:35:15 +00:00
Steve Naroff 1bf3b718cd Add -Wdeprecated-declarations to driver and add a test case.
llvm-svn: 68117
2009-03-31 17:28:26 +00:00
Steve Naroff f2a880ca22 Incorporate feedback from Eli.
llvm-svn: 68107
2009-03-31 10:29:45 +00:00
Chris Lattner 8b14b98bab Fix a problem in ASTContext::addRecordToClass handling forward declarations.
In a case like:

@class foo;
foo *P;

addRecordToClass was making an empty shadow struct for the foo interface and
completing it.  Later when an:

@interface foo
...
@endif

foo *Q;

was seen, ASTContext::addRecordToClass would think that foo was already laid
out and not lay out the definition.  This fixes it to create a forward declared
struct the first time around, then complete it when the definition is seen.

Note that this causes two tests to regress, because something is trying to get
the size of the forward declared structs returned by this.  Previously, this
would end up getting a size of zero but now it properly dies.  I'm not sure
what the right solution is for this, so I xfailed the tests.

Fariborz, please take a look at this.  The testcase in rdar://6676794 now gets
farther, but dies later because the objc ivar is not assigned a field number.

As an aside, I really don't like the fact that the objc front-end is creating
shadow C structs for ObjC types.  This seems like an implementation detail of
the code generator that could be fixed by better factoring of the extant code.

llvm-svn: 68106
2009-03-31 09:24:30 +00:00
Chris Lattner 5d68896c7b Codegen sometimes crashes on comparisons that aren't legal, just
disable this feature for now, to err on the side of rejecting instead
of sometimes crashing.  rdar://6326239

llvm-svn: 68088
2009-03-31 07:46:52 +00:00
Anders Carlsson dafd621b22 Check in test for namespace aliases+using directives.
llvm-svn: 68086
2009-03-31 05:47:19 +00:00
Ted Kremenek f0ec333fc1 Update test case.
llvm-svn: 68084
2009-03-31 03:34:38 +00:00
Douglas Gregor b67535d1b6 Parsing and AST representation for dependent template names that occur
within nested-name-specifiers, e.g., for the "apply" in

  typename MetaFun::template apply<T1, T2>::type

At present, we can't instantiate these nested-name-specifiers, so our
testing is sketchy.

llvm-svn: 68081
2009-03-31 00:43:58 +00:00
Fariborz Jahanian b35b4a9b42 fe support for objc2's nonfragile-abi synthesized ivars.
llvm-svn: 68077
2009-03-31 00:06:29 +00:00
Steve Naroff 7b753d21b5 Implement UCN support for C string literals (C99 6.4.3) and add some very basic tests. Chris Goller has graciously offered to write some test to help validate UCN support.
From a front-end perspective, I believe this code should work for ObjC @-strings. At the moment, I believe we need to tweak the code generation for @-strings (which doesn't appear to handle them). Will be investigating.

llvm-svn: 68076
2009-03-30 23:46:03 +00:00
Ted Kremenek cf2d8f0404 Add another uninitialized values test case illustrating that the CFG correctly
handles declarations with multiple variables.

llvm-svn: 68046
2009-03-30 18:29:27 +00:00
Daniel Dunbar 13357aef14 Driver: Unbreak ArgList::hasFlag.
- <rdar://problem/6726511> [driver] clang does not have -msoft-float
   hooked up.

llvm-svn: 68044
2009-03-30 18:13:26 +00:00
Daniel Dunbar 759b1c9b80 Fix -MD with no -MT when -o is specified (and fix test case).
llvm-svn: 68042
2009-03-30 17:59:58 +00:00
Daniel Dunbar a88692df30 Missed test case update (part of previous commit)
llvm-svn: 68029
2009-03-30 06:49:40 +00:00
Daniel Dunbar d67a32252c Driver: Support -M and -MM.
- Not particularly elegant, but my hand is forced by gcc.

Also, tweak -ccc-print-bindings output.

llvm-svn: 68027
2009-03-30 06:36:42 +00:00
Daniel Dunbar 52e96cc932 Improve dependency file support.
- Rip out various bits of logic from clang-cc's dependency file gen,
   force driver to provide instead.

 - -MD output now goes to proper location
<rdar://problem/6723948> clang -MD puts dep file in /tmp with wrong name

 - -M and -MM still don't work correctly.

llvm-svn: 68022
2009-03-30 00:34:04 +00:00
Daniel Dunbar f64f5307dc Driver: Add test case for darwin::Preprocess and darwin::Compile
tools, and enable them.

llvm-svn: 68019
2009-03-29 22:27:40 +00:00
Chris Lattner 32dc41c445 hoist some code for handling objc foreach construct out of Declaration processing
into ParseForStatement.  Merge two tests into one.

llvm-svn: 68010
2009-03-29 17:27:48 +00:00
Chris Lattner efb0f111f1 hoist checks for ; and in out of ParseInitDeclaratorListAfterFirstDeclarator
into ParseSimpleDeclaration, and improve a diagnostic.

llvm-svn: 68009
2009-03-29 17:18:04 +00:00
Sebastian Redl 4c0cd856b1 Reintroduce r67870 (rval ref overloading), since I can't reproduce any test failures on i386 or x86_64. If this fails for someone, please contact me.
llvm-svn: 67999
2009-03-29 15:27:50 +00:00
Anders Carlsson bb1e4724f1 More improvements to namespace aliases. We now support everything except aliases in using directives.
llvm-svn: 67966
2009-03-28 23:53:49 +00:00
Anders Carlsson 3694935cd2 Fix lookup bug
llvm-svn: 67964
2009-03-28 23:49:35 +00:00
Ted Kremenek 035cf930d5 Fix regression in pointer comparison with NULL (e.g., 0 != ptr). This fixes
<rdar://problem/6732151>.

llvm-svn: 67954
2009-03-28 19:59:33 +00:00
Anders Carlsson b81608499e As Eli pointed out, it is possible that a namespace lookup is ambiguous!
llvm-svn: 67932
2009-03-28 07:51:31 +00:00
Anders Carlsson ac2c96528f Check that the alias points to a valid namespace.
llvm-svn: 67925
2009-03-28 06:42:02 +00:00
Anders Carlsson dca83c4676 Check that the namespace alias doesn't conflict with a previous declaration in this scope.
llvm-svn: 67921
2009-03-28 06:23:46 +00:00
Anders Carlsson 72f307a26e Revert Sebastian's rvalue patch (r67870) since it caused test failures in
SemaCXX//overload-member-call.cpp
SemaCXX//overloaded-operator.cpp
SemaTemplate//instantiate-method.cpp

llvm-svn: 67912
2009-03-28 04:17:27 +00:00
Anders Carlsson 1894f0d499 Parse namespace aliases.
llvm-svn: 67908
2009-03-28 04:07:16 +00:00
Eli Friedman 09a9b6e335 Move where block-related variables are initialized so that block
types don't get generated when blocks aren't used.

llvm-svn: 67898
2009-03-28 03:24:54 +00:00
Eli Friedman 7c7a0e86ae Fix silly mistake in test.
llvm-svn: 67897
2009-03-28 03:14:28 +00:00
Eli Friedman e381f7e3e9 Misc small fixes/cleanups/comment changes.
llvm-svn: 67895
2009-03-28 02:45:41 +00:00
Eli Friedman 8b7b1b1aee Change compound assignment operators to keep track of both the promoted
LHS type and the computation result type; this encodes information into 
the AST which is otherwise non-obvious.  Fix Sema to always come up with the 
right answer for both of these types.  Fix IRGen and the analyzer to 
account for these changes.  This fixes PR2601.  The approach is inspired 
by PR2601 comment 2.

Note that this changes real *= complex in CodeGen from a silent 
miscompilation to an explicit error.

I'm not really sure that the analyzer changes are correct, or how to 
test them... someone more familiar with the analyzer should check those 
changes.

llvm-svn: 67889
2009-03-28 01:22:36 +00:00
Anders Carlsson 0cb4cc106c Implement access checking for protected base classes.
llvm-svn: 67887
2009-03-28 01:09:05 +00:00
Douglas Gregor 5c7c9cb678 Make our diagnostics about the obsolete GNU designated-initializer
syntax into extension warnings, and provide code-modification hints
showing how to fix the problem.

llvm-svn: 67885
2009-03-28 00:41:23 +00:00
Douglas Gregor 8aa6bf5b8e Fix <rdar://problem/6724396>, where we were silently dropping
GNU-style array designators, causing us to emit broken initializers.

llvm-svn: 67878
2009-03-27 23:40:29 +00:00
Douglas Gregor 333489bba3 Initial implementation of parsing, semantic analysis, and template
instantiation for C++ typename-specifiers such as

  typename T::type

The parsing of typename-specifiers is relatively easy thanks to
annotation tokens. When we see the "typename", we parse the
typename-specifier and produce a typename annotation token. There are
only a few places where we need to handle this. We currently parse the
typename-specifier form that terminates in an identifier, but not the
simple-template-id form, e.g.,

  typename T::template apply<U, V>

Parsing of nested-name-specifiers has a similar problem, since at this
point we don't have any representation of a class template
specialization whose template-name is unknown.

Semantic analysis is only partially complete, with some support for
template instantiation that works for simple examples. 

llvm-svn: 67875
2009-03-27 23:10:48 +00:00
Sebastian Redl ec74096050 Better overload resolution for rvalue references.
llvm-svn: 67870
2009-03-27 21:36:42 +00:00
Eli Friedman 7044b76707 Finish off semantic analysis for regparm, and remove the warning. Also
remove a redundant error in CodeGen.

llvm-svn: 67868
2009-03-27 21:06:47 +00:00
Anders Carlsson af06b977f9 It is OK to cast to a private base class if the current member belongs to the class that the private base class is a base of:
class A {};
class B : private A {
  void f(B *b) { A* a = b; }
};

llvm-svn: 67860
2009-03-27 19:01:12 +00:00
Anders Carlsson 733d77f1b4 Implement checking for base class access. Right now it's overly conservative but that will change. (Also, protected isn't implemented right now).
llvm-svn: 67827
2009-03-27 06:03:27 +00:00
Douglas Gregor 0b08ba44a1 If the user is trying to apply the -> or . member reference operator
to a function or function pointer, it's probably because the user
forgot to put in parentheses () to call the function.

llvm-svn: 67826
2009-03-27 06:00:30 +00:00
Douglas Gregor f4d17c4f22 Improve recovery when a constructor fails to type-check. Test case from Anders
llvm-svn: 67818
2009-03-27 04:38:56 +00:00
Douglas Gregor fdca4a7967 Tests and fixes for templates declared within (non-template)
classes. Test case from Anders Carlsson, fix from Piotr Rak!

llvm-svn: 67817
2009-03-27 04:21:56 +00:00
Chris Lattner 9eac931b5f Fix rdar://6719156 - clang should emit a better error when blocks are disabled but are used anyway
by changing blocks from being disabled in the parser to being disabled
in Sema.

llvm-svn: 67816
2009-03-27 04:18:06 +00:00
Daniel Dunbar adf511c056 Driver: Forward -fno-common to clang.
- <rdar://problem/6710978> ccc/clang-driver ignore -fno-common

llvm-svn: 67762
2009-03-26 16:37:00 +00:00
Daniel Dunbar 42b91a86f3 Driver: Test case for darwin::Link
llvm-svn: 67761
2009-03-26 16:29:05 +00:00
Daniel Dunbar c196421fbc Driver: Add darwin::Link tool.
- <rdar://problem/6717381> [driver] implement ld argument translation
   in new driver

llvm-svn: 67760
2009-03-26 16:23:12 +00:00
Steve Naroff 389925dc87 Fix <rdar://problem/6697053> instance variable is protected.
Treat @package the same as @public. The documentation for @package says it is analogous to private_extern for variables/functions. Fully implementing this requires some kind of linker support (so access is denied to code outside the classes executable image). I don't believe GCC fully implements this semantic. Will discuss with Fariborz offline.

llvm-svn: 67755
2009-03-26 16:01:08 +00:00
Eli Friedman 6568eef9f9 Sanity-check argument to indirect goto.
llvm-svn: 67746
2009-03-26 07:32:37 +00:00
Anders Carlsson 137108da15 Set the access specifier for templates inside classes.
llvm-svn: 67726
2009-03-26 01:24:28 +00:00
Anders Carlsson 2ed6ceba1d Check that the access specifier of a member redeclaration is the same as the original declaration.
llvm-svn: 67722
2009-03-26 00:24:17 +00:00
Eli Friedman 8d7ff4098c Fix for PR3869: actually enforce that the argument of an indirect goto
is of type void*.  I'll try to add the appropriate checking later.

llvm-svn: 67721
2009-03-26 00:18:06 +00:00
Douglas Gregor 97f1f1c46e The injected-class-name of class templates and class template
specializations can be treated as a template. Finally, we can parse
and process the first implementation of Fibonacci I wrote!

Note that this code does not handle all of the cases where
injected-class-names can be treated as templates. In particular,
there's an ambiguity case that we should be able to handle (but
can't), e.g.,

  template <class T> struct Base { }; 
  template <class T> struct Derived : Base<int>, Base<char> {
    typename Derived::Base b;       // error: ambiguous
    typename Derived::Base<double> d;  // OK 
  };

llvm-svn: 67720
2009-03-26 00:10:35 +00:00
Anders Carlsson a28908d575 Tighten the setAccess assert. We now allow AS_none if the decl contex is not a C++ record decl.
Also, fix fallout from the change.

llvm-svn: 67717
2009-03-25 23:38:06 +00:00
Douglas Gregor ef1a09a336 Implement template instantiation for static data members of class
templates, including in-class initializers. For example:

  template<typename T, T Divisor>
  class X {
  public:
    static const T value = 10 / Divisor;
  };

instantiated with, e.g.,

  X<int, 5>::value

to get the value '2'.

llvm-svn: 67715
2009-03-25 23:32:15 +00:00
Douglas Gregor f3430ae300 Fix notes regarding the instantiation of member classes (and test 'em).
llvm-svn: 67708
2009-03-25 21:23:52 +00:00
Douglas Gregor 8ea8fd48f2 Instantiation for member classes of class templates. Note that only
the declarations of member classes are instantiated when the owning
class template is instantiated. The definitions of such member classes
are instantiated when a complete type is required.

This change also introduces the injected-class-name into a class
template specialization.

llvm-svn: 67707
2009-03-25 21:17:03 +00:00
Chris Lattner 51a53f92a5 fix PR3880, fixing a comma swallowing bug handling macros that only take
... arguments.

llvm-svn: 67706
2009-03-25 21:08:24 +00:00
Mike Stump 871c1f6f88 Remove -f__block as codegen for __block variables should be solid.
llvm-svn: 67697
2009-03-25 18:05:39 +00:00
Mike Stump d2142cffbf Fixup codegen for block literals that bleed copy/dispose information
from previous block literals.

llvm-svn: 67696
2009-03-25 17:58:24 +00:00
Mike Stump 12ef15f8b2 Update to account for the great driver renaming.
llvm-svn: 67695
2009-03-25 17:56:16 +00:00
Douglas Gregor 167fa625f3 Fix parsing of template classes prefixed by nested-name-specifiers
llvm-svn: 67685
2009-03-25 15:40:00 +00:00
Daniel Dunbar aabb0b11a3 Driver: Handle -Xarch_, including warning for nasty -Xarch_ use cases
we aren't going to support. For example:
  clang -Xarch_i386 -S -Xarch_i386 -o -Xarch_i386 myi386asm.s ...

llvm-svn: 67680
2009-03-25 06:12:34 +00:00
Anders Carlsson 75fdaa465f Improve handling of base initializers. We now parse initializers in out of line decls, such as:
class C {
    C() { }
    
    int a;
};

C::C() : a(10) { }

We also diagnose when initializers are used on declarations that aren't constructors:

t.cpp:1:10: error: only constructors take base initializers
void f() : a(10) { }
         ^

Doug and/or Sebastian: I'd appreciate a review, especially the nested-name-spec test results (from the looks of it we now match gcc in that test.)

llvm-svn: 67672
2009-03-25 02:58:17 +00:00
Douglas Gregor 1880ba59f3 Template instantiation for conversion functions
llvm-svn: 67664
2009-03-25 00:34:44 +00:00
Sebastian Redl f769df5ef9 Parse deleted function definitions and hook them up to Doug's machinery.
llvm-svn: 67653
2009-03-24 22:27:57 +00:00
Daniel Dunbar 1386495406 Driver: Handle -flto, -O4, and tweak -emit-llvm to match llvm-gcc.
- -emit-llvm no longer changes what compilation steps are done.

 - -emit-llvm and -emit-llvm -S write output files with .o and .s
    suffixes, respectively.

 - <rdar://problem/6714125> clang-driver should support -O4 and -flto,
   like llvm-gcc

llvm-svn: 67645
2009-03-24 20:17:30 +00:00
Douglas Gregor ac1fb65d0c Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.

llvm-svn: 67643
2009-03-24 19:52:54 +00:00
Daniel Dunbar 88f356e16b Driver: Change default use of "clang" compiler.
- Don't default to using clang for C++ (use -ccc-clang-cxx to
   override).

 - Default to only using clang on i386 and x86_64 (use
   -ccc-clang-archs "" to override).

 - <rdar://problem/6712350> [driver] clang should not be used on
   powerpc by default
 - <rdar://problem/6705767> driver should default to -ccc-no-clang-cxx

I plan to add a warning that we are not using the clang compiler for
the given compilation so that users do not think clang is being used
in situations it isn't.

This change is motivated by the desire to be able to drop clang into a
build and have things "just work", even if it happens to get used to
compile C++ code or code for an architecture we don't support yet.

llvm-svn: 67640
2009-03-24 19:02:31 +00:00
Daniel Dunbar 038f5d6ef0 Driver: Translate -fverbose-asm for LLVM backend.
- <rdar://problem/6715707> driver should translate -fverbose-asm into
   -asm-verbose

llvm-svn: 67634
2009-03-24 17:59:06 +00:00
Daniel Dunbar 9ea0e77572 Driver: ArgList::getLastArg was in fact returning the first matching arg.
- <rdar://problem/6715818> clang doesn't honor gcc semantic that last
    -O optimization option wins.

llvm-svn: 67628
2009-03-24 17:31:30 +00:00
Anders Carlsson b57738b09c Fix the bug that Eli noticed where we wouldn't look at function decls outside the class declaration.
llvm-svn: 67627
2009-03-24 17:23:42 +00:00
Chris Lattner deab7250fb fix "Comment#1" from PR3872
llvm-svn: 67625
2009-03-24 17:05:27 +00:00
Douglas Gregor 4044d995c9 Template instantiation for constructors
llvm-svn: 67623
2009-03-24 16:43:20 +00:00
Daniel Dunbar 2afa8abdfb Update TestRunner.sh for renaming.
- Substitutes both clang and clang-cc.

 - Incorporates patch from Jon Simons to diagnose if clang or clang-cc
   isn't found.

 - Uses full path when running scripts, for more precision in the
   output.

llvm-svn: 67610
2009-03-24 06:17:45 +00:00
Daniel Dunbar 36245c5a90 Rename clang-driver to clang.
Again, I tried to update cmake but it is untested.

llvm-svn: 67606
2009-03-24 03:07:05 +00:00
Daniel Dunbar bf1fe8c36c Support member reference on ?: of struct type.
llvm-svn: 67603
2009-03-24 02:38:23 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Daniel Dunbar 4aacad1f93 Use not instead of ! in tests.
llvm-svn: 67601
2009-03-24 01:59:55 +00:00
Anders Carlsson 8f0d218598 Handle pointers to arrays of abstract types.
llvm-svn: 67598
2009-03-24 01:46:45 +00:00
Anders Carlsson b5a27b460c More work on diagnosing abstract classes. We can now handle cases like
class C {
  void g(C c);

  virtual void f() = 0;
};

In this case, C is not known to be abstract when doing semantic analysis on g. This is done by recursively traversing the abstract class and checking the types of member functions. 

llvm-svn: 67594
2009-03-24 01:19:16 +00:00
Eli Friedman 94c25c66b5 Fix PR3868 by making Evaluate handle cases like "(long)&a + 4".
llvm-svn: 67593
2009-03-24 01:14:50 +00:00
Eli Friedman 703a77f313 Fix a couple of tests.
llvm-svn: 67592
2009-03-24 01:11:18 +00:00
Douglas Gregor 2134209a2a Cleanup template instantiation for methods, destructors
llvm-svn: 67585
2009-03-24 00:38:23 +00:00
Douglas Gregor 654b07e029 Template instantiation for destructors. This is somewhat repetitive;
eliminating the duplication is next on the list.

llvm-svn: 67579
2009-03-24 00:15:49 +00:00
Douglas Gregor f4f296de01 Template instantiation for the declarations of member functions within
a class template. At present, we can only instantiation normal
methods, but not constructors, destructors, or conversion operators.

As ever, this contains a bit of refactoring in Sema's type-checking. In
particular:

  - Split ActOnFunctionDeclarator into ActOnFunctionDeclarator
    (handling the declarator itself) and CheckFunctionDeclaration
    (checking for the the function declaration), the latter of which
    is also used by template instantiation.
  - We were performing the adjustment of function parameter types in
    three places; collect those into a single new routine.
  - When the type of a parameter is adjusted, allocate an
    OriginalParmVarDecl to keep track of the type as it was written.
  - Eliminate a redundant check for out-of-line declarations of member
    functions; hide more C++-specific checks on function declarations
    behind if(getLangOptions().CPlusPlus).

llvm-svn: 67575
2009-03-23 23:06:20 +00:00
Ted Kremenek af6543455f A test case to test that -warn-dead-stores does not emit a warning for stores to variables marked with '#pragma unused'.
llvm-svn: 67570
2009-03-23 22:30:58 +00:00
Ted Kremenek fd14fade2f Implement '#pragma unused'.
llvm-svn: 67569
2009-03-23 22:28:25 +00:00
Fariborz Jahanian aedcfa49b9 Must allow for strong cast of floats as well (objc2 gc).
llvm-svn: 67551
2009-03-23 19:10:40 +00:00
Anders Carlsson eb0c532faa More improvements to abstract type checking. Handle arrays correctly, and make sure to check parameter types before they decay.
llvm-svn: 67550
2009-03-23 19:10:31 +00:00
Anders Carlsson 0d5ca29b78 It's an error to try to allocate an abstract object using new.
llvm-svn: 67542
2009-03-23 17:49:10 +00:00
Douglas Gregor 893c2c963a Fix PR3855. When we encounter an incompatible redeclaration of a
library function, accept this declaration and pretend that we do not
know that this is a library function. autoconf depends on this
(broken) behavior.

llvm-svn: 67541
2009-03-23 17:47:24 +00:00
Chris Lattner 5030e5eabe The individual pieces of an invalid paste as still candidates for expansion.
This matters in assembler mode, where this is silently allowed.
This fixes rdar://6709206.

llvm-svn: 67539
2009-03-23 17:32:45 +00:00
Ted Kremenek b294d196b3 analyzer: Provide temporary workaround for false positive reported by
<rdar://problem/6704930> involving SimpleConstraintManager not reasoning well
about symbolic constraint values involving arithmetic operators.

llvm-svn: 67534
2009-03-23 17:10:25 +00:00
Douglas Gregor d6b05f705b Tighten up the determination of whether a function declaration has a
prototype. Thanks Eli!

llvm-svn: 67533
2009-03-23 16:26:51 +00:00
Douglas Gregor d4eca014e0 Thanks to Eli for pointing out my misreading of 6.2.2p5
llvm-svn: 67530
2009-03-23 16:17:01 +00:00
Ted Kremenek c7fef2ad53 analyzer: Fix embarrassing regression in BasicStore when invalidating struct
values passed-by-reference to unknown functions.

llvm-svn: 67519
2009-03-23 15:42:58 +00:00
Eli Friedman 6400433980 Minor enhancements to Evaluate.
llvm-svn: 67503
2009-03-23 04:38:34 +00:00
Eli Friedman 7b4716750b Fix a subtle bug in CodeGen for the increment of a bitfield.
llvm-svn: 67499
2009-03-23 03:00:06 +00:00
Eli Friedman 04841eebcb Fix a few more instances of "&>".
llvm-svn: 67496
2009-03-23 00:04:01 +00:00
Sebastian Redl 3b27be6ceb Recognize rvalue references in C++03, but complain about them. This leads to far better error recovery.
llvm-svn: 67495
2009-03-23 00:00:23 +00:00
Eli Friedman 80160bd483 Partial implementation of PR3342: break out pointer sign
incompatibilities in assignments from other pointer incompatibilities.  
Based off of the patch in PR3342.  (This doesn't implement -Wno-pointer-sign,
but I don't know the driver code very well.)

llvm-svn: 67494
2009-03-22 23:59:44 +00:00
Sebastian Redl b28b407121 Disallow catching exceptions by rvalue reference.
llvm-svn: 67492
2009-03-22 23:49:27 +00:00
Eli Friedman e8dd7b3228 Adjust isModifiableLvalue to give a slightly more useful diagnostic for
attempting to illegally modify a BlockDeclRefExpr.

llvm-svn: 67491
2009-03-22 23:26:56 +00:00
Daniel Dunbar d8500f3b0f Driver: Implement 'missing argument' error.
llvm-svn: 67490
2009-03-22 23:26:43 +00:00
Eli Friedman 7fa3faa417 Fix code to mark block variables as const to actually work. Fix
isObjCObjectPointerType to work with qualified types.  Adjust test for 
changes.

If the SemaExpr changes are wrong or break existing code, feel free to 
delete the "ExprTy.addConst();" line and revert my changes to 
test/Sema/block-literal.c.

llvm-svn: 67489
2009-03-22 23:00:19 +00:00
Sebastian Redl e97585f717 Implement static_cast from lvalue to rvalue reference.
llvm-svn: 67487
2009-03-22 22:30:06 +00:00
Eli Friedman 38f8493752 Add testcase for incomplete call/return types for calls.
llvm-svn: 67486
2009-03-22 22:03:03 +00:00
Eli Friedman 3164fb15e2 Check that the return/argument types of calls are complete.
llvm-svn: 67485
2009-03-22 22:00:50 +00:00
Chris Lattner e64911a4ae switch getBuiltinLibFunction to use the new GetOrCreateLLVMFunction
functionality, fixing a crash on the attached testcase.  Eliminate the
BuiltinFunctions cache, as it can contain dangling pointers.  This fixes
a bunch of valgrind errors on test/CodeGen/builtins.c

llvm-svn: 67484
2009-03-22 21:56:56 +00:00
Eli Friedman bae2042bb5 Don't use &> in tests; dash doesn't understand it.
llvm-svn: 67483
2009-03-22 21:49:20 +00:00
Chris Lattner 827a3552a4 make alias definition logic more similar to functions/globals.
llvm-svn: 67481
2009-03-22 21:39:12 +00:00
Chris Lattner a5ae54acc4 fix PR3200 by making alias emission use the new infrastructure. Fold
some tests into the alias.c file.

llvm-svn: 67479
2009-03-22 21:21:57 +00:00
Anders Carlsson 576cc6f725 Disallow abstract types where appropriate.
llvm-svn: 67476
2009-03-22 20:18:17 +00:00
Chris Lattner 75acb0c356 fix a fixme: non-proto struct returning function definitions should be compiled
to something like:
define void @bar(%struct.foo* noalias sret %agg.result) nounwind {
instead of:
define void @bar(%struct.foo* noalias sret %agg.result, ...) nounwind {

llvm-svn: 67475
2009-03-22 19:35:37 +00:00
Anders Carlsson 7cbd8fb6b0 Keep track of whether a class is abstract or not. This is currently only used for the __is_abstract type trait.
llvm-svn: 67461
2009-03-22 01:52:17 +00:00
Chris Lattner 37082e2a39 fix test
llvm-svn: 67455
2009-03-21 23:59:11 +00:00
Mike Stump efd7caa825 Fixup codegen for nested block literals so that we generate
copy_helpers and dispose_helpers as necessary for them.

llvm-svn: 67453
2009-03-21 21:00:35 +00:00
Fariborz Jahanian 629aed9327 Issue error if variables are defined inside an objc class,
category or protocol.

llvm-svn: 67450
2009-03-21 18:06:45 +00:00
Daniel Dunbar 8e93780c86 Frontend: Handle empty input on stdin.
- PR3854.

I think it makes more sense to change MemoryBuffer::getSTDIN (return 0
should indicate error, not empty), but it is documented to return 0
for empty inputs, and some other code appears to rely on this.

llvm-svn: 67448
2009-03-21 17:55:43 +00:00
Chris Lattner a85d68e5d8 fix a crash that could occur when a variable declaration became a
function definition.

llvm-svn: 67446
2009-03-21 09:25:43 +00:00
Chris Lattner 149927c9f8 simplify and cleanup global variable creation stuff to all go through one
code path.

llvm-svn: 67445
2009-03-21 09:16:30 +00:00
Chris Lattner 6574906818 fix several problems with asm renaming, by pulling it into the mangling code:
1. it wasn't applying to definitions, only declarations, e.g. int x __asm("foo")
2. multiple definitions were conflicting, they weren't getting merged.
3. the code was duplicated in several places.

llvm-svn: 67442
2009-03-21 08:24:40 +00:00
Ted Kremenek 8b2c1cd5a2 Fix include-pth.c test case to (hopefully) more resilient to where and how tests
are executed.

llvm-svn: 67419
2009-03-20 23:45:36 +00:00
Daniel Dunbar ea9f032613 ccc/Driver: .s defaults to 'assembler-with-cpp' on Darwin.
- <rdar://problem/6669441> ccc doesn't handle assembler-with-cpp
   semantics correctly (but clang supports it)

 - This is sad, because it requires a fairly useless target
   hook. C'est la vie.

llvm-svn: 67418
2009-03-20 23:39:23 +00:00
Mike Stump 692c6e3729 Fix codegen for support for super inside block literal expressions.
llvm-svn: 67406
2009-03-20 21:53:12 +00:00
Ted Kremenek dfd72c2b44 Fix <rdar://problem/6704086> by allowing the format string checking in Sema to
allow non-literal format strings that are variables that (a) permanently bind to
a string constant and (b) whose string constants are resolvable within the same
translation unit.

llvm-svn: 67404
2009-03-20 21:35:28 +00:00
Fariborz Jahanian 07038f9785 Fix a crash during meta-data generation of objc2's nonfragile abi.
llvm-svn: 67402
2009-03-20 20:48:19 +00:00