Commit Graph

30192 Commits

Author SHA1 Message Date
Daniel Dunbar 8438464b41 Driver/Darwin: Honor --sysroot= when invoking the linker, on Darwin.
llvm-svn: 130723
2011-05-02 21:03:47 +00:00
Chad Rosier f897d3b88b Fixed test case asserts due to checkin of r130710.
llvm-svn: 130720
2011-05-02 20:39:21 +00:00
Devang Patel 2a7c219466 Emit debug info for __destroy_helper_block_ and __copy_helper_block.
llvm-svn: 130719
2011-05-02 20:37:08 +00:00
Eli Friedman 30458b51e3 Skip extra copy from aggregate where it isn't necessary; rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0.
llvm-svn: 130717
2011-05-02 20:24:29 +00:00
Ted Kremenek aa181174e7 Augment retain/release checker to not warn about tracked objects passed as arguments to C++ constructors. This is a stop-gap measure for Objective-C++ code that uses smart pointers to manage reference counts.
llvm-svn: 130711
2011-05-02 19:42:42 +00:00
Chad Rosier 24874a449c When using -std= flag added check to make sure language and standard are compatable
llvm-svn: 130710
2011-05-02 19:24:53 +00:00
Lenny Maiorani 0b510279c6 Implements strncasecmp() checker and simplifies some of the logic around creating substrings if necessary and calling the appropriate StringRef::compare/compare_lower().
llvm-svn: 130708
2011-05-02 19:05:49 +00:00
Chandler Carruth 38a328276c Don't abuse reinterpret cast to do something the API of PointerUnion
provides proper support for. This was caught by
-Wundefined-reinterpret-cast, and I think a reasonable case for it to
warn on.

Also use is<...> instead of dyn_cast<...> when the result isn't needed.

This whole thing should probably switch to using UsuallyTinyPtrVector.

llvm-svn: 130707
2011-05-02 18:54:36 +00:00
Manuel Klimek c638cd21fb Adds a test for the command line parser when a quoted string is not closed by a quote.
llvm-svn: 130704
2011-05-02 18:27:26 +00:00
Argyrios Kyrtzidis 69a2c924b9 Add a warning for when reinterpret_cast leads to undefined behavior, patch by Richard Trieu!
llvm-svn: 130703
2011-05-02 18:21:19 +00:00
Eli Friedman f4258eb484 Switch CallArgList from an std::pair to a new CallArg struct (which will eventually gain more members). Working towards modifying call emission to avoid unnecessary copies.
llvm-svn: 130700
2011-05-02 18:05:27 +00:00
Eli Friedman 43dca6a8d2 Simplify code a bit by using CallArgList::add. No intended functionality change.
llvm-svn: 130699
2011-05-02 17:57:46 +00:00
Rafael Espindola 4cfa7971e9 Disable CFI if not using the integrated assembler. We should probably do this only for
OS X, but it is probably not all that important.

llvm-svn: 130697
2011-05-02 17:43:32 +00:00
Fariborz Jahanian eb39741c0b More rule enforcement of zero bitfields for ms_struct.
llvm-svn: 130696
2011-05-02 17:20:56 +00:00
NAKAMURA Takumi c3a8529269 lib/Frontend/InitHeaderSearch.cpp: Tweak AddPath() to accept "/foo/bar" (not "X:\foo\bar") with -isysroot. test/PCH/reloc.c can pass.
FIXME: We should consider better isysroot scheme on Win32 hosts.
llvm-svn: 130683
2011-05-02 04:50:10 +00:00
NAKAMURA Takumi bb9ffbdc89 test/CodeGenCXX/vtable-debug-info.cpp: It does not crash on mingw.
FIXME: It would crash with -integrated-as. Implement -g on MCCOFF.
llvm-svn: 130682
2011-05-02 04:50:00 +00:00
NAKAMURA Takumi 0760218bca test/CodeGenCXX/debug-info-namespace.cpp: Add explicit -fverbose-asm to cc1 to let cygming pass.
This test seeks a verbose comment in output. By default, "-integrated-as" sets verbose-asm. Cygming is not ready for -integrated-as yet.

llvm-svn: 130681
2011-05-02 04:49:53 +00:00
Nick Lewycky d3c2df8d2b Remove redeclaration of Invalid. The code that set this to true was updating an
Invalid that was never read from again, causing non-type-template-parms to be
marked valid when in fact they weren't.

This was caught by GCC 4.6's -Wunused-but-set-variable warning.

llvm-svn: 130680
2011-05-02 01:48:46 +00:00
Nick Lewycky fc49f72b58 Remove unused variable spotted by GCC.
Devang, can we remove this call entirely? If I try that, "make check" passes
but the call has a side-effect of ensuring that the block's context exists in
the debug info. getContextDescriptor() is used in a void context for that side-
effect elsewhere in this file. Please take a look!

llvm-svn: 130679
2011-05-02 01:41:48 +00:00
Nick Lewycky 82e478009f Remove unused variable, but keep function call with side-effect.
llvm-svn: 130678
2011-05-02 01:07:19 +00:00
Chandler Carruth 61a8dacd00 I updated this constructor's interface, and didn't have to fix any
callers. Shockingly enough, *there are none*!

llvm-svn: 130677
2011-05-02 01:06:57 +00:00
Nick Lewycky cf8714ee7b Remove dead variable caught by GCC.
llvm-svn: 130676
2011-05-02 01:06:15 +00:00
Chandler Carruth 1d352ec6d9 Nuke stale code for separately importing the qualifer -- it's just part
of the QualifierLoc, and that's all we need to import now.

llvm-svn: 130675
2011-05-02 01:01:54 +00:00
Nick Lewycky 1c60a0bc98 Remove dead variable, flagged by gcc's -Wunused-but-set-variable.
llvm-svn: 130674
2011-05-02 00:46:56 +00:00
Nick Lewycky b4175cad29 Remove dead variable flagged by gcc's -Wunused-but-set-variable. No
functionality change.

llvm-svn: 130673
2011-05-02 00:41:17 +00:00
Nick Lewycky 18a1ee7f51 Remove a dead variable flagged by gcc's -Wunused-but-set-variable. No
functionality change.

llvm-svn: 130672
2011-05-02 00:40:24 +00:00
John McCall 824908373e Revise the representation of parameter scope data so that the
scope depth overlaps with the ObjCDeclQualifier, dropping
memory usage back to previous levels.

llvm-svn: 130671
2011-05-02 00:30:12 +00:00
Chandler Carruth 8d26bb0899 Add an optional field attached to a DeclRefExpr which points back to the
Decl actually found via name lookup & overload resolution when that Decl
is different from the ValueDecl which is actually referenced by the
expression.

This can be used by AST consumers to correctly attribute references to
the spelling location of a using declaration, and otherwise gain insight
into the name resolution performed by Clang.

The public interface to DRE is kept as narrow as possible: we provide
a getFoundDecl() which always returns a NamedDecl, either the ValueDecl
referenced or the new, more precise NamedDecl if present. This way AST
clients can code against getFoundDecl without know when exactly the AST
has a split representation.

For an example of the data this provides consider:
% cat x.cc
namespace N1 {
  struct S {};
  void f(const S&);
}
void test(N1::S s) {
  f(s);
  using N1::f;
  f(s);
}

