Commit Graph

4709 Commits

Author SHA1 Message Date
Guy Benyei 610541989a Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
llvm-svn: 174601
2013-02-07 10:55:47 +00:00
Richard Smith 645d755d3e Fix handling of module imports adding names to a DeclContext after qualified
name lookup has been performed in that context (this probably only happens in
C++).

1) Whenever we add names to a context, set a flag on it, and if we perform
lookup and discover that the context has had a lookup table built but has the
flag set, update all entries in the lookup table with additional names from
the external source.

2) When marking a DeclContext as having external visible decls, mark the
context in which lookup is performed, not the one we are adding. These won't
be the same if we're adding another copy of a pre-existing namespace.

llvm-svn: 174577
2013-02-07 03:37:08 +00:00
Richard Smith 9ce12e36ab Simplify FindExternalVisibleDeclsByName by making it return a bool indicating
if it found any decls, rather than returning a list of found decls. This
removes a returning-ArrayRef-to-deleted-storage bug from
MultiplexExternalSemaSource (in code not exercised by any of the clang
binaries), reduces the work required in the found-no-decls case with PCH, and
importantly removes the need for DeclContext::lookup to be reentrant.

No functionality change intended!

llvm-svn: 174576
2013-02-07 03:30:24 +00:00
Richard Smith f5f43546b3 AST dumping: indicate the previous declaration for a redeclaration, and
indicate the semantic DC if it's not the lexical DC. In passing, correct
the ascii-art child marker for a child of a FriendDecl.

llvm-svn: 174570
2013-02-07 01:35:44 +00:00
Dmitri Gribenko b614fab39d DeclPrinter: fix CXXConstructExpr printing with implicit default argument
This is an improvement of r173630, that handles the following case:

  struct VirualDestrClass
  {
    VirualDestrClass(int arg);
    virtual ~VirualDestrClass();
  };

  struct ConstrWithCleanupsClass
  {
    ConstrWithCleanupsClass(const VirualDestrClass& cplx = VirualDestrClass(42));
  };

  ConstrWithCleanupsClass cwcNoArg;

That was printed as:

  ConstrWithCleanupsClass cwcNoArg();

llvm-svn: 174296
2013-02-03 23:02:47 +00:00
Benjamin Kramer 325d74566f CodeGen: Remove unnecessary const_casts. No functionality change.
llvm-svn: 174292
2013-02-03 18:55:34 +00:00
Dmitri Gribenko fb04e1b40c Remove unneeded const_casts
llvm-svn: 174287
2013-02-03 16:10:26 +00:00
Dmitri Gribenko 37527c242a Constify ASTContext::getObjContainingInterface
llvm-svn: 174282
2013-02-03 13:23:21 +00:00
Richard Smith 4be2c36921 Correctly classify T{} as an array temporary if T is an array of class type with nontrivial destructor.
llvm-svn: 174261
2013-02-02 02:11:36 +00:00
Dmitri Gribenko 2e72dd4a43 Comment parsing: improve the fidelity of XML output for many block commands
This change introduces a 'kind' attribute for the <Para> tag, that captures the
kind of the parent block command.

For example:

\todo Meow.

used to be just <Para>Meow.</Para>, but now it is
<Para kind="todo">Meow.</Para>

llvm-svn: 174216
2013-02-01 20:23:57 +00:00
Alexander Kornienko 540bacb1b9 Use const visitors in ASTDumper.
http://llvm-reviews.chandlerc.com/D355
Patch by Philip Craig!

llvm-svn: 174171
2013-02-01 12:35:51 +00:00
Fariborz Jahanian 1a0cf80533 [Comment parsing] Add support for recognizing
\headerfile command and representing it in an xml
document. Patch reviewed by Dmitri Gribenko.
// rdar://12397511

llvm-svn: 174109
2013-01-31 23:12:39 +00:00
Tim Northover 9bb857a4f1 Add support for AArch64 target.
In cooperation with the LLVM patch, this should implement all scalar front-end
parts of the C and C++ ABIs for AArch64.

This patch excludes the NEON support also reviewed due to an outbreak of
batshit insanity in our legal department. That will be committed soon bringing
the changes to precisely what has been approved.

Further reviews would be gratefully received.

llvm-svn: 174055
2013-01-31 12:13:10 +00:00
Enea Zaffanella eb22c870ac Added outer template parameter lists to friend type AST nodes.
llvm-svn: 174050
2013-01-31 09:54:08 +00:00
Richard Trieu e673d71a07 When comparing two template template arguments in the template differ, consider
them the same if they are actually the same; having the same name isn't enough.

Similar to r174013, template template arguments were also mistakenly considered
the same when they had the same name but were in different namespaces.
In addition, when printing template template arguments, use the qualified name
if the regular name is the same.

llvm-svn: 174029
2013-01-31 02:47:46 +00:00
Richard Smith 56d1215b05 Fix -Wcovered-switch-default and -Wunused-private-field warnings.
llvm-svn: 174025
2013-01-31 02:04:38 +00:00
Richard Trieu de5cc7d3d8 Add indents to AST dumping and removed parenthesis from AST nodes.
Indents were given the color blue when outputting with color.
AST dumping now looks like this:

