Commit Graph

19137 Commits

Author SHA1 Message Date
Adrian Prantl adaeb8947a Simplify testcase.
rdar://problem/14386148

llvm-svn: 186901
2013-07-23 00:21:48 +00:00
Eli Bendersky aefa5e2ff2 Add a -fno-math-builtin option to the Clang -cc1
llvm-svn: 186899
2013-07-23 00:13:01 +00:00
Fariborz Jahanian 9e543afe19 ObjectiveC migration. Better handle migration to conforming
protocols by ignoring cases where all protocol properties
and methods are optional.

llvm-svn: 186895
2013-07-22 23:50:04 +00:00
Adrian Prantl 52f5b2502f Debug Info: Acknowledge the alignment when locating byref block variables.
Fixes rdar://problem/14386148

llvm-svn: 186894
2013-07-22 23:44:26 +00:00
Eli Friedman d1eec9cc96 Testcase for PR16673.
llvm-svn: 186891
2013-07-22 23:30:13 +00:00
Enea Zaffanella c7cb48c4b9 Fixed implementation of C89 6.5.7 p3.
Warning should be emitted only for InitListExpr nodes.

llvm-svn: 186859
2013-07-22 19:10:20 +00:00
Fariborz Jahanian d0f6f79f4e Objective-C migration: Use NS_OPTIONS when enumerators
have shift/bitwise operators or are power of 2.

llvm-svn: 186856
2013-07-22 18:53:45 +00:00
Argyrios Kyrtzidis ec852d908f [arcmt] Only disable ARC in the second compilation if there were actually ARC errors in the checking phase.
rdar://14490204

llvm-svn: 186850
2013-07-22 18:13:54 +00:00
Richard Smith ccf0151b71 Add testcase for PR16134, which no longer crashes with ToT.
llvm-svn: 186849
2013-07-22 18:09:32 +00:00
Aaron Ballman bf5cf8c6ea This test was missing its -verify argument.
llvm-svn: 186847
2013-07-22 17:55:04 +00:00
Reid Kleckner e7de47efbe [ms-cxxabi] Emit linkonce complete dtors in TUs that need them
Based on Peter Collingbourne's destructor patches.

Prior to this change, clang was considering ?1 to be the complete
destructor and the base destructor, which was wrong.  This lead to
crashes when clang tried to emit two LLVM functions with the same name.

In this ABI, TUs with non-inline dtors might not emit a complete
destructor.  They are emitted as inline thunks in TUs that need them,
and they always delegate to the base dtors of the complete class and its
virtual bases.  This change uses the DeferredDecls machinery to emit
complete dtors as needed.

Currently in clang try body destructors can catch exceptions thrown by
virtual base destructors.  In the Microsoft C++ ABI, clang may not have
the destructor definition, in which case clang won't wrap the virtual
virtual base destructor calls in a try-catch.  Diagnosing this in user
code is TODO.

Finally, for classes that don't use virtual inheritance, MSVC always
calls the base destructor (?1) directly.  This is a useful code size
optimization that avoids emitting lots of extra thunks or aliases.
Implementing it also means our existing tests continue to pass, and is
consistent with MSVC's output.

We can do the same for Itanium by tweaking GetAddrOfCXXDestructor, but
it will require further testing.

Reviewers: rjmccall

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1066

llvm-svn: 186828
2013-07-22 13:51:44 +00:00
Enea Zaffanella 1aac546d31 Implement the part of C89 6.5.7 p3 requiring a constant initializer list
when initializing aggregate/union types, no matter if static or not.

llvm-svn: 186817
2013-07-22 10:58:26 +00:00
Richard Smith 35828f1db6 PR16288: A template is only missing a default template argument if it provides
any default template arguments, not if it inherits some.

llvm-svn: 186804
2013-07-22 03:31:14 +00:00
Richard Smith bc46e4341e Implement DR257 / fix PR16659:
A constructor for an abstract class does not call constructors for virtual
  base classes, so it is not an error if no initializer is present for the
  virtual base and the virtual base cannot be default initialized.

Also provide a (disabled by default, for now) warning for the case where a
virtual base class's initializer is ignored in an abstract class's constructor,
and address a defect in DR257 where it was not carried through to C++11's rules
for implicit deletion of special member functions.

Based on a patch by Maurice Bos.

llvm-svn: 186803
2013-07-22 02:56:56 +00:00
Richard Smith 4e155170e8 Test updates missed from r186799.
llvm-svn: 186800
2013-07-21 23:13:17 +00:00
Richard Smith 8d0dc31dca Tighten up the set of operator new/operator delete calls we're permitted to
optimize, to follow the permissions granted in N3664. Under those rules, only
calls generated by new-expressions and delete-expressions are permitted to be
optimized, and direct calls to ::operator new and ::operator delete must be
treated as normal calls.

llvm-svn: 186799
2013-07-21 23:12:18 +00:00
Lubos Lunak 1f490f3aea report unused-value warning also for warn_unused types
llvm-svn: 186793
2013-07-21 13:15:58 +00:00
Richard Smith 72d74057ea Add missing check for creating an instance of an abstract class through an
implicit conversion sequence.