% ./bin/clang -fsyntax-only -Xclang -ast-dump x.cc
[...]
void test(N1::S s) (CompoundStmt 0x5b02010 <x.cc:5:20, line:9:1>
  (CallExpr 0x5b01df0 <line:6:3, col:6> 'void'
    (ImplicitCastExpr 0x5b01dd8 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay>
      (DeclRefExpr 0x5b01d80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)'))
    (ImplicitCastExpr 0x5b01e20 <col:5> 'const struct N1::S' lvalue <NoOp>
      (DeclRefExpr 0x5b01d58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S')))
  (DeclStmt 0x5b01ee0 <line:7:3, col:14>
    0x5b01e40 "UsingN1::;")
  (CallExpr 0x5b01fc8 <line:8:3, col:6> 'void'
    (ImplicitCastExpr 0x5b01fb0 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay>
      (DeclRefExpr 0x5b01f80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)' (UsingShadow 0x5b01ea0 'f')))
    (ImplicitCastExpr 0x5b01ff8 <col:5> 'const struct N1::S' lvalue <NoOp>
      (DeclRefExpr 0x5b01f58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S'))))

Now we can tell that the second call is 'using' (no pun intended) the using
declaration, and *which* using declaration it sees. Without this, we can
mistake calls that go through using declarations for ADL calls, and have no way
to attribute names looked up with using declarations to the appropriate
UsingDecl.

llvm-svn: 130670
2011-05-01 23:48:14 +00:00
John McCall 8fb0d9d24a Store a parameter index and function prototype depth in every
parameter node and use this to correctly mangle parameter
references in function template signatures.

A follow-up patch will improve the storage usage of these
fields;  here I've just done the lazy thing.

llvm-svn: 130669
2011-05-01 22:35:37 +00:00
Chandler Carruth bbf65b0501 Remove the NameQualifier struct, which was just a wrapper around
NestedNameSpecifierLoc. It predates when we had such an object.

Reference the NNSLoc directly in DREs, and embed it directly into the
MemberNameQualifier struct.

llvm-svn: 130668
2011-05-01 22:14:37 +00:00
Chandler Carruth e68f261dea Several cosmetic changes, no functionality changed.
Mostly trailing whitespace so that me editor nuking it doesn't muddy the
waters of subsequent commits that do change functionality.

Also nukes a stray statement that was harmless but redundant that
I introduced in r130666.

llvm-svn: 130667
2011-05-01 21:55:21 +00:00
Chandler Carruth 0e439960b8 Move the state bits in DeclRefExpr out of the pointer union and into
a bitfield in the base class. DREs weren't using any bits here past the
normal Expr bits, so we have plenty of room. This makes the common case
of getting a Decl out of a DRE no longer need to do any masking etc.

Also, while here, clean up code to use the accessor methods rather than
directly poking these bits, and provide a nice comment for DREs that
includes the information previously attached to the bits going into the
pointer union.

No functionality changed here, but DREs should be a tad faster now.

llvm-svn: 130666
2011-05-01 21:29:53 +00:00
Chandler Carruth 56b579a373 Switch getAs to castAs (didn't know about this before!) and simplify
some code.

llvm-svn: 130665
2011-05-01 21:29:41 +00:00
Chandler Carruth a62d8a50e2 Remove a stale comment, it no longer applied after my cleanups.
Also fix several misspellings in my comments. I cannot spell, and cannot
even be trusted to ask my editor how to spell apparently.

llvm-svn: 130662
2011-05-01 19:18:02 +00:00
Abramo Bagnara 4d42399d46 Fixed source range for extern linkage specification without braces.
llvm-svn: 130660
2011-05-01 16:25:54 +00:00
Rafael Espindola 9af3d4b193 Add r130624 back now that ELF has been fixed to work with -fno-dwarf2-cfi-asm.
llvm-svn: 130659
2011-05-01 15:45:27 +00:00
Chandler Carruth 73aa8f7027 Based on the new information in the AST provided by r130628, write
3 lines of code and improve a bunch of information in the libclang view
of the code.

Updates the two tests that exercise this with the new data, checking
that each new source location actually points back to the declared
template parameter.

llvm-svn: 130656
2011-05-01 09:53:37 +00:00
Chandler Carruth af85886563 Move several more type traits' implementations into the AST. A few were
already present in the AST, and I added the ones that weren't.

llvm-svn: 130655
2011-05-01 09:29:58 +00:00
Chandler Carruth 7ba7bd388b Switch __is_scalar to use the isScalarType predicate rather than
duplicating its logic.

llvm-svn: 130654
2011-05-01 09:29:55 +00:00
Chandler Carruth c5276e584e Have the array type traits build an expression with type 'size_t'
instead of 'int'.

The Embarcadero spec says 'unsigned int', not 'int'. That's what
'size_t' is on Windows, but for Clang using a 'size_t' that can be
larger than int seems more appropriate.

llvm-svn: 130653
2011-05-01 08:48:21 +00:00
Chandler Carruth f57eba3b20 Remove an inapplicable and completely out of place comment. The type is in fact 'bool'.
llvm-svn: 130652
2011-05-01 08:48:19 +00:00
Chandler Carruth 0d1a54f8e1 Remove more dead code for emitting diagnostics. The callers of these
functions already precluded dependent types from reaching them.

Also change one of the callers to not error when a trait is applied to
a dependent type. This is a perfectly reasonable pattern, and both Unary
and Binary type traits already support dependent types (by populating
the AST with a nonce value).

Remove the actual diagnostic, since these aren't errors.

llvm-svn: 130651
2011-05-01 08:41:10 +00:00
Argyrios Kyrtzidis d8970dde43 Improve traversing of BlockExprs in RecursiveASTVisitor.
llvm-svn: 130650
2011-05-01 08:06:46 +00:00
Chandler Carruth 9cf632cc35 Simplify the flow of some of the array type trait code.
Completely remove a switch which selected between the same two types.

llvm-svn: 130649
2011-05-01 07:49:26 +00:00
Chandler Carruth 20b9bc8638 Convert the expression trait evaluation to a static function and
a switch with any default case. This both warns when an enumerator is
missing and asserts if a value sneaks through despite the warning.

While in there fix a bunch of coding style issues with this code.

llvm-svn: 130648
2011-05-01 07:44:20 +00:00
Chandler Carruth b42fb19e9b Remove the default case from the unary type trait evaluation function,
adding an unreachable annotation. Remarkably this one was already
enumarting every trait.

llvm-svn: 130647
2011-05-01 07:44:17 +00:00
Chandler Carruth e46eaf3460 Remove a few more bogus returns when the switch covers all the
enumerators.

Also remove a default that led to llvm_unreachable to make another
switch warn if any enumerators fail to be covered.

llvm-svn: 130646
2011-05-01 07:23:23 +00:00
Chandler Carruth 8e2d6f4b31 Remove another default and a *completely* bogus return from a switch
over type traits.

Add the missing trait from this switch that Clang's warning uncovered.

llvm-svn: 130645
2011-05-01 07:23:20 +00:00
Chandler Carruth 8b0cf1d4d3 Mark that this function ends in a covering switch statement with every
case returning a value.

Silences a GCC warning.

llvm-svn: 130644
2011-05-01 07:23:17 +00:00
Chandler Carruth f2f5652d3d Remove the type traits UTT_IsLvalueExpr and UTT_IsRvalueExpr.
As might be surmised from their names, these aren't type traits, they're
expression traits. Amazingly enough, they're expression traits that we
have, and fully implement. These "type" traits are even parsed from the
same tokens as the expression traits. Luckily, the parser only tried the
expression trait parsing for these tokens, so this was all just a pile
of dead code.

llvm-svn: 130643
2011-05-01 07:23:14 +00:00
Alexis Hunt 61bc173784 Fully implement delegating constructors!
As far as I know, this implementation is complete but might be missing a
few optimizations. Exceptions and virtual bases are handled correctly.

Because I'm an optimist, the web page has appropriately been updated. If
I'm wrong, feel free to downgrade its support categories.

llvm-svn: 130642
2011-05-01 07:04:31 +00:00
Chandler Carruth 8e172c6054 More cleanup of the type traits implementation.
1) Moved the completeness checking routine above the evaluation routine
   so the reader sees that we do in fact check for complete types when
   necessary.
2) Remove the FIXME comment about not doing this.
3) Make the arguments to the evaluate function agree in order with those
   to the completeness checking function.
4) Completely specify the enumerators for the completeness checking
   function rather than relying on a default.
5) Remove a check for the Borland language to only require complete
   types in a few places. Borland's own documentation doesn't agree with
   this: some of the previously unspecified traits *do* require
   a complete type, some don't.
6) Correctly split the traits which do not require complete types from
   those that do, clarifying comments and citations to the standard or
   other documentation where relevant.

llvm-svn: 130641
2011-05-01 06:51:22 +00:00
Chandler Carruth d2479eaaed Order the type traits according to the standard's listing of unary type
traits where possible. For the rest, group them and add some
documentation regarding their origins.

No functionality change intended.

llvm-svn: 130639
2011-05-01 06:11:07 +00:00
Chandler Carruth 100f3a97f4 Begin cleaning up type trait expression implementations and settling on
a single pattern for implementing each.

llvm-svn: 130638
2011-05-01 06:11:03 +00:00
Francois Pichet af538d9ee6 Add a triple to this test, otherwise it fails under MSVC because wchar_t is unsigned with the i686-pc-win32 triple.
llvm-svn: 130636
2011-05-01 04:32:34 +00:00
John McCall ca87290f36 Improve the documentation for the two ObjCDeclQualifiers so that I
stop considering whether I can compress them. :)

llvm-svn: 130633
2011-05-01 03:04:29 +00:00
John McCall beaa11cac6 Compress some bits. Only matters for MSVC, or if we ever
devirtualize Decl (because bits can't get laid out in base
classes if the base is POD).

llvm-svn: 130632
2011-05-01 02:13:58 +00:00
Chandler Carruth dde65ea89a Switch the interface name for both TemplateTypeParmType and
SubstTemplateTypeParmType to be 'getIdentifier' instead of 'getName' as
it returns an identifier. This makes them more consistent with the
NamedDecl interface.

Also, switch back to using this interface to acquire the indentifier in
TypePrinter.cpp. I missed this in r130628.

llvm-svn: 130629
2011-05-01 01:05:51 +00:00
Chandler Carruth 0883632acb Re-applies the patch first applied way back in r106099, with
accompanying fixes to make it work today.

The core of this patch is to provide a link from a TemplateTypeParmType
back to the TemplateTypeParmDecl node which declared it. This in turn
provides much more precise information about the type, where it came
from, and how it functions for AST consumers.

To make the patch work almost a year after its first attempt, it needed
serialization support, and it now retains the old getName() interface.
Finally, it requires us to not attempt to instantiate the type in an
unsupported friend decl -- specifically those coming from template
friend decls but which refer to a specific type through a dependent
name.

A cleaner representation of the last item would be to build
FriendTemplateDecl nodes for these, storing their template parameters
etc, and to perform proper instantation of them like any other template
declaration. They can still be flagged as unsupported for the purpose of
access checking, etc.

This passed an asserts-enabled bootstrap for me, and the reduced test
case mentioned in the original review thread no longer causes issues,
likely fixed at somewhere amidst the 24k revisions that have elapsed.

llvm-svn: 130628
2011-05-01 00:51:33 +00:00
Rafael Espindola 37981e6099 Revert the previous patch while I figure out how to make llvm-gcc
less agressive about disabling cfi on linux :-(

llvm-svn: 130627
2011-04-30 23:07:10 +00:00
Rafael Espindola 1f6936b6c7 Update for cfi.
llvm-svn: 130624
2011-04-30 22:30:24 +00:00
Benjamin Kramer ed5ca78dc5 Remove unused function.
llvm-svn: 130622
2011-04-30 19:55:59 +00:00
Benjamin Kramer e63dbc373a Remove noisy semicolons.
llvm-svn: 130621
2011-04-30 19:55:55 +00:00
Eli Friedman 786d087ebd PR9792: Make sure to use the right definition of wchar_t when the default
wchar_t is an unsigned type.

llvm-svn: 130620
2011-04-30 19:24:24 +00:00
Eli Friedman fe0739dffb Some small improvements to the builtin (-ffreestanding) stdint.h; in
particular, make sure to handle WCHAR_MIN correctly.

llvm-svn: 130618
2011-04-30 19:02:59 +00:00
Rafael Espindola 6a10ed51c0 Pass -fno-dwarf2-cfi-asm and use FileCheck.
llvm-svn: 130617
2011-04-30 18:47:32 +00:00
Rafael Espindola e264187cf2 Implement -fno-dwarf2-cfi-asm.
llvm-svn: 130616
2011-04-30 18:35:43 +00:00
Douglas Gregor 85894a8f85 When comparing parameters of reference-to-qualified type during
partial ordering of function templates, use a simple superset
relationship rather than the convertibility-implying
isMoreQualifiedThan/compatibilyIncludes relationship. Fixes partial
ordering between references and address-space-qualified references.

llvm-svn: 130612
2011-04-30 17:07:52 +00:00
Ken Dyck d9c83e6cdf Replace a literal 8 with Context->getCharWidth() in
SynthesizeByrefCopyDestroyHelper(). No change in functionality intended.

llvm-svn: 130608
2011-04-30 16:08:27 +00:00
Chandler Carruth 61f4cbf38a Make type-traits reflect that Clang's vectors act like scalar types.
llvm-svn: 130606
2011-04-30 10:46:26 +00:00
Chandler Carruth 7623757cd0 Switch the type-trait like APIs on the AST to only check for incomplete
types after looking through arrays. Arrays with an unknown bound seem to
be specifically allowed in the library type traits in C++0x, and GCC's
builtin __is_trivial returns 'true' for the type 'int[]'. Now Clang
agrees with GCC about __is_trivial here.

Also hardens these methods against dependent types by just returning false.

llvm-svn: 130605
2011-04-30 10:31:50 +00:00
Chandler Carruth b077620c02 Extract a function to impose the completeness requirement on unary type
trait arguments. Reflow the logic to use early exit instead of a complex
condition expression. Switch to a switch for acting on different type
traits and add a bunch of the recently implemented type traits here.
This fixes one of the regressions with the new __is_standard_layout
trait to again require a complete type. It also fixes some latent bugs
in other traits that never did impose this despite the standard
requiring it. However, all these bugs were hidden for non-borland
systems where the default is to require a complete type.

It's unclear to me what the best approach here is: providing an explicit
lists for the ones requiring complete types only w/ Borland and using
a default for the rest, or forcing this switch to enumerate the traits
and make it clear which way each one goes.

I'm still working on cleaning up the tests so that they actually catch
this, a much more comprehensive update to the tests will come once I've
worked through the bugs I'm finding via inspection.

llvm-svn: 130604
2011-04-30 10:07:32 +00:00
Chandler Carruth 583edf8843 Rename the last '[hH]asStandardLayout' entites to '[iI]sStandardLayout'
based on Doug's preferences when we discussed this in IRC. This brings
the wording more in line with the standard.

llvm-svn: 130603
2011-04-30 10:07:30 +00:00
Chandler Carruth c1ce4f58e6 Hoist all of the type-specific trait logic for __is_standard_layout into
a Type method isStandardLayoutType, to keep our user API matching the
type trait builtins as closely as possible. Also, implement it in terms
of other Type APIs rather than in terms of other type traits. This
models the implementation on that of isLiteralType and isTrivialType.
There remain some common problems with these traits still, so this is
a bit of a WIP. However, we can now fix all of these traits at the same
time and in a consistent manner.

llvm-svn: 130602
2011-04-30 09:17:49 +00:00
Chandler Carruth b196374f53 Completely re-implement the core logic behind the __is_standard_layout
type trait. The previous implementation suffered from several problems:

1) It implemented all of the logic in RecordType by walking over every
   base and field in a CXXRecordDecl and validating the constraints of
   the standard. This made for very straightforward code, but is
   extremely inefficient. It also is conceptually wrong, the logic tied
   to the C++ definition of standard-layout classes should be in
   CXXRecordDecl, not RecordType.
2) To address the performance problems with #1, a cache bit was added to
   CXXRecordDecl, and at the completion of every C++ class, the
   RecordType was queried to determine if it was a standard layout
   class, and that state was cached. Two things went very very wrong
   with this. First, the caching version of the query *was never
   called*. Even within the recursive steps of the walk over all fields
   and bases the caching variant was not called, making each query
   a full *recursive* walk. Second, despite the cache not being used, it
   was computed for every class declared, even when the trait was never
   used in the program. This probably significantly regressed compile
   time performance for edge-case files.
3) An ASTContext was required merely to query the type trait because
   querying it performed the actual computations.
4) The caching bit wasn't managed correctly (uninitialized).

