Commit Graph

21646 Commits

Author SHA1 Message Date
Douglas Gregor bb3d786213 Reinstate change to non-type template arguments of integral type, so
that we extend/truncate then correct the sign to convert the non-type
template argument to the template parameter's type. Previously, we
reported an error when the non-type template argument was out of
range; now we just warn.

llvm-svn: 99600
2010-03-26 02:38:37 +00:00
John McCall a5beaf6958 Properly instantiate and link in friend function templates.
llvm-svn: 99596
2010-03-26 02:05:14 +00:00
Ted Kremenek c5260901e9 Update test case since c-index-test now works on invalid sources.
llvm-svn: 99595
2010-03-26 01:34:53 +00:00
Ted Kremenek 014e70b797 Return translation units from clang_createTranslationUnitFromSource()
if even they contain errors.

llvm-svn: 99594
2010-03-26 01:34:51 +00:00
Anders Carlsson 45bd753b4a More VTT builder cleanup.
llvm-svn: 99588
2010-03-26 00:58:21 +00:00
Eric Christopher bd9a3aecd6 This is just a simple v4si * v4si, make it so.
llvm-svn: 99587
2010-03-26 00:51:28 +00:00
Anders Carlsson c1b4747d5a More VTT cleanup.
llvm-svn: 99586
2010-03-26 00:50:17 +00:00
Douglas Gregor a14cb9fd38 Revert attempted fix for integral template arguments. It seems to have broken tramp3d-v4.
llvm-svn: 99583
2010-03-26 00:39:40 +00:00
Rafael Espindola 5b33408481 Mark virtual methods that are used in tables included in VTTs as used.
Fixes PR6706.

llvm-svn: 99582
2010-03-26 00:36:59 +00:00
Anders Carlsson e67698bd73 Start cleaning up the VTT builder to make it work more like the VTable builder.
llvm-svn: 99581
2010-03-26 00:35:45 +00:00
Anders Carlsson 382a96550b Remove some VTT builder arguments that were always zero.
llvm-svn: 99576
2010-03-26 00:11:51 +00:00
Douglas Gregor 63eed63312 Warn when the conversion of an integral non-type template argument to
the type of its corresponding non-type template parameter changes the
value. Previously, we were diagnosing this as an error, which was
wrong. We give reasonably nice warnings like:

test/SemaTemplate/temp_arg_nontype.cpp💯10: warning: non-type template
      argument value '256' truncated to '0' for template parameter of type
      'unsigned char'
Overflow<256> *overflow3; // expected-warning{{non-type template ...
         ^~~
test/SemaTemplate/temp_arg_nontype.cpp:96:24: note: template parameter is
      declared here
template<unsigned char C> struct Overflow;
                       ^

llvm-svn: 99561
2010-03-25 22:21:04 +00:00
Douglas Gregor 210b590562 Teach the diagnostic engine to provide more detailed information about
how to handle a diagnostic during template argument deduction, which
may be "substitution failure", "suppress", or "report". This keeps us
from, e.g., emitting warnings while performing template argument
deduction.

llvm-svn: 99560
2010-03-25 22:17:48 +00:00
John McCall e99d5f3044 When finishing a function definition, leave the function definition *after*
doing all the cleanup tasks and checks.  This gives us the proper context for
checking access to base and member destructors.

llvm-svn: 99559
2010-03-25 22:08:03 +00:00
Fariborz Jahanian f9c4585c80 Fix a code gen. bug involving generation of getter method
from properties of _Complex type. (radar 7351147).

llvm-svn: 99558
2010-03-25 21:56:43 +00:00
Anders Carlsson 151b062fee Don't add address points for virtual primary bases that aren't primary bases in the complete class.
llvm-svn: 99555
2010-03-25 21:45:14 +00:00
John McCall 27e70baa55 Fix a very minor oversight in privileges-elevation: we were only considering
friendship for a derived class if the base class specifier was non-public,
and thus not considering friendship for non-public members of public bases.

llvm-svn: 99554
2010-03-25 21:39:55 +00:00
John McCall e9eaf8e0f8 Handle simple friend-class decls in class templates better by ensuring that
we look for shadow friend decls in the appropriate scope before injecting
a new declaration.

llvm-svn: 99552
2010-03-25 21:28:06 +00:00
Fariborz Jahanian bb4978fbae Check for some code gen. for PR6641 test.
llvm-svn: 99526
2010-03-25 18:05:35 +00:00
John McCall 15ad0962dc Preserve type-source information in friend declarations.
llvm-svn: 99525
2010-03-25 18:04:51 +00:00
Daniel Dunbar 3f540c0d7d Remove support for nand atomic builtins. They are inconsistently implemented in
gcc, and the common expectation seems to be that they are unused. If and when
someone cares we can add them back with well documented demantics.

