Commit Graph

7550 Commits

Author SHA1 Message Date
Daniel Dunbar fd5ed84873 Revert r104117, "Provide a naming class for UnresolvedLookupExprs, even when
occuring on..." which breaks some Objective-C code. Working on getting a test
case...

llvm-svn: 104150
2010-05-19 21:07:14 +00:00
Ted Kremenek 26bde774df Add clang support for IBOutletCollection.
llvm-svn: 104135
2010-05-19 17:38:06 +00:00
Douglas Gregor 6044d691bb Revert r104106; it's breaking linking of Boost.Serialization.
llvm-svn: 104121
2010-05-19 17:02:24 +00:00
Benjamin Kramer fdb61d78e9 Implement codegen for __builtin_isnormal.
llvm-svn: 104118
2010-05-19 11:24:26 +00:00
Chandler Carruth 8fd2b8935e Provide a naming class for UnresolvedLookupExprs, even when occuring on
template names. We were completely missing naming classes for many unqualified
lookups, but this didn't trigger code paths that need it. This removes part of
an optimization that re-uses the template name lookup done by the parser to
determine if explicit template arguments actually form a template-id.
Unfortunately the technique for avoiding the duplicate lookup lost needed data
such as the class context in which the lookup succeeded.

llvm-svn: 104117
2010-05-19 09:39:06 +00:00
Douglas Gregor e9ceb31405 Profile type-dependent uses of overloaded operators in C++ the same
way regardless of whether some overloaded operator functions were
found by name lookup within the template. Fixes PR6851.

llvm-svn: 104107
2010-05-19 04:13:23 +00:00
Douglas Gregor 21553f5970 Teach clang to instantiate attributes on more declarations. Fixes PR7102.
llvm-svn: 104106
2010-05-19 03:39:53 +00:00
Douglas Gregor cbfbca14d0 Implement C++ builtin operator candidates for vector types.
llvm-svn: 104105
2010-05-19 03:21:00 +00:00
Douglas Gregor bd130a2962 Basic test for user-defined conversions involving vector types
llvm-svn: 104085
2010-05-18 23:05:44 +00:00
Fariborz Jahanian 9f963c2488 Misc. fixes to bring Objetive-C++'s handling of
gc attributes to be inline with Objective-C
(for radar 7925141).

llvm-svn: 104084
2010-05-18 23:04:17 +00:00
Douglas Gregor bdb604a806 Protect isIntegerConstantExpr from seeing type- or value-dependent
expressions in attributes, pragmas.

llvm-svn: 104083
2010-05-18 23:01:22 +00:00
Douglas Gregor 4618868a7d Implement C++ support for vector and extended vector types. This
involves extending implicit conversion sequences to model vector
conversions and vector splats, along with teaching the C++ conditional
operator-checking code about vector types.

Fixes <rdar://problem/7983501>.

llvm-svn: 104081
2010-05-18 22:42:18 +00:00
Ted Kremenek 49be9e0819 Teach CursorVisitor about duplicate ObjCPropertyDecls that can arise because of a current
design limitation in how we handle Objective-C class extensions.  This was causing the CursorVisitor
to essentially visit an @property twice (once in the @interface, the other in the class extension).
Fixes <rdar://problem/7410145>.

llvm-svn: 104055
2010-05-18 21:09:07 +00:00
Fariborz Jahanian 87b915a9bc These test now run in objective-c++ mode we well.
llvm-svn: 104041
2010-05-18 18:24:06 +00:00
Douglas Gregor 162b419a02 Add missing test case, provided by Steven Watanabe.
llvm-svn: 104037
2010-05-18 17:43:51 +00:00
Douglas Gregor 8b6be164d6 Fix typo test case
llvm-svn: 104027
2010-05-18 16:57:36 +00:00
Douglas Gregor a941dcae16 Add support for Microsoft's __thiscall, from Steven Watanabe!
llvm-svn: 104026
2010-05-18 16:57:00 +00:00
Anders Carlsson be48c548c5 Correctly initialize bases with member pointers. This should fix PR6441 but that test case is a bit weird and I'd like to investigate further before closing that bug.
llvm-svn: 104025
2010-05-18 16:51:41 +00:00
Douglas Gregor 86ad085b40 Give a slight edge to the context-sensitive keyword 'super' over
non-function-local declarations with names similar to what the user
typed. For example, this allows us to correct 'supper' to 'super' in
an Objective-C message send, even though the C function 'isupper' has
the same edit distance.

llvm-svn: 104023
2010-05-18 16:30:22 +00:00
Douglas Gregor 5fd04d4832 Tweak typo-correction logic a bit regarding "super", so that we
consider "super" as a candidate whenever we're parsing an expression
within an Objective-C method in an interface that has a superclass. At
some point, we'd like to give "super" a little edge over non-local
names; that will come later.

llvm-svn: 104022
2010-05-18 16:14:23 +00:00
John McCall 0e704f7fcd Permit Objective C object pointers to be const_casted.
llvm-svn: 104019
2010-05-18 09:35:29 +00:00
Douglas Gregor b92ea59481 I hate this commit.
Revert much of the implementation of C++98/03 [temp.friend]p5 in
r103943 and its follow-ons r103948 and r103952. While our
implementation was technically correct, other compilers don't seem to
implement this paragraph (which forces the instantiation of friend
functions defined in a class template when a class template
specialization is instantiated), and doing so broke a bunch of Boost
libraries. 

Since this behavior has changed in C++0x (which instantiates the
friend function definitions when they are used), we're going to skip
the nowhere-implemented C++98/03 semantics and go straight to the
C++0x semantics.

This commit is a band-aid to get Boost up and running again. It
doesn't really fix PR6952 (which this commit un-fixes), but it does
deal with the way Boost.Units abuses this particular paragraph.

llvm-svn: 104014
2010-05-18 05:45:02 +00:00
John McCall d3dfbd6f4f If a switch condition is constant, don't warn about missing enum cases.
If a switch condition is constant, warn if there's no case for it.

Constant switch conditions do come up in reasonable template code.

llvm-svn: 104010
2010-05-18 03:19:21 +00:00
John McCall a9e6e8d654 Teach the ObjC mangler to ignore member pointers just like gcc does.
llvm-svn: 104001
2010-05-17 23:56:34 +00:00
Chandler Carruth 3b43338870 Add a hack to silence warnings about failing to return from functions after
a temporary with a noreturn destructor has been created. Fixes PR6884 for now.

llvm-svn: 104000
2010-05-17 23:51:52 +00:00
Douglas Gregor 96cdb1590e Instantiate attributes on typedefs. This is a quick fix for PR7148,
when we really need a proper audit of our handling of attributes in
templates.

llvm-svn: 103999
2010-05-17 23:46:49 +00:00
Ted Kremenek 990783e345 Clean up test case and remove XFAIL. This test can now distinguish between
cases where Clang can suggest and fix and suggest and not auto-fix (because of
current limitations).

llvm-svn: 103987
2010-05-17 23:03:33 +00:00
Chris Lattner 467f6bcfe5 robustify the conflict marker stuff. Don't add 7 twice, which would
make it miss (invalid) things like:
<<<<<<<
>>>>>>>

and crash if 

<<<<<<< 

was at the end of the line.  When we find a >>>>>>> that is not at the
end of the line, make sure to reset Pos so we don't crash on something
like:
<<<<<<< >>>>>>>