llvm-svn: 186769
2013-07-20 19:41:36 +00:00
Richard Smith 070a5d6750 Undisable a test for a c++98-compat warning for inheriting constructors now that we implement them.
llvm-svn: 186768
2013-07-20 19:22:08 +00:00
Lubos Lunak edc138880d add type attribute warn_unused, for -Wunused-variable warnings (pr#14253)
The functionality is equivalent to the GCC attribute. Variables of tagged
types will be warned about as unused if they are not used in any way
except for possible (even non-trivial) ctors/dtors called. Useful for tagging
classes like std::string (which is not part of this commit).

llvm-svn: 186765
2013-07-20 15:05:36 +00:00
Lubos Lunak ba5ee4da1d avoid bogus warnings about "unknown" pragmas with -frewrite-includes (pr#14831)
llvm-svn: 186764
2013-07-20 14:30:01 +00:00
Lubos Lunak 4c22f6a695 fix sometimes incorrect line numbers in -frewrite-includes mode (pr#14795)
Every #include is surrounded by #if 0 in order to comment it out, which adds
lines. That is fixed up right after, but that all can be inside #if part
that is not processed, so fix up also after every end of a conditional part.

llvm-svn: 186763
2013-07-20 14:23:27 +00:00
Richard Trieu 8ed6f2aacf If a default argument is a dependent type, get the real type from the desugared
template.  Passing around dependent types can lead to integral arguments that
cannot be evaluated.

llvm-svn: 186757
2013-07-20 03:49:02 +00:00
Eli Friedman a54333264a Fix bug in computing POD-for-layout.
A class with a field of non-POD-for-layout type is not POD-for-layout.
This computation should not depend on whether the field is of POD type
in the language sense.

Fixes PR16537.

Patch by Josh Magee.

llvm-svn: 186741
2013-07-20 01:06:31 +00:00
Eli Friedman 75807f239e Make IgnoreParens() look through ChooseExprs.
This is the same way GenericSelectionExpr works, and it's generally a
more consistent approach.

A large part of this patch is devoted to caching the value of the condition
of a ChooseExpr; it's needed to avoid threading an ASTContext into
IgnoreParens().

Fixes <rdar://problem/14438917>.

llvm-svn: 186738
2013-07-20 00:40:58 +00:00
Larisse Voufo 98b20f1278 FIXME fix: improving diagnostics for template arguments deduction of class templates and explicit specializations
This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info.

llvm-svn: 186730
2013-07-19 23:00:19 +00:00
Larisse Voufo 47c0845e0b Revert "Use function overloading instead of template specialization for diagnosis of bad template argument deductions."
This reverts commit a730f548325756d050d4caaa28fcbffdae8dfe95.

llvm-svn: 186729
2013-07-19 22:53:23 +00:00
Eli Friedman fa163749c7 Fix pack instantiation with function types.
Make sure we correctly expand packs which expand to another
pack in a function type.

llvm-svn: 186728
2013-07-19 22:50:29 +00:00
Larisse Voufo 8d33da6d58 Use function overloading instead of template specialization for diagnosis of bad template argument deductions.
llvm-svn: 186727
2013-07-19 22:34:32 +00:00
Hans Wennborg e4b031ca03 Add a cl.exe compatible driver mode
The mode doesn't actually do anything yet, but this provides a
way to get into it.

llvm-svn: 186720
2013-07-19 20:33:20 +00:00
Reid Kleckner 673d81b8c7 Use an i686 triple for this test now that it uses stdcall
There seems to be a crash here if we have a calling convention attribute
that gets ignored and then we instantiate templates.

llvm-svn: 186719
2013-07-19 20:32:18 +00:00
Jean-Daniel Dupas 06028a5454 Fix another place where clang check objc selector name instead of checking the selector family
Summary: In ARC mode, clang emits a warning if the result of an 'init' method is unused but miss cases where the method does not follows the Cocoa naming convention but is properly declared as an init family method.

CC: cfe-commits, eli.friedman

Differential Revision: http://llvm-reviews.chandlerc.com/D1163

llvm-svn: 186718
2013-07-19 20:25:56 +00:00
Fariborz Jahanian c1c44f62bc ObjectiveC migrator: Another use case of enum
declaration which can be migrated to NS_ENUM.

llvm-svn: 186716
2013-07-19 20:18:36 +00:00
Reid Kleckner 569b8f83a4 Create calling convention AttributedType sugar nodes
Canonical types are unchanged.  The type printer had to be changed to
avoid printing any non-default implicit calling convention as well as
the calling convention attribute.

Reviewers: rjmccall

Differential Revision: http://llvm-reviews.chandlerc.com/D1132

llvm-svn: 186714
2013-07-19 19:51:03 +00:00
Eli Friedman 8917ad5d1f Fix for template substitution with packs.
When we see a pack, and replace it with a template argument which is
also a pack, we want to use the pack pattern, not the expanded pack.
The caller should take care of expanding the pack afterwards.

Fixes PR16646.

llvm-svn: 186713
2013-07-19 19:40:38 +00:00
Akira Hatanaka 0aa60efe9c [mips] Add support for command-line options -mno-check-zero-division and
-mcheck-zero-division.

llvm-svn: 186710
2013-07-19 18:58:48 +00:00
Argyrios Kyrtzidis 47b1517c52 [arcmt] After checking is successful disable auto-synthesize to avoid "@synthesize of 'weak' property is only
allowed in ARC" errors.

rdar://14461559

llvm-svn: 186709
2013-07-19 18:57:15 +00:00
Benjamin Kramer 875356ade3 Fix test to actually check things.
llvm-svn: 186701
2013-07-19 17:49:21 +00:00
Fariborz Jahanian 008ef72bee Fixes an ObjC migrator crash when last decl
in file is an enum.

llvm-svn: 186700
2013-07-19 17:44:32 +00:00
Richard Sandiford 4652d893bc [SystemZ] Add -march= command-line option
llvm-svn: 186694
2013-07-19 16:51:51 +00:00
Richard Sandiford 896f8db0bd [SystemZ] Enable frame-pointer elimination for -O1 and above
Copies the x86 behavior.

llvm-svn: 186674
2013-07-19 14:06:49 +00:00
Alexey Bataev 5ec3eb11fc OpenMP: basic support for #pragma omp parallel
llvm-svn: 186647
2013-07-19 03:13:43 +00:00
Fariborz Jahanian b0057bb4fc ObjectiveC migrator: add support to migrate to
NS_OPTIONS.

llvm-svn: 186641
2013-07-19 01:05:49 +00:00
Eli Friedman 7a2eca0f0f Fix crash-on-invalid with inheriting constructor.
Fixes PR16656.

llvm-svn: 186631
2013-07-18 23:59:50 +00:00
Eli Friedman ebea0f29e2 Clean up diagnostics for inheriting constructors.
No new diagnostics, just better wording and notes pointing at more
relevant locations.

llvm-svn: 186629
2013-07-18 23:29:14 +00:00
Alexander Kornienko a49732ff28 Added -lines X:Y option to specify line range to process. This is a more human-friendly alternative to -offset and -length.
Differential Revision: http://llvm-reviews.chandlerc.com/D1160

llvm-svn: 186625
2013-07-18 22:54:56 +00:00
Fariborz Jahanian 85e988bbea ObjectiveC migrator: Remove semicolon after the typedef
declaration when converting to NS_ENUM. This required
some code refactoring.

llvm-svn: 186619
2013-07-18 22:17:33 +00:00
Hans Wennborg 70850d83dc Turn Driver::CCCIsCXX and CCCIsCPP into a single Mode enum,
and add a new option --driver-mode= to control it explicitly.

The CCCIsCXX and CCCIsCPP flags were non-overlapping, i.e. there
are currently really three modes that Clang can run in: gcc, g++
or cpp, so it makes sense to represent them as an enum.

Having a command line flag to control it helps testing.

llvm-svn: 186605
2013-07-18 20:29:38 +00:00
Fariborz Jahanian 92463274e6 ObjectiveC migration. migration to NS_ENUM/SN_OPTION
- wip.

llvm-svn: 186604
2013-07-18 20:11:45 +00:00
Reid Kleckner 61b23b7edc [Driver] Use LLVM's response file parser because it can read UTF-16
MSBuild writes response files as UTF-16 little endian with a byte order
mark.  With this change, clang will be able to read them, although we
still can't parse any of their flags.

Adds a UTF-16-LE response file with a BOM for testing.

Differential Revision: http://llvm-reviews.chandlerc.com/D1137

llvm-svn: 186603
2013-07-18 20:00:53 +00:00
Aaron Ballman d7b6459f80 Test contents were somehow duplicated, resulting in any testcase that fails automatically failing twice. Removing the duplicates.
llvm-svn: 186590
2013-07-18 17:41:26 +00:00
Aaron Ballman f90ccb082b Replacing a morally duplicate diagnostic by adding it to an existing diagnostic's select list. Updates the tests for the more consistent diagnostic.
llvm-svn: 186584
2013-07-18 14:56:42 +00:00
Manuel Klimek be0474c047 Fix crash in libclang if code completion is used with unknown flags.
Use CaptureDroppedDiagnostics to make sure that there is a diagnostic
client installed when warning flags are parsed.

llvm-svn: 186582
2013-07-18 14:23:12 +00:00
Aaron Ballman 8b8ebdd9dd Removed a parameter from handleAttrWithMessage to make it more consistent with other attribute handlers, as well as other attribute error messages. Added missing test cases for the unavailable attribute, and updated the deprecated test case.
llvm-svn: 186578
2013-07-18 13:13:52 +00:00
JF Bastien 2a0a476e74 Fix volatile _Complex alignment test on platforms where 64-bit floating point isn't 64-bit aligned
Add x86-64 triple, and check its datalayout. Also add some comments, and use the new CHECK-LABEL.

llvm-svn: 186564
2013-07-18 06:11:45 +00:00
Adrian Prantl 01eb2a53c7 Don't generate bogus line table entries for __copy_helper_block_ and
__destroy_helper_block_, but do generate scope information.

llvm-svn: 186553
2013-07-18 00:28:05 +00:00
Richard Smith 6401768ac4 Reinstate r186040, with additional fixes and more test coverage (reverted in
r186331).

Original commit log:
  If we friend a declaration twice, that should not make it visible to
  name lookup in the surrounding context. Slightly rework how we handle
  friend declarations to inherit the visibility of the prior
  declaration, rather than setting a friend declaration to be visible
  whenever there was a prior declaration.

llvm-svn: 186546
2013-07-17 23:53:16 +00:00
Reid Kleckner 736bc98f9c MS wide bitfield error check in Sema
cl.exe treats wide bitfields as an error. This patch causes them to be
an error if IsMsStruct is true, as it is in straight C.

Patch by Warren Hunt!

Reviewers: eli.friedman

Differential Revision: http://llvm-reviews.chandlerc.com/D1125

llvm-svn: 186536
2013-07-17 20:46:03 +00:00
Jean-Daniel Dupas 3965574929 Improve idiomatic-parentheses by checking method family instead of relying on the selector name.
llvm-svn: 186524
2013-07-17 18:17:14 +00:00
Jordan Rose 5f6c173e7c [analyzer] Handle C++11 member initializer expressions.
Previously, we would simply abort the path when we saw a default member
initialization; now, we actually attempt to evaluate it. Like default
arguments, the contents of these expressions are not actually part of the
current function, so we fall back to constant evaluation.

llvm-svn: 186521
2013-07-17 17:16:42 +00:00
Jordan Rose 5fded08403 [analyzer] Handle C string default values for const char * arguments.
Previously, SValBuilder knew how to evaluate StringLiterals, but couldn't
handle an array-to-pointer decay for constant values. Additionally,
RegionStore was being too strict about loading from an array, refusing to
return a 'char' value from a 'const char' array. Both of these have been
fixed.

llvm-svn: 186520
2013-07-17 17:16:38 +00:00
Jordan Rose 05b2f98d89 [analyzer] Treat std::initializer_list as opaque rather than aborting.
Previously, the use of a std::initializer_list (actually, a
CXXStdInitializerListExpr) would cause the analyzer to give up on the rest
of the path. Now, it just uses an opaque symbolic value for the
initializer_list and continues on.

At some point in the future we can add proper support for initializer_list,
with access to the elements in the InitListExpr.

<rdar://problem/14340207>

llvm-svn: 186519
2013-07-17 17:16:33 +00:00
Timur Iskhodzhanov 633f59d126 Replace TEST* with CHECK-DAG in vbtable tests
llvm-svn: 186502
2013-07-17 12:23:51 +00:00
Pavel Labath 9ced602cc6 [analyzer] Add very limited support for temporary destructors
Summary:
This patch enables ExprEndgine to reason about temporary object destructors.
However, these destructor calls are never inlined, since this feature is still
broken. Still, this is sufficient to properly handle noreturn temporary
destructors and close bug #15599. I have also enabled the cfg-temporary-dtors
analyzer option by default.

Reviewers: jordan_rose

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1131

llvm-svn: 186498
2013-07-17 08:33:58 +00:00
NAKAMURA Takumi 39eb51e89a clang/test/CodeGen/volatile-complex.c: Loosen CHECKs for -Asserts.
llvm-svn: 186492
2013-07-17 06:39:40 +00:00
JF Bastien 27dcbb24e5 Propagate alignment for _Complex
_Complex load/store didn't have their alignment set properly, which was visible when GCC's torture tests use volatile _Complex.

Update some existing tests to check for alignment, and add a new test which also has over-aligned volatile _Complex (since the imaginary part shouldn't be overaligned, only the real part).

llvm-svn: 186490
2013-07-17 05:57:42 +00:00
Fariborz Jahanian cb7b8deecb ObjectiveC migrator: When adding conforming protocol,
only add outer-most conforming protocols as adding
others are redundant.

llvm-svn: 186473
2013-07-17 00:02:22 +00:00
Eli Friedman 4c27ac2348 Make Expr::isConstantInitializer match IRGen.
Sema needs to be able to accurately determine what will be
emitted as a constant initializer and what will not, so
we get accurate errors in C and accurate -Wglobal-constructors
warnings in C++.  This makes Expr::isConstantInitializer match
CGExprConstant as closely as possible.

llvm-svn: 186464
2013-07-16 22:40:53 +00:00
Fariborz Jahanian 2bc3dda186 ObjectiveC migrator. If a class implements a protocol's
properties, then class conforms to that protocol.

llvm-svn: 186460
2013-07-16 21:59:42 +00:00
Eli Friedman 64f2391899 Fix crash on complex constant zero.
Fixes <rdar://problem/14442543>.

llvm-svn: 186452
2013-07-16 20:19:04 +00:00
Fariborz Jahanian 3eb3159816 ObjectiveC migration: complete migrating class
declaration to include list of protocols class
conforms to. 

llvm-svn: 186443
2013-07-16 18:58:41 +00:00
Hans Wennborg ddef2e6c82 FileCheckize test/Driver/immediate-options.c
llvm-svn: 186438
2013-07-16 18:27:29 +00:00
Tim Northover e0482760fc Fix test on release builds.
Unfortunately I don't think there's a good way to validate branch targets on
release builds. Fortunately it's a minor part of this test (and based on
generic code) so I don't mind dropping it.

llvm-svn: 186398
2013-07-16 10:22:19 +00:00
Tim Northover 6aacd49094 ARM: implement low-level intrinsics for the atomic exclusive operations.
This adds three overloaded intrinsics to Clang:
    T __builtin_arm_ldrex(const volatile T *addr)
    int __builtin_arm_strex(T val, volatile T *addr)
    void __builtin_arm_clrex()

The intent is that these do what users would expect when given most sensible
types. Currently, "sensible" translates to ints, floats and pointers.

llvm-svn: 186394
2013-07-16 09:47:53 +00:00
Serge Pavlov dfdb731967 Limit number of bits in size representation so that bit size fit 64 bits.
This fixes PR8256 and some others.

llvm-svn: 186385
2013-07-16 07:14:18 +00:00
Eli Friedman e7b8aa9417 Merge attributes on typedef decls.
Not completely sure this is right, but it's clearly better than what
we did before this commit (effectively dropping the attribute).

<rdar://problem/14413117>

llvm-svn: 186373
2013-07-16 02:07:49 +00:00
Eli Friedman 69d27d2d05 Fix alignment of class derived from empty class.
The record layout code didn't properly take into account that
an empty class at offset 0 can have an alignment greater than 1.

Patch by Andrea Di Biagio.

llvm-svn: 186370
2013-07-16 00:21:28 +00:00
Eli Friedman cccd06487d Fix member refs with using decl + anonymous union.
Make sure we call BuildFieldReferenceExpr with the appropriate decl
when a member of an anonymous union is made public with a using decl.
Also, fix a crash on invalid field access into an anonymous union.

Fixes PR16630.

llvm-svn: 186367
2013-07-16 00:01:31 +00:00
David Blaikie f168f582a5 Test case for r18266 (serialization support for TagDecl:IsCompleteDefinitionRequired)
llvm-svn: 186351
2013-07-15 21:33:26 +00:00
Kaelyn Uhrain 786928dbd2 Fix a typo in the diagnostic note added in r186342.
llvm-svn: 186348
2013-07-15 21:18:33 +00:00
Kaelyn Uhrain bad7fb09b2 Move the "->" to "." fixit from r186128 into a separate note since
recovery is not attempted with the fixit. Also move the associated test
case from FixIt/fixit.cpp to SemaCXX/member-expr.cpp since the fixit is
no longer automatically applied.

llvm-svn: 186342
2013-07-15 19:54:54 +00:00
Chandler Carruth 9324d169bd Re-revert r86040, which was un-reverted in r186199.
This breaks the build of basic patterns with repeated friend
declarations. See the added test case in SemaCXX/friend.cpp or the test
case reported to the original commit log.

Original commit log:
  If we friend a declaration twice, that should not make it visible to
  name lookup in the surrounding context. Slightly rework how we handle
  friend declarations to inherit the visibility of the prior
  declaration, rather than setting a friend declaration to be visible
  whenever there was a prior declaration.

llvm-svn: 186331
2013-07-15 17:27:42 +00:00
Serge Pavlov 7cd8f6020f Fix to PR12262 - assertion when substituting explicit template arguments
does not substitute a sizeof-pack expression.
The solution is proposed by Richard Smith.
Differential Revision: http://llvm-reviews.chandlerc.com/D869

llvm-svn: 186306
2013-07-15 06:14:07 +00:00
Richard Smith 8d304d5c73 Make these tests more robust against IRgen choosing to emit more named metadata.
llvm-svn: 186279
2013-07-14 06:18:38 +00:00
Richard Smith 3460dbbaf6 Delete a test that is checking badly for a point bug that Clang never had (and that spuriously fails with modules enabled).
llvm-svn: 186278
2013-07-14 06:17:03 +00:00
Richard Smith 42713d763f If an unimported submodule of an imported module contains a declaration of a
global allocation or deallocation function, that should not cause that global
allocation or deallocation function to become unavailable.

llvm-svn: 186270
2013-07-14 02:01:48 +00:00
David Blaikie 48ad6dc463 PR16214, PR14467: DebugInfo: use "RequireCompleteType" to decide when to emit the full definition of a type in -flimit-debug-info
This simplifies the core benefit of -flimit-debug-info by taking a more
systematic approach to avoid emitting debug info definitions for types
that only require declarations. The previous ad-hoc approach (3 cases
removed in this patch) had many holes.

The general approach (adding a bit to TagDecl and callback through
ASTConsumer) has been discussed with Richard Smith - though always open
to revision.

llvm-svn: 186262
2013-07-13 21:08:14 +00:00
David Blaikie 66ed89d07f Correctly classify pack expansions as NON_CANONICAL_UNLESS_DEPENDENT
Test coverage for non-dependent pack expansions doesn't demonstrate a
failure prior to this patch (a follow-up commit improving debug info
will cover this commit specifically) but covers a related hole in our
test coverage.

Reviewed by Richard Smith & Eli Friedman.

llvm-svn: 186261
2013-07-13 21:08:08 +00:00
Richard Smith 95d99308c4 C++ modules: Don't call DeclContext::lookup when half-way through deserializing
decls. That can reenter deserialization and explode horribly by trying to merge
a declaration that we've not got very far through deserializing yet.

llvm-svn: 186236
2013-07-13 02:00:19 +00:00
Reid Kleckner c16c44714b [ms-cxxabi] Don't consider function templates for name backrefs
They don't seem to be used for back references, presumably because a
function template is unlikely to reoccur, while a class template name
may reoccur as a type.

This fixes a mangling issue for llvm::hash_combine() in Hashing.h.

Reviewers: timurrrr

Differential Revision: http://llvm-reviews.chandlerc.com/D1078

llvm-svn: 186233
2013-07-13 00:43:39 +00:00
Argyrios Kyrtzidis 8ade08edba Changes so that a few tests do not fail when running under guarded malloc.
Guarded malloc emits some messages at the beginning in stderr when enabled.
These messages caused a few tests to fail.

llvm-svn: 186219
2013-07-12 22:30:03 +00:00
Eli Friedman c6036aa831 Compute 'this' correctly for block in lambda.
Using CurFuncDecl is both correct and simple compared to crawling
the DeclContexts of the block.

Fixes <rdar://problem/14415072>.

llvm-svn: 186210
2013-07-12 22:05:26 +00:00
Kaelyn Uhrain 638264ea2a Provide a better diagnostic and a fixit for a '.' or '->' before the left paren
of a function call.

This fixes PR5898 and means we now have a better diagnostic here than GCC.

llvm-svn: 186208
2013-07-12 21:43:02 +00:00
Richard Smith 141942fcca Unrevert r186040, reverted in r186185, with fix for PR16597.
Original commit log:
  If we friend a declaration twice, that should not make it visible to
  name lookup in the surrounding context. Slightly rework how we handle
  friend declarations to inherit the visibility of the prior
  declaration, rather than setting a friend declaration to be visible
  whenever there was a prior declaration.

llvm-svn: 186199
2013-07-12 20:38:49 +00:00
Chandler Carruth 9bdd1bb403 Revert r186040 to fix PR16597 while Richard investigates what the best
fix is.

Original commit log:
  If we friend a declaration twice, that should not make it visible to
  name lookup in the surrounding context. Slightly rework how we handle
  friend declarations to inherit the visibility of the prior
  declaration, rather than setting a friend declaration to be visible
  whenever there was a prior declaration.

llvm-svn: 186185
2013-07-12 18:54:40 +00:00
Anna Zaks c30e0d759d [analyzer] Treat nullPtrType as a location type.
Fixes PR16584 (radar://14415223).

llvm-svn: 186172
2013-07-12 17:58:33 +00:00
Fariborz Jahanian 88890e7b50 Objective-C: Produce gcc compatible encoding of
ivar type in meta-data while preventing recursive
encoding in a corner case. // rdar://14408244

llvm-svn: 186169
2013-07-12 16:19:11 +00:00
Jordan Rose 78cd51b2ee [analyzer] Add support for __builtin_addressof.
...so we don't regress on std::addressof.

llvm-svn: 186140
2013-07-12 00:26:14 +00:00
Eli Friedman 84c0143ea0 Fix crash on zero-argument assignment operator.
Make sure we don't crash when checking whether an assignment operator
without any arguments is a special member.  <rdar://problem/14397774>.

llvm-svn: 186137
2013-07-11 23:55:07 +00:00
David Dean 9b9c78a929 Add the ability to use guarded malloc when running clang's lit tests.
llvm-svn: 186135
2013-07-11 23:37:50 +00:00
Kaelyn Uhrain 1bb5dbf628 Provide a fixit hint for changing '->' to '.' if there is no operator->
defined for a class.

llvm-svn: 186128
2013-07-11 22:38:30 +00:00
Eli Friedman a0e6a7fcd8 Make CXXBaseSpecifier::getType return unqual type.
Various pieces of code, like base initialization in Sema and RTTI IRGen,
don't properly ignore qualifiers on base classes.  Instead of auditing the
whole codebase, just strip them off in the getter.  (The type as written is
still available in the TypeSourceInfo for code that cares.)

Fixes PR16596.

llvm-svn: 186125
2013-07-11 22:22:22 +00:00
Fariborz Jahanian 14e9541916 Restore warning to its original text when
certain familiy of methods have the wrong type.
// rdar://14408244

llvm-svn: 186111
2013-07-11 19:13:34 +00:00
Fariborz Jahanian b248ca5548 ObjectiveC arc[qoi]: When due to change of certain methods'
result type, a diagnostic being issued, issue a 'note' 
mentioning reason behind the unexpected warning.
// rdar://14121570.

llvm-svn: 186105
2013-07-11 16:48:06 +00:00
Richard Smith 9ce302ed9c PR5066: If a declarator cannot have an identifier, and cannot possibly be
followed by an identifier, then diagnose an identifier as being a bogus part of
the declarator instead of tripping over it. Improves diagnostics for cases like

  std::vector<const int *p> my_vec;

llvm-svn: 186061
2013-07-11 05:10:21 +00:00
NAKAMURA Takumi d704cb755f clang/test/CodeGen/c11atomics.c: Fix testcase for -Asserts since r186054.
llvm-svn: 186055
2013-07-11 03:45:54 +00:00
Richard Smith 6cbd65d84d Add a __builtin_addressof that performs the same functionality as the built-in
& operator (ignoring any overloaded operator& for the type). The purpose of
this builtin is for use in std::addressof, to allow it to be made constexpr;
the existing implementation technique (reinterpret_cast to some reference type,
take address, reinterpert_cast back) does not permit this because
reinterpret_cast between reference types is not permitted in a constant
expression in C++11 onwards.

llvm-svn: 186053
2013-07-11 02:27:57 +00:00
Eli Friedman be4504df26 Simplify atomic load/store IRGen.
Also fixes a couple minor bugs along the way; see testcases.

llvm-svn: 186049
2013-07-11 01:32:21 +00:00
Richard Smith 7a73449b31 If we friend a declaration twice, that should not make it visible to name
lookup in the surrounding context. Slightly rework how we handle friend
declarations to inherit the visibility of the prior declaration, rather
than setting a friend declaration to be visible whenever there was a prior
declaration.

llvm-svn: 186040
2013-07-10 22:04:13 +00:00
Fariborz Jahanian 56f48d09f8 ObjC migrator: Improve on hueristics.
migrate to 'copy attribute if Object
class implements NSCopying otherwise 
assume implied 'strong'. Remove 
lifetime qualifier on property as it has
moved to property's attribute. Added TODO
comment for future work by poking into
setter implementation.

llvm-svn: 186037
2013-07-10 21:30:22 +00:00
Jordan Rose 6444653a06 [analyzer] Remove bogus assert: in C++11, 'new' can do list-initialization.
Previously, we asserted that whenever 'new' did not include a constructor
call, the type must be a non-record type. In C++11, however, uniform
initialization syntax (braces) allow 'new' to construct records with
list-initialization: "new Point{1, 2}".

Removing this assertion should be perfectly safe; the code here matches
what VisitDeclStmt does for regions allocated on the stack.

<rdar://problem/14403437>

llvm-svn: 186028
2013-07-10 19:14:10 +00:00
Kaelyn Uhrain 8ec9f5f60e Offer typo suggestions for 'using' declarations.
Patch courtesy of Luke Zarko <zarko@google.com>

llvm-svn: 186019
2013-07-10 17:34:22 +00:00
Eli Friedman 0cd2335755 Finish off mangling locals in block literals.
Specifically, handle the case where the block is in a default argument
in a class method.  The mangling here follows what we do for lambdas.

llvm-svn: 185991
2013-07-10 01:33:19 +00:00
Eli Friedman 3b7d46c3ae More local mangling fixes.
Compute mangling numbers for externally visible local variables and tags.
Change the mangler to consistently use discriminators where necessary.
Tweak the scheme we use to number decls which are not externally visible
to avoid unnecessary discriminators in common cases now that we request
them more consistently.

Fixes <rdar://problem/14204721>.

llvm-svn: 185986
2013-07-10 00:30:46 +00:00
Fariborz Jahanian a830ea7431 objc migrator: More refinment of property
attributes in migration. Specialli use of
'copy' attribute for retainable object types.

llvm-svn: 185985
2013-07-10 00:20:11 +00:00
Fariborz Jahanian db4fc28145 Objective-C: merge objc_requires_super attribute of
method declaration into its implementation to
prevent a bogus warning about mismatched attributes.
then make sure the warning about missing call to super comes out
of the method implementation. // rdar://14251387

llvm-svn: 185974
2013-07-09 22:02:20 +00:00
Adrian Prantl 7278788ffe Reapply an improved version of r180816/180817.
Do not generate VLAs as complex variables any more, as they are now
correctly represented as breg+0 locations in the backend.

(Paired commit with LLVM: r185966)

rdar://problem/13658587

llvm-svn: 185967
2013-07-09 20:29:03 +00:00
Fariborz Jahanian d83ef848bd ObjC migrator: Add -objcmt-migrate-property to do property
migration. Also, fixes an old bug where older migration 
flags were not being checked for properly.

llvm-svn: 185948
2013-07-09 16:59:14 +00:00
Anna Zaks e0ad10404d [analyzer] Fixup for r185609: actually do suppress warnings coming out of std::list.
list is the name of a class, not a namespace. Change the test as well - the previous
version did not test properly.

Fixes radar://14317928.

llvm-svn: 185898
2013-07-09 01:55:00 +00:00
Eli Friedman 999af7bf6e Fix recovery for missing * in objc property.
<rdar://problem/14354144>

llvm-svn: 185897
2013-07-09 01:38:07 +00:00
Richard Smith 701a3523ba Don't give # and ## special treatment when in -traditional-cpp mode. Patch by
Austin Seipp!

llvm-svn: 185896
2013-07-09 01:00:29 +00:00
Richard Smith baf2912b40 Generalize hack allowing 'const' in __has_attribute (etc) to allow any token
with identifier info. This covers most identifier-like entities (other than
the ISO646 keywords).

llvm-svn: 185895
2013-07-09 00:57:56 +00:00
Eli Friedman 544c956b72 Fix crash typo-correcting dependent member func.
PR16561.

llvm-svn: 185887
2013-07-08 23:35:04 +00:00
Fariborz Jahanian e61c907792 ObjC migration: more test for migration to
properties.

llvm-svn: 185884
2013-07-08 23:29:51 +00:00
Kaelyn Uhrain 476c823ec8 Attempt typo correction for function calls with the wrong number of arguments.
Combined with typo correction's new ability to apply global/absolute nested
name specifiers to possible corrections, cases such as in PR12287 where the
desired function is being shadowed by a lexically closer function with the
same name but a different number of parameters will now include a FixIt.

On a side note, since the test for this change caused
test/SemaCXX/typo-correction.cpp to exceed the typo correction limit for
a single file, I've included a test case for exceeding the limit and added
some comments to both the original and part two of typo-correction.cpp
warning future editors of the files about the limit.

llvm-svn: 185881
2013-07-08 23:13:44 +00:00
Fariborz Jahanian 7ac20e1031 ObjC migration: Skip over setter/getter with attributes
for now. 

llvm-svn: 185879
2013-07-08 22:49:25 +00:00
Fariborz Jahanian bfaabe40e7 [Objective-C migrator] replace candidate user setter/getter with
their equivalent property declaration. wip.

llvm-svn: 185873
2013-07-08 21:42:08 +00:00
Eli Friedman e6d3395d78 Fix Sema for compares with _Atomic vars.
Use UsualArithmeticConversions unconditionally in analysis of
comparisons and conditional operators: the method performs
the usual arithmetic conversions if both sides are arithmetic, and
usual unary conversions if they are not.  This is just a cleanup
for conditional operators; for comparisons, it fixes the issue that
we would try to check isArithmetic() on an atomic type.

Also, fix GetExprRange() in SemaChecking.cpp so it deals with variables
of atomic type correctly.

Fixes PR15537.

llvm-svn: 185857
2013-07-08 20:20:06 +00:00
NAKAMURA Takumi 270bca5dc9 clang/test/Index/comment-custom-block-command.cpp: This has not been failing since r175892 on valgrind.
That said, it fails with --vg-leak. Mark it as XFAIL: vg_leak instead.

llvm-svn: 185809
2013-07-08 12:00:29 +00:00
NAKAMURA Takumi c7fa08d5eb clang/test/Misc/permissions.cpp: Suppress this on MSYS with the feature 'shell-preserves-root'.
FIXME: Could we introduce another feature for it?
llvm-svn: 185797
2013-07-08 06:45:16 +00:00
NAKAMURA Takumi 9250b05696 clang/test/CodeGen/2008-01-25-ByValReadNone.c: Add explicit -triple x86_64-unknown-unknown.
It would emit @llvm.memcpy with "-triple x86_64-(mingw32|win32)" and had been failing since Nick's r185735.

  ; Function Attrs: nounwind
  declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #1

llvm-svn: 185796
2013-07-08 06:38:51 +00:00
David Majnemer ea5092a3b0 Sema: Do not merge new decls with invalid, old decls
Sema::MergeFunctionDecl attempts merging two decls even if the old decl
is invalid.  This can lead to interesting circumstances where we
successfully merge the decls but the result makes no sense.

Take the following for example:

template <typename T>
int main(void);

int main(void);

Sema will not consider these to be overloads of the same name because
main can't be overloaded, which means that this must be a redeclaration.

In this case the templated decl is compatible with the non-templated
decl allowing the Sema::CheckFunctionDeclaration machinery to move on
and do bizarre things like setting the previous decl of a non-templated
decl to a templated decl!

The way I see it, we should just bail from MergeFunctionDecl if the old
decl is invalid.

This fixes PR16531.

llvm-svn: 185779
2013-07-07 23:49:50 +00:00
Richard Smith 7a22921e5a Rename test to match C++1y paragraph number per N3690, and add additional test
case inspired by a stackoverflow question.

llvm-svn: 185772
2013-07-07 06:15:42 +00:00
Fariborz Jahanian ae26bb67f8 Objective-C: Warn when fast enumeration variable isn't used.
// rdar://14182680.

llvm-svn: 185762
2013-07-06 18:04:13 +00:00
David Majnemer 027f9c4026 Sema: Fix a crash when main is redeclared as a function-template.
This boils down to us sending invalid function decls to
CheckFunctionDeclaration becauswe we did not consider that CheckMain
could cause the decl to be invalid.  Instead, interogate the new decl's
main-validity and *then* send it over to get CheckFunctionDeclaration'd
if it was still valid after calling CheckMain.

llvm-svn: 185745
2013-07-06 02:13:46 +00:00
Nick Lewycky 02df2062c6 Update test for change in r185735.
llvm-svn: 185736
2013-07-06 00:30:27 +00:00
Fariborz Jahanian e8545dde7b Remove referece type onproperty of abstract
class type. // rdar://14261999

llvm-svn: 185734
2013-07-05 23:50:55 +00:00
Rafael Espindola 18627115f4 Use llvm::sys::fs::createUniqueFile.
Include a test that clang now produces output files with permissions matching
the umask.

llvm-svn: 185727
2013-07-05 21:13:58 +00:00
Argyrios Kyrtzidis 7b50fc520f [libclang] Introduce clang_Cursor_isObjCOptional, which returns whether the declaration was affected by "@optional"
rdar://14348525.

llvm-svn: 185722
2013-07-05 20:44:37 +00:00
Eli Friedman 86af13f0ab Fix regression from r185450.
As it turns out, the NoFunction bit for local class mangling needed to be
propagated into more places. r185450 turned what used to be an incorrect
mangling into an assertion.

llvm-svn: 185713
2013-07-05 18:41:30 +00:00
Fariborz Jahanian 873bae79ac Objective-C: diagnose when synthesizing an ivar of
abstract class type. // rdar://14261999

llvm-svn: 185710
2013-07-05 17:18:11 +00:00
Benjamin Kramer f5d46005b6 Add a test case for r185707/PR16547.
llvm-svn: 185708
2013-07-05 15:51:00 +00:00
Rafael Espindola c8c995a2bd Use the new --crash option in commands that are expected to crash.
llvm-svn: 185679
2013-07-05 02:53:30 +00:00
Roman Divacky 4575c64f9d Add test for r185584.
llvm-svn: 185668
2013-07-04 21:29:24 +00:00
Rafael Espindola 5c6c707e53 Require a shell for this test.
Some versions of python will expand the glob used in the test, others wont,
causing the test to fail when run with LIT_USE_INTERNAL_SHELL=1.

llvm-svn: 185653
2013-07-04 16:23:44 +00:00
Rafael Espindola 925213b0fa Add 'not' to commands that are expected to fail.
This is at least good documentation, but also opens the possibility of
using pipefail.

llvm-svn: 185652
2013-07-04 16:16:58 +00:00
Rafael Espindola 76e202c7b8 Looks like {{.*}} doesn't match the empty string. Fix test.
llvm-svn: 185650
2013-07-04 15:29:20 +00:00
Rafael Espindola 7ac579a3f8 Relax pattern to accept a signext on ppc64.
llvm-svn: 185649
2013-07-04 15:25:05 +00:00
Rafael Espindola be8a91b771 Replace 'grep foo | count 0' with 'not grep foo'.
This avoids depending on pipefail not being used.

llvm-svn: 185648
2013-07-04 15:22:16 +00:00
Rafael Espindola 0cf7c93849 Remove test for the old debug format which was XFAILed since 2009.
llvm-svn: 185647
2013-07-04 15:14:31 +00:00