The new implementation follows the system for all the other traits on
C++ classes by encoding all the state needed in the definition data and
building up the trait incrementally as each base and member are added to
the definition of the class.

The idiosyncracies of the specification of standard-layout classes
requires more state than I would like; currently 5 bits. I could
eliminate one of the bits easily at the expense of both clarity and
resilience of the code. I might be able to eliminate one of the other
bits by computing its state in terms of other state bits in the
definition. I've already done that in one place where there was a fairly
simple way to achieve it.

It's possible some of the bits could be moved out of the definition data
and into some other structure which isn't serialized if the serialized
bloat is a problem. That would preclude serialization of a partial class
declaration, but that's likely already precluded.

Comments on any of these issues welcome.

llvm-svn: 130601
2011-04-30 09:17:45 +00:00
Benjamin Kramer 08635fcc83 Initialize HasStandardLayout.
llvm-svn: 130600
2011-04-30 08:55:35 +00:00
Ted Kremenek 8067746554 Move the SelfInit checker to the 'cocoa.experimental' package.
llvm-svn: 130598
2011-04-30 06:46:45 +00:00
Daniel Dunbar 2f31fb99ef Driver/Darwin: Don't link -lgcc_s.1 when compiling as iOS for the simulator,
that library has never been in the SDK. Fortunately, it shouldn't be necessary,
since that library was also removed in 10.6.

llvm-svn: 130595
2011-04-30 04:25:16 +00:00
Daniel Dunbar 72ceb92aa3 Driver/Darwin: When using -mios-simulator-version-min, explicitly pass this on
to the linker.
 - Only do this explicitly with the argument for now, the linker will need to
   explicitly add support for this.

llvm-svn: 130594
2011-04-30 04:22:58 +00:00
Daniel Dunbar a9cbb6b9d5 Driver/Darwin: Reject invalid arch combinations with
-mios-simulator-version-min.