This isn't worth making testcases for, since each would require a new file.

rdar://7987078 - signal 11 compiling "<<<<<<<<<<"

llvm-svn: 103968
2010-05-17 20:27:25 +00:00
John McCall 3e294929b8 Correctly generate IR for ObjC messages sends to protocol-qualified types.
Fixes rdar://problem/7992749

llvm-svn: 103965
2010-05-17 20:12:43 +00:00
Douglas Gregor c4c574bd2e Test that mutability of class members that involve class definitions actually works
llvm-svn: 103959
2010-05-17 19:45:25 +00:00
Douglas Gregor 3b05bdba5a Teach ASTContext::getUnqualifiedArrayType() how to look through
typedefs. As a drive-by, teach hit how to build VLA types, since those
will eventually be supported in C++.

llvm-svn: 103958
2010-05-17 18:45:21 +00:00
Douglas Gregor c9a99c5e5c mutable is a storage class that can follow a class/struct/union definition. Fixes PR7153
llvm-svn: 103954
2010-05-17 18:19:56 +00:00
Fariborz Jahanian 16f94c6e8f Don't attempt to poke into an invalid field's class type
to mark its destructors as referenced which may cause 
a crash. Fixes radar 7896920

llvm-svn: 103953
2010-05-17 18:15:18 +00:00
Douglas Gregor fd7224fee0 Diagnose a redefinition error when there are two instantiations of friend
functions defined inside a class template. Fixes PR6952, the last
Boost.Units failure.

llvm-svn: 103952
2010-05-17 17:57:54 +00:00
Douglas Gregor 69f6a365d3 Determine when the instantiation of a friend function defined inside a
class template conflicts with an existing (non-template)
definition. This is another part of PR6952.

llvm-svn: 103948
2010-05-17 17:34:56 +00:00
Daniel Dunbar cd20ce1513 C++/Darwin/i386 ABI: Fix some problems with empty record handling.
- Check bases as part of isEmptyRecord().

 - C++ record fields are never empty in the Itanium ABI.

llvm-svn: 103944
2010-05-17 16:46:00 +00:00
Douglas Gregor 1cd6ea0b24 C++98/03 [temp.friend]p4 requires that inline function definitions
within class templates be instantiated along with each class template
specialization, even if the functions are not used. Do so, as a baby
step toward PR6952.

llvm-svn: 103943
2010-05-17 16:38:00 +00:00
Douglas Gregor 9154b5dffe Ensure that destructors are called for NRVO'd objects when the
function does not return. Thanks to Eli for pointing out this corner
case.

llvm-svn: 103941
2010-05-17 15:52:46 +00:00
Eli Friedman b41ad0fbea PR7117: Make sure we don't lose the calling convention for K&R-style
definitions.
 

llvm-svn: 103932
2010-05-17 02:50:18 +00:00
Chris Lattner 561aabd943 when code completing inside a C-style block comment, don't emit errors about
a missing */ since we truncated the file.

This fixes rdar://7948776

llvm-svn: 103913
2010-05-16 19:54:05 +00:00
Anders Carlsson e6ae81b0a2 Correctly diagnose array 'new' with initialization arguments when the new type is a typedef to an array type.
llvm-svn: 103909
2010-05-16 16:24:20 +00:00
Douglas Gregor cda95f47e5 When the type-id or new-type-id of a C++ "new" expression is a typedef
of an array type, use the outermost array bound as the number of
elements to allocate. Fixes PR7147.

llvm-svn: 103908
2010-05-16 16:01:03 +00:00
Chandler Carruth e299ba66f5 When constant folding reference variables with an initializer to the
initializer, don't fold paramters. Their initializers are just default
arguments which can be overridden. This fixes some spectacular regressions due
to more things making it into the constant folding.

llvm-svn: 103904
2010-05-16 09:32:51 +00:00
Chris Lattner fc1e1c649f really use valist.
llvm-svn: 103900
2010-05-16 05:00:34 +00:00
Chris Lattner bb53efb016 fix rdar://7985267 - Don't emit an error about a non-pod argument
passed to va_start, it doesn't actually pass it.

llvm-svn: 103899
2010-05-16 04:01:30 +00:00
Douglas Gregor 51150ab1f1 When initializing thread-safe statics, put the call to
__cxa_guard_abort along the exceptional edge into (in effect) a nested
"try" that rethrows after aborting. Fixes PR7144 and the remaining
Boost.ProgramOptions failures, along with the regressions that r103880
caused.

The crucial difference between this and r103880 is that we now follow
LLVM's little dance with the llvm.eh.exception and llvm.eh.selector
calls, then use _Unwind_Resume_or_Rethrow to rethrow.

llvm-svn: 103892
2010-05-16 01:24:12 +00:00
Douglas Gregor c278d1b3b9 Revert r103880 (thread-safe static initialization w/ exceptions),
because it's causing strange linker errors. Unfixes PR7144.

llvm-svn: 103890
2010-05-16 00:44:00 +00:00
Fariborz Jahanian e1b45a5e6b Fix API gen for objc_msgSend property of aggregate types
in Objective-c++ mode. Fixes radar 7986354.

llvm-svn: 103887
2010-05-15 23:05:52 +00:00
Douglas Gregor 58142dd8a1 When initializing thread-safe statics, put the call to
__cxa_guard_abort along the exceptional edge into (in effect) a nested
"try" that rethrows after aborting. Fixes PR7144 and the remaining
Boost.ProgramOptions failures.

llvm-svn: 103880
2010-05-15 17:55:51 +00:00
Douglas Gregor 4f0ed42601 Attempt to satisfy Release-Asserts build
llvm-svn: 103879
2010-05-15 17:28:53 +00:00
Chris Lattner 6459bbe14a sigh
llvm-svn: 103874
2010-05-15 16:56:34 +00:00
Chris Lattner 8b3b145342 fix _mm_shuffle_pd too, thanks to Joel Falcou for pointing this out.
llvm-svn: 103873
2010-05-15 16:54:46 +00:00
Douglas Gregor 170125648c When applying the named return value optimization, we still need to
destroy the variable along the exceptional edge; it's only during
normal execution that we avoid destroying this variable.

llvm-svn: 103872
2010-05-15 16:39:56 +00:00
John McCall 8b07ec253d Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of
  one of {primitive-id, primitive-Class, user-defined @class}
with
  a list of protocols.
An ObjCObjectPointerType is therefore just a pointer which always points to
one of these types (possibly sugared).  ObjCInterfaceType is now just a kind
of ObjCObjectType which happens to not carry any protocols.

Alter a rather large number of use sites to use ObjCObjectType instead of
ObjCInterfaceType.  Store an ObjCInterfaceType as a pointer on the decl rather
than hashing them in a FoldingSet.  Remove some number of methods that are no
longer used, at least after this patch.

By simplifying ObjCObjectPointerType, we are now able to easily remove and apply
pointers to Objective-C types, which is crucial for a certain kind of ObjC++
metaprogramming common in WebKit.

llvm-svn: 103870
2010-05-15 11:32:37 +00:00
Douglas Gregor 290c93ec0d Implement a simple form of the C++ named return value optimization for
return statements. We perform NRVO only when all of the return
statements in the function return the same variable. Fixes some link
failures in Boost.Interprocess (which is relying on NRVO), and
probably improves performance for some C++ applications.

