Commit Graph

3984 Commits

Author SHA1 Message Date
Douglas Gregor c65e1598ad A non-explicit constructor template with a second parameter that is a
parameter pack is a converting constructor. Fixes PR13003.

llvm-svn: 158040
2012-06-05 23:44:51 +00:00
Richard Smith 50fba8f0a9 PR13022: cope with parenthesized function types in MS name mangling.
llvm-svn: 157959
2012-06-04 22:46:59 +00:00
Richard Smith eb3cad53e7 Add a warning for when an array-to-pointer decay is performed on an array
temporary or an array subobject of a class temporary, and the resulting value
is used to initialize a pointer which outlives the temporary. Such a pointer
is always left dangling after the initialization completes and the array's
lifetime ends.

In order to detect this situation, this change also adds an
LValueClassification of LV_ArrayTemporary for temporaries of array type which
aren't subobjects of class temporaries. These occur in C++11 T{...} and GNU C++
(T){...} expressions, when T is an array type. Previously we treated the former
as a generic prvalue and the latter as a class temporary.

llvm-svn: 157955
2012-06-04 22:27:30 +00:00
Argyrios Kyrtzidis 6310fdd982 [objcmt] Don't migrate to subscripting syntax if the required methods have not
been declared on NSArray/NSDictionary.

rdar://11581975

llvm-svn: 157951
2012-06-04 21:23:26 +00:00
Benjamin Kramer 474261af7b Fix typos found by http://github.com/lyda/misspell-check
llvm-svn: 157886
2012-06-02 10:20:41 +00:00
Charles Davis e8ccc1134b Use fewer temporaries mangling APSInt objects. The performance difference
is negligible, but it makes the code clearer. Based on a suggestion by
Jordy Rose.

llvm-svn: 157601
2012-05-29 07:01:45 +00:00
Charles Davis 6770dea704 Fix mangling of integral template arguments between 1 and 10. Add a test case
for this. Reported by Timur Iskhodzhanov.

llvm-svn: 157583
2012-05-28 16:53:33 +00:00
Charles Davis ee855f06e7 Fix Lang's fix. This should fix the tests for +Asserts builds.
llvm-svn: 157561
2012-05-28 03:54:22 +00:00
Benjamin Kramer ea388a2832 PR12962: Fix a rare use after free when collecting virtual overrides.
The DenseMap reallocates after 64 insertions so this only happened in
large test cases under very specific circumstances.

llvm-svn: 157549
2012-05-27 22:41:08 +00:00
Lang Hames 6ccb51130e Fix call to APSInt constructor - it doesn't take an initial value, just a
bitwidth and signedness. Also rename the variable to reflect its purpose.

No test case - discovered during random code exploration.

llvm-svn: 157547
2012-05-27 21:39:49 +00:00
Charles Davis 5511dfb399 Mangle template instantiations properly (as of VC 7.x) when compiling for
the Microsoft Visual C++ ABI. Currently limited to type and integral
non-type arguments. Based on a patch by Timur Iskhodzhanov!

llvm-svn: 157524
2012-05-26 23:12:19 +00:00
Rafael Espindola 67a498cc5f Don't ignore linkage when ignoring visibility in the instantiation of a
method template.

llvm-svn: 157486
2012-05-25 17:22:33 +00:00
Rafael Espindola 340941dc16 Don't ignore linkage when ignoring visibility in the instantiation of a
function template.

llvm-svn: 157480
2012-05-25 16:41:35 +00:00
Rafael Espindola a28bf63d9a Consider the linkage for member class templates even when we have to ignore
the visibility.

llvm-svn: 157475
2012-05-25 15:51:26 +00:00
Rafael Espindola 0cf10ac9ab When ignoring visibility in an instantiation, still consider the linkage.
Similar fixes for function and member template to follow as I write the
testcases.

llvm-svn: 157470
2012-05-25 14:47:05 +00:00
Rafael Espindola 4d71d0f9fa Whitespace fixes.
llvm-svn: 157469
2012-05-25 14:17:45 +00:00
Eli Friedman f92f6454ef A minor tweak to the new volatile lvalue warning: don't warn on "(void)x", where "x" refers to a local variable. This should silence a useless warning in compiler-rt and other places.
llvm-svn: 157414
2012-05-24 21:05:41 +00:00
Eli Friedman c11535c248 Add a warning to diagnose statements in C++ like "*(volatile int*)x;". Conceptually, this is part of -Wunused-value, but I added a separate flag -Wunused-volatile-lvalue so it doesn't get turned off by accident with -Wno-unused-value. I also made a few minor improvements to existing unused value warnings in the process. <rdar://problem/11516811>.
llvm-svn: 157362
2012-05-24 00:47:05 +00:00
Richard Smith 01ade177e9 If the first argument of __builtin_object_size can be folded to a constant
pointer, but such folding encounters side-effects, ignore the side-effects
rather than performing them at runtime: CodeGen generates wrong code for
__builtin_object_size in that case.