llvm-svn: 130593
2011-04-30 04:20:40 +00:00
Daniel Dunbar b1189434dd Driver/Darwin: Change Darwin toolchain to explicitly track is-ios-sim bit, and
update -mios-simulator-version-min to set it.

llvm-svn: 130592
2011-04-30 04:18:16 +00:00
Daniel Dunbar 9aaeb6400b Driver/Darwin: Sketch initial support for a -mios-simulator-version-min= flag
and associated deployment target environment variable.

llvm-svn: 130591
2011-04-30 04:15:58 +00:00
Rafael Espindola 26cdfa71ef Update API.
llvm-svn: 130588
2011-04-30 03:46:18 +00:00
Nico Weber 1f41ab05f5 Fix gcc 'warning: multi-line comment'.
llvm-svn: 130583
2011-04-30 03:13:21 +00:00
Nico Weber e8fdcac02c Add lib/Tooling to the Makefile build.
llvm-svn: 130581
2011-04-30 03:09:18 +00:00
Nico Weber 1bb8e09c37 Add a Makefile to examples/Tooling for people who do not use cmake.
llvm-svn: 130577
2011-04-30 03:03:12 +00:00
Nico Weber 347339f790 Fix Makefile build of examples/clang-interpreter.
llvm-svn: 130576
2011-04-30 02:52:27 +00:00
Argyrios Kyrtzidis c8c7945a40 Add a couple of assertions to make sure the bitfields can fit the value assigned to them. No functionality change.
llvm-svn: 130573
2011-04-30 02:28:27 +00:00
Chad Rosier b9a8525bab Documentation for -Oz; Updated synopsis and item.
llvm-svn: 130570
2011-04-30 02:04:10 +00:00
Chad Rosier bc8d7c27d9 Add documentation for -Oz flag.
llvm-svn: 130569
2011-04-30 01:40:58 +00:00
Chad Rosier 3909e037ab Removed redundant case statements
llvm-svn: 130564
2011-04-30 00:03:48 +00:00
Devang Patel a3e3fded0a Tie constructor defintion with its declaration using AT_specification.
llvm-svn: 130561
2011-04-29 23:42:32 +00:00
Ted Kremenek e8e565ab81 Adjust test/Analysis/retain-release.m to also test the retain/release checker in Objective-C++ mode.
llvm-svn: 130559
2011-04-29 23:15:53 +00:00
Bob Wilson 9a5f84facb Add -Oz option and use it to set the inline threshold to 25.
Radar 9333566.  Patch by Chad Rosier!

llvm-svn: 130554
2011-04-29 22:49:50 +00:00
Fariborz Jahanian 52a8cca56f removes a meaningless comment.
llvm-svn: 130550
2011-04-29 22:11:28 +00:00
Fariborz Jahanian 99514b9168 block variables on lhs need be ir-gen'ed after the
rhs when its 'forwarding' pointer may be modified 
in rhs evaluation as result of call to Block_copy.
// rdar://9309454

llvm-svn: 130545
2011-04-29 21:53:21 +00:00
Ted Kremenek 491da68ef9 Guard in USRGenerator::GenLoc() against null Decl* from invalid code.
llvm-svn: 130541
2011-04-29 21:35:23 +00:00
Chandler Carruth f9e7410468 Disable -Wnon-pod-memset for now while I try to reduce the false
positives still further.

The plan is to:

1) Create a more targeted warning for memset of memory pointing at
   a type with virtual methods or bases where a vptr would be
   overwritten.
2) Consider turning the above warning back on by default.
3) Evaluate whether any false positives in the existing warning can be
   detected and white listed in the warning implementation.
4) If #3 lowers the noise floor enough, enable the full warning in -Wall
   or -Wextra.

Comments or suggestions welcome. Even more welcome are specific test
cases which trigger the warning and shouldn't.

llvm-svn: 130538
2011-04-29 20:58:14 +00:00
Ted Kremenek 2b2e06d1a3 Change -Wparentheses to not imply -Widiomatic-parentheses. Users rarely want to see these warnings, and often explicitly pass -Wparentheses.
llvm-svn: 130535
2011-04-29 20:30:39 +00:00
Anders Carlsson 73ad5bc9ea Serialize/deserialize the HasStandardLayout bit when writing/reading PCHs.
llvm-svn: 130525
2011-04-29 18:37:25 +00:00
Daniel Dunbar 252e8f9ac1 Driver/cc1as: Forward -mllvm arguments when compiling assembly files.
llvm-svn: 130516
2011-04-29 17:53:18 +00:00
Charles Davis 6c488f14f6 Remove comments about __int8 and friends from the mangler. Turns out we don't
actually have to implement them, since in modern versions of MSVC they're
aliases to the standard C types.

llvm-svn: 130509
2011-04-29 15:50:52 +00:00
Douglas Gregor f1fce5d3ef White-list yet more type trait names, since they're used as
identifiers in libc++.

llvm-svn: 130508
2011-04-29 15:31:39 +00:00
David Chisnall 10d2ded910 Don't crash if the AST doesn't have a sensible ObjC id type.
llvm-svn: 130500
2011-04-29 14:10:35 +00:00
Chandler Carruth c37485e6cb Relax the non-POD memset warning to use the less restrictive C++11
definition of POD. Specifically, this allows certain non-aggregate
types due to their data members being private.

The representation of C++11 POD testing is pretty gross. Any suggestions
for improvements there are welcome. Especially the name
'isCXX11PODType()' seems truly unfortunate.

llvm-svn: 130492
2011-04-29 09:46:08 +00:00
Francois Pichet c867975776 r130381 follow up: accept __uuidof expression for template argument reference.
llvm-svn: 130491
2011-04-29 09:08:14 +00:00
Sebastian Redl 2ac2c725e0 Add a decl update when a static data member of a class template is instantiated in a different PCH than its containing class. Otherwise we get double definition errors. Fixes a Boost.MPL problem that affects Boost.Accumulators and probably a lot more of Boost.
llvm-svn: 130488
2011-04-29 08:19:30 +00:00
Sebastian Redl b00047a475 Use std::vector for ASTReader's ASTBuffers, instead of std::deque.
llvm-svn: 130487
2011-04-29 08:19:19 +00:00
Sebastian Redl bc9a20949f Use -emit-llvm-only as suggested by Argyrios.
llvm-svn: 130486
2011-04-29 08:19:03 +00:00
Chandler Carruth efd5671a27 Don't assume that the AST methods will only be invoked on C++ types.
Teaches isLiteralType and isTrivialType to behave plausibly and most
importantly not crash on normal RecordDecls.

Sadly I have no real way to test this. I stumbled onto it by
mis-implementing a warning.

llvm-svn: 130483
2011-04-29 07:47:42 +00:00
Douglas Gregor f8e894a103 Oops
llvm-svn: 130469
2011-04-29 01:50:40 +00:00
Douglas Gregor 63180b1190 libstdc++ 4.2 also uses __is_same as a struct name, which conflicts with our new type trait __is_same
llvm-svn: 130468
2011-04-29 01:38:03 +00:00
Douglas Gregor 68dac4676d Use DirectoryLookup::getName() rather than getDir()->getName() in a context where we don't know whether we have a normal directory
llvm-svn: 130467
2011-04-29 00:45:09 +00:00
Ted Kremenek 5e1ed7b8dd Enhance clang_getCXTUResourceUsage() to report the sizes of the memory buffers used by PCH.
llvm-svn: 130460
2011-04-28 23:46:20 +00:00
Fariborz Jahanian 6d003c3041 Fixes debug info generation problem for ms_struct structs.
// rdar://8823265

llvm-svn: 130458
2011-04-28 23:43:23 +00:00
Argyrios Kyrtzidis 03535265ef Cut down unnecessary zero'ing when value-initializing arrays of C++ objects.
-C++ objects with user-declared constructor don't need zero'ing.
-We can zero-initialize arrays of C++ objects in "bulk" now, in which case don't zero-initialize each object again.

llvm-svn: 130453
2011-04-28 22:57:55 +00:00
Fariborz Jahanian 8409bce4ac ms_struct patch for initialization and field access irgen.
// rdar://8823265 - wip.

llvm-svn: 130451
2011-04-28 22:49:46 +00:00
Stuart Hastings 9f02fd9d8d Raise ARM byval minimum size from 32 to 64, addressing a performance
regression in mason.  rdar://problem/7662569

llvm-svn: 130444
2011-04-28 21:35:59 +00:00
Daniel Dunbar c44d313cff Driver/Darwin/ld: Set the deployment target following the version information in
the tool chain, instead of based on the translated arguments.