llvm-svn: 103867
2010-05-15 06:46:45 +00:00
Daniel Dunbar 36d4d1541c C++/ABI/x86_64: Member pointers should be classified as INTEGER.
llvm-svn: 103843
2010-05-15 00:00:37 +00:00
Daniel Dunbar 4bd95c65e7 C++/ABI/i386: Member function pointers should be passed by value.
llvm-svn: 103842
2010-05-15 00:00:30 +00:00
Douglas Gregor 2d15ecad39 Tweak test so that it does not require <typeinfo>
llvm-svn: 103819
2010-05-14 21:50:50 +00:00
Fariborz Jahanian 862fac958b Patch to fix a crash on incomplete class declaration.
Radar 7923673.

llvm-svn: 103812
2010-05-14 21:35:02 +00:00
Douglas Gregor 1c073f47da Emit an lvalue dynamic_cast even if the result is not used. Another
part (or possibly all) of PR7132.

llvm-svn: 103810
2010-05-14 21:31:02 +00:00
Ted Kremenek 6bca984b54 Add CXType and an initial set of supporting functions to libclang. This exposes details of
Clang's representation of the C type system to clients.  It is nowhere near complete, and will
be expanded on demand.

llvm-svn: 103809
2010-05-14 21:29:26 +00:00
Douglas Gregor fa8b4955bb When a failed dynamic_cast<T&> (which is an lvalue) results in a
throw, it should use invoke when needed. The fixes the
Boost.Statechrt failures that motivated PR7132, but there are a few
side issues to tackle as well.

llvm-svn: 103803
2010-05-14 21:14:41 +00:00
Fariborz Jahanian bdb1b0d6cb Implement new default property synthesis rules. Essentially, no longer
user directive is needed to force a property implementation.
It is decided based on those propeties which are declared in
the class (or in its protocols) but not those which must be
default implemented by one of its super classes. Implements radar 7923851.

llvm-svn: 103787
2010-05-14 18:35:57 +00:00
Chris Lattner ff895c140c Improve error recovery in C/ObjC when the first argument of a function
declarator is incorrect.  Not being a typename causes the parser to 
dive down into the K&R identifier list handling stuff, which is almost
never the right thing to do.

Before:

r.c:3:17: error: expected ')'
void bar(intptr y);
                ^
r.c:3:9: note: to match this '('
void bar(intptr y);
        ^
r.c:3:10: error: a parameter list without types is only allowed in a function definition
void bar(intptr y);
         ^

After:

r.c:3:10: error: unknown type name 'intptr'; did you mean 'intptr_t'?
void bar(intptr y);
         ^~~~~~
         intptr_t
r.c:1:13: note: 'intptr_t' declared here
typedef int intptr_t;
            ^

This fixes rdar://7980651 - poor recovery for bad type in the first arg of a C function

llvm-svn: 103783
2010-05-14 17:44:56 +00:00
Anders Carlsson 65c6d541dd Make sure that value-initialized pointers to data members are initialized correctly.
llvm-svn: 103771
2010-05-14 15:05:19 +00:00
Douglas Gregor 05cfc295f4 Namespaces can only be defined at global or namespace scope. Fixes PR6596.
llvm-svn: 103767
2010-05-14 05:08:22 +00:00
Douglas Gregor f3d3ae665c Make sure to search semantic scopes and appropriate template-parameter
scopes during unqualified name lookup that has fallen out to namespace
scope. Fixes PR7133.

llvm-svn: 103766
2010-05-14 04:53:42 +00:00
Douglas Gregor 83de20f5e3 A vtable is used if the key function is defined... even if that key
function's definition is an out-of-class definition marked
"inline". Fixes an assertion in WebKit.

llvm-svn: 103763
2010-05-14 04:08:48 +00:00
Daniel Dunbar 64585cdb66 XFAIL a test on Win32.
llvm-svn: 103762
2010-05-14 03:54:53 +00:00
Daniel Dunbar 6b45b67b26 C++/Darwin/x86: Teach IRgen it can pass reference types in registers.
llvm-svn: 103761
2010-05-14 03:40:53 +00:00
Daniel Dunbar 8363697282 Force -no-integrated-as in this test.
llvm-svn: 103758
2010-05-14 02:02:13 +00:00
Douglas Gregor 500d9f8221 Disable the available_externally optimization for inline virtual
methods for which the key function is guaranteed to be in another
translation unit. Unfortunately, this guarantee isn't the case when
dealing with shared libraries that fail to export these virtual method
definitions. 

I'm reopening PR6747 so we can consider this again at a later point in
time.

llvm-svn: 103741
2010-05-13 21:36:56 +00:00
Fariborz Jahanian 1bd96d13b2 Objective-C++ Sema. Fix a bug in instantiation of receivers.
Completes radar 7963410.

llvm-svn: 103719
2010-05-13 17:19:25 +00:00
Douglas Gregor 88d292ccb8 Rework when and how vtables are emitted, by tracking where vtables are
"used" (e.g., we will refer to the vtable in the generated code) and
when they are defined (i.e., because we've seen the key function
definition). Previously, we were effectively tracking "potential
definitions" rather than uses, so we were a bit too eager about emitting
vtables for classes without key functions. 

The new scheme:
  - For every use of a vtable, Sema calls MarkVTableUsed() to indicate
  the use. For example, this occurs when calling a virtual member
  function of the class, defining a constructor of that class type,
  dynamic_cast'ing from that type to a derived class, casting
  to/through a virtual base class, etc.
  - For every definition of a vtable, Sema calls MarkVTableUsed() to
  indicate the definition. This happens at the end of the translation
  unit for classes whose key function has been defined (so we can
  delay computation of the key function; see PR6564), and will also
  occur with explicit template instantiation definitions.
 - For every vtable defined/used, we mark all of the virtual member
 functions of that vtable as defined/used, unless we know that the key
 function is in another translation unit. This instantiates virtual
 member functions when needed.
  - At the end of the translation unit, Sema tells CodeGen (via the
  ASTConsumer) which vtables must be defined (CodeGen will define
  them) and which may be used (for which CodeGen will define the
  vtables lazily). 

From a language perspective, both the old and the new schemes are
permissible: we're allowed to instantiate virtual member functions
whenever we want per the standard. However, all other C++ compilers
were more lazy than we were, and our eagerness was both a performance
issue (we instantiated too much) and a portability problem (we broke
Boost test cases, which now pass).

Notes:
  (1) There's a ton of churn in the tests, because the order in which
  vtables get emitted to IR has changed. I've tried to isolate some of
  the larger tests from these issues.
  (2) Some diagnostics related to
  implicitly-instantiated/implicitly-defined virtual member functions
  have moved to the point of first use/definition. It's better this
  way.
  (3) I could use a review of the places where we MarkVTableUsed, to
  see if I missed any place where the language effectively requires a
  vtable.

Fixes PR7114 and PR6564.

llvm-svn: 103718
2010-05-13 16:44:06 +00:00
Ted Kremenek ecc31c93c2 Don't add a null successor to a CFGBlock when the contents of an @synchronized statement is empty.
Fixes <rdar://problem/7979430>.

llvm-svn: 103717
2010-05-13 16:38:08 +00:00
Chandler Carruth 5cb1abc6db Testcase for r103712.
llvm-svn: 103713
2010-05-13 12:04:17 +00:00
John McCall 01f21ad97c Rebuild builtin_id * as an ObjCObjectPointerType, where builtin_id is the
magic type that 'id' is a pointer to.

