Commit Graph

31676 Commits

Author SHA1 Message Date
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
Samuel Benzaquen b837248ad4 Add support for raw_ostream on the printing methods of Diagnostics.
Summary:
Add printToStream*(llvm::raw_ostream&) methods to Diagnostics, and reimplement everything based on streams instead of concatenating strings.
Also, fix some functions to start with lowercase to match the style guide.

Reviewers: klimek

CC: cfe-commits, revane

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

llvm-svn: 186715
2013-07-19 20:02:35 +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
Aaron Ballman db6d85ef92 Replace some existing type attribute diagnostics with a
single diagnostic that selects.  No functional changes intended.

llvm-svn: 186708
2013-07-19 18:53:44 +00:00
John Thompson cda95fe72c Add SourceRange to PPCallbacks::Defined callback.
llvm-svn: 186707
2013-07-19 18:50:04 +00:00
Enea Zaffanella 25723ce6fc Fix source range of implicitly instantiated friend declaration.
llvm-svn: 186702
2013-07-19 18:02:36 +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
Roman Divacky 4dcb5dbb53 This patch implements __get_cpuid_max() as an inline and __cpuid() and
__cpuid_count() as macros to be compatible with GCC's cpuid.h.  It also adds
bit_<foo> constants for the various feature bits as described in version 039
(May 2011) of Intel's SDM Volume 2 in the description of the CPUID
instruction.  The list of bit_<foo> constants is a bit exhaustive (GCC
doesn't do near this many).  More bits could be added from a newer version of
SDM if desired.

Patch by John Baldwin!

llvm-svn: 186696
2013-07-19 17:28:36 +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
Manuel Klimek 7a698519e8 Allow clang tools to display an overview when using the CommonOptionsParser.
Patch by Guillaume Papin.

llvm-svn: 186671
2013-07-19 12:20:59 +00:00
Timur Iskhodzhanov 03e8746f90 Simplify the CodeGenFunction::Build*Virtual*Call family of functions
llvm-svn: 186657
2013-07-19 08:14:45 +00:00
Craig Topper 61d01cc95e Remove trailing whitespace.
llvm-svn: 186652
2013-07-19 04:46:31 +00:00
Craig Topper ed1236d041 Remove unnecessary IsFirst variable from debug codde in GetDiagInfo.
llvm-svn: 186649
2013-07-19 03:59:51 +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
Jordan Rose e9c57229f9 [analyzer] Include analysis stack in crash traces.
Sample output:

0.     Program arguments: ...
1.     <eof> parser at end of file
2.     While analyzing stack:
       #0 void inlined()
       #1 void test()
3.     crash-trace.c:6:3: Error evaluating statement

llvm-svn: 186639
2013-07-19 00:59:08 +00:00
Eric Christopher 978c839315 Update createCompileUnit call for llvm changes.
llvm-svn: 186638
2013-07-19 00:51:58 +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
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 5937ec7502 Address -Wreorder warning in Driver.cpp
llvm-svn: 186617
2013-07-18 21:45:42 +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
Samuel Benzaquen a37bb8c01a Separate the notion of 'context' when recursing down in the parser and actual errors.
Summary:
Change how error messages are constructed and stored in Diagnostics.
Separate the notion of 'context' when recursing down in the parser and actual errors.
This will simplify adding some new features, like argument overloading and error recovery.

Reviewers: klimek

CC: cfe-commits, revane

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

llvm-svn: 186602
2013-07-18 19:47:59 +00:00
Aaron Ballman c2cbc66e7a Switching to use checkAttributeNumArgs for trivial cases. No functional changes intended.
llvm-svn: 186591
2013-07-18 18:01:48 +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
Daniel Jasper 998cabcff4 clang-format: Fix bad line break with pointers to members.
Before:
  void f() {
    (a->*
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(aaaa,
                                           bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
  }

After:
  void f() {
    (a->*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(
        aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
  }

Also add missing test case.

llvm-svn: 186583
2013-07-18 14:46:07 +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
Adrian Prantl b75016d299 s/BuiltinLocation/ArtificialLocation/
llvm-svn: 186557
2013-07-18 01:36:04 +00:00
Eric Christopher f8bc4d878c Instead of checking against some version of "isType()" go ahead and
use the conversion to bool to check if we've managed to get a type
that isn't default constructed - as we meant to in the first place.

llvm-svn: 186556
2013-07-18 00:52:50 +00:00
Adrian Prantl 593f10ed81 Fix a compile error caught by bb-chapuni.
llvm-svn: 186555
2013-07-18 00:47:12 +00:00
Adrian Prantl 9aab9002a6 Fix a compile error caught by bb-chapuni.
llvm-svn: 186554
2013-07-18 00:43:29 +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
Adrian Prantl 2e0637ff63 Replace llvm::DIBuilder::DisableDebugLocations() with two RAII interfaces
inspired by CodegenFunction::LexicalScope.
- NoLocation temporarily turns off debug locations altogether.
  This is useful for emitting instructions that should be
  counted towards the function prologue.
- BuiltinLocation temporarily switches to an artificial debug location
  that has a valid scope, but no line information. This is useful when
  emitting compiler-generated helper functions that have no source
  location associated with them.

llvm-svn: 186552
2013-07-18 00:28:02 +00:00
Adrian Prantl 02c0caa198 Clarified documentation.
llvm-svn: 186551
2013-07-18 00:27:59 +00:00
Adrian Prantl b1b3bfc068 Simplify logic by using the appropriate function.
llvm-svn: 186550
2013-07-18 00:27:56 +00:00
John Thompson b102856b0e Add condition expression result to if and elif callbacks.
llvm-svn: 186547
2013-07-18 00:00:36 +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
Eric Christopher ffdeb1eb03 80-column fixes.
llvm-svn: 186542
2013-07-17 22:52:53 +00:00
Robert Wilhelm 57c6711893 Even more code conformance.
llvm-svn: 186537
2013-07-17 21:14:35 +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
Daniel Jasper ee6d650f91 clang-format: Add space in corner case.
Before:
  SomeType s __attribute__((unused))(InitValue);
After:
  SomeType s __attribute__((unused)) (InitValue);

llvm-svn: 186535
2013-07-17 20:25:02 +00:00
David Blaikie 301fe5f69b Constify Replacements parameter to applyAllReplacements.
http://llvm-reviews.chandlerc.com/D1169

Patch by Guillaume Papin.

llvm-svn: 186526
2013-07-17 18:29:58 +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
NAKAMURA Takumi 3e7db845f7 SemaDeclCXX.cpp: Dissolve a ligature "fi" in comment.
llvm-svn: 186523
2013-07-17 17:57:52 +00:00
Enea Zaffanella c70b2519d5 Fixed source range of C++03 access declarations.
llvm-svn: 186522
2013-07-17 17:28:56 +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
Hans Wennborg fb624ce885 Option parsing tables: remove some unnecessary #defines
Also make some strings static and add missing #undef's

llvm-svn: 186518
2013-07-17 16:54:06 +00:00
Daniel Jasper c834c70986 Improve line breaking before multi-line strings.
The AlwaysBreakBeforeMultilineStrings rule does not really make sense
if it does not a column gain.

Before (in Google style):
  f(
      "aaaa"
      "bbbb");

After:
  f("aaaa"
    "bbbb");

llvm-svn: 186515
2013-07-17 15:38:19 +00:00
Samuel Benzaquen 21b3da0f93 Add TemplateArgument related matchers to the registry.
Summary:
Continue adding more matchers to the dynamic registry.
This time, we add TemplateArgument matchers.

Reviewers: klimek

CC: cfe-commits, revane

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

llvm-svn: 186514
2013-07-17 15:11:30 +00:00
Samuel Benzaquen 06e056c4d8 Add CXXCtorInitializer related matchers to the dynamic matcher registry.
Summary: Now that CXXCtorInitializer is already supported in ASTNodeKind, add CXXCtorInitializer matchers to the dynamic matcher registry.

Reviewers: klimek

CC: cfe-commits, revane

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

llvm-svn: 186508
2013-07-17 14:28:00 +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
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
Rafael Espindola a07f720a1b Use the simpler is_directory.
llvm-svn: 186487
2013-07-17 04:23:07 +00:00
Fariborz Jahanian dfb7687162 More code conformance.
llvm-svn: 186474
2013-07-17 00:05:08 +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
Alexander Kornienko 9404234241 Avoid breaking non-trailing block comments.
Motivating example:
// column limit ------------------->
void ffffffffffff(int aaaaaa /* test */);

Formatting before the patch:
void ffffffffffff(int aaaaaa /* test
                              */);

Formatting after the patch:
void
ffffffffffff(int aaaaaa /* test */);

llvm-svn: 186471
2013-07-16 23:47: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
Argyrios Kyrtzidis 884bee86a6 [arcmt] Remove some dead code.
Patch by Rafael Espíndola.

llvm-svn: 186462
2013-07-16 22:24:06 +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
Alexander Kornienko 657c67b164 Don't break line comments with escaped newlines.
Summary:
These can appear when comments contain command lines with quoted line
breaks. As the text (including escaped newlines and '//' from consecutive lines)
is a single line comment, we used to break it even when it didn't exceed column
limit. This is a temporary solution, in the future we may want to support this
case completely - at least adjust leading whitespace when changing indentation
of the first line.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 186456
2013-07-16 21:06:13 +00:00
Daniel Jasper 8369aa5e12 clang-format: Improve handling of unterminated string literals.
Before, clang-format would simply eat these as they were recognized as
whitespace. With this patch, they are mostly left alone.

llvm-svn: 186454
2013-07-16 20:28:33 +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
Rafael Espindola 16125fb652 Update for llvm API change.
llvm-svn: 186448
2013-07-16 19:44:23 +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
Craig Topper f59ba9f545 Fix formatting. No functional change.
llvm-svn: 186437
2013-07-16 18:27:27 +00:00
Daniel Jasper 6ab5468637 Revamp the formatting of C++11 braced init lists.
The fundamental concept is:
Format as if the braced init list was a function call (with parentheses
replaced by braces). If there is no name/type before the opening brace
(e.g. if the braced list is nested), assume a zero-length identifier
just before the opening brace.

This behavior is gated on a new style flag, which for now replaces the
SpacesInBracedLists style flag. Activate this style flag for Google
style to reflect recent style guide changes.

llvm-svn: 186433
2013-07-16 18:22:10 +00:00
Samuel Benzaquen 0dbabb52a4 Add more types to ASTNodeKind. Refactor common instantiation code.
Summary:
Add support for CXXCtorInitializer and TemplateArgument types to ASTNodeKind.
This change is to support more matchers from clang/ASTMatchers/ASTMatchers.h in the dynamic layer (clang/ASTMatchers/Dynamic).

Reviewers: klimek

CC: cfe-commits

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

llvm-svn: 186422
2013-07-16 15:47:24 +00:00
Fariborz Jahanian 0080fb5a18 This patch removes unused parameter allProperties and converts remaining
parameters in ArrayRef'ize Sema::ActOnAtEnd  to ArrayRef.
Patch by Robert Wilhelm.

llvm-svn: 186421
2013-07-16 15:33:19 +00:00
Manuel Klimek 6a46149cb1 Remove unnecessary assignment.
llvm-svn: 186412
2013-07-16 13:58:44 +00:00
Manuel Klimek 55d8fb56d3 Fixes another hard to test problem with iterator invalidation.
As every match call can recursively call back into the memoized match
via a nested traversal matcher (for example:
stmt(hasAncestor(stmt(hasDescendant(stmt(hasDescendant(stmt()))))))),
and every memoization step might clear the cache, we must not store
iterators into the result cache when calling match on a submatcher.

llvm-svn: 186411
2013-07-16 13:20:30 +00:00
Daniel Jasper 655d96ab3b clang-format: Improve detection of function types.
This fixes an incorrect detection that led to a formatting error.
Before:
  some_var = function (*some_pointer_var)[0];
After:
  some_var = function(*some_pointer_var)[0];

llvm-svn: 186402
2013-07-16 11:37:21 +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
Craig Topper 694ddc73ea Add 'const' qualifiers to static const char* variables.
llvm-svn: 186383
2013-07-16 05:03:10 +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
Fariborz Jahanian 5bd5affe2d ObjC migrator: build conforming interface
declaration (not yet used). wip.

llvm-svn: 186369
2013-07-16 00:20:21 +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
Fariborz Jahanian d36150d7ca ObjC migrator: finding conforming protocol
candidates for each class. wip.

llvm-svn: 186349
2013-07-15 21:22:08 +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
Samuel Benzaquen 79656e19c8 Add support for type traversal matchers.
Summary:
Fixup the type traversal macros/matchers to specify the supported types.
Make the marshallers a little more generic to support any variadic function.
Update the doc script.

Reviewers: klimek

CC: cfe-commits, revane

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

llvm-svn: 186340
2013-07-15 19:25:06 +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
Daniel Jasper 49a9448d95 clang-format: Improve c-style cast detection.
Before:
  #define x ((int) - 1)
  #define p(q) ((int *) & q)
After:
  #define x ((int)-1)
  #define p(q) ((int *)&q)

llvm-svn: 186324
2013-07-15 15:04:42 +00:00
Daniel Jasper fa21c0724c Improvement of change r186320.
Fixed a test that by now passed for the wrong reason.

Before:
  llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
                                                 aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
  llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
               << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);

Also reformatted Format.cpp with the latest changes (1 formatting fix
and 1 layout change of a <<-chain).

llvm-svn: 186322
2013-07-15 14:33:14 +00:00
Daniel Jasper 0d5e44df3c Improve formatting of operator<< chains.
Before:
  llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: "
               << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

After:
  llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
               << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
               << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

llvm-svn: 186320
2013-07-15 14:12:30 +00:00
Aaron Ballman d0d27ab306 Replacing an empty switch with its moral equivalent. No functional changes intended.
llvm-svn: 186318
2013-07-15 13:41:33 +00:00
Craig Topper d6d31aceea Add 'static' and 'const' qualifiers to some arrays of strings.
llvm-svn: 186314
2013-07-15 08:24:27 +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
Craig Topper e5ce831c7c Use llvm::array_lengthof to replace sizeof(array)/sizeof(array[0]).
llvm-svn: 186300
2013-07-15 03:38:40 +00:00
Eric Christopher e9348f6df5 Reformat line.
llvm-svn: 186294
2013-07-14 21:15:27 +00:00
Eric Christopher 324bbbd16a Move BlockLiteralGeneric earlier in CGDebugInfo and remove
BlockLiteralGenericSet and replace with a call to isType() on the
BlockLiteralGeneric.

llvm-svn: 186293
2013-07-14 21:12:44 +00:00
Eric Christopher 35f1f9fc28 Update a few comments and reformat a decl for clarity.
llvm-svn: 186292
2013-07-14 21:00:07 +00:00
Craig Topper 122ec3a338 Replace C++0x in a comment with C++11
llvm-svn: 186287
2013-07-14 17:04:56 +00:00
Craig Topper 3195e25399 Change cxx0x to cxx11 in diagnostic name.
llvm-svn: 186286
2013-07-14 17:02:30 +00:00
Craig Topper fa159c144a Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size.
llvm-svn: 186284
2013-07-14 16:47:36 +00:00
Richard Smith 49e56440f9 Add missing include guards into headers in lib/Headers. While it may appear
that these headers should not be included more than once, they are in fact
included twice when building our builtins module (in order for it to generate
submodules for them), and without this, any modular build enabling AVX and
including any builtin header fails.

Testing this is tricky because including any of these headers in a modular
build is liable to fail, due to unrelated builtin headers in the same module
including headers which might not be available on the system running the tests.
Suggestion on that front are welcome (but we're getting close to being able to
run a buildbot that has modules enabled for all tests, which would nicely solve
the testing problem).

llvm-svn: 186275
2013-07-14 05:41:45 +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 a8d23ce8ce Serialization support for TagDecl::IsCompleteDefinitionRequired
Requested by Richard Smith in post-commit review of r186262

llvm-svn: 186266
2013-07-14 01:07:41 +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
David Blaikie ab277d6400 Simplify getTypeInfoImpl handling of 'non-canonical unless dependent' types.
These types are not dependent in this context, so just look through
the sugar.

Review by Richard Smith & Eli Friedman.

llvm-svn: 186260
2013-07-13 21:08:03 +00:00
Fariborz Jahanian 9a3512b11d Fixes a typo caught by Arthur O'Dwyer
llvm-svn: 186249
2013-07-13 17:16:41 +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
Fariborz Jahanian 9eabf45fce ObjC migrator: More knobs for migrating
conforming protocols to each class. wip.

llvm-svn: 186231
2013-07-13 00:04:20 +00:00
Fariborz Jahanian 1be015300c ObjC migrator: early work for migrating implicitly conforming
protocols to classes. This is wip.

llvm-svn: 186220
2013-07-12 22:32:19 +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
Bill Wendling 021c8ded04 Use function attributes to pass along the stack protector buffer size instead of making it a target option.
llvm-svn: 186218
2013-07-12 22:26:07 +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
Fariborz Jahanian c682ef566e fixes a typo caught by Jordan.
llvm-svn: 186171
2013-07-12 16:41:56 +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
Daniel Jasper 77d5d31320 clang-format: Improve <<-formatting.
This fixes a regression caused by r186115.

Before:
  Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
       bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                  << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
  Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
      << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
      << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

llvm-svn: 186164
2013-07-12 15:14:05 +00:00
Daniel Jasper 5aad4e5614 clang-format: Fix string literal breaking.
Before this patch, it did not cooperate with
Style::AlwaysBreakBeforeMultilineStrings. Thus, it would turn

  aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa");

into:

  aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa "
                              "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa");

and only a second format step would lead to the desired (with that
option):

  aaaaaaaaaaaa(aaaaaaaaaaaaa,
               "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa "
               "aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa");

This could even lead to clang-format breaking the string at a different
character and thus leading to a completely different end result.

llvm-svn: 186154
2013-07-12 11:37:05 +00:00
Daniel Jasper aea3bde06b clang-format: Break before/between array subscript expressions.
clang-format used to treat array subscript expressions much like
function call (just replacing () with []). However, this is not really
appropriate especially for expressions with multiple subscripts.

Although it might seem counter-intuitive, the most consistent solution
seems to be to always (if necessary) break before a square bracket,
never after it. Also, multiple subscripts of the same expression should
be aligned if they are on subsequent lines.

Before:
  aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa][
      bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa][
      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;

After:
  aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa]
                           [bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
      [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
      [bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;

llvm-svn: 186153
2013-07-12 11:19:37 +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
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
Daniel Jasper 51efbad732 clang-format: Fix bug concerning the alignment of "}".
Before:
    int i;  // indented 2 space more than clang-format would use.
    SomeReturnType  // clang-format invoked on this line.
    SomeFunctionMakingLBraceEndInColumn80() {
  }  // This is the indent clang-format would prefer.

After:
    int i;  // indented 2 space more than clang-format would use.
    SomeReturnType  // clang-format invoked on this line.
    SomeFunctionMakingLBraceEndInColumn80() {
    }

llvm-svn: 186120
2013-07-11 21:27:40 +00:00
Daniel Jasper 718bd366cf clang-format: Break before trailing annotations.
(if they are not function-like).

Before:
  SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa)
      OVERRIDE;

After:
  SomeFunction(aaaaaaaaaaaaaaaaaaaaaa,
               aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;

llvm-svn: 186117
2013-07-11 21:02:56 +00:00
Daniel Jasper 4e9678f7a1 clang-format: Avoid line breaks before the first <<.
This puts a slight penalty on the linebreak before the first "<<", so
that clang-format generally tries to keep things on the first line.

User feedback has shown that this is generally desirable.

Before:
  llvm::outs()
      << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =" << aaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
  llvm::outs() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ="
               << aaaaaaaaaaaaaaaaaaaaaaaaaaa;

llvm-svn: 186115
2013-07-11 20:41:21 +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
Eli Bendersky e3cef2ad5d Simplify GetBuiltinNames by hoising the NoBuiltins argument out of it.
llvm-svn: 186106
2013-07-11 16:53:04 +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
Daniel Jasper a3501d4b81 Improve detection of trailing return types.
Trailing return types can only occur in declaration contexts.

Before:
  void f() { auto a = b -> c(); }

After:
  void f() { auto a = b->c(); }

llvm-svn: 186087
2013-07-11 14:33:06 +00:00
Daniel Jasper 185de2499b Fix indentation problem for comments in call chains
Before:
SomeObject
    // Calling someFunction on SomeObject
        .someFunction();

After:
SomeObject
    // Calling someFunction on SomeObject
    .someFunction();

llvm-svn: 186085
2013-07-11 13:48:16 +00:00
Daniel Jasper 40db06af64 Keep trailing annotations close to their argument.
Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
    aaaaaaaaaaaa);

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    GUARDED_BY(aaaaaaaaaaaa);

llvm-svn: 186077
2013-07-11 12:34:23 +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
Eli Friedman 035b39e3bd Fix build.
Sorry about that.

llvm-svn: 186054
2013-07-11 02:28:36 +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
Richard Smith af9de91fd2 Make CheckAddressOfOperand a member of Sema so it can be reused by
__builtin_addressof.

llvm-svn: 186052
2013-07-11 02:26:56 +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
Eric Christopher 872018b5be Use a LexicalScope here since it is one and it will encapsulate
the two sets of debug scope and cleanup scope.

llvm-svn: 186030
2013-07-10 20:14:36 +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
Daniel Jasper b10cbc45ad Add experimental flag for adaptive parameter bin-packing.
This is not activated for any style, might change or go away
completely.

For those that want to play around with it, set
ExperimentalAutoDetectBinPacking to true.

clang-format will then:
Look at whether function calls/declarations/definitions are currently
formatted with one parameter per line (on a case-by-case basis). If so,
clang-format will avoid bin-packing the parameters. If all parameters
are on one line (thus that line is "inconclusive"), clang-format will
make the choice dependent on whether there are other bin-packed
calls/declarations in the same file.

The reason for this change is that bin-packing in some situations can be
really bad and an author might opt to put one parameter on each line. If
the author does that, he might want clang-format not to mess with that.
If the author is unhappy with the one-per-line formatting, clang-format
can easily be convinced to bin-pack by putting any two parameters on the
same line.

llvm-svn: 186003
2013-07-10 14:02:49 +00:00
Serge Pavlov ed5fe90bb8 Fixed comment of Sema::FindInstantiatedDecl.
llvm-svn: 185997
2013-07-10 04:59:14 +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 8978a9dd0a Get rid of dead/useless code for block mangling.
llvm-svn: 185989
2013-07-10 01:13:27 +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
Peter Collingbourne 41148a8a19 Apply BlackList -> SpecialCaseList rename in Clang.
Differential Revision: http://llvm-reviews.chandlerc.com/D1095

llvm-svn: 185979
2013-07-09 22:03:30 +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
Daniel Jasper 6cdec7cf05 Initial support for formatting trailing return types.
This fixes llvm.org/PR15170.

For now, the basic formatting rules are (based on the C++11 standard):
* Surround the "->" with spaces.
* Break before "->".

Also fix typo.

llvm-svn: 185938
2013-07-09 14:36:48 +00:00
Rafael Espindola ab417699dd ArrayRef'ize Sema::FinalizeDeclaratorGroup, Sema::BuildDeclaratorGroup and
Sema::ActOnDocumentableDecls.

Patch by Robert Wilhelm.

llvm-svn: 185931
2013-07-09 12:05:01 +00:00
Daniel Jasper bd05888fa0 Avoid confusing indentations for chained function calls.
Basically treat a function with a trailing call similar to a function
with multiple parameters.

Before:
  aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa))
      .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();

After:
  aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
                           aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa))
      .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();

