Commit Graph

27768 Commits

Author SHA1 Message Date
John McCall 553d45aaf3 Slight bugfix to the attribute-distribution logic for GC attributes.
Slight optimization of getObjCGCAttrKind.

llvm-svn: 123295
2011-01-12 00:34:59 +00:00
Rafael Espindola 25f4620c67 Set unnamed_addr in every type info.
llvm-svn: 123293
2011-01-11 23:55:05 +00:00
Francois Pichet c3e73b343c Add a comment for r123231.
llvm-svn: 123291
2011-01-11 23:38:13 +00:00
Douglas Gregor 74c6d19c1f Add TemplateArgument::CreatePackCopy() to create a new parameter pack
in ASTContext-allocated memory, copying the provided template
arguments. Use this new routine where we can. No functionality change.

llvm-svn: 123289
2011-01-11 23:09:57 +00:00
Rafael Espindola bb7f7686c5 Set unnamed_addr in VTTs.
llvm-svn: 123280
2011-01-11 22:29:55 +00:00
Douglas Gregor 2fcb863b2b Implement partial ordering of class template partial specializations
and function templates that contain variadic templates. This involves
three small-ish changes:

  (1) When transforming a pack expansion, if the transformed argument
  still contains unexpanded parameter packs, build a pack
  expansion. This can happen during the substitution that occurs into
  class template partial specialiation template arguments during
  partial ordering. 
 
  (2) When performing template argument deduction where the argument
  is a pack expansion, match against the pattern of that pack
  expansion.

  (3) When performing template argument deduction against a non-pack
  parameter, or a non-expansion template argument, deduction fails if
  the argument itself is a pack expansion (C++0x
  [temp.deduct.type]p22).

llvm-svn: 123279
2011-01-11 22:21:24 +00:00
Rafael Espindola b1e879c80f Set unnamed_addr for type infos that we are confortable marking as hidden. I
think it is safe to mark all type infos with unnamed_addr, but I am not sure.

llvm-svn: 123275
2011-01-11 21:44:37 +00:00
Rafael Espindola 5674c644cf Add unnamed_addr to vtables.
llvm-svn: 123272
2011-01-11 21:10:26 +00:00
Eric Christopher 50c59e9e9a Add back 122079 so we can ignore the argument some more.
llvm-svn: 123271
2011-01-11 20:37:13 +00:00
Argyrios Kyrtzidis 4b7433fab2 [analyzer] Introduce ObjCSelfInitChecker, which checks initialization methods to verify that they assign 'self' to the
result of an initialization call (e.g. [super init], or [self initWith..]) before using any instance variable or
returning 'self'.

llvm-svn: 123264
2011-01-11 19:45:25 +00:00
Argyrios Kyrtzidis 9c23e6c689 [analyzer] Support post-visiting ObjCIvarRefExprs for checkers.
llvm-svn: 123263
2011-01-11 19:45:20 +00:00
Argyrios Kyrtzidis 52f04650ae [analyzer] Add 'bool ignorePrefix' parameter to cocoa::deriveNamingConvention to control whether
the prefix should be ignored.

E.g. if ignorePrefix is true, "_init" and "init" selectors will both be result in InitRule, but if
ignorePrefix is false, only "init" will return InitRule.

llvm-svn: 123262
2011-01-11 19:45:16 +00:00
Argyrios Kyrtzidis 1790c975e7 [analyzer] Add 'isLoad' parameter in Checker::visitLocation() to conveniently distinguish between loads/stores.
llvm-svn: 123261
2011-01-11 19:45:13 +00:00
Douglas Gregor 552c7cf22c Add another test for [temp.func.order]p5/[temp.deduct.partial]p11,
from James Widman.

llvm-svn: 123245
2011-01-11 17:51:55 +00:00
Douglas Gregor b837ea4eee Implement C++ [temp.func.order]p5 more directly, by passing down the
number of explicit call arguments. This actually fixes an erroneous
test for [temp.deduct.partial]p11, where we were considering
parameters corresponding to arguments beyond those that were
explicitly provided.

llvm-svn: 123244
2011-01-11 17:34:58 +00:00
Bob Wilson b9fa00e0c2 Remove special handling for opaque Neon vector types.
Clang does not wrap the vectors in structs anymore so this isn't needed.