llvm-svn: 103708
2010-05-13 08:39:13 +00:00
John McCall bb4ea81ab9 When performing template argument deduction, match Objective C pointers
against pointer patterns.

llvm-svn: 103706
2010-05-13 07:48:05 +00:00
Ted Kremenek 3e7199b286 Add test case for <rdar://problem/7880658>.
llvm-svn: 103701
2010-05-13 06:58:45 +00:00
Ted Kremenek 12e0f2937e Specially handle CaseStmts in CursorVisitor because they can be nested and walking them
can blow out the stack.

llvm-svn: 103687
2010-05-13 00:25:00 +00:00
Fariborz Jahanian cac49a8f8a Objective-C++ Sema. Support for conversion of a C++
class object used as a receiver to an objective-c
pointer via a converwsion function. wip.

llvm-svn: 103672
2010-05-12 23:29:11 +00:00
Chris Lattner bf5c83745a "this patch properly addresses escaping < and > which might appear
(e.g. for C++ operators) in the xml dump.

I also re-enabled the unit test for ast-print-xml (or so I think)
at least, make test didn't fail..."

patch by Sebastien Binet!

llvm-svn: 103671
2010-05-12 23:27:11 +00:00
Daniel Dunbar 6399208c14 Revert "Move macro definitions for IBOutlet and IBAction into the source
code. ...", this was a lit bug which should be fixed in r103652.

llvm-svn: 103654
2010-05-12 21:54:41 +00:00
Ted Kremenek 6cdc2c1bc8 Move macro definitions for IBOutlet and IBAction into the source code. This hopefully
unbreaks the test with lit+Windows.

llvm-svn: 103650
2010-05-12 21:44:56 +00:00
Fariborz Jahanian b0901b7951 Objective-C++ Sema - Allow static_cast of one objc pointer to
another.

llvm-svn: 103630
2010-05-12 18:16:59 +00:00
Douglas Gregor 17158425f2 Whenever we instantiate a function definition or class, enter a new
potentially-evaluated expression context, to ensure that used
declarations get properly marked. Fixes PR7123.

llvm-svn: 103624
2010-05-12 17:27:19 +00:00
Douglas Gregor 54818f0c37 When we emit an error during the implicit definition of a special
member function (default constructor, copy constructor, copy
assignment operator, destructor), emit a note showing where that
implicit definition was required.

llvm-svn: 103619
2010-05-12 16:39:35 +00:00
Daniel Dunbar 0856bf7b13 Yes another annotate-tokens tweak.
llvm-svn: 103615
2010-05-12 15:10:09 +00:00
Daniel Dunbar c5f10c8d48 Increase test portability.
llvm-svn: 103614
2010-05-12 14:46:02 +00:00
Ted Kremenek c316e4ef50 Make test portable.
llvm-svn: 103588
2010-05-12 07:24:45 +00:00
Ted Kremenek d58be13b68 Make test case invariant to macro definition location.
llvm-svn: 103587
2010-05-12 07:21:07 +00:00
Ted Kremenek 8278a32802 Re-apply r103581 with updated tests. It turns out we were computing bogus locations for
many things.

llvm-svn: 103583
2010-05-12 06:16:13 +00:00
Ted Kremenek a53bead8db Temporarily revert r103581 so I can fix the failing tests.
llvm-svn: 103582
2010-05-12 06:03:33 +00:00
Ted Kremenek 847941b1f4 Correctly check if a cursor is a declaration before returning its location/range in clang_getCursorLocation()/clang_getCursorExtent(). This fixes a horrible bug reported in
<rdar://problem/7961995> and <rdar://problem/7967123> where declarations with attributes
would get grossly annotated with the wrong tokens because the attribute would be interpreted
as if it was a Decl*.

llvm-svn: 103581
2010-05-12 06:00:25 +00:00
Ted Kremenek 5d61614eab Adjust clang_annotateTokens() to correctly account for the TypeSourceInfo for DeclaratorDecls
when annotating tokens.  Fixes <rdar://problem/7971430>.

llvm-svn: 103577
2010-05-12 05:29:33 +00:00
Chris Lattner 42464b8b92 don't force 16 threads.
llvm-svn: 103566
2010-05-12 02:47:23 +00:00
John McCall ef8b9b3cde Correct spelling of expected error message. Apparently I forgot to re-run
the test suite after modifying this diagnostic.

llvm-svn: 103537
2010-05-12 01:15:36 +00:00
John McCall cf819ab383 When checking scopes for indirect goto, be more permissive (but still safe)
about the permitted scopes.  Specifically:
  1) Permit labels and gotos to appear after a prologue of variable initializations.
  2) Permit indirect gotos to jump out of scopes that don't require cleanup.
  3) Diagnose possible attempts to indirect-jump out of scopes that do require
     cleanup.
This requires a substantial reinvention of the algorithm for checking indirect
goto.  The current algorithm is Omega(M*N), with M = the number of unique
scopes being jumped from and N = the number of unique scopes being jumped to,
with an additional factor that is probably (worst-case) linear in the depth
of scopes.  Thus the entire thing is likely cubic given some truly bizarre
ill-formed code;  on well-formed code the additional factor collapses to
an amortized constant (when amortized over the entire function) and so
the algorithm is quadratic.  Even this requires every label to appear in
its own scope, which would be very unusual for indirect-goto code (and
extremely unlikely for well-formed code);  it is far more likely that
all labels will be in the same scope and so the algorithm becomes linear.
For such a marginal feature, I am fairly happy with this result.

(this is using JumpDiagnostic's definition of scope, where successive
variables in a block appear in their own scope)

llvm-svn: 103536
2010-05-12 00:58:13 +00:00
Daniel Dunbar 0547ad38e3 Speculatively revert r103497, "Do not mark the virtual members of an
implicitly-instantiated class as ...", which seems to have broken bootstrap.

llvm-svn: 103515
2010-05-11 21:32:35 +00:00
Daniel Dunbar 12ebb47a07 IRgen/i386/C++: Fix isSingleElementStruct computation for C++ record decls.
- Fixes PR7098.

llvm-svn: 103514
2010-05-11 21:15:36 +00:00
Douglas Gregor 0c4aad15c2 Do not mark the virtual members of an implicitly-instantiated class as
referenced unless we see one of them defined (or the key function
defined, if it as one) or if we need the vtable for something. Fixes
PR7114.

llvm-svn: 103497
2010-05-11 20:24:17 +00:00
Fariborz Jahanian f7ba3208a3 Fix test.
llvm-svn: 103487
2010-05-11 18:48:13 +00:00
Douglas Gregor c97d7a2c6a The C++98/03 standard is disturbingly silent about out-of-scope
explicit instantiations of template. C++0x clarifies the intent
(they're ill-formed in some cases; see [temp.explicit] for
details). However, one could squint at the C++98/03 standard and
conclude they are permitted, so reduce the error to a warning
(controlled by -Wc++0x-compat) in C++98/03 mode.

llvm-svn: 103482
2010-05-11 17:39:34 +00:00
Douglas Gregor 112de35e5b Static data members intialized in-class that have constant values are
value-dependent if their initializers are value-dependent; my recent
tweak to these dependent rules overstepped by taking away this
value-dependents. Fixes a Boost.GIL regression.