Also fix typo.

llvm-svn: 185930
2013-07-09 11:57:27 +00:00
Daniel Jasper b1f74a8152 Fix alignment of closing brace in braced initializers.
Before:
someFunction(OtherParam, BracedList{
                           // comment 1 (Forcing intersting break)
                           param1, param2,
                           // comment 2
                           param3, param4
             });
After:
someFunction(OtherParam, BracedList{
                           // comment 1 (Forcing intersting break)
                           param1, param2,
                           // comment 2
                           param3, param4
                         });

To do so, the UnwrappedLineParser now stores the information about the
kind of brace in the FormatToken.

llvm-svn: 185914
2013-07-09 09:06:29 +00:00
Daniel Jasper 6331da0672 Format overloaded operators like other functions.
This fixes llvm.org/PR16328 (at least partially).

Before:
SomeLoooooooooooooooooooooooooooooogType operator<<(
    const SomeLooooooooogType &a, const SomeLooooooooogType &b);

After:
SomeLoooooooooooooooooooooooooooooogType
operator<<(const SomeLooooooooogType &a, const SomeLooooooooogType &b);

llvm-svn: 185908
2013-07-09 07:43:55 +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
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
Kaelyn Uhrain 53e721980b Make a couple of useful typo correction callbacks more widely available.
llvm-svn: 185880
2013-07-08 23:13:39 +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
Daniel Jasper 6a09df7964 Fix incorrect incorrect cast identification in clang-format.
This fixes llvm.org/PR16534.