llvm-svn: 130440
2011-04-28 21:23:41 +00:00
Daniel Dunbar c76da44eeb tests: Tweak test to not write to the same temporary twice, in the hopes of avoiding sporadic win32 failures about renaming a temporary.
llvm-svn: 130439
2011-04-28 21:23:38 +00:00
Ted Kremenek 8d58790019 Enhance clang_getCXTUResourceUsage() to report how much memory is used by SourceManager's memory buffers.
llvm-svn: 130433
2011-04-28 20:36:42 +00:00
Argyrios Kyrtzidis 9d3c504078 Get the base element type even in multidimensional arrays.
llvm-svn: 130427
2011-04-28 20:07:15 +00:00
Lenny Maiorani 18470e3287 Use StringRef::substr() and unbounded StringRef::compare() instead of bounded version of StringRef::compare() because bounded version of StringRef::compare() is going to be removed.
llvm-svn: 130425
2011-04-28 19:31:12 +00:00
Ted Kremenek 414a2c0951 Make the top-level driver ignore -fobjc-default-synthesize-properties while this feature undergoes more review and development. This is still available as a -cc1 option for testing.
llvm-svn: 130424
2011-04-28 19:26:03 +00:00
Stuart Hastings dd77c8efa2 Replace unitary array with scalar. rdar://problem/7662569
llvm-svn: 130423
2011-04-28 19:24:47 +00:00
Lenny Maiorani ed2cc6ccbb Eliminates an assert in the strncpy/strncat checker caused by not validating a cast was successful. If the value of an argument was unknown, the cast would result in a NULL pointer which was later being dereferenced.
This fixes Bugzilla #9806.

llvm-svn: 130422
2011-04-28 18:59:43 +00:00
Argyrios Kyrtzidis e07425a5e7 When value-initializing the elements of an array not not included in the initializer make sure
that a non-trivial C++ constructor gets called.

Fixes rdar://9347552 & http://llvm.org/PR9801

llvm-svn: 130421
2011-04-28 18:53:58 +00:00
Argyrios Kyrtzidis fddbcfbec4 Don't waste memory if the initializer expression is empty.
llvm-svn: 130420
2011-04-28 18:53:55 +00:00
Stuart Hastings 4b21495e42 Replace SmallVector with an array, as suggested by Frits van Bommel. rdar://problem/7662569
llvm-svn: 130417
2011-04-28 18:16:06 +00:00
Douglas Gregor d517d55484 When determining whether two types are reference-compatible, check
non-CVR qualifiers as well as CVR qualifiers. For example, don't allow
a reference to an integer in address space 1 to bind to an integer in
address space 2.

llvm-svn: 130411
2011-04-28 17:56:11 +00:00
Manuel Klimek 7030b869a0 Fixes ArrayTypeTraitExpr (-Wnon-virtual-dtor).
llvm-svn: 130407
2011-04-28 17:03:03 +00:00
Douglas Gregor b6100f2bdc Only call the MacroExpands callback when we're actually going to
expand the macro, based on a patch by Ori Avtalion. Fixes PR9799.

llvm-svn: 130402
2011-04-28 16:36:13 +00:00
Douglas Gregor 068730992c libstdc++ 4.4 uses __is_signed as an identifier, while Clang treats it
as a keyword for the __is_signed type trait. Cope with this conflict
via some hackish recovery: if we see a declaration of the form

 static const bool __is_signed

then we stop treating __is_signed as a keyword and instead treat it as
an identifier. It's ugly, but it's better than making the __is_signed
type trait conditional on some language flag. Fixes PR9804.

llvm-svn: 130399
2011-04-28 15:48:45 +00:00
Lenny Maiorani 4af23c8159 Implements strcasecmp() checker in Static Analyzer.
llvm-svn: 130398
2011-04-28 15:09:11 +00:00
Chandler Carruth 6e1f9babcd Silence more -Wnon-pod-memset given its current implementation. I may be
able to revert these based on a patch I'm working on, but no reason for
people to be spammed with warnings in the interim.

llvm-svn: 130394
2011-04-28 08:19:45 +00:00
Ted Kremenek 4c62882604 Add comment to CFGBlock suggested by Jiri Slaby.
llvm-svn: 130387
2011-04-28 06:19:35 +00:00
Francois Pichet fc15ae466c Update r130381 to check for UO_AddrOf.
llvm-svn: 130384
2011-04-28 05:12:34 +00:00
Ted Kremenek f5df0ce949 Enhance clang_getCXTUResourceUsage() to report the amount of memory used by ASTContext's side tables.
llvm-svn: 130383
2011-04-28 04:53:38 +00:00
Francois Pichet a1c1352a36 Support &__uuidof(type) as a non type template argument.
This idiom is used everywhere in MFC/COM code and as such this patch removes hundreds of errors when parsing MFC code with clang.

Example: 
template <class T, const GUID* g = &__uuidof(T)>
class ComTemplate  { };

typedef ComTemplate<struct_with_uuid, &__uuidof(struct_with_uuid)> COM_TYPE;

Of course this is just parsing support. Trying to use this in CodeGen will generate:
error: cannot yet mangle expression type CXXUuidofExpr

llvm-svn: 130381
2011-04-28 04:39:50 +00:00
Ted Kremenek 21735e608d Enhance clang_getCXTUResourceUsage() to report the amount of memory used by SourceManager's content cache allocator.
llvm-svn: 130380
2011-04-28 04:10:31 +00:00
Francois Pichet bfaf477a99 SEH was crashing under -fms-extensions.
llvm-svn: 130377
2011-04-28 03:14:31 +00:00
John McCall 7f0a0d55c0 Implement the mangling for non-ADL call expressions that we just
worked out.

llvm-svn: 130376
2011-04-28 02:52:03 +00:00
John McCall a85af56e66 When block-capturing a variable with a non-trivial destructor,
make sure to mark the destructor.  This normally isn't required,
because the destructor should have been marked as part of the
declaration of the local, but it's necessary when the variable
is a parameter because it's the call sites that are responsible
for those destructors.

llvm-svn: 130372
2011-04-28 02:15:35 +00:00
John Wiegley d352222839 A few corrections to type traits that missed the last checkin
llvm-svn: 130371
2011-04-28 02:06:46 +00:00
Francois Pichet 4c3b68c366 Because of r130359 this test no longer fail on Windows.
llvm-svn: 130370
2011-04-28 02:01:57 +00:00
Francois Pichet 84133e41be Upgrade Microsoft's __int8, __int16, __int32 and __int64 types from builtin defines to real types.
Otherwise statements like:
  __int64 var = __int64(0);

would be expanded to:
  long long var = long long(0);

and fail to compile.

llvm-svn: 130369
2011-04-28 01:59:37 +00:00
Ted Kremenek b5fabb2f9f Convert assertion in memset checking to a runtime check (because real code may provide a deviant definition of memset).
llvm-svn: 130368
2011-04-28 01:38:02 +00:00
John Wiegley d25f8eb393 Removed test that depended on ast-test
llvm-svn: 130367
2011-04-28 01:09:13 +00:00
John Wiegley 1c0675e155 Parsing/AST support for Structured Exception Handling
Patch authored by Sohail Somani.

Provide parsing and AST support for Windows structured exception handling.

llvm-svn: 130366
2011-04-28 01:08:34 +00:00
Douglas Gregor 1d684c253f More cleanup of template argument deduction and its handling of
non-CVR qualifiers. We can now properly match address-space--qualified
references during template argument deduction.

llvm-svn: 130365
2011-04-28 00:56:09 +00:00
Matt Beaumont-Gay 7e92e57b0b Fix modified-header-crash.c for read-only source trees
llvm-svn: 130359
2011-04-28 00:23:49 +00:00
John Wiegley 6242b6a688 Implementation of Embarcadero array type traits
Patch authored by John Wiegley.

These are array type traits used for parsing code that employs certain
features of the Embarcadero C++ compiler: __array_rank(T) and
__array_extent(T, Dim).

llvm-svn: 130351
2011-04-28 00:16:57 +00:00
Ted Kremenek 04f93b9cf1 Update regex in scan-build for parsing statistics.
llvm-svn: 130347
2011-04-27 23:43:27 +00:00
Douglas Gregor 1784688de7 Clean up the handling of non-CVR qualifiers in template argument
deduction. The good news is that address spaces are a lot less broken
in this regard than I'd expected.

llvm-svn: 130346
2011-04-27 23:34:22 +00:00
John Wiegley 65497cce20 t/clang/type-traits
Patch authored by John Wiegley.

These type traits are used for parsing code that employs certain features of
the Embarcadero C++ compiler.  Several of these constructs are also desired by
libc++, according to its project pages (such as __is_standard_layout).

