Don't try to get the layout of an invalid decl in getDeclAlign.
When the decl that we're getting alignment for is a FieldDecl, and the field's
parent record is invalid, skip the actual field alignment calculation (and
return 1-byte alignment in the general case).
Also, assert in in getASTRecordLayout that the decl is valid. This was
inspired by PR16292; see also r184581 and r184751.
Chandler Carruth [Tue, 25 Jun 2013 11:13:47 +0000 (11:13 +0000)]
Fix a couple of PPC predefined macros that I spotted while driving by
this code. These aren't technically standard predefines for the platform
but apparantly lots of folks use them as they show up within LLVM's own
codebase. ;] This may even fix some self host issues w/ the JIT!!!
Jordan Rose [Tue, 25 Jun 2013 01:56:08 +0000 (01:56 +0000)]
[analyzer] Handle zeroing CXXConstructExprs.
Re-apply r184511, reverted in r184561, with the trivial default constructor
fast path removed -- it turned out not to be necessary here.
Certain expressions can cause a constructor invocation to zero-initialize
its object even if the constructor itself does no initialization. The
analyzer now handles that before evaluating the call to the constructor,
using the same "default binding" mechanism that calloc() uses, rather
than simply ignoring the zero-initialization flag.
Jordan Rose [Tue, 25 Jun 2013 01:55:59 +0000 (01:55 +0000)]
[analyzer] Don't initialize virtual base classes more than once.
In order to make sure virtual base classes are always initialized once,
the AST contains initializers for the base class in /all/ of its
descendents, not just the immediate descendents. However, at runtime,
the most-derived object is responsible for initializing all the virtual
base classes; all the other initializers will be ignored.
The analyzer now checks to see if it's being called from another base
constructor, and if so does not perform virtual base initialization.
Richard Smith [Tue, 25 Jun 2013 01:25:15 +0000 (01:25 +0000)]
Fix deserializing of class template partial specializations. Assign sequence
numbers as we deserialize class template partial specializations. We can't
assume that the old sequence numbers will work.
The sequence numbers are still deterministic, but are now a lot less
predictable for class template partial specializations in modules/PCH.
Eli Friedman [Tue, 25 Jun 2013 00:46:32 +0000 (00:46 +0000)]
Delete a couple dead checks.
Use castAs<> where appropriate. Don't check conditionals which are
always true. Delete a bit of dead code. Reindent a bunch of code which
is no longer guarded by an if statement.
Ted Kremenek [Mon, 24 Jun 2013 21:35:39 +0000 (21:35 +0000)]
Tweak -Wdeprecated-objc-pointer-introspection to have a subgroup for results of using -performSelectorXXX.
-performSelector: and friends return a value that is boxed as an Objective-C
pointer. Sometimes it is an Objective-C pointer, sometimes it isn't.
Some clients may wish to silence this warning based on calling
this method.
This is a large test and thus it will only run if you pass in --param
run_long_tests=trueto LIT. This is intended so that this test can run on
buildbots and not when one runs make check.
[NeonIntrinsicTestEmitter] Add requirement to arm neon intrinsic tests for the feature long_tests.
This will prevent the tests from running on normal make check. You will need to
actually pass in --param run_long_tests=true to LIT in order to run these.
[libclang/codecompletion] Make sure the top-level decl hash takes into account ImportDecls.
The top-level hash is used to determine if we need to update the global code-completion results.
ImportDecls did not affect the hash so a newly introduced ImportDecl would not trigger an update of the global results.
Eli Friedman [Mon, 24 Jun 2013 20:24:19 +0000 (20:24 +0000)]
Change mangling of objects inside block literals.
This changes the mangling of local static variables/etc. inside blocks
to do something simple and sane. This avoids depending on the way we mangle
blocks, which isn't really appropriate here.
John, please take a look at this to make sure the mangling I chose is sane.
Reid Kleckner [Mon, 24 Jun 2013 19:21:52 +0000 (19:21 +0000)]
[ms-cxxabi] Use sugared types in the mangler instead of canonical types
At this point, it's clear that the MSVC mangler uses the type-as-written
instead of the canonical type, so this should bring us closer to MSVC.
The main thrust of this change is to fix the way we mangle decayed array
parameters of function pointer parameters. With a DecayedType sugar
node, this code can now be much simpler.
Fixes PR16096.
This also fixes a separate issue that Richard spotted in review.
Because separate declarations of the same entity can be spelled and
mangled differently, MSVC always mangles the earliest declaration in an
attempt to avoid link errors. Clang now does the same.
Anna Zaks [Mon, 24 Jun 2013 18:12:12 +0000 (18:12 +0000)]
[analyzer] Add a debug checker that prints Exploded Graph
Add a debug checker that is useful to understand how the ExplodedGraph is
built; it can be triggered using the following command:
Rafael Espindola [Mon, 24 Jun 2013 17:59:44 +0000 (17:59 +0000)]
Convert last use of PathV1.h in Compilation.cpp
The way we decide which file to remove is fairly odd. I took a quick look at
maybe changing that, but it would be a more work than I want to put at this
right now, so I left pair of FIXMEs.
Reid Kleckner [Mon, 24 Jun 2013 17:51:48 +0000 (17:51 +0000)]
[AST] Introduce a new DecayedType sugar node
The goal of this sugar node is to be able to look at an arbitrary
FunctionType and tell if any of the parameters were decayed from an
array or function type. Ultimately this is necessary to implement
Microsoft's C++ name mangling scheme, which mangles decayed arrays
differently from normal pointers.
Add some invalid-decl checks to clang_Type_getOffsetOf.
print-size-type.cpp was checking for specific record layout output for invalid
decls; I've removed the checks but left the records as tests for not crashing.
Richard Smith [Mon, 24 Jun 2013 07:20:36 +0000 (07:20 +0000)]
Avoid adding entries to the DeclContext lookup table multiple times when lazily
constructing a lookup table.
Previously, buildLookup would add lookup table entries for each item lexically
within the DC, and adding the first entry with a given name would trigger the
external source to add all its entries with that name. Then buildLookup would
carry on and re-add those entries all over again.
Instead, follow a simple rule: a declaration from an external source is only
ever made visible by the external source. One exception to this: since we don't
usually build a lookup table for the TU in C, and we never serialize one, we
don't expect the external source to provide lookups in the TU in C, so we build
those ones ourselves.
David Blaikie [Mon, 24 Jun 2013 07:13:13 +0000 (07:13 +0000)]
DebugInfo: ensure negative enumerators are emitted as such
There's still a problem here - since we're not appropriately using the
signedness/range of the enum to chooset the encoding and emission of
enumerators, but GCC has some bugs around this too so I assume that's
not /such/ a high priority though I may get to it soon out of
completeness.
Richard Smith [Mon, 24 Jun 2013 01:46:41 +0000 (01:46 +0000)]
When setting the external visible declarations for a decl context, check
whether they replace any existing lookups in the context, rather than
accumulating a bunch of lookup results referring to the same entity.
Dmitri Gribenko [Sun, 23 Jun 2013 23:33:14 +0000 (23:33 +0000)]
Documentation parsing: recognize \relates, \related, \relatesonly, \relatedonly
so that -Wdocumentation-unknown-command does not warn on these commands.
Fixes PR16092.
Chandler Carruth [Sun, 23 Jun 2013 11:28:48 +0000 (11:28 +0000)]
Fix the addition of Clang's profile runtime library to the link step
when specifying --coverage (or related) flags.
The system for doing this was based on the old LLVM-hosted profile_rt
library, and hadn't been updated for Linux to use the new compiler-rt
library. Also, it couldn't possibly work on multiarch or biarch systems
in many cases. The whole thing now works much the same as the sanitizer
libraries that are built and used out of the compiler-rt repo.
Note that other target OSes haven't been updated because I don't know if
they're doing anything special with the installation path of profile_rt.
I suspect however that *all* of these are wrong and would encourage
maintainers of each target to take a hard look at how compiler-rt
runtime libraries are linked on their platforms.
Chandler Carruth [Sun, 23 Jun 2013 10:10:25 +0000 (10:10 +0000)]
The makefile build system had two lists of the 32-bit runtime libraries
to build and one had grown out of sync. Put this list in a variable so
this doesn't happen again.
The whole thing here is somewhat suspicious as we don't support 32-bit
environments with a 64-bit bi-arch capable compiler, but none have
complained yet about this so I'm just leaving it alone.
Chandler Carruth [Sun, 23 Jun 2013 08:24:15 +0000 (08:24 +0000)]
Add and tighten up tests for cross compiling tool selection. This now
verifies that we run the assembler and linker in the correct mode, and
that we can successfully use a bi-arch variant of a GCC installation in
a generic cross compilation invocation of Clang.
Dmitri Gribenko [Sat, 22 Jun 2013 23:03:37 +0000 (23:03 +0000)]
Comment parsing: followup to r184610: allow multiple \returns
Remove unneeded member in CommentSema, add a test for the XML schema (the
schema already allowed multiple paragraphs in <ResultDiscussion>, but there
were no tests for that), fix HTML generation (it is not allowed to have <p>
inside <dl>).
Larisse Voufo [Sat, 22 Jun 2013 13:56:11 +0000 (13:56 +0000)]
Instantiation bug fix extension (cf. r184503) -- minor code fixes, including a typo that caused a runtime assertion after firing diagnosis for class definitions, with the 'template' keyword as template header, in friend declarations.
Chandler Carruth [Sat, 22 Jun 2013 11:35:51 +0000 (11:35 +0000)]
Reword and reformat some of the "Multiarch" code in the toolchain setup.
There are fundamentally two different things that were getting conflated
here.
1) A bi-arch GCC toolchain install. This is not a full blown cross
compiler, but it supports targetting both 32-bit and 64-bit variants
of the same architecture using multilib OS installs and runtimes.
2) A "multiarch" Debian OS/runtime layout that lays out the libraries,
headers, etc as-if there were going to be a full blown cross compiler
even when in reality it is just a bi-arch GCC targeting two variants.
Also, these tend to use oddly "canonicalized" triples without the
vendor in them unlike the typical cross compiler runtime library
search that vanilla GCC cross compilers perform.
Now, when we mean the bi-arch nature of GCC accomplished with just
a suffix or tweak to the GCC paths, we say 'Biarch' or something
related. When we mean the Debian layout of includes and libraries, we
say multiarch or reference the multiarch triple.
In the process of reading and often renaming stuff in all these places,
also reformat with clang-format. No functionality change should be going
on here, this is just tidying up.
Anna Zaks [Sat, 22 Jun 2013 00:23:26 +0000 (00:23 +0000)]
[analyzer] Use output form collections’ count to decide if ObjC for loop should be entered
This fixes false positives by allowing us to know that a loop is always entered if
the collection count method returns a positive value and vice versa.
Anna Zaks [Sat, 22 Jun 2013 00:23:20 +0000 (00:23 +0000)]
[CFG] Set the “loop target” (back edge) for VisitObjCForCollectionStmt loops
Add the back edge info by creating a basic block, marked as loop target. This is
consistent with how other loops are processed, but was omitted from
VisitObjCForCollectionStmt.
Tim Northover [Fri, 21 Jun 2013 23:05:33 +0000 (23:05 +0000)]
Teach ARM va_arg to ignore empty structs.
Empty structs are ignored for parameter passing purposes, but va_arg was
incrementing the pointer anyway which could lead to va_list getting out of
sync.
Tim Northover [Fri, 21 Jun 2013 22:49:34 +0000 (22:49 +0000)]
Check for trivial constructibility before emptiness in ARM ABI.
According to the Itanium ABI (3.1.1), types with non-trivial copy constructors
passed by value should be passed indirectly, with the caller creating a
temporary.
We got this mostly correct, but forgot that empty structs can have non-trivial
constructors too and passed them incorrectly. This simply reverses the order of
the check.