Before:
aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION;
After:
aaaaa& operator+(const aaaaa&) LLVM_DELETED_FUNCTION;

llvm-svn: 185828
2013-07-08 14:58:01 +00:00
Daniel Jasper 3ac9b9e258 Reformat clang-format's source files after r185822 and others.
llvm-svn: 185823
2013-07-08 14:34:09 +00:00
Daniel Jasper ee7539a387 Prefer similar line breaks.
This adds a penalty for clang-format for each break that occurs in
a set of parentheses (including fake parenthesis that determine
the range of certain operator precendences) that have not yet been
broken. Thereby, clang-format prefers similar line breaks.

This fixes llvm.org/PR15506.

Before:
const int kTrackingOptions =
    NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited |
    NSTrackingActiveAlways;

After:
const int kTrackingOptions = NSTrackingMouseMoved |
                             NSTrackingMouseEnteredAndExited |
                             NSTrackingActiveAlways;

Also removed ParenState::ForFakeParenthesis which has become unused.

llvm-svn: 185822
2013-07-08 14:25:23 +00:00
Manuel Klimek 7e3d9698fd Fix use of invalidated iterator bug in AST match finder.
Pulled out the cache clearing in the case of descendant matching, too,
for consistency, also it is not technically needed there.

FIXME: Make cache size configurable and add unit test.
llvm-svn: 185820
2013-07-08 14:16:30 +00:00
Alexander Kornienko 614d96a1f6 Fix for corner cases in code handling leading "* " decorations in block comments
Summary:
Fixes problems that lead to incorrect formatting of these and similar snippets:
/*
 **
 */