llvm-svn: 130342
2011-04-27 23:09:49 +00:00
Ted Kremenek f8ac5288a3 Remove unused method CFGBlock::hasBinaryBranchTerminator().
llvm-svn: 130336
2011-04-27 22:16:58 +00:00
Eli Friedman 7ec652a7a2 Don't print fixits for format specifiers in cases where the fixit does not actually fix the warning. PR8781.
I'm not sure what the preferred way to write a test for whether a fixit is emitted.

llvm-svn: 130335
2011-04-27 22:06:20 +00:00
Ted Kremenek f26109664e Update scan-build to '-analyzer-checker debug.Stats' instead of the old '-analyzer-stats' -cc1 argument.
llvm-svn: 130320
2011-04-27 18:53:08 +00:00
Chandler Carruth ede9d33cde Heh, funny thing, 'void' isn't a POD type. Nice of us to suggest it to
silence this warning. ;]

Fixed that obvious bug and added a bit more testing as well.

llvm-svn: 130318
2011-04-27 18:48:59 +00:00
Stuart Hastings f2752a3938 Re-enable byval for ARM in clang. rdar://problem/7662569
llvm-svn: 130312
2011-04-27 17:24:02 +00:00
Fariborz Jahanian 595ec5d43c Some refactoring of my ms_struct patch.
// rdar://8823265 related.

llvm-svn: 130311
2011-04-27 17:14:21 +00:00
Douglas Gregor 5fc8c9eafb When printing a base-specifier, print the ellipsis ("...") if it is a
pack expansion. Fixes PR9452.

llvm-svn: 130310
2011-04-27 17:07:55 +00:00
Douglas Gregor 90ebf258c6 ASTImporter support for NestedNameSpecifier, from Olaf Krzikalla
llvm-svn: 130307
2011-04-27 16:48:40 +00:00
Manuel Klimek 6825eebcd6 This is the next step in building the standalone tools infrastructure:
This patch simplifies writing of standalone Clang tools. As an
example, we add clang-check, a tool that runs a syntax only frontend
action over a .cc file. When you integrate this into your favorite
editor, you get much faster feedback on your compilation errors, thus
reducing your feedback cycle especially when writing new code.

The tool depends on integration of an outstanding patch to CMake to
work which allows you to always have a current compile command
database in your cmake output directory when you set
CMAKE_EXPORT_COMPILE_COMMANDS.

llvm-svn: 130306
2011-04-27 16:39:14 +00:00
Lenny Maiorani 005b5c1aee More accurately model realloc() when the size argument is 0. realloc() with a size of 0 is equivalent to free(). The memory region should be marked as free and not used again.
Unit tests f2_realloc_0(), f6_realloc(), and f7_realloc() contributed by Marshall Clow <mclow.lists@gmail.com>. Thanks! 

llvm-svn: 130303
2011-04-27 14:49:29 +00:00
Chandler Carruth 53caa4d4fa Add a warning (-Wnon-pod-memset) for calls to memset() with
a destination pointer that points to a non-POD type. This can flag such
horrible bugs as overwriting vptrs when a previously POD structure is
suddenly given a virtual method, or creating objects that crash on
practically any use by zero-ing out a member when its changed from
a const char* to a std::string, etc.

llvm-svn: 130299
2011-04-27 07:05:31 +00:00
John McCall 5476666d17 Diagnose attempts to implicitly instantiate a template before it is
fully defined.  Somehow this escaped notice for a very long time.

llvm-svn: 130298
2011-04-27 06:46:31 +00:00
Douglas Gregor da6c89de48 Introduce a new parser annotation token for primary expressions. When
ClassifyName() builds a primary expression, generate one of these
annotation tokens rather than jumping into the parser.

llvm-svn: 130297
2011-04-27 06:18:01 +00:00
Eric Christopher 956d96ce34 Remove this assert, I don't think it's being helpful and people have
been running into it.

llvm-svn: 130296
2011-04-27 05:48:06 +00:00
Douglas Gregor 9b2d706e05 Clean out some cruft I introduced when adding Sema::ClassifyName()
llvm-svn: 130295
2011-04-27 05:44:51 +00:00
Douglas Gregor 19b7acff10 Simplify the parser's handling of Sema::ClassifyName() for types, by
creating a type-annotation token rather than jumping into the
declaration parsing.

llvm-svn: 130293
2011-04-27 05:41:15 +00:00
Ted Kremenek 08b434f450 Allow 'Environment::getSVal()' to allow an optional way for checkers to do a direct lookup to values bound to expressions, without
resulting to lazy logic.  This is critical for the OSAtomicChecker that does a simulated load on any arbitrary expression.

llvm-svn: 130292
2011-04-27 05:34:09 +00:00
Chandler Carruth 938e4a89dd Add the test that I intended to submit with r130055, but forgot to add.
Apologies.

llvm-svn: 130291
2011-04-27 05:25:42 +00:00
Francois Pichet 33477fdfd5 Add support for Microsoft __interface keyword. An __interface class is basically a normal class containing just pure virtual functions. No urgency to enforce that restriction in clang for now, so make __interface an "class" alias.
llvm-svn: 130290
2011-04-27 05:07:51 +00:00
Argyrios Kyrtzidis f7620e4d49 If a null statement was preceded by an empty macro keep its instantiation source location
in NullStmt.

llvm-svn: 130289
2011-04-27 05:04:02 +00:00
Douglas Gregor 8b02cd0bea Extend Sema::ClassifyName() to support C++, ironing out a few issues
in the classification of template names and using declarations. We now
properly typo-correct the leading identifiers in statements to types,
templates, values, etc. As an added bonus, this reduces the number of
lookups required for disambiguation.

llvm-svn: 130288
2011-04-27 04:48:22 +00:00
Anders Carlsson c5d3ba1aad When compiling with -fno-threadsafe-statics, guard variables for globals with internal linkage don't have to be i64, i8 works just fine!
llvm-svn: 130286
2011-04-27 04:37:08 +00:00
Douglas Gregor ae79fdf170 Fix test
llvm-svn: 130285
2011-04-27 04:02:56 +00:00
Douglas Gregor 5e16c168fd Improve diagnostics for typo correction via Sema::ClassifyName(), by
looking at the context and the correction and using a custom
diagnostic. Also, enable some Fix-It tests that were somewhat lamely
disabled.

llvm-svn: 130283
2011-04-27 03:47:06 +00:00
Douglas Gregor 713dab5695 Add triple in the hope of unbreaking the bubuildbot
llvm-svn: 130280
2011-04-27 03:24:57 +00:00
John McCall 4adb38cdf4 FixOverloadedFunctionReference needs to rebuild member accesses of
instance methods to have bound-member type.

Fixing that broke __unknown_anytype, which I've in turn fixed.

llvm-svn: 130266
2011-04-27 00:36:17 +00:00
Douglas Gregor 30ee16f5dd When comparing Objective-C pointers during overload resolution to
determine which is a better conversion to "void*", be sure to perform
the comparison using the safe-for-id
ASTContext::canAssignObjCInterfaces() rather than the asserts-with-id
ASTContext::canAssignObjCInterfaces().

Fixes <rdar://problem/9327203>.

llvm-svn: 130259
2011-04-27 00:01:52 +00:00
Fariborz Jahanian bcb23a180b With ms_struct attribut, Zero-length bitfields following
non-bitfield members are ignore. // rdar://8823265 wip

llvm-svn: 130257
2011-04-26 23:52:16 +00:00
Douglas Gregor aec2584760 When computing Objective-C pointer conversions in C++, retain
the qualifiers (e.g., GC qualifiers) on the type we're converting
from, rather than just blindly adopting the qualifiers of the type
we're converting to or dropping qualifiers altogether. 

As an added bonus, properly diagnose GC qualifier mismatches to
eliminate a crash in the overload resolution failure diagnostics.

llvm-svn: 130255
2011-04-26 23:16:46 +00:00
Manuel Klimek 0c69fd2760 To be able to replay compilations we need to accurately remodel how
includes get resolved, especially when they are found relatively to
another include file. We also try to get it working for framework
includes, but that part of the code is untested, as I don't have a code
base that uses it.

llvm-svn: 130246
2011-04-26 21:50:03 +00:00
Devang Patel e67eca43d6 We need pointer size in bits here.
llvm-svn: 130244
2011-04-26 21:16:49 +00:00
Argyrios Kyrtzidis ae40e4e10e Gcc pads the size of an array using the alignment of its elements.
The size of the array may not be aligned according to alignment of its elements if an alignment attribute is
specified in a typedef. Fixes rdar://8665729 & http://llvm.org/PR5637.

llvm-svn: 130242
2011-04-26 21:05:39 +00:00
John McCall 0009fcc39e Make yet another placeholder type, this one marking that an expression is a bound
member function, i.e. something of the form 'x.f' where 'f' is a non-static
member function.  Diagnose this in the general case.  Some of the new diagnostics
are probably worse than the old ones, but we now get this right much more
universally, and there's certainly room for improvement in the diagnostics.