llvm-svn: 99522
2010-03-25 17:13:09 +00:00
Anders Carlsson a5736bde2e Use the new vtable layout code for construction vtables.
llvm-svn: 99516
2010-03-25 16:49:53 +00:00
Douglas Gregor 6c689cc75c Use Daniel's trick for XFAIL'd tests
llvm-svn: 99515
2010-03-25 16:40:13 +00:00
John Thompson 957816fbf3 PS3 needs __PPC__. Should this be in the PPC target?
llvm-svn: 99513
2010-03-25 16:18:32 +00:00
Douglas Gregor 66767ea93c Add another test for weird substitutions into function types during template argument deduction
llvm-svn: 99510
2010-03-25 15:42:11 +00:00
Douglas Gregor da61afaf9d Improve our handling of local instantiation scopes in two related ways:
- When substituting template arguments as part of template argument
    deduction, introduce a new local instantiation scope.
  - When substituting into a function prototype type, introduce a new
    "temporary" local instantiation scope that merges with its outer
    scope but also keeps track of any additions it makes, removing
    them when we exit that scope.

Fixes PR6700, where we were getting too much mixing of local
instantiation scopes due to template argument deduction that
substituted results into function types.

llvm-svn: 99509
2010-03-25 15:38:42 +00:00
Anders Carlsson a4147148ff When -fdump-vtable-layouts is specified, construction vtable initializers will be generated using the new vtable layout code. (The code is still not completely in place but this is a huge step forward).
llvm-svn: 99508
2010-03-25 15:26:28 +00:00
Nuno Lopes b23f8f9dd5 add dump() method to CanQual for debugging purposes
llvm-svn: 99505
2010-03-25 13:19:42 +00:00
John McCall 598b4405a6 Properly instantiate friend class template declarations and link them into
the redeclaration chain.  Recommitted from r99477 with a fix:  we need to
merge in default template arguments from previous declarations.

llvm-svn: 99496
2010-03-25 06:39:04 +00:00
Zhongxing Xu 169b5b189e Add a utility method.
llvm-svn: 99495
2010-03-25 06:33:37 +00:00
Bob Wilson 63d45e51fb Revert 99477 since it appears to be breaking the clang-x86_64-darwin10-fnt
buildbot.  The tramp3d test fails.
--- Reverse-merging r99477 into '.':
U    test/SemaTemplate/friend-template.cpp
U    test/CXX/temp/temp.decls/temp.friend/p1.cpp
U    lib/Sema/SemaTemplateInstantiateDecl.cpp
U    lib/Sema/SemaAccess.cpp

llvm-svn: 99481
2010-03-25 04:40:43 +00:00
Ted Kremenek 4d745dd5cb Fix two bugs in format-string checking:
(1) Do not assume the data arguments start after the format string
(2) Do not use the fact that a function is variadic to treat it like a va_list printf function

Fixes PR 6697.

llvm-svn: 99480
2010-03-25 03:59:12 +00:00
Ted Kremenek 186508c7d6 Fix '+=' accumulation error when parsing numeric amounts in a format string.
llvm-svn: 99479
2010-03-25 03:59:09 +00:00
John McCall ac418d44ed Properly instantiate and link in friend-class-template declarations.
llvm-svn: 99477
2010-03-25 02:56:08 +00:00
Ted Kremenek 599d73aa72 Add c-index-test support for printing USRs.
llvm-svn: 99476
2010-03-25 02:00:39 +00:00
Ted Kremenek f64a38907d Require that all Clang-based USRs start with the prefix 'c:' for the "USR space".
llvm-svn: 99475
2010-03-25 02:00:36 +00:00
Zhongxing Xu b6e1c13c36 Add methods to remove a GDM entry.
Instead of setting the ReturnExpr GDM to NULL, remove it.

llvm-svn: 99470
2010-03-25 01:39:39 +00:00
Anders Carlsson d03325c54f More address point map shuffling.
llvm-svn: 99462
2010-03-25 00:51:13 +00:00
Anders Carlsson 0534b0201e Shuffle some code around; this will make it easier to use the new layout code for address points.
llvm-svn: 99461
2010-03-25 00:35:49 +00:00
Douglas Gregor 031296e316 Kill off two more uses of Sema::CheckReferenceInit in favor of the new
initialization code. Exposed a bug where we were not marking an
implicit conversion as an lvalue when we were forming a call to a
conversion function whose return type is a reference.