llvm-svn: 157310
2012-05-23 04:13:20 +00:00
Rafael Espindola 96dcb8d4bb Function template version of the previous patch.
llvm-svn: 157207
2012-05-21 20:31:27 +00:00
Rafael Espindola 93c289c28a Produce a hidden symbol for zed in
struct HIDDEN foo {
  };
  template <class P>
  struct bar {
  };
  template <>
  struct HIDDEN bar<foo> {
    DEFAULT static void zed();
  };
  void bar<foo>::zed() {
  }

Before we would produce a hidden symbol in

  struct HIDDEN foo {
  };
  template <class P>
  struct bar {
  };
  template <>
  struct bar<foo> {
    DEFAULT static void zed();
  };
  void bar<foo>::zed() {
  }

But adding HIDDEN to the specialization would cause us to produce a default
symbol.

llvm-svn: 157206
2012-05-21 20:15:56 +00:00
Peter Collingbourne f44bdf9c5f CUDA: add CodeGen support for global variable address spaces.
Because in CUDA types do not have associated address spaces,
globals are declared in their "native" address space, and accessed
by bitcasting the pointer to address space 0.  This relies on address
space 0 being a unified address space.

llvm-svn: 157167
2012-05-20 21:08:35 +00:00
Dmitri Gribenko 898cff0bbd Use RecordDecl::field_iterator because D1, D2 are RecordDecls. No functional change.
llvm-svn: 157119
2012-05-19 17:17:26 +00:00
Benjamin Kramer 1458c1c009 Simplify some users of DeclarationName::getNameKind. Fold getFETokenInfoAsVoid into its only caller.
llvm-svn: 157116
2012-05-19 16:03:58 +00:00
Abramo Bagnara e1decdf68a Added two missing const qualifiers.
llvm-svn: 156988
2012-05-17 12:44:05 +00:00
Rafael Espindola 96e6824c31 Fix the visibility of instantiations of static data members.
Fixes pr12835.

llvm-svn: 156897
2012-05-16 02:10:38 +00:00
Argyrios Kyrtzidis 7bd957c12a [objcmt] Rewrite messages to NSString's stringWithUTF8String:/stringWithCString:
to use the @() boxing syntax.

It will also rewrite uses of stringWithCString:encoding: where the encoding that is
used is NSASCIIStringEncoding or NSUTF8StringEncoding.

rdar://11438360

llvm-svn: 156868
2012-05-15 22:22:10 +00:00
Rafael Espindola 7f90b7d4c2 Fix our handling of visibility in explicit template instantiations.
* Don't copy the visibility attribute during instantiations. We have to be able
  to distinguish

 struct HIDDEN foo {};
 template<class T>
 DEFAULT void bar() {}
 template DEFAULT void bar<foo>();

from

 struct HIDDEN foo {};
 template<class T>
 DEFAULT void bar() {}
 template void bar<foo>();

* If an instantiation has an attribute, it takes precedence over an attribute
  in the template.

* With instantiation attributes handled with the above logic, we can now
  select the minimum visibility when looking at template arguments.

llvm-svn: 156821
2012-05-15 14:09:55 +00:00
John McCall 8b3f5ffb0a Change the mangling of a ref-qualifier on a function type so that
it is placed in a position which is never ambiguous with a
reference-to-function type.  This follows some recent discussion
and ensuing proposal on cxx-abi-dev.  It is not necessary to
change the mangling of CV-qualifiers because you cannot
apply CV-qualification in the normal sense to a function type.
It is not necessary to change the mangling of ref-qualifiers on
method declarations because they appear in an unambiguous
location.

In addition, mangle CV-qualifiers and ref-qualifiers on function
types when they occur in positions other than member pointers
(that is, when they appear as template arguments).

This is a minor ABI break with previous releases of clang.  It
is not considered critical because (1) ref-qualifiers are
relatively rare, since AFAIK we're the only implementing compiler,
and (2) they're particularly likely to come up in contexts that
do not rely on the ODR for correctness.  We apologize for any
inconvenience;  this is the right thing to do.

llvm-svn: 156794
2012-05-15 02:01:59 +00:00
Argyrios Kyrtzidis 45f5118248 The Lexer constructor expects a source location at the start of the
file buffer, not at the start of lexing.

Fixes assertion hit in format diagnostics. rdar://11418366

llvm-svn: 156647
2012-05-11 21:39:18 +00:00
Argyrios Kyrtzidis 6062da47b8 [objc] When boxing a BOOL/NSInteger/NSUInteger type, use the corresponding
numberWithBool:/numberWithInteger:/numberWithUnsignedInteger: NSNumber selectors.

rdar://11428703

llvm-svn: 156583
2012-05-10 23:12:03 +00:00
Argyrios Kyrtzidis 9dd40890e3 When AST-dumping the ObjCBoxedExpr node, also print out what selector it chose.
llvm-svn: 156564
2012-05-10 20:02:31 +00:00
Richard Smith e2648bac3a A union can have a constexpr defaulted default constructor, if it has an
in-class initializer for one of its fields. Value-initialization of such
a type should use the in-class initializer!

The former was just a bug, the latter is a (reported) standard defect.

llvm-svn: 156274
2012-05-07 01:07:30 +00:00
Richard Smith 99fdf8d418 A conversion operator in a base class shouldn't hide another conversion operator
in the same class, even if they convert to the same type. Fixes PR12712.