llvm-svn: 130239
2011-04-26 20:42:42 +00:00
Daniel Dunbar a59b0a6e3c IRgen/Darwin: Fix refacto introduced in Triple changes.
llvm-svn: 130233
2011-04-26 19:43:00 +00:00
Fariborz Jahanian 6b4e26bee2 Add ms_struct attribute on record typee
(and ignore it for now) - wip.

llvm-svn: 130224
2011-04-26 17:54:40 +00:00
Argyrios Kyrtzidis a9b630e4d7 Emit a -Wnull-dereference warning for "*null" not just "*null = something". Addresses rdar://9269271.
llvm-svn: 130207
2011-04-26 17:41:22 +00:00
Argyrios Kyrtzidis 21362becdc Disable a test that fails on windows; for some reason we don't detect that the header has different timestamp.
llvm-svn: 130204
2011-04-26 16:49:25 +00:00
NAKAMURA Takumi 72516899db include/clang/AST/StmtIterator.h: std::pair should be provided by <utility>. libcxx needs it.
llvm-svn: 130183
2011-04-26 03:17:13 +00:00
Eric Christopher 6f095d613a Temporarily revert r130176, it appears to have broken a few tests.
llvm-svn: 130179
2011-04-26 01:02:04 +00:00
Devang Patel 420c8de92e Emit intrinsic at current insert point, not at the end of current block.
llvm-svn: 130177
2011-04-25 23:52:27 +00:00
Stuart Hastings 83da03c2ab Turn on byval parameters in Clang for ARM APCS. rdar://problem/7662569
llvm-svn: 130176
2011-04-25 23:48:12 +00:00
Devang Patel 4f325d1f0f Simplify. There is no need to have a method to just call another method.
llvm-svn: 130175
2011-04-25 23:43:36 +00:00
Fariborz Jahanian 24ac1599fc Generalize case for built-in expressions having
side-effect to generate their ir. Not just for
__builtin_expect. // rdar://9330105

llvm-svn: 130172
2011-04-25 23:10:07 +00:00
Argyrios Kyrtzidis e1b97c40c5 For the warnings related to -Wparentheses, display first the note about how to silence the warning and
any other suggestion after that. Related to rdar://9300260.

llvm-svn: 130169
2011-04-25 23:01:29 +00:00
Ted Kremenek 4f76f4ae31 Re-enable disable free optimization where the FrontendAction is not freed when -disable-free is passed. This accidentally was commited in r128011.
llvm-svn: 130168
2011-04-25 22:57:55 +00:00
Ted Kremenek 8dcc466886 When generating printf fixits, preserve the original formating for unsigned integers (e.g., 'x', 'o').
llvm-svn: 130164
2011-04-25 22:32:59 +00:00
Fariborz Jahanian 5a866c0bf2 Ir-gen the side-effect(s) when __builtin_expect is
constant-folded. // rdar://9330105

llvm-svn: 130163
2011-04-25 22:30:02 +00:00
Argyrios Kyrtzidis daa41f59e4 Fix a crash when ASTReader emits diagnostic when another one is in flight. Fixes rdar//9334563.
llvm-svn: 130162
2011-04-25 22:23:56 +00:00
Lenny Maiorani e553e40467 Implements the strncmp() checker just like the strcmp() checker, but with bounds. Requires LLVM svn r129582.
llvm-svn: 130161
2011-04-25 22:21:00 +00:00
Argyrios Kyrtzidis bd0a3fe5e8 'extern' variables in functions don't shadow externs in global scope. Fixes rdar://8883302, this time for C++ as well.
llvm-svn: 130157
2011-04-25 21:39:50 +00:00
Nico Weber a0b2dddcf0 Add libstdc++ search paths for GCC 4.6.0 on Arch Linux. Patch by Jakub Wieczorek.
llvm-svn: 130152
2011-04-25 20:59:30 +00:00
Daniel Dunbar 462e7ed497 Driver: When compilation fails, don't try to remove output files we don't have
write access to.

llvm-svn: 130150
2011-04-25 20:43:05 +00:00
Chris Lattner f03406f103 don't use compound literals in MM macros, since they will be instantiated
into user code which may warn about them with -pedantic.  Patch by Jonathan Sauer!

llvm-svn: 130149
2011-04-25 20:42:40 +00:00
Chris Lattner cdb591af03 fix PR9474, a crash with -fshort-enum and C++ templates: when instantiating
the enum decl, we need to use an integer type the same size as the enumerator,
which may not be the promoted type with packed enums.

llvm-svn: 130148
2011-04-25 20:37:58 +00:00
Fariborz Jahanian 743dda49d9 Recognize gcc's ms_struct pragma (and ignore for now).
This is wip.

llvm-svn: 130138
2011-04-25 18:49:15 +00:00
Douglas Gregor 90609aa394 Minor tweak to avoid having to dig through canonical types multiple times when checking a qualification conversion
llvm-svn: 130136
2011-04-25 18:40:17 +00:00
Francois Pichet aa48352f82 Add Windows SEH keywords.
llvm-svn: 130132
2011-04-25 17:23:15 +00:00
Douglas Gregor b90f5185b6 When Sema::ClassifyName() finds an invalid ivar reference, return an
invalid expression rather than the far-more-generic "error". Fixes a
mild regression in error recovery uncovered by the GCC testsuite.

llvm-svn: 130128
2011-04-25 15:05:41 +00:00
Chandler Carruth bc0f9aeac3 Remove some more hard CR-LF lines. These were particularly weird as they were
only a few lines of the file. Also set their properties to have explicitly
native eol sytle.

llvm-svn: 130124
2011-04-25 07:09:43 +00:00
John Wiegley f9f6584e95 t/clang/expr-traits
Patch authored by David Abrahams.

These two expression traits (__is_lvalue_expr, __is_rvalue_expr) are used for
parsing code that employs certain features of the Embarcadero C++ compiler.

llvm-svn: 130122
2011-04-25 06:54:41 +00:00
Chandler Carruth 03b77b37d6 Remove hard coded dos line endings, let subversion translate them on
update.

Despite the diff, nothing but line endings changed here.

llvm-svn: 130121
2011-04-25 06:34:35 +00:00
Nico Weber adf8ba98e7 Let clang detect gcc triple on Ubuntu Natty. Patch by Thomas Jablin.
llvm-svn: 130119
2011-04-25 03:17:35 +00:00
Eli Friedman 5792e02fa1 Missing bit of r130117.
llvm-svn: 130118
2011-04-24 22:31:41 +00:00
Eli Friedman ea7b85bfe0 PR4304: Add warning for designators in strict c89 mode.
llvm-svn: 130117
2011-04-24 22:14:22 +00:00
Benjamin Kramer d47a12a4e2 Use template magic to make dumping of vectors slightly less fragile.
No intended functionality change.

llvm-svn: 130114
2011-04-24 17:44:50 +00:00
Ken Dyck bb2c24008f Convert size and alignment variables to CharUnits in EmitAggregateCopy(). No
change in functionality intended.

llvm-svn: 130113
2011-04-24 17:37:26 +00:00
Ken Dyck 239a3357af Convert type size and alignment to CharUnits in CheckAggExprForMemSetUse().
No change in functionality intended.

llvm-svn: 130112
2011-04-24 17:25:32 +00:00
Ken Dyck df94cb7dbe Convert the return type of GetNumNonZeroBytesInInit() to CharUnits. No
change in functionality intended.

llvm-svn: 130111
2011-04-24 17:17:56 +00:00
Ken Dyck 3b4bd9a164 Eliminate some literal 8s by converting size variables in EmitGCMove() and
EmitFinalDestCopy() to CharUnits. No change in functionality intended.

llvm-svn: 130110
2011-04-24 17:08:00 +00:00
Ken Dyck a8094505e2 Replace calls to ASTContext::getTypeInfo() with calls to
ASTContext::getTypeSize() when only the size part is used. No change in
functionality intended.

llvm-svn: 130109
2011-04-24 17:02:38 +00:00
Ken Dyck 272b6fa0f0 Simplify AppendTailPadding() by converting its parameter to CharUnits. No
change in functionality intended.

llvm-svn: 130108
2011-04-24 16:53:44 +00:00
Ken Dyck 7a0b19f978 Eliminate literal 8s from LayoutUnionField by converting NumBytesToAppend to
CharUnits. No change in functionality intended.

llvm-svn: 130107
2011-04-24 16:47:33 +00:00
Ken Dyck 345a6de9b4 Eliminate literal 8s from LayoutBitField(), converting variables to
CharUnits or replacing the 8s with char align. No change in functionality
intended.