llvm-svn: 123241
2011-01-11 16:53:49 +00:00
Ted Kremenek 841df11dab Remove ProgramPoint parameter from GenericNodeBuilder::generateNode().
llvm-svn: 123240
2011-01-11 16:53:44 +00:00
Douglas Gregor 7a7dc6f504 Add example from C++0x [temp.deduct.type]p21, which already works
llvm-svn: 123237
2011-01-11 15:36:52 +00:00
Abramo Bagnara 1339223186 Added warning about invalid register specification for local variables.
llvm-svn: 123236
2011-01-11 15:16:52 +00:00
Francois Pichet bf711d90ed In Microsoft mode, force 64 bit hex integer constants to signed type if the LL or i64 suffix is used. This MSVC behavior.
For example:

void f(long long){ printf("long long"); }
void f(unsigned long long) { printf("unsigned long long"); }
int main() {
   f(0xffffffffffffffffLL);
}
Will print "long long" using MSVC.

This patch also fixes 16 compile errors related to overloading issues when parsing the MSVC 2008 C++ standard lib.

llvm-svn: 123231
2011-01-11 12:23:00 +00:00
Francois Pichet 12df1dc8f2 Microsoft integer suffix changes:
i64 is like LL
i32 is like L

Also set isMicrosoftInteger to true only if the suffix is well formed.

llvm-svn: 123230
2011-01-11 11:57:53 +00:00
Francois Pichet 9b76fa9b07 Rename GenericNodeBuilder to GenericNodeBuilderRefCount to avoid namespace clash using MSVC.
llvm-svn: 123228
2011-01-11 10:41:37 +00:00
Ted Kremenek a00bccc0c5 Rework ExprEngine::processCFGBlockEntrance()
to use a node builder.  This paves the way
for Checkers to interpose (via a "visit" method)
at the entrance to blocks.

llvm-svn: 123217
2011-01-11 06:37:47 +00:00
Ted Kremenek f82068a994 Remove several silly methods from ento::CoreEngine
that just forwarded to ento::SubEngine.

llvm-svn: 123216
2011-01-11 04:49:40 +00:00
Douglas Gregor aec93c6bbe Ensure that the result type of an Objective-C class message send is
complete. However, if it returns a reference type, don't require the
type it refers to to be complete. Fixes <rdar://problem/8807070>.

llvm-svn: 123214
2011-01-11 03:23:19 +00:00
Douglas Gregor 5cde386e5e When mapping from a function parameter pack to the set of function
parameters it expanded to, map exactly the number of function
parameters that were expanded rather than just running to the end of
the instantiated parameter list. This finishes the implementation of
the last sentence of C++0x [temp.deduct.call]p1.

llvm-svn: 123213
2011-01-11 03:14:20 +00:00
Ted Kremenek f4ef3d3ca1 Rename misc. methods in ento::Worklist to start
with lowercase letter.

llvm-svn: 123212
2011-01-11 02:34:50 +00:00
Ted Kremenek 926c96211e Rename misc. methods in GRSubEngine to start
with a lower-case letter.  No functionality change.

llvm-svn: 123211
2011-01-11 02:34:45 +00:00
Douglas Gregor 0dd423ef33 Implement the last bullet of [temp.deduct.type]p5 and part of the last
sentence of [temp.deduct.call]p1, both of which concern the
non-deducibility of parameter packs not at the end of a
parameter-type-list. The latter isn't fully implemented yet; see the
new FIXME.

llvm-svn: 123210
2011-01-11 01:52:23 +00:00
Michael J. Spencer e503f89b4b Replace all uses of PathV1::isDirectory with PathV2::fs::is_directory.
llvm-svn: 123208
2011-01-11 01:21:20 +00:00
Douglas Gregor 180dda9b6e Make sure that we parse a '>>' that closes two template argument lists
appropritely when there are no other template arguments.

llvm-svn: 123204
2011-01-11 00:45:18 +00:00
Douglas Gregor 94a32477fd When we're inside a functional cast, '>' is an operator. Fixes PR8912.
llvm-svn: 123201
2011-01-11 00:33:19 +00:00
Devang Patel bc47498973 Fix debug info for __block variable referenced outside of block.
llvm-svn: 123199
2011-01-11 00:30:27 +00:00
Douglas Gregor 8008ba75a5 Add testing for unexpanded parameter packs in all of the C++
expression kinds. This is (indirectly) a test verifying that the
recursive AST visitor is visiting the children of these expression
nodes.

llvm-svn: 123198
2011-01-11 00:27:36 +00:00
Rafael Espindola 0ee986c1f1 Add unnamed_addr to constructors and destructors.
llvm-svn: 123197
2011-01-11 00:26:26 +00:00
Bob Wilson bd4520b535 Move DefaultABIInfo::classifyReturnType where it belongs. No functional change.
llvm-svn: 123195
2011-01-10 23:54:17 +00:00
Matt Beaumont-Gay 2083ba400f Only traverse template argument locations if we actually have explicit
template arguments.