llvm-svn: 99459
2010-03-25 00:20:38 +00:00
Douglas Gregor deb714ceeb Switch static_cast from the old reference-initialization code (via
CheckReferenceInit) over to the new initialization code
(InitializationSequence), which is better-tested and doesn't require
us to compute the entire conversion sequence twice.

llvm-svn: 99452
2010-03-24 23:38:29 +00:00
Douglas Gregor 99970f008c Check for ret, so that we know we hit the end of the function
llvm-svn: 99448
2010-03-24 23:19:27 +00:00
Douglas Gregor 02dde146e0 When returning from a function that has a reference return type, use
EmitReferenceBindingToExpr() rather than assuming we have an
lvalue. This is just the lowest hanging fruit for PR6024, which still
requires a bit of work.

llvm-svn: 99447
2010-03-24 23:14:04 +00:00
Rafael Espindola 1dbd474f2e Discussing with dgregor we decided that we should not force the emission of
implicit methods on explicit template instantiation definitions. As a
consequence, we should emit them at every use, even if we see a explicit
template instantiation declaration.

This is already the current behaviour, but it is good to test for that :-)

llvm-svn: 99443
2010-03-24 22:43:31 +00:00
Ted Kremenek 8edc6dfd20 Use llvm::SmallString instead of std::string.
llvm-svn: 99442
2010-03-24 22:39:47 +00:00
Ted Kremenek aeaf3d2ce6 Improve static analyzer diagnostic concerning the use of 'mktemp'
llvm-svn: 99441
2010-03-24 22:39:45 +00:00
Douglas Gregor e50c05244f make the vtable tester a little friendlier, with a clean target and without requiring . to be in your path
llvm-svn: 99433
2010-03-24 21:52:55 +00:00
Douglas Gregor dc76403cc1 When pulling apart an initializer that involves a CXXConstructExpr, do
not pick apart a CXXTemporaryObjectExpr because such an object
construction was explicitly written in the source code. Fixes PR6657.

llvm-svn: 99427
2010-03-24 21:22:47 +00:00
Douglas Gregor 023da0d43a Make sure that we have File IDs for all of the unsaved files before we
deserialize diagnostics.

llvm-svn: 99426
2010-03-24 21:04:06 +00:00
Fariborz Jahanian 9b37b1d6bb Allow conversion of qualified Class type to unqualified
Class type to match gcc's. Fixes radar 7789113.

llvm-svn: 99425
2010-03-24 21:00:27 +00:00
Douglas Gregor cc9c92cfc2 XFAIL the -nostdinc++ test on Windows; it doesn't look like we even have the notion of separate C and C++ paths there
llvm-svn: 99422
2010-03-24 20:45:20 +00:00
Douglas Gregor b8ddb138a9 Control warnings about GNU extensions with -Wgnu, which has a subgroup
for GNU designated-initializer syntax (-Wgnu-designator).

llvm-svn: 99421
2010-03-24 20:42:51 +00:00
Douglas Gregor 64b046fce4 Implement support for -nostdc++. Fixes PR6446.
llvm-svn: 99417
2010-03-24 20:13:48 +00:00
Fariborz Jahanian c5b7bfc657 Improve diagnostics when ivar added to class
extension (radar 6812436).

llvm-svn: 99408
2010-03-24 18:08:23 +00:00
Douglas Gregor 8fdd0e8cd6 Silently drop dependent friend function template specializations,
since we have absolutely no way to match them when they are declared
nor do we have a way to represent these parsed-but-not-checked friend
declarations.

llvm-svn: 99407
2010-03-24 17:31:23 +00:00
Douglas Gregor 2538674a98 Change two class forward declarations to struct forward declarations, silencing a Clang warning
llvm-svn: 99405
2010-03-24 16:59:08 +00:00
Fariborz Jahanian 47b4629b3b Code gen for multi-dimensional dynamic allocations.
Fixes PR6641.

llvm-svn: 99404
2010-03-24 16:57:01 +00:00
Anders Carlsson e90954de64 More vtable improvements. We now compute and keep track of all vtable related information which avoids computing the same vtable layout over and over.
llvm-svn: 99403
2010-03-24 16:42:11 +00:00
John McCall 69f7586c5b Walk out of enums when determining effective context.
llvm-svn: 99391
2010-03-24 09:04:37 +00:00
John McCall 1f0479e3d7 Correct that last fixit: if the user wrote
template <> friend void foo(int);
we need to change it to
  friend void foo<>(int);
or else the user won't get the template specialization they obviously want.