llvm-svn: 103476
2010-05-11 16:41:27 +00:00
Douglas Gregor 0e4de76610 A DeclRefExpr that refers to a member function or a static data member
of the current instantiation is value-dependent. The C++ standard
fails to enumerate this case and, therefore, we missed it. Chandler
did all of the hard work of reducing the last remaining
Boost.PtrContainer failure (which had to do with static initialization
in the Serialization library) down to this simple little test.

While I'm at it, clean up the dependence rules for template arguments
that are declarations, and implement the dependence rules for template
argument packs.

llvm-svn: 103464
2010-05-11 08:41:30 +00:00
Chandler Carruth 6bd2d6c4be Add a test for a subtle instantiation pattern that showed up within a Boost
miscompile reduction. Clang already handles this correctly, but let's make sure
it stays that way.

llvm-svn: 103463
2010-05-11 08:02:08 +00:00
Fariborz Jahanian eee1669adb Allow static_cast to objective-c pointers.
Fixes radar 7952457.

llvm-svn: 103447
2010-05-10 23:46:53 +00:00
Daniel Dunbar 341db487a8 tests: Avoid spurious use of /dev/null.
llvm-svn: 103446
2010-05-10 23:31:31 +00:00
Fariborz Jahanian 43a40f9399 Objective-C++ Code gen. Handle code gen. for property
reference dot-syntax notation in a varierty of cases.
Fixes radar 7964490.

llvm-svn: 103440
2010-05-10 22:57:35 +00:00
Devang Patel b319adec49 If variable location is invalid then use current location.
This fixes radar 7959934.

llvm-svn: 103408
2010-05-10 17:24:58 +00:00
Chris Lattner abfb58d1d2 pch'ify CXXNewExpr and CXXZeroInitValueExpr
llvm-svn: 103390
2010-05-10 01:22:27 +00:00
Chris Lattner cba86142a4 pchify CXXTemporary, CXXBindTemporaryExpr, and
CXXExprWithTemporaries.

llvm-svn: 103387
2010-05-10 00:25:06 +00:00
Chris Lattner e2437f4538 pch'ify default argument definitions and uses.
llvm-svn: 103376
2010-05-09 06:40:08 +00:00
Chris Lattner 9826733963 pch'ify 'this' and 'throw'
llvm-svn: 103375
2010-05-09 06:15:05 +00:00
Chris Lattner 13a5ecc6ff pch'ify typeid.
llvm-svn: 103374
2010-05-09 06:03:39 +00:00
Chris Lattner b7e7f722a2 pchify CXXMemberCallExpr correctly. Before it would serialize
and deserialize as a CallExpr which is close, but ends up
deserializing with the wrong stmt class.

llvm-svn: 103371
2010-05-09 05:36:05 +00:00
Douglas Gregor 14f232ea20 Improve our handling of the -Wunused-variable warning in templates. In
particular, don't complain about unused variables that have dependent
type until instantiation time, so that we can look at the type of the
variable. Moreover, only complain about unused variables that have
neither a user-declared constructor nor a non-trivial destructor.

llvm-svn: 103362
2010-05-08 23:05:03 +00:00
Douglas Gregor 0bbe94d6df Don't complain about an __builtin_va_arg expression's result being
unused, since the operation has side effects.

llvm-svn: 103360
2010-05-08 22:41:50 +00:00
Douglas Gregor ff73a9e380 When instantiating statements that involve conditions (if, while, do,
for, and switch), be careful to construct the full expressions as soon
as we perform template instantation, so we don't either forget to call
temporary destructors or destroy temporaries at the wrong time. This
is the template-instantiation analogue to r103187, during which I
hadn't realized that the issue would affect the handling of these
constructs differently inside and outside of templates.

Fixes a regression in Boost.Function.

llvm-svn: 103357
2010-05-08 22:20:28 +00:00
Douglas Gregor 90cf2c98bb Record template argument deduction failures for member function
templates and conversion function templates. 

llvm-svn: 103349
2010-05-08 20:18:54 +00:00
Douglas Gregor d09efd43d3 When printing an overload candidate that failed due to SFINAE, print a
specific message that includes the template arguments, e.g.,

test/SemaTemplate/overload-candidates.cpp:27:20: note: candidate template
      ignored: substitution failure [with T = int *]
  typename T::type get_type(const T&); // expected-note{{candidate ...
                   ^

llvm-svn: 103348
2010-05-08 20:07:26 +00:00
Douglas Gregor 1d72edd7c5 Improve overload-candidate diagnostic for a function template that
failed because the explicitly-specified template arguments did not
match its template parameters, e.g.,

test/SemaTemplate/overload-candidates.cpp:18:8: note: candidate
template
      ignored: invalid explicitly-specified argument for template
      parameter 'I'
  void get(const T&);
       ^
test/SemaTemplate/overload-candidates.cpp:20:8: note: candidate
template
      ignored: invalid explicitly-specified argument for 1st template
      parameter
  void get(const T&);
       ^