Node
|-Node
| `-Node
`-Node
  `-Node

Compared to the previous:

(Node
  (Node
    (Node))
  (Node
    (Node)))

llvm-svn: 174022
2013-01-31 01:44:26 +00:00
Douglas Gregor 8e9f55ff13 When comparing two templates in the template differ, consider them the
same if they are actually the same; having the same name isn't
enough. Fixes <rdar://problem/12931988>.

llvm-svn: 174013
2013-01-31 01:08:35 +00:00
Dmitri Gribenko 28800da1b3 Comment parsing: resolve more named character references
This reimplements r173850 with a better approach:
(1) use a TableGen-generated matcher instead of doing a linear search;
(2) avoid allocations for new strings by converting code points to string
    iterals with TableGen.

llvm-svn: 173931
2013-01-30 14:29:28 +00:00
Dmitri Gribenko b1c1f90314 Revert unintended change
llvm-svn: 173927
2013-01-30 12:40:40 +00:00
Dmitri Gribenko 9feeef40f5 Move UTF conversion routines from clang/lib/Basic to llvm/lib/Support
This is required to use them in TableGen.

llvm-svn: 173924
2013-01-30 12:06:08 +00:00
Richard Smith debc59d1f3 Semantic analysis and CodeGen support for C11's _Noreturn. This is modeled as
an attribute for consistency with our other noreturn mechanisms.

llvm-svn: 173898
2013-01-30 05:45:05 +00:00
Fariborz Jahanian ef6a39c80b Removed couple of html named character references in
my last patch.

llvm-svn: 173856
2013-01-30 00:10:09 +00:00
Fariborz Jahanian 7b3ae19048 [Doc parsing] Patch to parse Doxygen-supported HTML character
references to their UTIF-8 encoding. Reviewed offline by Doug.
// rdar://12392215

llvm-svn: 173850
2013-01-29 23:42:26 +00:00
Joey Gouly 0942e0b5e1 Fix a crash in OpenCL code by using the proper (RHS) bit-width.
llvm-svn: 173802
2013-01-29 15:09:40 +00:00
Douglas Gregor 0b7bc7f996 Don't crash while printing APValues that are lvalues casted to a
decidedly non-reference, non-pointer type. Fixes <rdar://problem/13090123>.

llvm-svn: 173747
2013-01-29 01:26:43 +00:00
John McCall 5c1f1d09c8 Abstract the behavior of when to use base-class tail padding.
For fun, I added a comedy "actually obey the C++11 POD rules" option
which nobody is allowed to use.

llvm-svn: 173744
2013-01-29 01:14:22 +00:00
Dmitri Gribenko 6835e37cec Decl printer: fix CXXConstructExpr with implicit default argument
Patch by Will Wilson.

llvm-svn: 173630
2013-01-27 21:28:24 +00:00
Dmitri Gribenko 01b065117b Comment parsing: attach any tag type's documentation to its typedef if latter
does not have one of its own. // rdar://13067629

Original patch (r173586 and r173587) by Fariborz Jahanian, modified by me.

llvm-svn: 173626
2013-01-27 21:18:39 +00:00
NAKAMURA Takumi 69b664dfd7 Revert r173586 (and r173587) , "Attach any tag type's documentation to its typedef if"
It caused unexpected warnings with @tparam.

llvm-svn: 173614
2013-01-27 11:09:41 +00:00
Fariborz Jahanian 0ea5183fd7 Fix comment.
llvm-svn: 173587
2013-01-26 20:50:23 +00:00
Fariborz Jahanian 6522ad6e77 Attach any tag type's documentation to its typedef if
latter does not have one of its own. // rdar://13067629

llvm-svn: 173586
2013-01-26 20:49:30 +00:00
Enea Zaffanella f11ceb6897 Added ASTContext methods getIntPtrType and getUIntPtrType.
llvm-svn: 173581
2013-01-26 17:08:37 +00:00
Dmitri Gribenko d06f7ff6d3 Constify some getters of DesignatedInitExpr
llvm-svn: 173574
2013-01-26 15:15:52 +00:00
Richard Trieu d215b8d557 Highlight various parts of the AST dump with color. Colors are controlled by
-f(no-)color-diagnostics.  In addition, dumpColor() function calls are added
to force color printing.  No structural changes to -ast-dump.

llvm-svn: 173548
2013-01-26 01:31:20 +00:00
Dmitri Gribenko 7146930591 Comment parsing: actually check for a block command after "\param x"
This fixes PR15068.

llvm-svn: 173539
2013-01-26 00:36:14 +00:00
Fariborz Jahanian 7865220da4 patch for PR9027 and // rdar://11861085
Title: [PR9027] volatile struct bug: member is not loaded at -O;
This is caused by last flag passed to @llvm.memcpy being false, 
not honoring that aggregate has at least one 'volatile' data member 
(even though aggregate itself has not been qualified as 'volatile'. 
As a result, optimization optimizes away the memcpy altogether.
Patch review by John MaCall (I still need to fix up a test though).

llvm-svn: 173535
2013-01-25 23:57:05 +00:00
Fariborz Jahanian 66024d0244 simplify code by removing excessive bracing.
llvm-svn: 173521
2013-01-25 23:08:39 +00:00
Fariborz Jahanian 40abf3424c Attach enum's documentation to its typedef if
latter does not have one of its own. // rdar://13067629

llvm-svn: 173516
2013-01-25 22:48:32 +00:00
John McCall 6bd2a89d5a The standard ARM C++ ABI dictates that inline functions are
never key functions.  We did not implement that rule for the
iOS ABI, which was driven by what was implemented in gcc-4.2.
However, implement it now for other ARM-based platforms.

llvm-svn: 173515
2013-01-25 22:31:03 +00:00
John McCall 359b885e12 First pass at abstracting out a class for the target C++ ABI.
llvm-svn: 173514
2013-01-25 22:30:49 +00:00
Richard Smith f3814ad426 Clean up: since we have FunctionDecl::IsInline, make it store the right value
for template instantiations, and use it to simplify the implementation of
FunctionDecl::isInlined().

This incidentally changes the result of isInlined on a declared-but-not-defined
non-inline member function from true to false. This is sort of a bug fix, but
currently isInlined is only called on function definitions, so it has no visible
effects.

llvm-svn: 173397
2013-01-25 00:08:28 +00:00
Fariborz Jahanian bbcf8548cb removed duplicated comment.
llvm-svn: 173378
2013-01-24 22:26:55 +00:00
Fariborz Jahanian e735ff93e8 Patch to check for integer overflow. It has been
commented on and approved by Richard Smith.

llvm-svn: 173377
2013-01-24 22:11:45 +00:00
Dmitri Gribenko aeeca770b3 Add constness for NestedNameSpecifier::Create parameter
llvm-svn: 173274
2013-01-23 17:06:56 +00:00
Dmitri Gribenko b53f37c978 Constify some getters in RedeclarableTemplateDecl
llvm-svn: 173272
2013-01-23 16:52:57 +00:00
Joey Gouly dd7f4566b1 Add a new LangOpt NativeHalfType. This option allows for native half/fp16
operations (as opposed to storage only half/fp16).

Also add some semantic checks for OpenCL half types.

llvm-svn: 173254
2013-01-23 11:56:20 +00:00
Nico Weber bbe1394c96 Fix a bug in VarDecl::getSourceRange() for static member arrays with an element
type with an implicit initializer expression.

Patch from Will Wilson <will@indefiant.com>!

llvm-svn: 173170
2013-01-22 17:00:09 +00:00
Tim Northover 178723a687 Switch to APFloat constructor taking fltSemantics.
This change also makes the serialisation store the required semantics,
fixing an issue where PPC128 was always assumed when re-reading a
128-bit value.

llvm-svn: 173139
2013-01-22 09:46:51 +00:00
Timur Iskhodzhanov 52b8a05234 First step towards vftable generation with -cxx-abi microsoft PR13231
llvm-svn: 173035
2013-01-21 13:02:41 +00:00
Guy Benyei 1b4fb3e08b Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)
llvm-svn: 172973
2013-01-20 12:31:11 +00:00
Dmitri Gribenko b2e5482bd1 Use llvm::hexDigitValue in comment lexer
llvm-svn: 172924
2013-01-19 22:06:05 +00:00
Richard Smith 5011a0022a Some builtins do not evaluate their arguments. Teach EvaluatedExprVisitor not
to visit them.

llvm-svn: 172769
2013-01-17 23:46:04 +00:00
Douglas Gregor cd78037ad1 In Objective-C ARC, completely ignore ownership qualifiers on the
return type of a function by canonicalizing them away. They are
useless anyway, and conflict with our rules for template argument
deduction and __strong. Fixes <rdar://problem/12367446>.

llvm-svn: 172768
2013-01-17 23:36:45 +00:00
Matt Beaumont-Gay 978cca9f49 Suppress all -Wunused-value warnings from macro body expansions.
This is inspired by a number of false positives in real code, including
PR14968. I've added test cases reduced from these false positives to
test/Sema/unused-expr.c, as well as corresponding test cases that pass the
offending expressions as arguments to a no-op macro to ensure that we do warn
there.

This also removes my previous tweak from r166522/r166534, so that we warn on
unused cast expressions in macro arguments.

There were several test cases that were using -Wunused-value to test general
diagnostic emission features; I changed those to use other warnings or warn on
a macro argument expression. I stared at the test case for PR14399 for a while
with Richard Smith and we believe the new test case exercises the same
codepaths as before.

llvm-svn: 172696
2013-01-17 02:06:08 +00:00
Richard Smith 10876ef571 Implement C++11 semantics for [[noreturn]] attribute. This required splitting
it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their
semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as
affecting the function type, whereas [[noreturn]] does not).

llvm-svn: 172691
2013-01-17 01:30:42 +00:00
Douglas Gregor eed4979db9 Treat hidden Objective-C protocol definitions as if they were
undefined, and don't find methods or protocols within those protocol
definitions. This completes <rdar://problem/10634711>.

llvm-svn: 172686
2013-01-17 00:38:46 +00:00
Argyrios Kyrtzidis 6b4f341ecd [objcmt] Rewrite a NSDictionary dictionaryWithObjects:forKeys: to a dictionary literal
if we can see the elements of the arrays.

for example:

 NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:[NSArray arrayWithObjects:@"A", @"B", nil]];

-->

 NSDictionary *dict = @{ @"A" : @"1", @"B" : @"2" };

rdar://12428166

llvm-svn: 172679
2013-01-16 23:54:48 +00:00
Douglas Gregor 048fbfa302 Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility.

The bulk of this change replaces myriad hand-rolled loops over the
linked list of Objective-C categories/extensions attached to an
interface declaration with loops using one of the four new category
iterator kinds:

  visible_categories_iterator: Iterates over all visible categories
  and extensions, hiding any that have their "hidden" bit set. This is
  by far the most commonly used iterator.

  known_categories_iterator: Iterates over all categories and
  extensions, ignoring the "hidden" bit. This tends to be used for
  redeclaration-like traversals.

  visible_extensions_iterator: Iterates over all visible extensions,
  hiding any that have their "hidden" bit set.

  known_extensions_iterator: Iterates over all extensions, whether
  they are visible to normal name lookup or not.

The effect of this change is that any uses of the visible_ iterators
will respect module-import visibility. See the new tests for examples.

Note that the old accessors for categories and extensions are gone;
there are *Raw() forms for some of them, for those (few) areas of the
compiler that have to manipulate the linked list of categories
directly. This is generally discouraged.

Part two of <rdar://problem/10634711>.
 

llvm-svn: 172665
2013-01-16 23:00:23 +00:00
David Greene 9431926064 Fix Cast
Avoid a cast-away-const error by properly using const_cast<>.

llvm-svn: 172558
2013-01-15 22:09:40 +00:00
Alexander Kornienko 00911f1d55 Resolved merge error with r172323 (llvm::X -> X)
llvm-svn: 172528
2013-01-15 12:20:21 +00:00
Alexander Kornienko ebc17b5b87 Dump comments in -ast-dump.
http://llvm-reviews.chandlerc.com/D269

"Added dumping of declaration comments in ASTDumper. This required moving the
comment dumping code from CommentDumper so that the indentation is correct."

Patch by Philip Craig!

llvm-svn: 172409
2013-01-14 14:07:11 +00:00
Dmitri Gribenko aaf7f2978c Remove an unneeded const_cast
llvm-svn: 172370
2013-01-14 00:25:25 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Rafael Espindola 6239e05adc comment
llvm-svn: 172317
2013-01-12 15:27:44 +00:00
Rafael Espindola c48f7341cc bar
llvm-svn: 172316
2013-01-12 15:27:43 +00:00
Rafael Espindola 19de5613ea Disable caching of visibility.
The testcase in pr14929 shows that this is extremely hard to do. If we choose
to apply the attribute, that causes the visibility of some decls to change and
that can happen really late (during codegen).

Current gcc warns and ignores the attribute in this testcase with a warning.
This suggest that the correct solution is to find a point in the compilation
where we can compute the visibility and
* assert it was never computed before
* reject any attempts to compute it again in the future (with warnings).

llvm-svn: 172305
2013-01-12 06:42:30 +00:00
Douglas Gregor c147b0bc31 Provide Decl::getOwningModule(), which determines the (sub)module in
which a particular declaration resides. Use this information to
customize the "definition of 'blah' must be imported from another
module" diagnostic with the module the user actually has to
import. Additionally, recover by importing that module, so we don't
complain about other names in that module.

Still TODO: coming up with decent Fix-Its for these cases, and expand
this recovery approach for other name lookup failures.

llvm-svn: 172290
2013-01-12 01:29:50 +00:00
Fariborz Jahanian 37494a176c comment parsing: when property accessors don't have comment
of their own (or are syntheszed), use prperty's comment.
for them. // rdar://12791315

llvm-svn: 172278
2013-01-12 00:28:34 +00:00
Sean Callanan 19dfc93912 Fixed a bug that caused the AST importer to erroneously
import incomplete definitions for RecordDecls and then
mark the resulting definition as complete.

llvm-svn: 172273
2013-01-11 23:17:47 +00:00
Fariborz Jahanian 8b115b7872 Issue warning when case value is too large to fit
in case condition type. // rdar://11577384.
Test is conditionalized on x86_64-apple triple as
I am not sure if the INT_MAX/LONG_MAX values in the test
will pass this test for other hosts.

llvm-svn: 172016
2013-01-09 23:04:56 +00:00
David Blaikie 5a6a020d9b Suppress GCC -Wreturn warning.
Modified from a patch by David Greene.

llvm-svn: 171982
2013-01-09 17:48:41 +00:00
Rafael Espindola 3bd836a58e Handle static functions being redeclared in function scope.
Fixes pr14861.

llvm-svn: 171978
2013-01-09 16:34:58 +00:00
Rafael Espindola ef5ea1df4e Clear the LV cache when setting the instantiated from link.
Fixes pr14835.

llvm-svn: 171857
2013-01-08 14:58:32 +00:00
Richard Smith 1ecd564487 Move ref qualifiers from Type bitfields into FunctionProtoType, stealing two
bits from the number of parameters. This brings the bitfields down from 33 bits
to 32 bits, reducing the size of Types by 4 bytes on 32-bit systems.

llvm-svn: 171827
2013-01-08 00:50:27 +00:00
Fariborz Jahanian 0a17f59db8 Minor refactoring of my last patch
related to // rdar://12958878

llvm-svn: 171792
2013-01-07 21:31:08 +00:00
Fariborz Jahanian c41cf0598f objective-C: when searching for declarations in protocol
list of classes, etc., make sure to look into protocol
definitions. // rdar://12958878

llvm-svn: 171777
2013-01-07 19:21:03 +00:00
Alexander Kornienko 5bc364eb05 Implement Attr dumping for -ast-dump.
http://llvm-reviews.chandlerc.com/D234

Patch by Philip Craig!

llvm-svn: 171760
2013-01-07 17:53:08 +00:00
David Tweed 042e0883cb Scalar shifts in the OpenCL specification (as of v. 1.2) are defined to be
with respect to the lower "left-hand-side bitwidth" bits, even when negative);
see OpenCL spec 6.3j. This patch both implements this behaviour in the code
generator and "constant folding" bits of Sema, and also prevents tests
to detect undefinedness in terms of the weaker C99 or C++ specifications
from being applied. 

llvm-svn: 171755
2013-01-07 16:43:27 +00:00
Rafael Espindola 3c98afe2ae Assert that redeclarations have the same linkage.
It is somewhat hard to test linkage, so I decided to try to add an assert. This
already found some interesting cases where there were different.

llvm-svn: 171585
2013-01-05 01:28:37 +00:00
Rafael Espindola 885106795e Style fix: We don't use lowercase-and-underscored template parameter names.
Thanks for dgregor for noticing it.

llvm-svn: 171532
2013-01-04 21:18:45 +00:00
Rafael Espindola 66748e93e2 Fix typo. Thanks to dgregor for noticing it.
llvm-svn: 171521
2013-01-04 20:41:40 +00:00
Fariborz Jahanian cb6c867c46 Fix up various builtin declaration of objc_msgSend families
to match those foung in objc.h an avoid spurious warnings. 
// rdar://12489098

llvm-svn: 171492
2013-01-04 18:45:40 +00:00
Richard Smith 89645bc888 s/CXX0X/CXX11/g, except for __GNU_EXPERIMENTAL_CXX0X__, and update a few nearby 'C++0x' comments.
llvm-svn: 171372
2013-01-02 12:01:23 +00:00
Richard Smith 2bf7fdb723 s/CPlusPlus0x/CPlusPlus11/g
llvm-svn: 171367
2013-01-02 11:42:31 +00:00
Rafael Espindola 6525f96f01 Convert an if that never happens to an assert.
llvm-svn: 171354
2013-01-02 04:19:07 +00:00
Dmitri Gribenko 10af67a9c3 Comment lexing: replace manual comparison with StringRef::find_first_of
This gives an about 1.8% improvement on Clang bootstrap with -Wdocumentation

llvm-svn: 171262
2012-12-30 19:45:46 +00:00
Rafael Espindola 5cab029e4b Don't get confused if a extern "C" builtin function is redeclared without
the extern "C".

llvm-svn: 171260
2012-12-30 17:23:09 +00:00
Nico Weber 9dff378a12 ArrayRefize CXXTryStmt.
llvm-svn: 171239
2012-12-29 20:13:03 +00:00
Nico Weber a2a0eb940a ArrayRefize a CompoundStmt constructor.
llvm-svn: 171238
2012-12-29 20:03:39 +00:00
Rafael Espindola 576127d90e Reject overloading of two static extern C functions.
This patch moves hasCLanguageLinkage to be VarDecl and FunctionDecl methods
so that they can be used from SemaOverload.cpp and then fixes the logic
in Sema::IsOverload.

llvm-svn: 171193
2012-12-28 14:21:58 +00:00
Richard Smith 9e575dafad Replace magic numbers in CheckICE with an enum.
llvm-svn: 171192
2012-12-28 13:25:52 +00:00
Richard Smith 74fc72143a PR14729: Fix typo in CheckICE for BinaryConditionalOperators.
llvm-svn: 171191
2012-12-28 12:53:55 +00:00
Erik Verbruggen 11a2eccc8b Fix for PR12222.
Changed getLocStart() and getLocEnd() to be required for Stmts, and make
getSourceRange() optional. The default implementation for getSourceRange()
is build the range by calling getLocStart() and getLocEnd().

llvm-svn: 171067
2012-12-25 14:51:39 +00:00
Guy Benyei f0a014bbb7 Add intel_ocl_bicc calling convention as a function attribute to clang. The calling convention is already implemented in LLVM.
llvm-svn: 171056
2012-12-25 08:53:55 +00:00
Rafael Espindola 54606d57a2 Add 171048 back but invalidate the cache of all redeclarations when setting
the body of a functions. The problem was that hasBody looks at the entire chain
and causes problems to -fvisibility-inlines-hidden if the cache was not
invalidated.

Original message:

Cache visibility of decls.

This unifies the linkage and visibility caching. I first implemented this when
working on pr13844, but the previous fixes removed the performance advantage of
this one.
This is still a step in the right direction for making linkage and visibility
cheap to use.

llvm-svn: 171053
2012-12-25 07:31:49 +00:00
NAKAMURA Takumi eb63feb5bd Revert r171048, "Cache visibility of decls."
It broke stage2.

llvm-svn: 171050
2012-12-25 04:47:44 +00:00
Rafael Espindola f92a59f0cb Cache visibility of decls.
This unifies the linkage and visibility caching. I first implemented this when
working on pr13844, but the previous fixes removed the performance advantage of
this one.

This is still a step in the right direction for making linkage and visibility
cheap to use.

llvm-svn: 171048
2012-12-25 00:39:58 +00:00
Douglas Gregor 2d5a5613ce Use a safe default width for template-diff'ing integral arguments, in
case we can't find an exact width to use. Fixes crash in
<rdar://problem/12456626>.

llvm-svn: 170951
2012-12-21 23:03:27 +00:00
Fariborz Jahanian 7a16a02eec Fixes couple of friend declaration -ast-print bug
found by running -ast-print on all-std-headers.cpp
which caused it to go into infinite loop. Now
-ast-print prints all declarations found in 
all-std-headers.cpp.

llvm-svn: 170928
2012-12-21 21:43:05 +00:00
Bill Wendling 4442605f18 Revert r170500. It over-zealously converted *ALL* things named Attributes, which is wrong here.
llvm-svn: 170721
2012-12-20 19:22:21 +00:00
Alexander Kornienko 9bdeb11508 Minor coding style issue: NULL -> 0
llvm-svn: 170688
2012-12-20 12:23:54 +00:00
Alexander Kornienko 787f4c399f ASTDumper coding style fixes.
http://llvm-reviews.chandlerc.com/D226

Patch by Philip Craig!

llvm-svn: 170684
2012-12-20 11:08:38 +00:00
Richard Smith da4de6c246 Fix another uninitialized bool member bug found by -fsanitize=bool. This one
appears to currently be benign (we happen to test the flags in the right
order, so we never depend on the uninitialized value).

llvm-svn: 170640
2012-12-20 02:47:01 +00:00
John McCall 393a78d4d3 Robustify the @encode code and add support for _Atomic.
Fixes PR14628.

llvm-svn: 170639
2012-12-20 02:45:14 +00:00
Richard Smith 5bb4cdfaa9 Fix code that attempted to produce a diagnostic with one DiagnosticEngine, then
produce a note for that diagnostic either with a different DiagnosticEngine or
after calling DiagnosticEngine::Reset(). That didn't make any sense, and did the
wrong thing if the original diagnostic was suppressed.

llvm-svn: 170636
2012-12-20 02:22:15 +00:00
Alexander Kornienko 90ff607894 Implement AST dumper for Decls.
http://llvm-reviews.chandlerc.com/D52

Patch by Philip Craig!

llvm-svn: 170634
2012-12-20 02:09:13 +00:00
Fariborz Jahanian 0389e528ab Audit DeclPrinter with -ast-dump on Cocoa.h and
fix any bad objectiveC syntax coming out of
DeclPrinter. This is on going. Also, introduce a new
PrintPolicy and use it as needed when declaration tag
is to be produced via DeclPrinter.

llvm-svn: 170606
2012-12-19 23:36:00 +00:00
Dmitri Gribenko c55c6fc6e3 Fix PR14591: Windows newlines in doxygen comments cause failed assertion in
TextDiagnostic

Patch by Janusz Chorko.

llvm-svn: 170566
2012-12-19 17:34:55 +00:00
Dmitri Gribenko 696d7226d6 Comment parsing: add a missing 'else'. Found by inspection.
No testcase because we were just building an extra AST node and eventually
throwing it away, so it did not affect correctness.

llvm-svn: 170563
2012-12-19 17:17:09 +00:00
Bill Wendling 7967fc14b9 Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future.
llvm-svn: 170500
2012-12-19 07:18:12 +00:00
Richard Smith d59b832320 PR13470: Ensure that copy-list-initialization isntantiates as
copy-list-initialization (and doesn't add an additional copy step):

Fill in the ListInitialization bit when creating a CXXConstructExpr. Use it
when instantiating initializers in order to correctly handle instantiation of
copy-list-initialization. Teach TreeTransform that function arguments are
initializations, and so need this special treatment too. Finally, remove some
hacks which were working around SubstInitializer's shortcomings.

llvm-svn: 170489
2012-12-19 01:39:02 +00:00
David Blaikie ff7d47a354 Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as per review discussion in r170365
This does limit these typedefs to being sequences, but no current usage
requires them to be contiguous (we could expand this to a more general
iterator pair range concept at some point).

Also, it'd be nice if SmallVector were constructible directly from an ArrayRef
but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the
inverse conversion. (& generalizing over all range-like things, while nice,
would require some nontrivial SFINAE I haven't thought about yet)

llvm-svn: 170482
2012-12-19 00:45:41 +00:00
Eli Friedman 40ea264c25 Fix a crash in diagnostic printing when a template class type is diff'ed
against itself. PR14489.

llvm-svn: 170474
2012-12-18 23:32:47 +00:00
Fariborz Jahanian 9b7ab87738 This is the libclang patch providing minimal API to
use clang's formatter. Currently, formatter is used 
to format declaration tags for xml comments. Since formatter
is in flux and its change will break several of the clang comment
tests, only a single tests is formatted using this facility.
Doug has reviewed and approved it for check-in. 

llvm-svn: 170467
2012-12-18 23:02:59 +00:00
Guy Benyei d8a08ea98d Re-commit r170428 changes with Linux style file endings.
Add OpenCL images as clang builtin types.

llvm-svn: 170432
2012-12-18 14:38:23 +00:00
Guy Benyei 11169dded0 Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.
llvm-svn: 170431
2012-12-18 14:30:41 +00:00
Guy Benyei b13abb952a Add OpenCL images as clang builtin types.
llvm-svn: 170428
2012-12-18 12:30:03 +00:00
Rafael Espindola 74a133fa9a Merge storage classes even when contexts don't match.
This fixes the storage class of extern decls that are merged with file level
statics. The patch also fixes the linkage computation so that they are
considered internal.

llvm-svn: 170406
2012-12-18 04:18:55 +00:00
Rafael Espindola 7581f3269a Fix isThisDeclarationADefinition for extern following tentative.
An extern declaration following a tentative definition should not itself be
considered a tentative definition.
Fixes pr14614.

llvm-svn: 170377
2012-12-17 22:23:47 +00:00
Argyrios Kyrtzidis 53e3d6d7f0 Don't hit an assertion failure when calculating the __PRETTY_FUNCTION__
of a member function with parenthesized declarator.

Like this test case:

class Foo {
  const char *(baz)() {
    return __PRETTY_FUNCTION__;
  }
};

llvm-svn: 170233
2012-12-14 19:44:11 +00:00
Alexander Kornienko 18ec81b854 Rename StmtDumper to ASTDumper.
Patch contributed by Philip Craig!

llvm-svn: 170127
2012-12-13 13:59:55 +00:00
Douglas Gregor c50d4924eb Use @import rather than @__experimental_modules_import, since the
latter is rather a mess to type.

llvm-svn: 169919
2012-12-11 22:11:52 +00:00
Fariborz Jahanian f762b72f35 objective-C blocks: Check for record type when deciding if
byref variable requires extended layout info. to prevent 
a crash involving arrays declared __block. // rdar://12787751

llvm-svn: 169908
2012-12-11 19:58:01 +00:00
Alexander Kornienko 61c93bdf77 StmtDumper coding style changes
Summary:
A few small coding style changes for StmtDumper, including:
- rename Dump* methods to dump*
- uninline some methods
- comment fixes
- whitespace fixes

Please review and commit if okay.

Reviewers: alexfh

Reviewed By: alexfh

CC: cfe-commits, alexfh, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D190

llvm-svn: 169866
2012-12-11 15:28:09 +00:00
Alexander Kornienko 7bd0f9be94 Rename StmtDumper::DumpSubTree() to dumpStmt()
Summary:
Also rename DumpDeclarator() to dumpDecl(). Once Decl dumping is added, these will be the two main methods of the class, so this is just for consistency in naming.

There was a DumpStmt() method already, but there was no point in having it, so I have merged it into VisitStmt(). Similarly, DumpExpr() is merged into VisitExpr().

Reviewers: alexfh

Reviewed By: alexfh

CC: cfe-commits, alexfh

Differential Revision: http://llvm-reviews.chandlerc.com/D156

llvm-svn: 169865
2012-12-11 15:20:44 +00:00
Richard Smith 6b02d46dae Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial
while building the class, we eagerly declare those special members. The impact
of this is bounded, since it does not trigger implicit declarations of special
members in classes which merely *use* those classes.

In order to determine whether we need to apply this rule, we also need to
eagerly declare move operations and destructors in cases where they might be
deleted. If a move operation were supposed to be deleted, it would instead
be suppressed, and we could need overload resolution to determine if we fall
back to a trivial copy operation. If a destructor were implicitly deleted,
it would cause the move constructor of any derived classes to be suppressed.

As discussed on cxx-abi-dev, C++11's selected constructor rules are also
retroactively applied as a defect resolution in C++03 mode, in order to
identify that class B has a non-trivial copy constructor (since it calls
A's constructor template, not A's copy constructor):

struct A { template<typename T> A(T &); };
struct B { mutable A a; };

llvm-svn: 169673
2012-12-08 08:32:28 +00:00
Richard Smith 1a2532b3fe Remove some remnants of the assumption that there is at most one of each
flavour of special member.

llvm-svn: 169670
2012-12-08 04:10:18 +00:00
Richard Smith 92f241f188 Properly compute triviality for explicitly-defaulted or deleted special members.
Remove pre-standard restriction on explicitly-defaulted copy constructors with
'incorrect' parameter types, and instead just make those special members
non-trivial as the standard requires.

This required making CXXRecordDecl correctly handle classes which have both a
trivial and a non-trivial special member of the same kind.

This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the
new triviality computation technology.

llvm-svn: 169667
2012-12-08 02:53:02 +00:00
Richard Smith 593f993a68 Implement C++03 [dcl.init]p5's checking for value-initialization of references
properly, rather than faking it up by pretending that a reference member makes
the default constructor non-trivial. That leads to rejects-valids when putting
such types inside unions.

llvm-svn: 169662
2012-12-08 02:01:17 +00:00
Eli Bendersky f6f93ee31c Currently when AST record layouts are dumped with -fdump-record-layouts, the
following:

sizeof=132, dsize=132, align=4
nvsize=132, nvalign=4

Is not indented, so when classes are nested there is no way to know to
which class it belongs.

Fix this problem by indenting the size summary properly for each class.

llvm-svn: 169654
2012-12-08 00:07:24 +00:00
Richard Smith 7808c6aa7e Don't use dyn_cast on a Type* which might not be canonical. Fixes an extremely obscure record layout bug.
llvm-svn: 169467
2012-12-06 03:04:50 +00:00
Fariborz Jahanian 3ec39215f9 More C++ testing of declarations embedded in
<declaration> tag of Comment XML  and fixing 
DeclPrint of templates along the way - wip. 
//rdar://12378714

llvm-svn: 169453
2012-12-06 00:09:40 +00:00
Fariborz Jahanian de872af437 In DeclPrint add printing of '= default'
in constructors.

llvm-svn: 169440
2012-12-05 22:53:06 +00:00
Fariborz Jahanian 69c403c5c9 In DeclPrint add printing of 'explicit'
constructors.

llvm-svn: 169435
2012-12-05 22:19:06 +00:00
Fariborz Jahanian 14ef4790d1 Testing C++ declarations embedded in
<declaration> tag of Comment XML.
Added DeclPrint support for constructors
and fix tests accordingly.
This is wip. // rdar://12378714

llvm-svn: 169412
2012-12-05 19:54:11 +00:00
Fariborz Jahanian bfc3ef55be Testing C++ declarations embedded in
<declaration> tag of Comment XML and 
added support for friend declaration printing.
This is wip. // rdar://12378714

llvm-svn: 169346
2012-12-05 00:38:44 +00:00
Fariborz Jahanian 1ace8cb994 Testing C declarations embedded in
<declaration> tag of Comment XML and fixed a
missing block literal printout as result of the testing. 
// rdar://12378714

llvm-svn: 169307
2012-12-04 21:15:23 +00:00
Fariborz Jahanian 4cf177e238 objective-c blocks: Consider padding due to alignment
after the fixed size block header when generating
captured block variable info. // rdar://12773256

llvm-svn: 169285
2012-12-04 17:20:57 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Fariborz Jahanian 95759ff807 Testing objective-C declarations embedded in
<declaration> tag of Comment XML and fixed a
missing declaration of ivars private to @implementation
as result of the testing. // rdar://12378714

llvm-svn: 169193
2012-12-04 00:47:33 +00:00
Benjamin Kramer 444a1304ad Include pruning and general cleanup.
llvm-svn: 169095
2012-12-01 17:12:56 +00:00
Benjamin Kramer d7d2b1fe45 Don't include Type.h in DeclarationName.h.
Recursively prune some includes.

llvm-svn: 169094
2012-12-01 16:35:25 +00:00
Benjamin Kramer ea70eb30a0 Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't pull in all the generated Attr code.
Required to pull some functions out of line, but this shouldn't have a perf impact.
No functionality change.

llvm-svn: 169092
2012-12-01 15:09:41 +00:00
Richard Smith 328aae595c Refactor to reduce duplication in handling of special member functions. No functionality change.
llvm-svn: 168977
2012-11-30 05:11:39 +00:00
Rafael Espindola c12edd4e68 Now that the underlying problem has been fixed, add r168411 back.
Original commit message:

Remove redundant code.

llvm-svn: 168900
2012-11-29 16:38:22 +00:00
Rafael Espindola 8778c28022 Merge function types in C.
Among other differences, GCC accepts

  typedef int IA[];
  typedef int A10[10];
  static A10 *f(void);
  static IA  *f(void);
  void g(void) {
    (void)sizeof(*f());
  }

but clang used to reject it with:

  invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []')

The intention of c99's 6.2.7 seems to be that we should use the composite type
and accept as gcc does.

Doing the type merging required some extra fixes:
  * Use the type from the function type in initializations, even if an parameter
    is available.
  * Fix the merging of the noreturn attribute in function types.
  * Make CodeGen  handle the fact that an parameter type can be different from
    the corresponding type in the function type.

llvm-svn: 168895
2012-11-29 16:09:03 +00:00
Timur Iskhodzhanov 6732d350ef [-cxx-abi microsoft] Also spill the argument-back-references context when mangling templates
llvm-svn: 168862
2012-11-29 08:58:47 +00:00
Fariborz Jahanian 998f0a3360 objective-C blocks: Make sure that identical logic is used
in deciding a copy/dispose field is needed in a byref structure
and when generating the copy/dispose helpers. In certain
cases, these fields were being added but no copy/dispose was
being generated. This was uncovered in ARC, but not in MRR.
// rdar://12759433

llvm-svn: 168825
2012-11-28 23:12:17 +00:00
Richard Smith 1c33fe8fea Store on the CXXRecordDecl whether the class has, or would have, a copy
constructor/assignment operator with a const-qualified parameter type. The
prior method for determining this incorrectly used overload resolution.

llvm-svn: 168775
2012-11-28 06:23:12 +00:00
Argyrios Kyrtzidis 0f05fb9cba Introduce ASTUnresolvedSet, an UnresolvedSet-like class, whose contents are
allocated using the allocator associated with an ASTContext.

Use this inside CXXRecordDecl::DefinitionData instead of an UnresolvedSet to
avoid a potential memory leak.

rdar://12761275

llvm-svn: 168771
2012-11-28 03:56:16 +00:00
Argyrios Kyrtzidis a6567c4102 Don't return a pointer to an UnresolvedSetImpl in the CXXRecordDecl interface,
expose only the iterators instead.

llvm-svn: 168770
2012-11-28 03:56:09 +00:00
Eli Friedman 4e91899e7b Fix the definition of the vfork() builtin on Haiku. PR14378.
llvm-svn: 168674
2012-11-27 02:58:24 +00:00
Rafael Espindola 7dc71d03b9 Revert r168411 for now.
llvm-svn: 168667
2012-11-27 01:44:24 +00:00
Timur Iskhodzhanov 09848e709c Fix PR14413 - incorrect mangling of anonymous namespaces with -cxx-abi microsoft
llvm-svn: 168583
2012-11-26 08:55:48 +00:00
Rafael Espindola befe130dd2 Add r168519 back, but with a fix to also merge the used flag in variables.
llvm-svn: 168564
2012-11-25 14:07:59 +00:00
NAKAMURA Takumi c232cb8542 Revert r168519, "Merge used flags so that we don't have to iterate on isUsed. With this change"
It brought bunch of (possibly false) warnings.

llvm/unittests/VMCore/PassManagerTest.cpp:60:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char ModuleNDNM::ID=0;
                     ^
llvm/unittests/VMCore/PassManagerTest.cpp:86:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char ModuleNDM2::ID=0;
                     ^
llvm/unittests/VMCore/PassManagerTest.cpp:106:21: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char ModuleDNM::ID=0;
                    ^
llvm/unittests/VMCore/PassManagerTest.cpp:217:16: warning: variable 'initcount' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int LPass::initcount=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:218:16: warning: variable 'fincount' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int LPass::fincount=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:259:16: warning: variable 'inited' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int BPass::inited=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:260:16: warning: variable 'fin' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int BPass::fin=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:283:24: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char OnTheFlyTest::ID=0;
                       ^
8 warnings generated.

llvm-svn: 168549
2012-11-24 23:17:09 +00:00
Rafael Espindola 99e3bfbd17 Merge used flags so that we don't have to iterate on isUsed. With this change
"clang -cc1 -fsyntax-only" on the preprocessed output of

#define M extern int a;
#define M2 M M
#define M4 M2 M2
#define M8 M4 M4
#define M16 M8 M8
#define M32 M16 M16
#define M64 M32 M32
#define M128 M64 M64
#define M256 M128 M128
#define M512 M256 M256
#define M1024 M512 M512
#define M2048 M1024 M1024
#define M4096 M2048 M2048
#define M8192 M4096 M4096
#define M16384 M8192 M8192
M16384

goes from 2.994s to 1.416s. GCC is at 0.022s, so we still have a long way to go.

llvm-svn: 168519
2012-11-23 16:26:30 +00:00
Rafael Espindola 88806c2865 Remove redundant check.
llvm-svn: 168515
2012-11-23 14:29:54 +00:00
Richard Smith d80b2d57cf Fix CXXRecordDecl::forallBases to not look through bases which are dependent
and defined within the current instantiation, but which are not part of the
current instantiation. Previously, it would look at bases which could be
specialized separately from the current template.

llvm-svn: 168477
2012-11-22 00:24:47 +00:00
Rafael Espindola 6dcddfb852 Remove redundant code.
llvm-svn: 168411
2012-11-21 02:53:22 +00:00
Rafael Espindola a508c5de58 Remove redundant code.
llvm-svn: 168410
2012-11-21 02:47:19 +00:00
Dmitri Gribenko 76b91c3431 Documentation parsing: propely handle a lone '\endverbatim' and emit a warning.
We actually used to assert on this.

Thanks to NAKAMURA Takumi for noticing this!

llvm-svn: 168277
2012-11-18 00:30:31 +00:00
Dmitri Gribenko dddfc51397 StmtDumper: remove incomplete support for limiting the maximum dump depth.
There are better ways of limiting the amount of information if there is a need
for that.

Patch by Philip Craig.

llvm-svn: 168206
2012-11-16 21:43:31 +00:00
Matt Beaumont-Gay c08fa18596 Fix PR14321, a crash when Clang is built with GCC 4.7 at -O1 or greater.
GCC 4.7 reuses stack slots fairly aggressively, which exposes more temporary
lifetime bugs.

No new test, this was caught by the existing CodeGenCXX/mangle-ms-templates.cpp.

llvm-svn: 168124
2012-11-16 01:14:52 +00:00
Richard Smith 1648847248 A step towards sorting out handling of triviality of special members in C++11.
Separate out the notions of 'has a trivial special member' and 'has a
non-trivial special member', and use them appropriately. These are not
opposites of one another (there might be no special member, or in C++11 there
might be a trivial one and a non-trivial one). The CXXRecordDecl predicates
continue to produce incorrect results, but do so in fewer cases now, and
they document the cases where they might be wrong.

No functionality changes are intended here (they will come when the predicates
start producing the right answers...).

llvm-svn: 168119
2012-11-16 00:53:38 +00:00
Fariborz Jahanian 0e3043b2ed block extended signatur option. Change previous option
to a cc1 -fencode-extended-block-signature and pass it
to cc1 and recognize this option to produce extended block
type signature. // rdar://12109031 

llvm-svn: 168063
2012-11-15 19:02:45 +00:00
Eli Friedman 6745c3b732 Fix a trivial bool-related bug I spotted while skimming David Fang's
current list of powerpc-darwin8 failures.

llvm-svn: 168016
2012-11-15 01:21:59 +00:00
Eli Friedman c2c982c78b Make template diffing handle integral expressions of various widths correctly.
PR14342.

llvm-svn: 168005
2012-11-14 23:57:08 +00:00
Fariborz Jahanian 64223e6db1 objective-C blocks: under cc1 flag -encode-extended-block-signature,
generate expanded signature encoding to include types as we
already do this for protocol method lists.
// rdar://12109031

llvm-svn: 167997
2012-11-14 23:11:38 +00:00
Douglas Gregor 91155087e9 Teach the AST importer to merge enumerator constants. Fixes
<rdar://problem/12676166>, and tested on the LLDB side of the world.

llvm-svn: 167990
2012-11-14 22:29:20 +00:00
Fariborz Jahanian a9d4464baf objective-C blocks: Provide layout map for byref
variables captured in a block. // rdar://12184410

llvm-svn: 167931
2012-11-14 17:15:51 +00:00
Richard Smith 5fa94b09b4 PR14279: Work around this major miscompilation by treating move operations as
non-trivial if they would not call a move operation, even if they would in fact
call a trivial copy operation. A proper fix is to follow, but this small
directed fix is intended for porting to the 3.2 release branch.

llvm-svn: 167920
2012-11-14 07:36:28 +00:00
David Blaikie 72ee18c12a Remove debugging assert.
Found by Richard Smith in post-commit review of r167906.

llvm-svn: 167911
2012-11-14 04:41:34 +00:00
David Blaikie 095deba533 Provide the correct mangling and linkage for certain unnamed nested classes.
This corrects the mangling and linkage of classes (& their member functions) in
cases like this:

  struct foo {
    struct {
      void func() { ... }
    } x;
  };

we were accidentally giving this nested unnamed struct 'no' linkage where it
should've had the linkage of the outer class. The mangling was incorrecty too,
mangling as TU-wide unnamed type mangling of $_X rather than class-scoped
mangling of UtX_.

This also fixes -Wunused-member-function which would incorrectly diagnose
'func' as unused due to it having no linkage & thus appearing to be TU-local
when in fact it might be correctly used in another TU.

Similar mangling should be applied to function local classes in similar cases
but I've deferred that for a subsequent patch.

Review/discussion by Richard Smith, John McCall, & especially Eli Friedman.

llvm-svn: 167906
2012-11-14 01:52:05 +00:00
Richard Smith 41ae3288fd Remove another questionable use of hasTrivial*. The relevant thing for this
test was whether the /selected/ operator= was trivial, not whether the class
had any trivial (or any non-trivial) operator=s.

llvm-svn: 167897
2012-11-14 00:50:40 +00:00
Nico Weber 3ad723ca2e [ms] Make mangleIntegerLiteral less aware of exact type of the literal.
Integer literal mangling does not actually depend on exact type of the literal.
This will simplify calling mangleIntegerLiteral when literal type is not known,
for example, when sizes or offsets are mangled as integer literals.

Also, call mangleNumber instead of directly printing mangled values of 0/1, to
avoid this knowledge from being in multiple places.

Patch from Evgeny Eltsin!

llvm-svn: 167878
2012-11-13 22:09:44 +00:00
Richard Smith a0e5e54e8d Remove abuse of hasTrivial*, and fix miscompile wherein global arrays with
internal linkage, no uses, trivial construction, and nontrivial destruction
were not emitted.

llvm-svn: 167756
2012-11-12 21:38:00 +00:00
David Blaikie 6bffd6fe81 80 cols & unnecessary braces from r167736.
Post-commit review feedback by Eli Friedman.

llvm-svn: 167739
2012-11-12 19:32:32 +00:00
David Blaikie 8fab8e53fb Correct printing of nested anonymous type member accesses.
Patch by Florent Bruneau!

llvm-svn: 167736
2012-11-12 19:12:12 +00:00
Rafael Espindola ab53a72781 Remove calls to getMostRecentDecl. The case they were added for in r117526 are
now covered by attribute merging.

llvm-svn: 167714
2012-11-12 04:32:23 +00:00
Rafael Espindola d5ed033d56 In Sema::MergeVarDecl we handle merging of storage classes and visibility
attributes. In cases where the merged declaration is fully equivalent to the
two original ones, some of the code was getLVForDecl was duplicated.

Cases that are still handled in getLVForDecl are things like

__private_extern__ int N;
int N;

For which we cannot produce a single merged decl with all the information.

llvm-svn: 167703
2012-11-12 04:10:23 +00:00
Douglas Gregor dc97457178 Rework my implementation of circular-reference finding to not use
CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the
failure introduced in r167651.

llvm-svn: 167668
2012-11-10 07:24:09 +00:00
Douglas Gregor 6200470112 Diagnostic circular inheritance involving dependent base classes. We
would have diagnosed this at instantiation time anyway, if only we
didn't hang on all of these test cases. Fixes <rdar://problem/12629723>

llvm-svn: 167651
2012-11-10 01:18:17 +00:00
Argyrios Kyrtzidis 6566e23e13 Add a FileCharacteristic parameter to SourceManager::createFileIDForMemBuffer
for completeness and use it in CompilerInstance::InitializeSourceManager if
the input is a memory buffer.

llvm-svn: 167628
2012-11-09 19:40:45 +00:00
Nico Weber 5ed8a8a06a [ms] Implement int64_t version of mangleNumber() in terms of the APSInt version.
No intended functionality change.

llvm-svn: 167602
2012-11-09 00:05:56 +00:00
Nico Weber 7d37f05a44 [Windows] Fix mangling of number literal '0'
Do this by making the mangleNumber(APSInt) overload look like
the int64_t version. (The latter should probably just delegate
to the former).

Test from Evgeny Eltsin!

llvm-svn: 167599
2012-11-08 23:38:59 +00:00
David Blaikie 3a0de21233 Fix a source range regression in C++ new expressions with call initializers.
Introduced in r167507, discovered in review by Abramo Bagnara.

llvm-svn: 167597
2012-11-08 22:53:48 +00:00
Abramo Bagnara 8d16bd4d10 Allow to pass from syntactic form of InitListExpr to semantic form (just as viceversa). No functionality change.
llvm-svn: 167591
2012-11-08 18:41:43 +00:00
Abramo Bagnara 9b836fb019 Fixed range of implicit MemberExpr.
llvm-svn: 167581
2012-11-08 13:52:58 +00:00
Manuel Klimek 874030e684 Create helper functions in StmtDumper for outputting the indentation, newlines, and brackets.
This is preparation for adding Decl dumping.

Patch by Philip Craig.

llvm-svn: 167509
2012-11-07 00:33:12 +00:00
David Blaikie 7b97aef997 PR13552: Fix the end location of a CXXNewExpr.
Spent longer than reasonable looking for a nice way to test this & decided to
give up for now. Open to suggestions/requests. Richard Smith suggested adding
something to ASTMatchers but it wasn't readily apparent how to test this with
that.

llvm-svn: 167507
2012-11-07 00:12:38 +00:00
Dmitri Gribenko 941ab0fb6f Remove a const_cast by propagating constness to the member function.
llvm-svn: 167357
2012-11-03 14:24:57 +00:00
Richard Trieu 6df8945f04 Fix the template type diffing to handle integral template arguments.
llvm-svn: 167252
2012-11-01 21:29:28 +00:00
Rafael Espindola 973aa207e8 Fix an incorrect assert, the LHS can be an LValue.
llvm-svn: 167232
2012-11-01 14:32:20 +00:00
Argyrios Kyrtzidis b26a24cca2 [libclang] Introduce clang_Cursor_getReceiverType which returns the CXType for
the receiver of an ObjC message expression.

rdar://12578643

llvm-svn: 167201
2012-11-01 02:01:34 +00:00
Anna Zaks 408f7d0144 Address Jordan's review: comments, spaces.
llvm-svn: 167091
2012-10-31 01:18:22 +00:00
Rafael Espindola 9c006de3d3 Move two helper functions to AST so that sema can use them.
llvm-svn: 166853
2012-10-27 01:03:43 +00:00
Eli Friedman a7137bc1c2 Fix indentation.
llvm-svn: 166830
2012-10-26 23:05:34 +00:00
Douglas Gregor 1423a5cfd7 When an externally-supplied record layout has a size that clearly
doesn't include padding up to the alignment of the record, take this
as a cue that the alignment of the record should (conservatively) be
set to 1. This is similar to other the other cues we use to determine
that the record has a lower alignment, e.g., that the
externally-supplied layout places fields at lower offsets than we
would. Fixes <rdar://problem/12582052>; test case in LLDB.

llvm-svn: 166824
2012-10-26 22:31:14 +00:00