/*
 **/

/*
 * */

/*
 *test
 */

Clang-format used to think that all the cases above use "* " decoration, and
failed to calculate insertion position properly. It also used to remove leading 
"* " in the last line.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

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

llvm-svn: 185818
2013-07-08 14:12:07 +00:00
Craig Topper ac9201a48f Simplify code. No functional change.
llvm-svn: 185792
2013-07-08 04:47:18 +00:00
Craig Topper 0a4e1f586c Introduce a typedef for the type of NewlyDeducedPacks to avoid repeating the small size of the inner SmallVector.
llvm-svn: 185789
2013-07-08 04:44:01 +00:00
Craig Topper 4b482ee0ef Remove 'else' after 'return'
llvm-svn: 185787
2013-07-08 04:24:47 +00:00
Craig Topper c1bbe8d6d2 Function argument formatting fixes. No functional change.
llvm-svn: 185786
2013-07-08 04:16:49 +00:00
Craig Topper 7965357ce4 Function argument formatting fixes.
llvm-svn: 185785
2013-07-08 04:13:06 +00:00
Craig Topper 61ac906bdd Use SmallVectorImpl::reverse_iterator instead of SmallVector to avoid specifying the vector size.
llvm-svn: 185784
2013-07-08 03:55:09 +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
Enea Zaffanella a90af72e8f Fixed source location info for UnaryTransformTypeLoc nodes.
llvm-svn: 185765
2013-07-06 18:54:58 +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
Sylvestre Ledru 8e5d82e541 Remove some useless declarations (found by scan-build)
llvm-svn: 185752
2013-07-06 08:00:09 +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
Fariborz Jahanian e4055692f4 [comment parsing]: Removes an unsafe API whose
use can cause crash. No test is available. It is uncovered
by code browsing.  // rdar://14348205

