Douglas Gregor [Tue, 4 Jan 2011 18:56:13 +0000 (18:56 +0000)]
Implement name mangling for sizeof...(pack), to silence the last of
the switch-enum warnings. Test is forthcoming, once I've dealt with
some template argument deduction issues.
Implement -Wself-assign, which warns on code such as:
int x = 42;
x = x; // Warns here.
The warning avoids macro expansions, templates, user-defined assignment
operators, and volatile types, so false positives are expected to be low.
The common (mis-)use of this code pattern is to silence unused variable
warnings, but a more idiomatic way of doing that is '(void)x;'.
A follow-up to this will add a note and fix-it hint suggesting this
replacement in cases where the StmtExpr consists precisely of the self
assignment.
Enhance the diagnostic for negative array sizes to include the
declaration name of the array when present. This ensures that
a poor-man's C++03 static_assert will include the user error message
often embedded in the name.
Update all the tests to reflect the new wording, and add a test for the
name behavior.
Douglas Gregor [Tue, 4 Jan 2011 02:33:52 +0000 (02:33 +0000)]
When creating the injected-class-name for a class template involving a
non-type template parameter pack, make sure to create a pack expansion
for the corresponding template argument.
Rename MaybeSkipFunctionBodyForCodeCompletion -> trySkippingFunctionBodyForCodeCompletion and check isCodeCompletionEnabled() before doing the call.
Suggestions by Chris.
Douglas Gregor [Mon, 3 Jan 2011 21:37:45 +0000 (21:37 +0000)]
Properly rebuild pack expansions whose pattern is a non-type template
argument. As part of this, be more careful when determining if there
are any parameter packs that cannot be expanded.
Douglas Gregor [Mon, 3 Jan 2011 21:13:47 +0000 (21:13 +0000)]
Unwrap template argument packs when checking the template arguments of
a class template partial specialiation, and look through pack
expansions when checking the conditions of C++0x [temp.class.spec]p8.
Fix PR8841 by checking for both semantic and lecical dependent
contexts. This prevents -Wunused-function from firing on friend function
definitions inside of class templates for example.
Douglas Gregor [Mon, 3 Jan 2011 19:04:46 +0000 (19:04 +0000)]
Refactor the tree transform's many loops over sets of expressions
(transforming each in turn) into calls into one central routine
(TransformExprs) that transforms a list of expressions. This
refactoring is preparatory work for pack expansions whose in an
expression-list.
In the latest episode of "Deserializing bugs caused by accessors" the series reached a thrilling climax when
FunctionDecl::setPure crashed a poor user's code.
Remove the use of this accessor when deserializing, along with several other in the neighborhood. Fixes rdar://8759653.
David Greene [Mon, 3 Jan 2011 17:28:52 +0000 (17:28 +0000)]
Support lit fixes for PR8199
Replace "clang++" with "clang\+\+" because we have to escape regexp
special characters now. This is in preparation for changes to lit to
fix PR8199. Tests will fail until the lit part gets committed.
Douglas Gregor [Mon, 3 Jan 2011 09:37:44 +0000 (09:37 +0000)]
When we attempt to create a built-in that involves a library type we
don't have access to (e.g., fprintf, which needs the library type
FILE), fail with a warning and forget about the builtin
entirely. Previously, we would actually provide an error, which breaks
autoconf's super-lame checks for fprintf, longjmp, etc. Fixes PR8316.
Nick Lewycky [Fri, 31 Dec 2010 17:31:54 +0000 (17:31 +0000)]
Remove stray emacs mode markers in all these files that was causing emacs to
open them in fundamental-mode instead of c++-mode.
Also twiddle whitespace for consistency in ToolChains.cpp.
Francois Pichet [Fri, 31 Dec 2010 10:43:42 +0000 (10:43 +0000)]
MSVC doesn't require an accessible copy-constructor when binding a temporary class object to a const-reference.
Note: this is not a C++0x behavior change, it was already like that in MSVC 2003.
This fixes a compile error when parsing MSVC header files with clang.
David Chisnall [Thu, 30 Dec 2010 14:05:53 +0000 (14:05 +0000)]
Expose Objective-C type encodings of declarations to libclang users. This also adds a method in ASTContext which encodes FunctionDecls using the same encoding format that is used for Objective-C methods.
Rafael Espindola [Wed, 29 Dec 2010 23:02:58 +0000 (23:02 +0000)]
Fix PR8796.
The problem was that we were asserting the we never added an empty class
to the same offset twice. This is not true for unions, where two members, empty
or not, can have the some offset.
Francois Pichet [Mon, 27 Dec 2010 01:32:00 +0000 (01:32 +0000)]
More __uuidof validation:
1. Do not validate for uuid attribute if the type is template dependent.
2. Search every class declaration and definition for the uuid attribute.
David Chisnall [Sun, 26 Dec 2010 22:13:16 +0000 (22:13 +0000)]
Add support for GNU runtime property set / get structure functions. Minor refactoring of Mac runtime (returns the same function for both, as the Mac runtimes currently only provide a single entry point for setting and getting struct properties, although this will presumably be fixed at some point).
Chris Lattner [Sat, 25 Dec 2010 23:25:43 +0000 (23:25 +0000)]
The -fshort-wchar option causes wchar_t to become unsigned, in addition to being
16-bits in size. Implement this by splitting WChar into two enums, like we have
for char. This fixes a miscompmilation of XULRunner, PR8856.
Ted Kremenek [Fri, 24 Dec 2010 08:39:33 +0000 (08:39 +0000)]
Add basic support for pointer arithmetic in
SimpleSValBuilder. This clears up some
false positives emitted by ArrayBoundCheckerV2
due to the lack of support for pointer arithmetic.
ifndef _MSC_VER out #pragma mark on MSVC. It still tries to parse the text even
though it doesn't know what it is, and complains about invalid tokens ;/.
Handle locations coming from macro instantiations properly in SourceManager::isBeforeInTranslationUnit().
Fixes rdar://8790245 and http://llvm.org/PR8821.
John McCall [Fri, 24 Dec 2010 02:08:15 +0000 (02:08 +0000)]
Refactor how we collect attributes during parsing, and add slots for attributes
on array and function declarators. This is pretty far from complete, and I'll
revisit it later if someone doesn't beat me to it.
Douglas Gregor [Fri, 24 Dec 2010 00:35:52 +0000 (00:35 +0000)]
Fix a thinko in a helper routine for template argument deduction that
caused an assertion when dealing with non-type template parameter
packs. Add some tests for deduction and instantiation of non-type
template parameter packs.
Douglas Gregor [Fri, 24 Dec 2010 00:15:10 +0000 (00:15 +0000)]
When instantiating a non-type template parameter pack, be sure to
extract the appropriate argument from the argument pack (based on the
current substitution index, of course). Simple instantiation of pack
expansions involving non-type template parameter packs now works.
Douglas Gregor [Thu, 23 Dec 2010 22:44:42 +0000 (22:44 +0000)]
Implement parsing of function parameter packs and non-type template
parameter packs (C++0x [dcl.fct]p13), including disambiguation between
unnamed function parameter packs and varargs (C++0x [dcl.fct]p14) for
cases like
void f(T...)
where T may or may not contain unexpanded parameter packs.
Ted Kremenek [Thu, 23 Dec 2010 21:35:43 +0000 (21:35 +0000)]
Add -fobjc-default-synthesized-properties flag
to allow us to explicitly control whether or
not Objective-C properties are default synthesized.
Currently this feature only works when using
the -fobjc-non-fragile-abi2 flag (so there is
no functionality change), but we can now turn
off this feature without turning off all the features
coupled with -fobjc-non-fragile-abi2.
Douglas Gregor [Thu, 23 Dec 2010 17:13:55 +0000 (17:13 +0000)]
Reimplement the comparison of a class template partial
specialization's template arguments against the primary template's
template arguments using the obvious, correct method of checking the
injected-class-name type (C++ [temp.class.spec]p9b3). The previous
incarnation of this comparison attempted to use its own formulation of
the injected-class-name, which is redudant and, with the introduction
of variadic templates, became wrong (again).
Douglas Gregor [Thu, 23 Dec 2010 16:00:30 +0000 (16:00 +0000)]
When forming the injected-class-name of a variadic template, the
template argument corresponding to a template parameter pack is an
argument pack of a pack expansion of that template parameter
pack. Implements C++0x [temp.dep.type]p2 (at least, as much of it as
we can).
Ted Kremenek [Thu, 23 Dec 2010 02:42:49 +0000 (02:42 +0000)]
It's amazing what you find when you actually
set the RUN line correctly in a test file!
Mark a bunch of tests for ArrayBoundCheckerV2
as FIXME's, as our current lack of pointer
arithmetic handling causes these to be all
false positives/negatives.
Douglas Gregor [Thu, 23 Dec 2010 01:52:01 +0000 (01:52 +0000)]
Implement the part of C++0x [temp.arg.explicit]p3 that pertains to
parameter packs. In particular, a parameter pack not otherwise deduced
is deduced to an empty parameter pack.
The C++0x wording here is a bit unfortunate; this should really only
apply to function templates, and it mentions "trailing" parameter
packs, which doesn't really make sense in the context of function
templates. Will file a core issue separately.
Douglas Gregor [Thu, 23 Dec 2010 01:24:45 +0000 (01:24 +0000)]
Implement the rest of C++0x [temp.deduct.type]p9, which specifies that
the presence of a pack expansion anywhere except at the end of a
template-argument-list causes the entire template-argument-list to be
a non-deduced context.
Jeffrey Yasskin [Thu, 23 Dec 2010 01:01:28 +0000 (01:01 +0000)]
Change all self assignments X=X to (void)X, so that we can turn on a
new gcc warning that complains on self-assignments and
self-initializations. Fix one bug found by the warning, in which one
clang::OverloadCandidate constructor failed to initialize its
FunctionTemplate member.
Douglas Gregor [Wed, 22 Dec 2010 23:09:49 +0000 (23:09 +0000)]
Unify the consistency checking for deduced template arguments into a
single routine. Extend that routine to handle consistency
checking for template argument packs, so that we can compare the
deduced packs for template parameter packs across different pack
expansions.
Douglas Gregor [Wed, 22 Dec 2010 21:19:48 +0000 (21:19 +0000)]
Implement template argument deduction for pack expansions whose
pattern is a template argument, which involves repeatedly deducing
template arguments using the pattern of the pack expansion, then
bundling the resulting deductions into an argument pack.
We can now handle a variety of simple list-handling metaprograms using
variadic templates. See, e.g., the new "count" metaprogram.
Move AnalysisConsumer.cpp and ExprEngine.cpp into the Checkers subdir temporarily
to avoid cyclic dependency between the libraries and fix the linux build.
Douglas Gregor [Wed, 22 Dec 2010 18:55:49 +0000 (18:55 +0000)]
When performing template argument deduction where the argument is a
dependent template specialization type, the number of template
arguments need not match precisely. Rather than checking the number of
arguments eagerly (which does not consider argument packs), let the
deduction routine for template argument lists cope with too many/too
few arguments.