llvm-svn: 130106
2011-04-24 16:40:29 +00:00
Sebastian Redl 010288f7c1 Set the correct anonymous namespace (must be last reopening), and behave correctly in the presence of the ever-annoying linkage specifications.
llvm-svn: 130105
2011-04-24 16:28:21 +00:00
Sebastian Redl fa1f370b7d Fix adding an anonymous namespace in a chained PCH to a namespace from a previous PCH.
Fix anonymous namespaces in PCH.

llvm-svn: 130104
2011-04-24 16:28:13 +00:00
Sebastian Redl ab238a7d18 Synthesizing the definition of an implicit member is an AST modification, so notify any mutation listeners of it. This fixes a crasher in chained PCH, where an implicit destructor in a PCH gets a definition in a chained PCH, which is then lost. However, any further use of the destructor would cause its definition to be regenerated in the final file, hiding the bug.
llvm-svn: 130103
2011-04-24 16:28:06 +00:00
Sebastian Redl f830df4e9d On reading DeclContexts from PCH, check for visible updates even if the context was empty in the original version. Also, if there are any, tell the context that it has external visible decls. This fixes the problem that a namespace that was empty in the initial PCH (could also happen if the initial PCH didn't include any std header but caused implicit creation of namespace std, e.g. due to implicit declaration of a virtual destructor) never found any declaration declared in *any* chained PCH. Very ugly when the chained PCH includes all that std stuff, as the errors were effectively the same as not including std headers.
llvm-svn: 130102
2011-04-24 16:27:54 +00:00
Sebastian Redl 83f3b859ab Make the invalid declarator recovery when parsing members work the same as when parsing global decls. It's still rather broken (skipping much too far when the declarator belongs to a function definition), but at least not so broken as to mismatch braces. Tested by the removal of the fixme in the template test case.
llvm-svn: 130101
2011-04-24 16:27:48 +00:00
Sebastian Redl ddb3ab494d Give MultiplexConsumer.h a header guard.
llvm-svn: 130100
2011-04-24 16:27:41 +00:00
Sebastian Redl e2d93b154f Fix PathDiagnosticClients.h header guard. (Case error)
llvm-svn: 130099
2011-04-24 16:27:36 +00:00
Sebastian Redl 14afaf0093 Store the full list of pending instantiations in a chained PCH. Previously we attempted to store only new pending instantiations, but our filter was incorrect, dropping implicit instantiations of class template members. It's just not worth coming up with a complex filter that is correct, when the only cost is PCH files that are a few hundred bytes (at most) larger.
llvm-svn: 130098
2011-04-24 16:27:30 +00:00
Francois Pichet dd876125df Downgrade unnecessary "typename" from error to warning in Microsoft mode.
This fixes 1 error when parsing MSVC 2008 headers with clang. 

Must "return true;" even if it is a warning because the rest of the code path assumes that SS is set to something. The parser will get back on its feet and continue parsing the rest of the declaration correctly so it is not a problem.

llvm-svn: 130088
2011-04-24 11:24:13 +00:00
Ken Dyck 27337a8800 Convert AccessInfo::AccessAlignment to CharUnits. No change in functionality
intended.

llvm-svn: 130087
2011-04-24 10:13:17 +00:00
Jay Foad dbf81d8ddf PR9214: Convert the DIBuilder API to use ArrayRef.
llvm-svn: 130086
2011-04-24 10:11:03 +00:00
Ken Dyck f76759c6fa Convert CGBitFieldInfo::FieldByteOffset to CharUnits. No change in
functionality intended.

llvm-svn: 130085
2011-04-24 10:04:59 +00:00
John McCall 617339e692 GCC seems to create address-of expression manglings when passing *any*
function as a template argument where a pointer to function is wanted.
Just extend the existing hack.

llvm-svn: 130084
2011-04-24 08:43:07 +00:00
John McCall 6dc0a2b467 Update the mangler for some of the "new" unresolved-name manglings.
I've sent off an email requesting clarification on a few things that
I wasn't sure how to handle.

This also necessitated making prefixes and unresolved-prefixes get
mangled separately.

llvm-svn: 130083
2011-04-24 08:23:24 +00:00
Douglas Gregor 0e7dde535d Implement a new identifier-classification scheme where Sema
performs name lookup for an identifier and resolves it to a
type/expression/template/etc. in the same step. This scheme is
intended to improve both performance (by reducing the number of
redundant name lookups for a given identifier token) and error
recovery (by giving Sema a chance to correct type names before the
parser has decided that the identifier isn't a type name). For
example, this allows us to properly typo-correct type names at the
beginning of a statement:

t.c:6:3: error: use of undeclared identifier 'integer'; did you mean
'Integer'?
  integer *i = 0;
  ^~~~~~~
  Integer
t.c:1:13: note: 'Integer' declared here
typedef int Integer;
            ^


Previously, we wouldn't give a Fix-It because the typo correction
occurred after the parser had checked whether "integer" was a type
name (via Sema::getTypeName(), which isn't allowed to typo-correct)
and therefore decided to parse "integer * i = 0" as an expression. By
typo-correcting earlier, we typo-correct to the type name Integer and
parse this as a declaration. 

Moreover, in this context, we can also typo-correct identifiers to
keywords, e.g.,

t.c:7:3: error: use of undeclared identifier 'vid'; did you mean
'void'?
  vid *p = i;
  ^~~
  void

and recover appropriately.

Note that this is very much a work-in-progress. The new
Sema::ClassifyName is only used for expression-or-declaration
disambiguation in C at the statement level. The next steps will be to
make this work for the same disambiguation in C++ (where
functional-style casts make some trouble), then push it
further into the parser to eliminate more redundant name lookups.

Fixes <rdar://problem/7963833> for C and starts us down the path of
<rdar://problem/8172000>.

llvm-svn: 130082
2011-04-24 05:37:28 +00:00
John McCall d8d1e2ae66 The ABI settled on mangling float literals with lowercase hex dumps.
APInt::toString doesn't do those, but it's easy to postprocess that output,
and that's probably better than adding another knob to that method.

llvm-svn: 130081
2011-04-24 03:07:16 +00:00
Argyrios Kyrtzidis 82270b4679 Put -Wunneeded-internal-declaration under UnusedFunction group so it will be disabled with -Wno-unused-function.
llvm-svn: 130080
2011-04-24 02:56:06 +00:00
Chandler Carruth e71d0628f7 Implement most of the remaining logic in __is_literal type trait. This
should now support all of the C++98 types, and all of the C++0x types
Clang supports.

llvm-svn: 130079
2011-04-24 02:49:34 +00:00
Chandler Carruth 65fa1fd18e Add support for '__is_literal_type' spelling of the existing
'__is_literal' type trait for GCC compatibility. At least one relased
version if libstdc++ uses this name for the trait despite it not being
documented anywhere.

llvm-svn: 130078
2011-04-24 02:49:28 +00:00
Chandler Carruth ad7d404732 Begin tracking trivialness of move constructors and move assignment
operators in C++ record declarations.

This patch starts off by updating a bunch of the standard citations to
refer to the draft 0x standard so that the semantics intended for move
varianst is clear. Where necessary these are duplicated so they'll be
available in doxygen.

It adds bit fields to keep track of the state for the move constructs,
and updates all the code necessary to track this state (I think) as
members are declared for a class. It also wires the state into the
various trait-like accessors in the AST's API, and tests that the type
trait expressions now behave correctly in the presence of move
constructors and move assignment operators.

This isn't complete yet due to these glaring FIXMEs:
1) No synthesis of implicit move constructors or assignment operators.
2) I don't think we correctly enforce the new logic for both copy and
   move trivial checks: that the *selected* copy/move
   constructor/operator is trivial. Currently this requires *all* of them
   to be trivial.
3) Some of the trait logic needs to be folded into the fine-grained
   trivial bits to more closely match the wording of the standard. For
   example, many of the places we currently set a bit to track POD-ness
   could be removed by querying other more fine grained traits on
   demand.

llvm-svn: 130076
2011-04-23 23:10:33 +00:00
Chandler Carruth 78ef0957d4 Flesh out these tests just a tad more. This provides targeted
'DerivesHasFoo' types for various non-POD constructs in the base class.
Only __is_pod and __is_trivial are wired up to these, not sure how much
more of this type of exhaustive testing is really interesting.

llvm-svn: 130075
2011-04-23 21:02:37 +00:00
Chandler Carruth 0850b9d4c9 Test POD and trivial type traits given a class derived from a generic
non-POD type.

It might be nicer to have a Derives* variant for each of HasCons,
HasCopy, etc. Then we could test each of those and also test the __has_*
traits. WIP.

llvm-svn: 130074
2011-04-23 20:51:42 +00:00