llvm-svn: 103344
2010-05-08 19:15:54 +00:00
Douglas Gregor 02eb4835ce When template argument deduction fails because the call had too
many/too few arguments, use the same diagnostic we use for arity
mismatches in non-templates (but note that it's a function template).

llvm-svn: 103341
2010-05-08 18:13:28 +00:00
Douglas Gregor 3626a5cac2 When printing a non-viable overload candidate that failed due to
conflicting deduced template argument values, give a more specific
reason along with those values, e.g.,

test/SemaTemplate/overload-candidates.cpp:4:10: note: candidate template
      ignored: deduced conflicting types for parameter 'T' ('int' vs. 'long')
const T& min(const T&, const T&); 
         ^

llvm-svn: 103339
2010-05-08 17:41:32 +00:00
Douglas Gregor 14653638de Fix test for Release-Asserts build
llvm-svn: 103337
2010-05-08 16:04:01 +00:00
Douglas Gregor 5597ab4076 When we encounter a non-dependent type during template instantiation,
mark any declarations we see inside of that type as
"referenced". Fixes PR7079.

llvm-svn: 103323
2010-05-07 23:12:07 +00:00
John McCall b1fb0d3610 The FP constant evaluator was missing a few cases of unary operators that return floats
but whose operand isn't a float:  specifically, __real__ and __imag__.  Instead
of filtering these out, just implement them.

Fixes <rdar://problem/7958272>.

llvm-svn: 103307
2010-05-07 22:08:54 +00:00
Chris Lattner ca025db769 add PCH support for a bunch of C++ Decls, patch by
Andrew Sutton!

llvm-svn: 103301
2010-05-07 21:43:38 +00:00
Ted Kremenek 37c220c8ed Extend C++ usrs to include type mangling for tag decl arguments, indicating whether a method
is static, and mangling in the qualifers of the method.

llvm-svn: 103289
2010-05-07 20:39:40 +00:00
Douglas Gregor 496e8b345c Reapply the reference-binding patch applied below, along with a fix to
ensure that we complete the type when we need to look at constructors
during reference binding.

When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion. 

Re-fixes PR7080.

llvm-svn: 103283
2010-05-07 19:42:26 +00:00
Fariborz Jahanian fdf474b05e Fixes a Code gen crash trying to use a dot-syntax for
a property of a c++ class object (radar 7957369).

llvm-svn: 103279
2010-05-07 18:56:13 +00:00
Douglas Gregor 56f14e575d Revert r103220. It seems to be breaking self-host
llvm-svn: 103259
2010-05-07 15:55:52 +00:00
Rafael Espindola a1f9cc1bec Fix PR4386 by implementing gcc's old behaviour (4.2) when initializing
variables with a comparison of a function pointer with 0.

llvm-svn: 103253
2010-05-07 15:18:43 +00:00
Sebastian Redl 872fad8627 Test case for my last fix.
llvm-svn: 103252
2010-05-07 11:15:33 +00:00
Ted Kremenek 586ff60cfc Add initial USR support for mangling in the types of C++ functions and methods.
llvm-svn: 103225
2010-05-07 01:04:32 +00:00
Ted Kremenek fca5afb421 Add USR test case for C++ operator methods.
llvm-svn: 103223
2010-05-07 01:04:23 +00:00
Fariborz Jahanian c5158203dd Implement encoding of methods which have instantiated
template arguments.

llvm-svn: 103221
2010-05-07 00:28:49 +00:00
Douglas Gregor d80c0238bb When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion. 

Fixes PR7080.

llvm-svn: 103220
2010-05-07 00:28:31 +00:00
John McCall 7ddbcf4f4b After some discussion, conservatively extend our sentinel check to discard
casts, but still require the (casted) type to be a pointer.  Fixes PR5685.

llvm-svn: 103216
2010-05-06 23:53:00 +00:00
Ted Kremenek 0b4b46e3e1 Add USR support for C++ namespaces, and unify mangling of location information in USRs
for anonymous symbols.

llvm-svn: 103212
2010-05-06 23:38:28 +00:00
Douglas Gregor 4b718ee691 It turns out that we should be allowing redeclarations within function
scope. Thanks to Steven Watanabe for correcting me.

llvm-svn: 103210
2010-05-06 23:31:27 +00:00
Douglas Gregor d8bb3aff76 Do not give implicitly-defined virtual members functions
available_externally linkage, since they may not have been given a
strong definition in another translation unit. Without this patch, the
following test case fails to link with a GCC-compiled libstdc++:

  #include <sstream>
  int main() { std::basic_stringbuf<char> bs; }

Fixes the last problem with the Boost.IO library.

llvm-svn: 103208
2010-05-06 23:13:35 +00:00
Douglas Gregor ae498b3211 The global variable for the VTT might not have external linkage; allow
us to find local variables, too. Fixes the last remaining
Boost.Rational failure.

llvm-svn: 103203
2010-05-06 22:18:21 +00:00
John McCall 4fa0d5f2bd Diagnose deprecated/unavailable functions selected by overload resolution.
Fixes rdar://problem/4232969, or at least the clang parts of it.

llvm-svn: 103191
2010-05-06 18:15:07 +00:00
Douglas Gregor e60e41add9 Rework our handling of temporary objects within the conditions of
if/switch/while/do/for statements. Previously, we would end up either:

  (1) Forgetting to destroy temporaries created in the condition (!),
  (2) Destroying the temporaries created in the condition *before*
  converting the condition to a boolean value (or, in the case of a
  switch statement, to an integral or enumeral value), or
  (3) In a for statement, destroying the condition's temporaries at
  the end of the increment expression (!).

We now destroy temporaries in conditions at the right times. This
required some tweaking of the Parse/Sema interaction, since the parser
was building full expressions too early in many places.

Fixes PR7067.

llvm-svn: 103187
2010-05-06 17:25:47 +00:00
Fariborz Jahanian b8993384f3 Code Gen support for Getter/Setter synthesis of
C++ object properties. (still radar 7468090).

llvm-svn: 103182
2010-05-06 15:45:36 +00:00
John McCall cc7e5bff5c Rearchitect -Wconversion and -Wsign-compare. Instead of computing them
"bottom-up" when implicit casts and comparisons are inserted, compute them
"top-down" when the full expression is finished.  Makes it easier to
coordinate warnings and thus implement -Wconversion for signedness
conversions without double-warning with -Wsign-compare.  Also makes it possible
to realize that a signedness conversion is okay because the context is
performing the inverse conversion.  Also simplifies some logic that was
trying to calculate the ultimate comparison/result type and getting it wrong.
Also fixes a problem with the C++ explicit casts which are often "implemented"
in the AST with a series of implicit cast expressions.

llvm-svn: 103174
2010-05-06 08:58:33 +00:00
Chris Lattner 44456d294c simplify EmitAggMemberInitializer a bit and make it work in 32-bit mode,
fixing PR7063.

llvm-svn: 103171
2010-05-06 06:35:23 +00:00
Chris Lattner dbff4bf5f4 implement codegen support for __builtin_isfinite, part of PR6083
llvm-svn: 103168
2010-05-06 06:04:13 +00:00
Chris Lattner 68784efaf6 optimize builtin_isnan/isinf to not do an extraneous extension from
float -> double (which happens because they are modelled as int(...)
functions), and add a testcase for isinf.

llvm-svn: 103167
2010-05-06 05:50:07 +00:00
Zhongxing Xu 1a56a488ed Turn -analyzer-inline-call on for C functions. This also fixed a bug that
after inlining post-call checking shouldn't be done.

llvm-svn: 103161
2010-05-06 03:38:27 +00:00
Zhongxing Xu 9174b2c2f9 Make -analyzer-inline-call not a separate analysis. Instead it's a boolean
flag now, and can be used with other analyses. Only turned it on for C++ 
methods for now.

llvm-svn: 103160
2010-05-06 02:59:29 +00:00
Douglas Gregor e902956f59 Partial and full specializations of a class template may have a
different tag kind ("struct" vs. "class") than the primary template,
which has an affect on access control.

Should fix the last remaining Boost.Accumulors failure.

llvm-svn: 103144
2010-05-06 00:28:52 +00:00
Ted Kremenek 5b0773e201 Workaround a really serious caching bug in SourceManager::isBeforeInTranslationUnit() where the
method will sometimes return different results for the same input SourceLocations.  I haven't
unraveled this method completely yet, so this truly is a workaround until a better fix comes
along.

llvm-svn: 103143
2010-05-06 00:22:25 +00:00
Chris Lattner 3baada6fd7 Pass the globaldecl into GetOrCreateLLVMFunction so that llvm
function attributes like byval get applied to the function 
definition. This fixes PR7058 and makes i386 llvm/clang bootstrap 
pass all the same tests as x86-64 bootstrap for me (the llvmc 
tests still fail in both).

llvm-svn: 103131
2010-05-05 22:55:13 +00:00
Douglas Gregor bf1fb44efa When implicit definition of the copy-assignment operator fails,
provide a note that shows where the copy-assignment operator was
needed. We used to have this, but I broke it during refactoring. 

Finishes PR6999.

llvm-svn: 103127
2010-05-05 22:38:15 +00:00
Douglas Gregor d450f06ef4 When we emit a non-constant initializer for a global variable of
reference type, make sure that the initializer we build is the
of the appropriate type for the *reference*, not for the thing that it
refers to. Fixes PR7050.

llvm-svn: 103115
2010-05-05 20:15:55 +00:00
Douglas Gregor 370eadf38d For thread-safe static initialization of local statics with
destructors, place the __cxa_atexit call after the __cxa_guard_release
call, mimicking GCC/LLVM-GCC behavior. Noticed while debugging
something related.

llvm-svn: 103088
2010-05-05 15:38:32 +00:00
Douglas Gregor b22ee88652 Support for 'template' as a disambiguator (PR7030)
ParseOptionalCXXScopeSpecifier() only annotates the subset of
    template-ids which are not subject to lexical ambiguity. Add support
    for the more general case in ParseUnqualifiedId() to handle cases
    such as A::template B().

    Also improve some diagnostic locations.

Fixes PR7030, from Alp Toker!

llvm-svn: 103081
2010-05-05 05:58:24 +00:00
Douglas Gregor 94f9a4820a Reimplement code generation for copying fields in the
implicitly-generated copy constructor. Previously, Sema would perform
some checking and instantiation to determine which copy constructors,
etc., would be called, then CodeGen would attempt to figure out which
copy constructor to call... but would get it wrong, or poke at an
uninstantiated default argument, or fail in other ways.

The new scheme is similar to what we now do for the implicit
copy-assignment operator, where Sema performs all of the semantic
analysis and builds specific ASTs that look similar to the ASTs we'd
get from explicitly writing the copy constructor, so that CodeGen need
only do a direct translation.

However, it's not quite that simple because one cannot explicit write
elementwise copy-construction of an array. So, I've extended
CXXBaseOrMemberInitializer to contain a list of indexing variables
used to copy-construct the elements. For example, if we have:

  struct A { A(const A&); };
  
  struct B {
    A array[2][3];
  };

then we generate an implicit copy assignment operator for B that looks
something like this:

  B::B(const B &other) : array[i0][i1](other.array[i0][i1]) { }

CodeGen will loop over the invented variables i0 and i1 to visit all
elements in the array, so that each element in the destination array
will be copy-constructed from the corresponding element in the source
array. Of course, if we're dealing with arrays of scalars or class
types with trivial copy-assignment operators, we just generate a
memcpy rather than a loop.

Fixes PR6928, PR5989, and PR6887. Boost.Regex now compiles and passes
all of its regression tests.

Conspicuously missing from this patch is handling for the exceptional
case, where we need to destruct those objects that we have
constructed. I'll address that case separately.

llvm-svn: 103079
2010-05-05 05:51:00 +00:00
Anders Carlsson 58fe1756fb Use a more appropriate LLVM type for the vtable pointer.
llvm-svn: 103078
2010-05-05 05:47:36 +00:00
Ted Kremenek 680fe51e2c Rework clang_annotateTokens() to annotate tokens with information that more closely matches
clang_getCursor().  Tokens are now annotated with the cursor (for the matching AST element)
that most closely encompasses that token.

llvm-svn: 103064
2010-05-05 00:55:23 +00:00
John McCall 4a39ab8078 Emit the globals, metadata, etc. associated with static variables even when
they're unreachable.  This matters because (if they're POD, or if this is C)
the scope containing the variable might be reachable even if the variable
isn't.  Fixes PR7044.