llvm-svn: 185732
2013-07-05 23:20: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
Fariborz Jahanian 266926d85e [objc migrator]: More knobs to do migration to
use of objc's properties.

llvm-svn: 185724
2013-07-05 20:46:03 +00:00
Eli Friedman eecc09a99c Don't use mangleCXXRTTIName in TBAA for C code.
This changes the TBAA code so it doesn't use mangleCXXRTTIName in C,
because it doesn't really make sense there.  Also, as sort of a
defense-in-depth change, fix the mangler so it handles C RecordDecls
correctly.

No tests because I don't know the TBAA code well enough to write a test,
and I don't know how else to trigger mangling a local struct in C.

Fixes a crash with r185450 reported by Joerg Sonnenberger.

llvm-svn: 185721
2013-07-05 20:27:40 +00:00
Rafael Espindola a36e78ef5d Use llvm::sys::fs::createTemporaryFile.
llvm-svn: 185717
2013-07-05 20:00:06 +00:00
Craig Topper 5603df45df Use SmallVectorImpl& for function arguments instead of SmallVector.
llvm-svn: 185715
2013-07-05 19:34:19 +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
Rafael Espindola e4ffbdf349 Fix PR16547.
We should not be asking unique_file to prepend the system temporary directory
when creating the html report. Unfortunately I don't think we can test this
with the current infrastructure since unique_file ignores MakeAbsolute if the
directory is already absolute and the paths provided by lit are.