llvm-svn: 123194
2011-01-10 23:53:06 +00:00
Rafael Espindola b7f60e3474 Add unnamed_addr when creating artificial string globals. For example, in
static const char foo[] = "foo";
static const char *bar = "bar";

the global created to hold "bar" will have it, but foo will not.

llvm-svn: 123192
2011-01-10 22:34:03 +00:00
Douglas Gregor 48d2411597 Implement more of C++0x [temp.arg.explicit]p9, allowing extension of
pack expansions in template argument lists and function parameter
lists. The implementation of this paragraph should be complete
*except* for cases where we're substituting into one of the unexpanded
packs in a pack expansion; that's a general issue I haven't solved yet.

llvm-svn: 123188
2011-01-10 20:53:55 +00:00
Bob Wilson b39017ad19 Fix a comment typo.
llvm-svn: 123184
2011-01-10 18:23:55 +00:00
Bob Wilson ce3ee6539e NEON vector support for ARM is in pretty good shape now. Update the docs.
llvm-svn: 123183
2011-01-10 17:55:14 +00:00
Douglas Gregor b94a6177fc Repent for my copy-and-paste sins, factoring out the code that forms
argument packs from a set of deduced arguments, then checks that those
argument packs match previously-deduced argument packs.

llvm-svn: 123182
2011-01-10 17:53:52 +00:00
Douglas Gregor a8bd0d94f8 Factor out the code to set up template argument deduction for a set of
template argument packs. This also ensures that explicitly-specified
template arguments get properly represented in those cases.

llvm-svn: 123180
2011-01-10 17:35:05 +00:00
Zhongxing Xu b84ec97699 Remove dead code.
llvm-svn: 123168
2011-01-10 11:28:29 +00:00
Zhongxing Xu fb060c9014 Fix CMakeLists.txt.
llvm-svn: 123167
2011-01-10 09:33:41 +00:00
Zhongxing Xu 40c9d8a4c5 Revert r123160. There are linking dependency problems.
llvm-svn: 123166
2011-01-10 09:23:01 +00:00
Douglas Gregor a8bac7f514 Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:

template<class ... Types> void f(Types ... values);
void g() { 
  f<int*, float*>(0, 0, 0);   // Types is deduced to the sequence int*, float*, int
}

There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.

The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now. 

llvm-svn: 123163
2011-01-10 07:32:04 +00:00
Douglas Gregor eff85ad41b Unbreak the CMake build.
llvm-svn: 123162
2011-01-10 07:26:53 +00:00
Zhongxing Xu 7d4ab7d915 ExprEngine.cpp and AnalysisConsumer.cpp should not be in the Checkers directory.
llvm-svn: 123160
2011-01-10 05:52:42 +00:00
Zhongxing Xu 03f169ef71 Add some expression kinds to CheckerVisitor.def.
llvm-svn: 123159
2011-01-10 05:39:35 +00:00
Zhongxing Xu 5609e21337 In C++, assignment and compound assignment operators return an lvalue.
llvm-svn: 123158
2011-01-10 03:54:19 +00:00
Zhongxing Xu 0710f5c5e1 The isPrefix() checking is redundant. Lvalue incremental/decremental expressions
are all prefixes.

llvm-svn: 123156
2011-01-10 03:22:57 +00:00
Michael J. Spencer f6efe58d45 Replace all uses of PathV1::exists with PathV2::fs::exists.
llvm-svn: 123150
2011-01-10 02:34:13 +00:00
Zhongxing Xu 7042251985 Fix comment.
llvm-svn: 123147
2011-01-10 02:22:04 +00:00
Francois Pichet 96df71ad90 Don't crash if SpecString is an empty string.
llvm-svn: 123134
2011-01-09 22:32:25 +00:00
Benjamin Kramer 39f987ffd0 Make a helper function static.
llvm-svn: 123118
2011-01-09 13:21:33 +00:00
Alexis Hunt a50dd46ee8 Rename CXXCtorInitializer::BaseOrMember to Initializee, since it will also be
used to store the CXXConstructorDecl in a delegating constructor.

llvm-svn: 123095
2011-01-08 23:01:16 +00:00
Alexis Hunt 1d7926502f Renamed CXXBaseOrMemberInitializer to CXXCtorInitializer. This is both shorter,
more accurate, and makes it make sense for it to hold a delegating constructor
call.