llvm-svn: 99390
2010-03-24 08:27:58 +00:00
John McCall 816d75b701 Support friend function specializations.
llvm-svn: 99389
2010-03-24 07:46:06 +00:00
Douglas Gregor d6bc5e6bbc When a declaration of a function is missing an exception specification
that was present in a prior declaration, emit a warning rather than a
hard error (which we did before, and still do with mismatched
exception specifications). Moreover, provide a fix-it hint with the
throw() clause that should be added, e.g.,

t.C:10:7: warning: 'operator new' is missing exception specification
      'throw(std::bad_alloc)'
void *operator new(unsigned long sz)
      ^
                                     throw(std::bad_alloc)

As part of this, disable the warning when we're missing an exception
specification on operator new, operator new[], operator delete, or
operator delete[] when exceptions are turned off (-fno-exceptions).

Fixes PR5957.

llvm-svn: 99388
2010-03-24 07:14:45 +00:00
Anders Carlsson 67fbf9853f Use getNamedGlobal instead of getGlobalVariable. (Fixes self-host).
llvm-svn: 99385
2010-03-24 05:32:05 +00:00
Anders Carlsson 91e18c93c4 Make the license header in smmintrin.h match the other SSE headers.
llvm-svn: 99384
2010-03-24 05:31:31 +00:00
John McCall c62bb64c65 Implement a framework for the delay of arbitrary diagnostics within
templates.  So delay access-control diagnostics when (for example) the target
of a friend declaration is a specific specialization of a template.

I was surprised to find that this was required for an access-controlled selfhost.

llvm-svn: 99383
2010-03-24 05:22:00 +00:00
Douglas Gregor bcf0a47e7a When performing name lookup for the allocation or deallocation
operators, make sure that the implicitly-declared global new and
delete operators are always available. Fixes PR5904.

llvm-svn: 99382
2010-03-24 05:07:21 +00:00
Anders Carlsson b35ea55e2e More vtable work; preparations for moving over to the new vtable layout code (finally).
llvm-svn: 99381
2010-03-24 03:57:14 +00:00
Douglas Gregor 5112157958 Each non-local class instantiation is its own local instantiation
scope. Fixes PR6619.

llvm-svn: 99377
2010-03-24 01:33:17 +00:00
Anders Carlsson 95e0223baf Remove old thunks code.
llvm-svn: 99374
2010-03-24 00:57:54 +00:00
Douglas Gregor f9f54eab43 Make sure to properly track the anonymous namespace that lives inside
each namespace, even when the outer namespace has multiple
definitions. As part of this, collapsed two pointers worth of storage
(original namespace and inner anonymous namespace) into a single
pointer with a distinguishing bit, since the two are mutually
exclusive, saving a pointer per NamespaceDecl. Fixes PR6620.

llvm-svn: 99368
2010-03-24 00:46:35 +00:00
Anders Carlsson 68fdb871dc Flip the switch and use the new vtable layout code for thunks by default. Add a thunks.cpp test.
llvm-svn: 99367
2010-03-24 00:41:37 +00:00
Anders Carlsson bad991dbfd Add CodeGenFunction::GenerateThunk and implement it.
llvm-svn: 99365
2010-03-24 00:39:18 +00:00
Anders Carlsson 4a3cdf5ac7 Minor cleanup.
llvm-svn: 99364
2010-03-24 00:35:44 +00:00
Anders Carlsson 3537413c4a Remove parts of virt.cpp
llvm-svn: 99363
2010-03-24 00:32:03 +00:00
Douglas Gregor 4165bd6772 Implement computation of the final overriders for each virtual
function within a class hierarchy (C++ [class.virtual]p2).

We use the final-overrider computation to determine when a particular
class is ill-formed because it has multiple final overriders for a
given virtual function (e.g., because two virtual functions override
the same virtual function in the same virtual base class). Fixes
PR5973.

We also use the final-overrider computation to determine which virtual
member functions are pure when determining whether a class is
abstract or diagnosing the improper use of an abstract class. The
prior approach to determining whether there were any pure virtual
functions in a class didn't cope with virtual base class subobjects
properly, and could not easily be fixed to deal with the oddities of
subobject hiding. Fixes PR6631.

llvm-svn: 99351
2010-03-23 23:47:56 +00:00
Fariborz Jahanian 519675bbf5 Add some missing files to xcode project
llvm-svn: 99318
2010-03-23 20:23:06 +00:00
Rafael Espindola fa1708fdea revert 99311. Looks like it broke darwin bootstrap.
llvm-svn: 99317
2010-03-23 19:55:22 +00:00
Ted Kremenek 5921b83f54 Improve diagnostic for @property/ivar type mismatch by including the types of the
ivar and @property respectively.