llvm-svn: 156247
2012-05-06 00:04:32 +00:00
Argyrios Kyrtzidis a18347eddb Use raw_ostream in TypePrinter and eliminate uses of temporary std::strings.
Part of rdar://10796159

llvm-svn: 156228
2012-05-05 04:20:37 +00:00
Argyrios Kyrtzidis bbff3da622 Make BuiltinType::getName return a StringRef and introduce BuiltinType::getNameAsCString
to get a const char* if necessary.

This avoids unnecessary conversions when we want to use the result of getName as
a StringRef.

Part of rdar://10796159

llvm-svn: 156227
2012-05-05 04:20:28 +00:00
Douglas Gregor 93a586fa90 Synchronize the representations of DeclarationName and Selector so
that bridging between the two is free. Saves ~4k of code size,
although I don't see any measurable performance difference
(unfortunately).

llvm-svn: 156187
2012-05-04 18:24:37 +00:00
James Molloy 3636554b63 Fix handling of wint_t - we can't assume wint_t is purely an integer promotion of wchar_t - they may differ in signedness.
Teach ASTContext about WIntType, and have it taken from TargetInfo like WCharType. Should fix test/Sema/format-strings.c for ARM, with the exception of one subtest which will fail if wint_t and wchar_t are the same size and wint_t is signed, wchar_t is unsigned.

There'll be a followup commit to fix that.

Reviewed by Chandler and Hans at http://llvm.org/reviews/r/8

llvm-svn: 156165
2012-05-04 10:55:22 +00:00
Chandler Carruth b41171b70b Fix non-deterministic iteration order when walking the specializations
of templates by using the newly introduce FoldingSetVector. This
preserves insertion order for all iteration of specializations.

I've also included a somewhat terrifying testcase that rapidly builds up
a large number of functions. This is enough that any system with ASLR
will have non-deterministic debug information generated for the test
case without the fix here as the debug information is generated in part
by walking these specializations.

llvm-svn: 156133
2012-05-03 23:49:05 +00:00
Douglas Gregor 1798cd797b Inline DenseMapInfo<clang::DeclarationName>::getHashValue() for a 0.4% speedup on <rdar://problem/11004361>
llvm-svn: 156129
2012-05-03 23:28:32 +00:00
Douglas Gregor 0da530562a Split DeclarationName::getFETokenInfoAsVoid() into hot/cold paths and
(trivially) make DeclContext::lookup()'s const version inlinable. Good
for 0.3% on <rdar://problem/11004361>.

llvm-svn: 156126
2012-05-03 23:18:44 +00:00
David Blaikie c0f5866169 Correctly constify clang::CXXMemberCallExpr::getRecordDecl()
llvm-svn: 156074
2012-05-03 16:25:49 +00:00
Argyrios Kyrtzidis 5f20a7e02e Utilize getLocStart()/getLocEnd() on my recent change.
llvm-svn: 155952
2012-05-01 22:19:11 +00:00
John McCall e42a336604 Add support for laying out vtordisps according to our current
working knowledge of the Microsoft ABI.  Based on a patch by
Dmitry Sokolov.

llvm-svn: 155905
2012-05-01 08:55:32 +00:00
John McCall 23dfaa1cef When mangling a synthetic function declaration, we might not have
type-source information for its parameters.  Don't crash when
mangling them in the MS C++ ABI.  Patch by Timur Iskhodzhanov!

llvm-svn: 155879
2012-05-01 02:33:44 +00:00
Douglas Gregor b52637051f Print inline for inline namespaces, from Faisal Vali
llvm-svn: 155875
2012-05-01 01:43:38 +00:00
John McCall d7bca7629c My first effort to do this more subtly failed, so elaborately
test for an invalid declaration at every single place in the
constant evaluator that's about to request a struct layout.

llvm-svn: 155868
2012-05-01 00:38:49 +00:00
Argyrios Kyrtzidis d8e076972f Store the source range of a CXXOperatorCallExpr in the Expr object instead of
calculating it recursively.

boost::assign::tuple_list_of uses the trick of chaining call operator expressions in order to declare a "list of tuples", e.g:
    std::vector<tuple> v = boost::assign::tuple_list_of(1, "foo")(2, "bar")(3, "qqq");

Due to CXXOperatorCallExpr calculating its source range recursively we would get
significant slowdowns with a large number of chained call operator expressions and the
potential for stack overflow.

rdar://11350116

llvm-svn: 155848
2012-04-30 22:12:22 +00:00
David Blaikie 2d7c57ec1d Remove the ref/value inconsistency in filter_decl_iterator.
filter_decl_iterator had a weird mismatch where both op* and op-> returned T*
making it difficult to generalize this filtering behavior into a reusable
library of any kind.

This change errs on the side of value, making op-> return T* and op* return
T&.

(reviewed by Richard Smith)

llvm-svn: 155808
2012-04-30 02:36:29 +00:00
Benjamin Kramer a81efed0be isCXX98PODType: Avoid dispatch on the language standard when recursing.
llvm-svn: 155758
2012-04-28 13:37:45 +00:00