I will take a quick look at making this api a bit less error prone.

llvm-svn: 185707
2013-07-05 15:05:40 +00:00
Rafael Espindola 1d0912a475 We don't need to check for windows' error codes in here.
The operator== calls equivalent which calls default_error_condition which
handles windows to posix conversion.

llvm-svn: 185702
2013-07-05 14:15:24 +00:00
Daniel Jasper 6f9c8d2148 Fix formatting for allocation of new pointer variables.
Before:
T **t = new T * ;
T **q = new T * ();

After:
T **t = new T *;
T **q = new T *();

llvm-svn: 185699
2013-07-05 13:30:40 +00:00
Daniel Jasper 0e90c3d92c Improve detection for preventing certain kind of formatting patterns.
This is a better implementation of r183097. The main purpose is to
prevent certain constructs to be formatted "like a block of text".

Before:
aaaaaaaaaaaaa<
    aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa = new aaaaaaaaaaaaa<
    aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(bbbbbbbbbbbbbbbbbbbbbbbb);
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (*cccccccccccccccc)[
    dddddddddddddddddddddddddddddddddddddddddddddddddddddddd];

After:
aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa,
              aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
              aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa =
    new aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa,
                      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(
        bbbbbbbbbbbbbbbbbbbbbbbb);
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] =
    (*cccccccccccccccc)[
        dddddddddddddddddddddddddddddddddddddddddddddddddddddddd];

llvm-svn: 185687
2013-07-05 09:14:35 +00:00