llvm-svn: 123084
2011-01-08 20:30:50 +00:00
Alexis Hunt 4049b8d4cd Check for delegating constructors and (currently) return an error about them.
llvm-svn: 123076
2011-01-08 19:20:43 +00:00
Chandler Carruth b35635e942 Remove a kludge from analysis based warnings that used to detect
temporaries with no-return destructors. The CFG now properly supports
temporaries and implicit destructors which both makes this kludge no
longer work, and conveniently removes the need for it.

Turn on CFG handling of implicit destructors and initializers. Several
ad-hoc benchmarks don't indicate any measurable performance impact from
growing the CFG, and it fixes real correctness problems with warnings.

As a result of turning on these CFG elements, we started to tickle an
inf-loop in the unreachable code logic used for warnings. The fix is
trivial.

llvm-svn: 123056
2011-01-08 06:54:40 +00:00
Ted Kremenek bf4832cda8 Add semantic checking that the "thousands grouping"
prefix in a printf format string is matched
with the appropriate conversion specifier.

llvm-svn: 123055
2011-01-08 05:28:46 +00:00
Ted Kremenek a322cae011 Add printf format string parsing support for '
prefix to format conversions (POSIX extension).

llvm-svn: 123054
2011-01-08 05:28:38 +00:00
Eric Christopher 7d5f2ff6c9 Fix typo.
llvm-svn: 123041
2011-01-07 22:44:49 +00:00
Douglas Gregor b41e2d9298 Variadic templates example: a nearly-complete implementation of a TR1
function class template. 

llvm-svn: 123024
2011-01-07 19:56:20 +00:00
Ted Kremenek ef81e9e243 Fix crash in CFGBuilder on invalid code. We still need
to reject this code, but at least clang doesn't
crash anymore.

Crash reported in PR 8880.

llvm-svn: 123017
2011-01-07 19:37:16 +00:00
Douglas Gregor fe6e33a3c5 Variadic templates example: a nearly-complete implementation of a TR1
tuple class template. This implementation is boosted directly from the
variadic templates proposal. N2080.

Note that one section is #ifdef'd out. I'll implement that aspect of
template argument deduction next.

llvm-svn: 123016
2011-01-07 19:37:08 +00:00
Douglas Gregor 2cd32a0251 When instantiating the arguments to an initializer, use the
TreeTransform version of TransformExprs() rather than explicit loop,
so that we expand pack expansions properly. Test cast coming soon...

llvm-svn: 123014
2011-01-07 19:35:17 +00:00
Douglas Gregor 9f627df2f2 Fix a valgrind error when transforming function prototypes with
function parameter pack expansions.

llvm-svn: 123007
2011-01-07 19:27:47 +00:00
Roman Divacky 7e96295fb5 Use -check-prefix to make it clear the test is SVR4/DARWINPPC specific.
llvm-svn: 123005
2011-01-07 19:01:39 +00:00
Roman Divacky 1b805a0bc9 Drop the _darwin/_svr4 suffixes.
llvm-svn: 123004
2011-01-07 19:00:05 +00:00
Fariborz Jahanian 13f3b2f79b Update AST reader/writer to handle new AppleKext.
Fix an unexpected hickup caused by exceeding size of
generated table (and a misleading comment). Improve
on help message for -fapple-kext.

llvm-svn: 123003
2011-01-07 18:59:25 +00:00
Douglas Gregor f30101186f Implement substitution of a function parameter pack for its set of
instantiated function parameters, enabling instantiation of arbitrary
pack expansions involving function parameter packs. At this point, we
can now correctly compile a simple, variadic print() example:

  #include <iostream>
  #include <string>

  void print() {}

  template<typename Head, typename ...Tail>
  void print(const Head &head, const Tail &...tail) {
    std::cout << head;
    print(tail...);
  }

  int main() {
    std::string hello = "Hello";
    print(hello, ", world!", " ", 2011, '\n');
  }

llvm-svn: 123000
2011-01-07 16:43:16 +00:00
Francois Pichet 044f3d78f4 Prefix all attribute enumerators with attr_ for consistency.
llvm-svn: 122992
2011-01-07 03:17:31 +00:00
Francois Pichet a8fcc8d70b Do not use cdecl, fastcall, stdcall etc.. as identifier name. They are reserved keywords at least on MSVC.
llvm-svn: 122991
2011-01-07 02:58:13 +00:00
John McCall 1c926b78fe Rework a few things about how we emit ObjC's for enumeration statement.
In particular, the iteration variable (if present) should be created and
destroyed in a narrow span around the loop body, and the body should
be emitted in a cleanup scope in case it's not a compound statement.
Otherwise, rename a few variables and use phis instead of temporary
variables for the index and buffer count.