llvm-svn: 103052
2010-05-04 20:45:42 +00:00
Fariborz Jahanian 60c7e16b64 Fixes a code gen. crash when ivar object has trivial constructor.
llvm-svn: 103028
2010-05-04 19:29:32 +00:00
Douglas Gregor c8be95274d When instantiating a function that was declared via a typedef, e.g.,
typedef int functype(int, int);
    functype func;

also instantiate the synthesized function parameters for the resulting
function declaration. 

With this change, Boost.Wave builds and passes all of its regression
tests.

llvm-svn: 103025
2010-05-04 18:18:31 +00:00
Fariborz Jahanian eeb233793d Fixes a code gen crash when block is a reference type, etc.
(radar 7495203).

llvm-svn: 103022
2010-05-04 17:59:32 +00:00
Douglas Gregor cd121fb013 Introduce a limit on the depth of the macro instantiation backtrace
printed in a diagnostic, similar to the limit we already have on the
depth of the template instantiation backtrace. The macro instantiation
backtrace is limited to 10 "instantiated from:" diagnostics; when it's
longer than that, we'll show the first half, then say how many were
suppressed, then show the second half. The limit can be changed with
-fmacro-instantiation-limit=N, and turned off with N=0.

This eliminates a lot of note spew with libraries making use of the
Boost.Preprocess library.

llvm-svn: 103014
2010-05-04 17:13:42 +00:00
Douglas Gregor 40c92bbe4f When creating a call to a base subobject's operator= in an
implicitly-defined copy assignment operator, suppress the protected
access check. This eliminates the remaining failure in the
Boost.SmartPtr library (that was a product of the copy-assignment
generation rewrite) and, presumably, the Boost.TR1 library as well.

llvm-svn: 103010
2010-05-04 15:20:55 +00:00
John McCall 9720514f3b An access is permitted if the current template instantiates to the appropriate
class.  Add some conservative support for the idea.  Fixes PR 7024.

llvm-svn: 102999
2010-05-04 05:11:27 +00:00
John McCall e61b02bcaf When inheriting a default argument expression, inherit the full expression,
not just the inner expression.  This is important if the expression has any
temporaries.  Fixes PR 7028.

Basically a symptom of really tragic method names.

llvm-svn: 102998
2010-05-04 01:53:42 +00:00
Fariborz Jahanian 751f7bc03c Fixes a Code Gen. Crash when calling destructor on a __block
variabe. Blocks and their construction/destruction is
wip though. 

llvm-svn: 102985
2010-05-04 00:26:07 +00:00
Douglas Gregor 1bd7a94460 When computing the template arguments for the instantiation of a
friend function template, be sure to adjust the computed template
argument lists based on the location of the definition of the function
template: it's possible that the definition we're instantiating with
and the template declaration that we found when creating the
specialization are in different contexts, which meant that we would
end up using the wrong template arguments for instantiation.

Fixes PR7013; all Boost.DynamicBitset tests now pass.

llvm-svn: 102974
2010-05-03 23:29:10 +00:00
John McCall 5828ee7a27 Just bail out immediately when emitting an unreachable function-local static
variable.  Surprisingly, this does seem to be the right way to solve this.

llvm-svn: 102961
2010-05-03 21:39:56 +00:00
Fariborz Jahanian ce7ddf7bf7 Test for my last patch.
llvm-svn: 102956
2010-05-03 21:06:59 +00:00
Douglas Gregor 70b21be380 When instantiating a function-local variable definition, introduce the
mapping from the declaration in the template to the instantiated
declaration before transforming the initializer, in case some crazy
lunatic decides to use a variable in its own initializer. Fixes PR7016.

llvm-svn: 102945
2010-05-03 20:22:41 +00:00
Ted Kremenek acc59c3ec9 Workaround: Don't add ObjCMethodDecls to the vector of TopLevelDecls since they don't go in
the DeclContext for the translation unit.  This is to workaround a fundamental issue in how
ObjC decls (within an @implementation) are parsed before the ObjCContainerDecl is available.

llvm-svn: 102944
2010-05-03 20:16:35 +00:00
Douglas Gregor aee1f51485 If we're generating code to create a pointer-to-member function
aggregate and the result of the aggregate is unused, bail out
early. Fixes PR7027.

llvm-svn: 102942
2010-05-03 20:00:27 +00:00
Douglas Gregor 3f324d569b Diagnose unused exception parameters under a different warning group
(-Wunused-exception-parameter) than normal variables, since it's more
common to name and then ignore an exception parameter. This warning is
neither enabled by default nor by -Wall. Fixes <rdar://problem/7931045>.

