Chris Lattner [Wed, 25 Jan 2012 05:34:41 +0000 (05:34 +0000)]
reapply r148902:
"use the new ConstantVector::getSplat method where it makes sense."
Also simplify a bunch of code to use the Builder->getInt32 instead
of doing it the hard and ugly way. Much more progress could be made
here, but I don't plan to do it.
Richard Smith [Wed, 25 Jan 2012 02:14:59 +0000 (02:14 +0000)]
Fix PR11848: decree that an alias template contains an unexpanded parameter pack
iff its substitution contains an unexpanded parameter pack. This has the effect
that we now reject declarations such as this (which we used to crash when
expanding):
template<typename T> using Int = int;
template<typename ...Ts> void f(Int<Ts> ...ints);
The standard is inconsistent on how this case should be treated.
Nick Lewycky [Wed, 25 Jan 2012 01:19:14 +0000 (01:19 +0000)]
With a little more work in the tentative parse determining whether a statement
is a declaration-stmt or an expression, we can discern a subset of cases where
the user erred in omitting the typename keyword before a dependent type name.
Fixes PR11358!
Douglas Gregor [Wed, 25 Jan 2012 01:14:32 +0000 (01:14 +0000)]
Introduce a generation number for selector lookups in the global
method pool, so that we don't perform the same lookups into the same
PCH/module file repeatedly.
Douglas Gregor [Wed, 25 Jan 2012 00:59:09 +0000 (00:59 +0000)]
Whenever Sema attempts to look in the global method pool, try to load
additional data from the external Sema source. This properly copes
with modules that are imported after we have already searched in the
global method pool for a given selector. For PCH, it's a slight
pessimization to be fixed soon.
Douglas Gregor [Wed, 25 Jan 2012 00:49:42 +0000 (00:49 +0000)]
Rework the external Sema source's ReadMethodPool() so that it doesn't
return pre-built lists. Instead, it feeds the methods it deserializes
to Sema so that Sema can unique them, which keeps the chains shorter.
Ted Kremenek [Wed, 25 Jan 2012 00:35:05 +0000 (00:35 +0000)]
Reduce peak memory usage of the static analyzer on sqlite3 (when using inlining) by 30%.
This is accomplished by periodically reclaiming nodes in the graph. This was an optimization
done before the CFG was linearized, but the CFG linearization destroyed that optimization since each
freshly created node couldn't be reclaimed and we only looked at a window of nodes created between
each ProcessStmt. This optimization can be reclaimed my merely expanding the window to N number of nodes.
arc migrator: Provide infrastructure to add options
specific to migrator. Use its first option to
warn migrating from GC to arc when
NSAllocateCollectable/NSReallocateCollectable is used.
// rdar://10532541
Douglas Gregor [Wed, 25 Jan 2012 00:19:56 +0000 (00:19 +0000)]
Factor out the addition of a method into the global method pool, and
teach it to always add the new method at the *end* of the list rather
than as the second element in the list.
[libclang] In clang::getCursorKindForDecl() don't return "UnexposedDecl"
for forward references of classes and protocols, this breaks libclang API usage.
Nick Lewycky [Tue, 24 Jan 2012 21:15:41 +0000 (21:15 +0000)]
Add a new warning, -Wover-aligned, which detects attempts to use the default
allocator to construct an object which declares more alignment than the default
allocator actually provides. Fixes PR9527!
Chandler Carruth [Tue, 24 Jan 2012 20:08:17 +0000 (20:08 +0000)]
Fix one of the (larger) FIXMEs where we were misusing the Driver's idea
of the target triple to stand in for the "host" triple.
Thanks to a great conversation with Richard Smith, I'm now much more
confident in how this is proceeding. In all of the places where we
currently reason about the "host" architecture or triple, what we really
want to reason about in the detected GCC installation architecture or
triple, and the ways in which that differs from the target. When we find
a GCC installation with a different triple from our target *but capable
of targeting our target* through an option such as '-m64', we want to
detect *that* case and change the paths within the GCC installation (and
libstdc++ installation) to reflect this difference.
This patch makes one function do this correctly. Subsequent commits will
hoist the logic used here into the GCCInstallation utility, and then
reuse it through the rest of the toolchains to fix the remaining places
where this is currently happening.
[libclang] When calling clang_getCursorReferenced on a class or protocol
forward reference, do give an interface or protocol cursor back, don't give
an 'UnexposedDecl' one.
Chandler Carruth [Tue, 24 Jan 2012 19:28:29 +0000 (19:28 +0000)]
Address one part of the FIXME I introduced my switching the triple
inside of GCCInstallation to be a proper llvm::Triple. This is still
a touch ugly because we have to use it as a string in so many places,
but I think on the whole the more structured representation is better.
Comments of course welcome if this tradeoff isn't working for folks.
The following patch adds __attribute__((no_address_safety_analysis)) which will allow to disable
address safety analysis (such as e.g. AddressSanitizer or SAFECode) for a specific function.
When building with AddressSanitizer, add AddressSafety function attribute to every generated function
except for those that have __attribute__((no_address_safety_analysis)).
With this patch we will be able to
1. disable AddressSanitizer for a particular function
2. disable AddressSanitizer-hostile optimizations (such as some cases of load widening) when AddressSanitizer is on.
Chandler Carruth [Tue, 24 Jan 2012 19:17:46 +0000 (19:17 +0000)]
Start hoisting the logic for computing the target triple into its own
function. The logic for this, and I want to emphasize that this is the
logic for computing the *target* triple, is currently scattered
throughout various different HostInfo classes ToolChain factoring
functions. Best part, it is largely *duplicated* there. The goal is to
hoist all of that up to here where we can deal with it once, and in
a consistent manner.
Unfortunately, this uncovers more fun problems: the ToolChains assume
that the *actual* target triple is the one passed into them by these
factory functions, while the *host* triple is the one in the driver.
This already was a lie, and a damn lie, when the '-target' flag was
specified. It only really worked when the difference stemmed from '-m32'
and '-m64' flags. I'll have to fix that (and remove all the FIXMEs I've
introduced here to document the problem) before I can finish hoisting
the target-calculation logic.
Douglas Gregor [Tue, 24 Jan 2012 19:01:26 +0000 (19:01 +0000)]
Promote the extension warning for attempts to catch a reference or
pointer to incomplete type from an ExtWarn to an error. We put the
ExtWarn in place as part of a workaround for Boost (PR6527), but it
(1) doesn't actually match a GCC extension and (2) has been fixed for
two years in Boost, and (3) causes us to emit code that fails badly at
run time, so it's a bad idea to keep it. Fixes PR11803.
Douglas Gregor [Tue, 24 Jan 2012 15:24:38 +0000 (15:24 +0000)]
Only mark an IdentifierInfo as having changed since deserialization
when it actually has changed (and not, e.g., when we've simply attached a
deserialized macro definition). Good for ~1.5% reduction in module
file size, mostly in the identifier table.
Chandler Carruth [Tue, 24 Jan 2012 10:43:44 +0000 (10:43 +0000)]
Remove HostInfo::useDriverDriver(). This was only used in two places
inside the innards of the Driver implementation, and only ever
implemented to return 'true' for the Darwin OSes. Instead use a more
direct query on the target triple and a comment to document why the
target matters here.
If anyone is worried about this predicate getting wider use or improper
use, I can make it a local or private predicate in the driver.
Chandler Carruth [Tue, 24 Jan 2012 10:21:46 +0000 (10:21 +0000)]
Hoist the targeted triple object into an actual object in the Driver.
The Driver has a fixed target, whether we like it or not, the
DefaultTargetTriple is not a default. This at least makes things more
honest. I'll eventually get rid of most (if not all) of
DefaultTargetTriple with this proper triple object. Bit of a WIP.
David Blaikie [Tue, 24 Jan 2012 06:03:59 +0000 (06:03 +0000)]
Support decltype in member initializers.
This is the last piece of N3031 (decltype in weird places) - supporting
the use of decltype in a class ctor's member-initializer-list to
specify the base classes to initialize.
David Blaikie [Tue, 24 Jan 2012 05:34:08 +0000 (05:34 +0000)]
Reword/rename -Wswitch-unreachable-default.
Rewording the diagnostic to be more precise/correct: "default label in switch
which covers all enumeration values" and changed the switch to
-Wcovered-switch-default
Chandler Carruth [Tue, 24 Jan 2012 01:55:55 +0000 (01:55 +0000)]
Make driver tests more resilient to output trees containing symlinks --
the tests are making assertions about the name of the clang binary, so
we should ensure that the name is as stable as possible.
Sebastian Redl [Mon, 23 Jan 2012 22:09:39 +0000 (22:09 +0000)]
Minor fixups for auto deduction of initializer lists.
Fix some review comments.
Add a test for deduction when std::initializer_list isn't available yet.
Fix redundant error messages. This fixes and outstanding FIXME too.
Kaelyn Uhrain [Mon, 23 Jan 2012 20:18:59 +0000 (20:18 +0000)]
In CorrectTypo, use the cached correction as a starting point instead.
Previously, for unqualified lookups, a positive cache hit is used as the
only non-keyword correction and a negative cache hit immediately returns
an empty TypoCorrection. With the new callback objects, this behavior
causes false negatives by not accounting for the fact that callback
objects alter the set of potential/allowed corrections. The new behavior
is to seed the set of corrections with the cached correction (for
positive hits) to estabilishing a baseline edit distance. Negative cache
hits are only stored or used when either no callback object is provided
or when it returns true for a call to ValidateCandidate with an empty
TypoCorrection (i.e. when ValidateCandidate does not seem to be doing
any checking of the TypoCorrection, such as when an instance of the base
callback class is used solely to specify the set of keywords to be accepted).
Douglas Gregor [Mon, 23 Jan 2012 15:59:30 +0000 (15:59 +0000)]
Handle pseudo-object expressions (and any other placeholder
expression) when code-completing member access expressions. Fixes
<rdar://problem/10717172>.
Douglas Gregor [Mon, 23 Jan 2012 15:29:33 +0000 (15:29 +0000)]
Downgrade C++11 narrowing conversion errors to warnings default-mapped
to an error, so that users can turn them off if necessary. Note that
this does *not* change the behavior of in a SFINAE context, where we
still flag an error even if the warning is disabled. This matches
GCC's behavior.
David Blaikie [Mon, 23 Jan 2012 04:58:54 +0000 (04:58 +0000)]
Rename -Wswitch-enum-redundant-default to -Wswitch-redundant-default.
This is for consistency, since the flag is actually under -Wswitch now, rather
than -Wswitch-enum (since it's really valuable for the former and rather
orthogonal to the latter)
David Blaikie [Mon, 23 Jan 2012 04:46:12 +0000 (04:46 +0000)]
Implement -Wswitch-enum correctly.
Clang previously implemented -Wswitch-enum the same as -Wswitch. This patch
corrects the behavior to match GCC's. The critical/only difference being that
-Wswitch-enum is not silenced by the presence of a default case in the switch.
Nico Weber [Mon, 23 Jan 2012 03:19:29 +0000 (03:19 +0000)]
In ms mode, a move assignment operator shouldn't mark a copy ctor as deleted.
MSVC2010's pair class has a move assignment operator but no explicit copy
constructor, which makes it unusable without this change.
For symmetry, let move copy constructors not mark the default assignment
operator as deleted either. Both changes match cl.exe's behavior. Fixes
pr11826.
Also update the standard excerpt to point to the right paragraph.
David Blaikie [Sun, 22 Jan 2012 02:31:55 +0000 (02:31 +0000)]
Fix -Wswitch to warn about out of bounds enum cases even when there's a default
For consistency with GCC & reasonable sanity. The FIXME suggests that the
original author was perhaps using the default check for some other purpose,
not realizing the more obvious limitation/false-negatives it creates, but this
doesn't seem to produce any regressions & fixes the included test.
David Blaikie [Sun, 22 Jan 2012 01:58:03 +0000 (01:58 +0000)]
Move -Wswitch-enum to -Wswitch
This matches GCC's documented (& actual) behavior. What Clang had implemented
as -Wswitch-enum was actually GCC's -Wswitch behavior. -Wswitch is on by
default (part of -Wall) and warns if a switch-over-enum, without a default
case, covers all enum values.
-Wswitch-enum, on the other hand, does not have the default clause and should
fire even in the presence of a default. This warning is off by default.
With this change the -Wswitch-enum flag is off-by-default in Clang but has no
functionality at the moment. I'll add that in a future commit.
Francois Pichet [Sat, 21 Jan 2012 23:26:50 +0000 (23:26 +0000)]
In Microsoft Mode, disable the C++11 strict integral conversion rules for enumerator that were introduced with r148439. Otherwise MSVC headers won't compile in C++ 11 mode.
David Blaikie [Sat, 21 Jan 2012 18:12:07 +0000 (18:12 +0000)]
Add -Wswitch-enum-redundant-default.
This warning acts as the complement to the main -Wswitch-enum warning (which
warns whenever a switch over enum without a default doesn't cover all values of
the enum) & has been an an-doc coding convention in LLVM and Clang in my
experience. The purpose is to ensure there's never a "dead" default in a
switch-over-enum because this would hide future -Wswitch-enum errors.
The name warning has a separate flag name so it can be disabled but it's grouped
under -Wswitch-enum & is on-by-default because of this.
The existing violations of this rule in test cases have had the warning disabled
& I've added a specific test for the new behavior (many negative cases already
exist in the same test file - and none regressed - so I didn't add more).
Reviewed by Ted Kremenek ( http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120116/051690.html )