llvm-svn: 122988
2011-01-07 01:49:06 +00:00
Fariborz Jahanian a4cfff87b9 Add all options needed to support -fapple-kext. wip.
llvm-svn: 122987
2011-01-07 01:05:02 +00:00
Douglas Gregor dd47216cc4 Factor out the template transformation of a sequence of function
parameters into parameter types, so that substitution of
explicitly-specified function template arguments uses the same
path. This enables the use of explicitly-specified function template
arguments with variadic templates.

llvm-svn: 122986
2011-01-07 00:20:55 +00:00
Devang Patel c07c98f853 Add target triple.
llvm-svn: 122980
2011-01-06 22:30:05 +00:00
Douglas Gregor 7825bf3a12 Implement template argument deduction from a call to a function
template whose last parameter is a parameter pack. This allows us to
form a call to, e.g.,

  template<typename ...Args1, typename ...Args2>
  void f(std::pair<Args1, Args2> ...pairs);

given zero or more instances of "pair".

llvm-svn: 122973
2011-01-06 22:09:01 +00:00
Devang Patel 5df8acf809 test case for r122971.
llvm-svn: 122972
2011-01-06 21:40:22 +00:00
Fariborz Jahanian b5b7e9088b Put warning about makeing a string writable into
its own deprecated diagnostics group so it can be
turned off selectively. // rdar://8827606

llvm-svn: 122967
2011-01-06 18:45:19 +00:00
Bob Wilson 44acad8e60 Add cortex-m3 CPU to getCPUDefineSuffix mapping.
Patch by Sylvère Teissier.

llvm-svn: 122965
2011-01-06 16:57:20 +00:00
Abramo Bagnara 88cf54160f Added testcase for commit r122963.
llvm-svn: 122964
2011-01-06 16:56:00 +00:00
Roman Divacky 965b0b72b1 PowerPC fixes.
Fix the width and align of bool type on Darwin to be 32bits
while keeping it 8 everywhere else.

Change the definition of va_list to default to SV4 ABI one
and let darwin subtarget override this.

Both changes submitted by Nathan Whitehorn and reviewed
by Rafael Espindola.

llvm-svn: 122956
2011-01-06 08:27:10 +00:00
Chandler Carruth 080afea262 Tweak the wording of this warning further based on a suggestion from Chris.
llvm-svn: 122951
2011-01-06 06:29:28 +00:00
Chris Lattner 56f64c14b7 fix rdar://8823139, a crash on a comment in a preprocessed .s file
that contains the ## operator.

llvm-svn: 122946
2011-01-06 05:01:51 +00:00
John McCall 8190451ddc Introduce an AttributedType, but don't actually use it anywhere yet.
The initial TreeTransform is a cop-out, but it's more-or-less equivalent
to what we were doing before, or rather what we're doing now and might
eventually stop doing in favor of using this type.
I am simultaneously intrigued by the possibilities of rebuilding a
dependent Attri

llvm-svn: 122942
2011-01-06 01:58:22 +00:00
Jakob Stoklund Olesen 4072e59189 Clang should not warn on code in clang that is only there to remove warnings.
llvm-svn: 122941
2011-01-06 01:37:28 +00:00
Douglas Gregor df50b8448c When default-initializing a TemplateArgumentLocInfo, make sure that we
initialize *all* of the bits to zero. Also, when the pattern of a
template argument pack expansion, make sure to set the ellipsis
location along all paths.

This should clear up the valgrind failure that popped up in Clang.

llvm-svn: 122931
2011-01-06 00:33:28 +00:00
Douglas Gregor 86bea351a9 Fast-path an arity check when performing template argument deduction that compares two parameter-type-lists. No functionality change.
llvm-svn: 122928
2011-01-05 23:23:17 +00:00
Douglas Gregor f6272cd7e9 Eliminate an unnecessary dance where we tried to cope with the lack of
TypeSourceInfo when transforming a function parameter. The callees of
this routine already assume that TypeSourceInfo will be present, and
we want to always be sure that it exists.

llvm-svn: 122927
2011-01-05 23:16:57 +00:00
Douglas Gregor 5499af4ef9 Initial implementation of function parameter packs. This implementation allows:
1) Declaration of function parameter packs
  2) Instantiation of function parameter packs within function types.
  3) Template argument deduction of function parameter packs when
  matching two function types.

We're missing all of the important template-instantiation logic for
function template definitions, along with template argument deduction
from the argument list of a function call, so don't even think of
trying to use these for real yet.