llvm-svn: 102931
2010-05-03 18:51:14 +00:00
Douglas Gregor 50ec46d4af Complain when we try to initialize an object of Objective-C class type
(which is ill-formed) with an initializer list. Also, change the
fallback from an assertion to a generic error message, which is far
friendlier. Fixes <rdar://problem/7730948>.

llvm-svn: 102930
2010-05-03 18:24:37 +00:00
Douglas Gregor cbbf3e3b4a It's okay to reference an enum in a template definition, even though
it's ill-formed to form an enum template. Fixes <rdar://problem/7933063>.

llvm-svn: 102926
2010-05-03 17:48:54 +00:00
Anders Carlsson 3572d44190 When computing the address of a virtual member function pointer, use the pointer width instead of hardcoding for 64-bit.
llvm-svn: 102921
2010-05-03 16:05:06 +00:00
Douglas Gregor df9ae794ca Try to unbreak clang-i686-darawin10 builder
llvm-svn: 102920
2010-05-03 15:51:04 +00:00
Fariborz Jahanian 58f11d6245 Do not issue warning on unimplemented property in the class, if it
conforms to a protocol as one of its super classes does. This is because
conforming super class will implement the property. This implements 
new warning rules for unimplemented properties (radar 7884086).

llvm-svn: 102919
2010-05-03 15:49:20 +00:00
Anders Carlsson f93cb3bacb Get rid of virt.cpp.
llvm-svn: 102918
2010-05-03 15:49:15 +00:00
Anders Carlsson c6bb0e117f The array form of 'new' can never have initializers.
llvm-svn: 102917
2010-05-03 15:45:23 +00:00
Douglas Gregor 5cf8d67bc9 When declaring a namespace alias, ignore previous declarations that
aren't in scope. Fixes PR7014.

llvm-svn: 102915
2010-05-03 15:37:31 +00:00
Douglas Gregor 95c70ec678 When instantiating a member function declared via a typedef, don't try
to enter the instantiated parameter declarations into the local
instantiation scope; they can't be referenced anyway. Fixes PR7022.

llvm-svn: 102914
2010-05-03 15:32:18 +00:00
Douglas Gregor 456ad1a817 When a class contains a non-empty anonymous union or struct, mark is
as non-empty. Fixes PR7021.

llvm-svn: 102913
2010-05-03 15:18:25 +00:00
Anders Carlsson d040e6b25a Don't build an aggregate constructor loop when the constructor is trivial.
llvm-svn: 102912
2010-05-03 15:09:17 +00:00
Anders Carlsson 604f560c39 Add test case that I forgot to check in.
llvm-svn: 102905
2010-05-03 14:22:40 +00:00
Anders Carlsson 16e94af67c Don't copy or initialize empty classes. Fixes PR7012.
llvm-svn: 102891
2010-05-03 01:20:20 +00:00
Douglas Gregor b139cd5843 Complete reimplementation of the synthesis for implicitly-defined copy
assignment operators. 

Previously, Sema provided type-checking and template instantiation for
copy assignment operators, then CodeGen would synthesize the actual
body of the copy constructor. Unfortunately, the two were not in sync,
and CodeGen might pick a copy-assignment operator that is different
from what Sema chose, leading to strange failures, e.g., link-time
failures when CodeGen called a copy-assignment operator that was not
instantiation, run-time failures when copy-assignment operators were
overloaded for const/non-const references and the wrong one was
picked, and run-time failures when by-value copy-assignment operators
did not have their arguments properly copy-initialized.

This implementation synthesizes the implicitly-defined copy assignment
operator bodies in Sema, so that the resulting ASTs encode exactly
what CodeGen needs to do; there is no longer any special code in
CodeGen to synthesize copy-assignment operators. The synthesis of the
body is relatively simple, and we generate one of three different
kinds of copy statements for each base or member:

  - For a class subobject, call the appropriate copy-assignment
    operator, after overload resolution has determined what that is.
  - For an array of scalar types or an array of class types that have
    trivial copy assignment operators, construct a call to
    __builtin_memcpy.
  - For an array of class types with non-trivial copy assignment
    operators, synthesize a (possibly nested!) for loop whose inner
    statement calls the copy constructor.
  - For a scalar type, use built-in assignment.

This patch fixes at least a few tests cases in Boost.Spirit that were
failing because CodeGen picked the wrong copy-assignment operator
(leading to link-time failures), and I suspect a number of undiagnosed
problems will also go away with this change.

Some of the diagnostics we had previously have gotten worse with this
change, since we're going through generic code for our
type-checking. I will improve this in a subsequent patch.

llvm-svn: 102853
2010-05-01 20:49:11 +00:00
Chris Lattner 036078ca76 with recent optimizer changes, these all get devirtualized.
llvm-svn: 102825
2010-05-01 01:42:06 +00:00
Douglas Gregor fabf95d066 After substituting a template argument for a non-type template
parameter with pointer-to-member type, we may have to perform a
qualification conversion, since the pointee type of the parameter
might be more qualified than the pointee type of the argument we form
from the declaration. Fixes PR6986.

llvm-svn: 102777
2010-04-30 21:46:38 +00:00
Douglas Gregor 0be628ff64 Fix a thinko that caused us not to compute __builtin_offset as a
constant expression in C. 

llvm-svn: 102762
2010-04-30 20:35:01 +00:00
Douglas Gregor 14cf752486 Clean up our handling of local instantiation scopes, which keep track
of the mapping from local declarations to their instantiated
counterparts during template instantiation. Previously, we tried to do
some unholy merging of local instantiation scopes that involved
storing a single hash table along with an "undo" list on the
side... which was ugly, and never handled function parameters
properly.

Now, we just keep separate hash tables for each local instantiation
scope, and "combining" two scopes means that we'll look in each of the
combined hash tables. The combined scope stack is rarely deep, and
this makes it easy to avoid the "undo" issues we were hitting. Also,
I've simplified the logic for function parameters: if we're declaring
a function and we need the function parameters to live longer, we just
push them back into the local instantiation scope where we need them. 

Fixes PR6990.

llvm-svn: 102732
2010-04-30 18:55:50 +00:00
Abramo Bagnara b639ab9ffc Attribute noreturn is now put in declaration attributes. Fixed a double warning generation.
llvm-svn: 102705
2010-04-30 09:13:03 +00:00
John McCall 5af1aa6393 An edge from a call expression to the exit block is only an abnormal edge
if *none* of the successors of the call expression is the exit block.
This matters when a call of bool type is the condition of (say) a while
loop in a function with no statements after the loop.  This *can* happen
in C, but it's much more common in C++ because of overloaded operators.

Suppresses some substantial number of spurious -Wmissing-noreturn warnings.

llvm-svn: 102696
2010-04-30 07:10:06 +00:00
Douglas Gregor 8b895228d9 Fix ADL for types declared in transparent decls, from Alp Toker!
llvm-svn: 102695
2010-04-30 07:08:38 +00:00
John McCall b3cec96a7c Account for the VTT argument when making an implicit copy constructor for
a class with virtual bases.  Just a patch until Sema starts (correctly) doing
most of this analysis.

Fixes PR 6622.

llvm-svn: 102692
2010-04-30 05:56:45 +00:00