llvm-svn: 99312
2010-03-23 19:02:22 +00:00
Rafael Espindola 4d3745ade6 Avoid producing implicit methods when we have a explicit template instantiation
declaration.

llvm-svn: 99311
2010-03-23 18:56:16 +00:00
Fariborz Jahanian 6c67b90752 Code gen for compound assignment of complex
types using property syntax to access setter/getters.
(also radar 7351147).

llvm-svn: 99307
2010-03-23 18:43:00 +00:00
Anders Carlsson 55e89f877c More work on thunks - don't assert if there's a variable with the same name as the thunk already.
llvm-svn: 99303
2010-03-23 18:18:41 +00:00
Fariborz Jahanian 3131496622 Patch to implement code gen. use of compound assignent on
properties of complex type. Radar 7351147.

llvm-svn: 99299
2010-03-23 18:08:50 +00:00
Anders Carlsson cd836f0b5f More thunks scaffolding.
llvm-svn: 99294
2010-03-23 17:17:29 +00:00
Anders Carlsson 5c5abad5d9 More work on thunks.
llvm-svn: 99287
2010-03-23 16:36:50 +00:00
Douglas Gregor b525ef87fc When recovering from a qualified typedef name, don't clear out the
DeclContext because we don't want a NULL DeclContext. Instead, use the
current context.

llvm-svn: 99281
2010-03-23 15:26:55 +00:00
Anders Carlsson 274fc82289 Move ThunkInfo as well.
llvm-svn: 99280
2010-03-23 15:17:13 +00:00
Anders Carlsson 67fd3a50dc Move ReturnAdjustment and ThisAdjustment out into CGVtable.h
llvm-svn: 99279
2010-03-23 15:13:06 +00:00
Duncan Sands de4fe3538a Ignore a more comprehensive set of gcc-special format attributes.
llvm-svn: 99277
2010-03-23 14:44:19 +00:00
Zhongxing Xu e248dca300 Bind the constructed object value to CXXConstructExpr.
llvm-svn: 99271
2010-03-23 09:13:17 +00:00
Zhongxing Xu b473f91498 update CMakeLists.txt
llvm-svn: 99269
2010-03-23 08:14:19 +00:00
Zhongxing Xu bf2f0d74a2 Clear the return expr GDM after using it.
llvm-svn: 99268
2010-03-23 08:09:29 +00:00
Zhongxing Xu 1ff3dcef1f Add a AggExprVisitor class. It contains lots of boiler
plate code for evaluating expressions of C++ class type.

llvm-svn: 99267
2010-03-23 07:32:14 +00:00
Anders Carlsson 995891667f Use the canonical destructor, which fixes the self-host build. Thanks to Eli for noticing.
llvm-svn: 99260
2010-03-23 05:15:24 +00:00
Zhongxing Xu 7fffbcc756 merge line.
llvm-svn: 99259
2010-03-23 05:13:26 +00:00
Daniel Dunbar 30b24e95fa Frontend: Don't free the CompilerInstance or FrontendActions when running under
-disable-free. Among other things, this fixes freeing of the LLVM module on
exit.
 - Note that this means we are disable-free'ing of a lot more stuff than we used to -- this should flush out bugs in anything left that is trying to do real work in its destructor. I did a mini-audit but '::~' is not totally uncommon.

llvm-svn: 99258
2010-03-23 05:09:16 +00:00
Daniel Dunbar cb9eaf59fb PPCallbacks: Add hook for reaching the end of the main file, and fix DependencyFile to not do work in its destructor.
llvm-svn: 99257
2010-03-23 05:09:10 +00:00
Zhongxing Xu 3c0c81a4d4 Since we now may have basicblocks with the same block is in different function,
change the block counter map from unsigned -> unsigned to 
<StackFrameContext*, unsigned> -> unsigned.

llvm-svn: 99255
2010-03-23 05:05:02 +00:00
Anders Carlsson 917229cf75 Baby steps towards making thunks be emitted from the new vtable layout code.
llvm-svn: 99254
2010-03-23 04:59:02 +00:00
Anders Carlsson 7cea12ff9b Some renames.
llvm-svn: 99253
2010-03-23 04:44:10 +00:00
Anders Carlsson af82f63b47 Always emit associated thunks when emitting the function itself. Remove getVtableAddressPoint, it's not used.
llvm-svn: 99252
2010-03-23 04:31:31 +00:00