llvm-svn: 122926
2011-01-05 23:12:31 +00:00
Douglas Gregor 5ddf182fd3 Fix an embarrassing think in the disambiguation logic for the ellipsis in a parameter-type-list
llvm-svn: 122924
2011-01-05 23:06:07 +00:00
Fariborz Jahanian a61f676cfe Don't warn on missing 'copy' attribute on a 'block'
property when it is 'readonly'. // rdar://8820813

llvm-svn: 122923
2011-01-05 23:00:04 +00:00
Douglas Gregor 9cc2782277 hasInit() -> hasDefaultArg()
llvm-svn: 122905
2011-01-05 21:14:17 +00:00
Douglas Gregor 3c6bd2ad38 Add Decl::isParameterPack(), which covers both function and template
parameter packs, along with ParmVarDecl::isParameterPack(), which
looks for function parameter packs. Use these routines to fix some
obvious FIXMEs.

llvm-svn: 122904
2011-01-05 21:11:38 +00:00
Douglas Gregor f491ee2ea6 Propagate the "deduced from array bound" bit when comparing deduced
template argument packs. Plus, remove a FIXME that I fixed yesterday.

llvm-svn: 122903
2011-01-05 21:00:53 +00:00
Douglas Gregor 51bc571955 When we're converting deduced template arguments to the type of the
corresponding template parameter, make sure that prior converted
template arguments are available for substitution.

llvm-svn: 122902
2011-01-05 20:52:18 +00:00
Argyrios Kyrtzidis 7a808c0f00 Use the proper enum as parameter, instead of unsigned. No functionality change.
llvm-svn: 122900
2011-01-05 20:09:36 +00:00
Douglas Gregor 79aaca42ac Eliminate two "unsupported" errors relating to variadic templates: one
for template template argument pack expansions (which was no longer
used) and another that was a placeholder for an llvm_unreachable.

llvm-svn: 122898
2011-01-05 19:06:29 +00:00
Douglas Gregor e4ff4b56fe Replace the representation of template template argument pack
expansions with something that is easier to use correctly: a new
template argment kind, rather than a bit on an existing kind. Update
all of the switch statements that deal with template arguments, fixing
a few latent bugs in the process. I"m happy with this representation,
now.

And, oh look! Template instantiation and deduction work for template
template argument pack expansions.

llvm-svn: 122896
2011-01-05 18:58:31 +00:00
Chris Lattner 63c41a2458 fix a -Wself-assign warning
llvm-svn: 122894
2011-01-05 18:41:53 +00:00
Douglas Gregor eb29d18e5d Add semantic analysis for the creation of and an AST representation
for template template argument pack expansions. This allows fun such
as: 

  template<template<class> class ...> struct apply_impl { /*...*/ };
  template<template<class> class ...Metafunctions> struct apply {
    typedef typename apply_impl<Metafunctions...>::type type;
  };

However, neither template argument deduction nor template
instantiation is implemented for template template argument packs, so
this functionality isn't useful yet.

I'll probably replace the encoding of template template
argument pack expansions in TemplateArgument so that it's harder to
accidentally forget about the expansion. However, this is a step in
the right general direction.

llvm-svn: 122890
2011-01-05 17:40:24 +00:00
Douglas Gregor e9a8035962 Parse template template argument pack expansions. They're still not
implemented, however.

llvm-svn: 122888
2011-01-05 17:33:50 +00:00
Douglas Gregor 7dba51f8f8 Update C++ [temp.param]p11 citation to reflect the changes in C++0x. No functionality change
llvm-svn: 122878
2011-01-05 16:21:17 +00:00
Douglas Gregor 0018cdc105 Implement C++0x [temp.param]p11 for non-type and template template
parameter packs. Also, the "no template parameters after a template
parameter pack" rule only applies to primary class templates.

llvm-svn: 122877
2011-01-05 16:19:19 +00:00
Douglas Gregor cdc62c938a Implement proper parameter pack matching for non-type template
parameters and template template parameters.

llvm-svn: 122875
2011-01-05 16:01:49 +00:00
Douglas Gregor f550077ef5 Implement support for template template parameter packs, e.g.,
template<template<class> class ...Metafunctions>
    struct apply_to_each;

llvm-svn: 122874
2011-01-05 15:48:55 +00:00
John McCall 8aea3e1876 Fix the -Asserts build.
llvm-svn: 122872
2011-01-05 12:34:30 +00:00
John McCall 3882ace207 Refactor the application of type attributes so that attributes from
the declaration-specifiers and on the declarator itself are moved
to the appropriate declarator chunk.  This permits a greatly
simplified model for how to apply these attributes, as well as
allowing a much more efficient query for the GC attribute.
Now all qualifier queries follow the same basic strategy of
"local qualifiers, local qualifiers on the canonical type,
then look through arrays".  This can be easily optimized by
changing the canonical qualified-array-type representation.

Do not process type attributes as decl attributes on declarations
with declarators.

When computing the type of a block, synthesize a prototype
function declarator chunk if the decl-spec type was not a
function.  This simplifies the logic for building block signatures.

Change the logic which inserts an objc_read_weak on a block
literal to only fire if the block has a __weak __block variable,
rather than if the return type of the block is __weak qualified,
which is not actually a sensible thing to ask.

llvm-svn: 122871
2011-01-05 12:14:39 +00:00
Douglas Gregor 78edf99f46 Use Parser::ExpectAndConsume() uniformly to eat semicolons after
Objective-C declarations and statements. Fixes
<rdar://problem/8814576> (wrong source line for diagnostics about
missing ';'), and now we actually consume the ';' at the end of a
@compatibility_alias directive!

llvm-svn: 122855
2011-01-05 01:10:06 +00:00
Douglas Gregor 66990031e2 Many of the built-in operator candidates introduced into overload
resolution require that the pointed-to type be an object type, but we
weren't filtering out non-object types. Do so, fixing PR7851.

llvm-svn: 122853
2011-01-05 00:13:17 +00:00
Douglas Gregor f8a7912633 Eliminate some completely useless code that attempted to perform some
conversions on the substituted non-type template arguments of a class
template partial specialization. C++ [temp.class.spec]p8 actually
prohibits all of the cases where this code would have fired.

Hey, it's better than having to deal with variadic templates here!

llvm-svn: 122852
2011-01-04 23:42:36 +00:00
Douglas Gregor ca4686dc38 Improve our handling of non-type template parameters in partial
specializations. We weren't dealing with any of the cases where the
type of the non-type template argument differs from the type of the
corresponding template parameter in the primary template. We would
think that the template parameter in the partial specialization was
not deducible (and warn about it, incorrectly), then fail to convert a
deduced parameter to the type of the template parameter in the partial
specialization (which may involve truncation, among other
things). Fixes PR8905.

llvm-svn: 122851
2011-01-04 23:35:54 +00:00
Douglas Gregor 4234eb23b3 Tweak test for portability
llvm-svn: 122850
2011-01-04 22:41:29 +00:00
Douglas Gregor 61d841372a Remove an unnecessary FIXME for variadic templates
llvm-svn: 122848
2011-01-04 22:26:51 +00:00
Douglas Gregor aef93f292f Minor cleanups for template argument deduction in the presence of
variadic templates. No functionality change.

llvm-svn: 122847
2011-01-04 22:23:38 +00:00
Matt Beaumont-Gay 7237c4c4a6 Fix wording for err_invalid_use_of_bound_member_func
llvm-svn: 122846
2011-01-04 22:22:07 +00:00
Douglas Gregor ad6edc1eef Simplistic test case for mangling of variadic templates. There is more to be done in this area
llvm-svn: 122845
2011-01-04 22:16:00 +00:00
Douglas Gregor aaa6a908ac Improve the checking of deduced template arguments stored within template argument packs when finishing template argument deduction for a function template
llvm-svn: 122843
2011-01-04 22:13:36 +00:00
Fariborz Jahanian 3aa19e9a70 Fold -fobjc-nonfragile-abi2 into -fobjc-nonfragile-abi.
// rdar://8818375

llvm-svn: 122831
2011-01-04 20:05:20 +00:00
Marshall Clow 0caac444fa Test commit; added blank line to TODO.txt
llvm-svn: 122824
2011-01-04 19:19:20 +00:00
Douglas Gregor be63bbfd24 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.

llvm-svn: 122820
2011-01-04 18:56:13 +00:00
Douglas Gregor 35c7e84eb7 There is nothing interesting to analyze with a sizeof...(pack) expression
llvm-svn: 122818
2011-01-04 18:46:34 +00:00
Douglas Gregor 820ba7ba43 Implement the sizeof...(pack) expression to compute the length of a
parameter pack.

Note that we're missing proper libclang support for the new
SizeOfPackExpr expression node.

llvm-svn: 122813
2011-01-04 17:33:58 +00:00
Abramo Bagnara ba85497ae4 Prefer getAs<ComplexType> rather than cast<ComplexType> on canonical type. Suggestion by Douglas Gregor!
llvm-svn: 122807
2011-01-04 09:50:03 +00:00
Chandler Carruth e0cee6a8b0 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.

llvm-svn: 122804
2011-01-04 06:52:15 +00:00
Chandler Carruth a92409c3ec 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.

llvm-svn: 122802
2011-01-04 04:44:35 +00:00
Douglas Gregor 857591143e 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.

llvm-svn: 122799
2011-01-04 02:33:52 +00:00
Douglas Gregor 44e7df67d9 Implement pack expansion of base initializers, so that we can
initialize those lovely mixins that come from pack expansions of base
specifiers.

llvm-svn: 122793
2011-01-04 00:32:56 +00:00
Argyrios Kyrtzidis bd9dfb2e29 Rename MaybeSkipFunctionBodyForCodeCompletion -> trySkippingFunctionBodyForCodeCompletion and check isCodeCompletionEnabled() before doing the call.
Suggestions by Chris.

llvm-svn: 122792
2011-01-04 00:27:27 +00:00
Argyrios Kyrtzidis cd12b63b47 Fix 80 column violation.
llvm-svn: 122784
2011-01-03 23:15:14 +00:00
Douglas Gregor 752a595655 Implement pack expansions whose pattern is a base-specifier.
llvm-svn: 122782
2011-01-03 22:36:02 +00:00
Argyrios Kyrtzidis d5756a609d When in code-completion, skip obj-c method bodies for speed up.
llvm-svn: 122781
2011-01-03 22:33:06 +00:00
Douglas Gregor 7ec835f35b Add a test that is currently failing
llvm-svn: 122780
2011-01-03 21:56:22 +00:00
Douglas Gregor 98318c2259 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.

llvm-svn: 122776
2011-01-03 21:37:45 +00:00
Douglas Gregor 875b6fe364 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.

llvm-svn: 122774
2011-01-03 21:13:47 +00:00
Douglas Gregor 1440693c50 Diagnose the presence of unexpanded parameter packs within class
template partial specialization arguments.

llvm-svn: 122769
2011-01-03 20:35:03 +00:00
Argyrios Kyrtzidis a8636f1b3e Remove a couple of setters that have no callers.
llvm-svn: 122766
2011-01-03 19:52:51 +00:00
Argyrios Kyrtzidis 76dbe8c800 Speed up code-completion by skipping function bodies.
When we are in code-completion mode, skip parsing of all function bodies except the one where the
code-completion point resides.

For big .cpp files like 'SemaExpr.cpp' the improvement makes a huge difference, in some cases cutting down
code-completion time -62% !

We don't get diagnostics for the bodies though, so modify the code-completion tests that check for errors.

See rdar://8814203.

llvm-svn: 122765
2011-01-03 19:44:02 +00:00
Douglas Gregor 968f23ab97 Implement support for pack expansions in initializer lists and
expression lists.

llvm-svn: 122764
2011-01-03 19:31:53 +00:00
Chandler Carruth 8e666510f6 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.

llvm-svn: 122763
2011-01-03 19:27:19 +00:00
Fariborz Jahanian 9a7d57d57f Consider zero-length array of structs when
computing ivar layouts for objc-gc.
Fixes // rdar://8800513

llvm-svn: 122762
2011-01-03 19:23:18 +00:00
Douglas Gregor a3efea1881 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. 

No functionality change.

llvm-svn: 122761
2011-01-03 19:04:46 +00:00
Fariborz Jahanian c63f1c5ab6 Guard lazy synthesis of provisional ivars under the new
-fobjc-default-synthesize-properties flag.

llvm-svn: 122757
2011-01-03 18:08:02 +00:00
Argyrios Kyrtzidis 7cd69249fa 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.

llvm-svn: 122756
2011-01-03 17:57:40 +00:00
Chandler Carruth 540960f4a2 Fix PR8654, ensuring each branch of an #if, #elif, #else, ... chain
receives a PPCallback.

Patch by Richard Smith.

llvm-svn: 122755
2011-01-03 17:40:17 +00:00
David Greene 7b29345ff3 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.

llvm-svn: 122753
2011-01-03 17:28:52 +00:00
Douglas Gregor fdfd41375a Another variadic template metafunction test case: summing values.
llvm-svn: 122752
2011-01-03 17:25:02 +00:00
Douglas Gregor e8e9dd624c Implement support for pack expansions whose pattern is a non-type
template argument (described by an expression, of course). For
example:

  template<int...> struct int_tuple { };

  template<int ...Values>
  struct square {
    typedef int_tuple<(Values*Values)...> type;
  };

It also lays the foundation for pack expansions in an initializer-list.
  

llvm-svn: 122751
2011-01-03 17:17:50 +00:00