Commit Graph

32160 Commits

Author SHA1 Message Date
Daniel Jasper 42401c8d13 clang-format: Fix segfault in overloaded operator parsing.
Before, constructs like:
  using A::operator+;

caused a segfault. This fixes llvm.org/PR17050.

llvm-svn: 189749
2013-09-02 09:20:39 +00:00
Pavel Labath d527cf89e6 [analyzer] Add very limited support for temporary destructors
This is an improved version of r186498. It enables ExprEngine 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.

Now, the analyzer correctly handles expressions like "a || A()", and executes the
destructor of "A" only on the paths where "a" evaluted to false.

Temporary destructor processing is still off by default and one has to
explicitly request it by setting cfg-temporary-dtors=true.

Reviewers: jordan_rose

CC: cfe-commits

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

llvm-svn: 189746
2013-09-02 09:09:15 +00:00
Daniel Jasper 7240762504 clang-format: Fix case-indentation in macros.
Before:
  #define OPERATION_CASE(name)           \
    case OP_name:                        \
    return operations::Operation##name

After:
  #define OPERATION_CASE(name)           \
    case OP_name:                        \
      return operations::Operation##name

llvm-svn: 189743
2013-09-02 08:26:29 +00:00
Aaron Ballman 4d236845e9 Possibly appeasing the build bots from r189711
llvm-svn: 189712
2013-08-31 01:22:55 +00:00
Aaron Ballman 00e99966c4 Consolidating the notion of a GNU attribute parameter with the attribute argument list.
llvm-svn: 189711
2013-08-31 01:11:41 +00:00
Eric Christopher fb4b433bbb Typo.
llvm-svn: 189710
2013-08-31 00:27:38 +00:00
Eric Christopher d1428bf635 Add initial clang targeted compatible decls for Intrin.h. Step towards
a windows compatible builtin header.

Currently uses x86intrin.h for implementing intel intrinsics in a clang
specific manner.

llvm-svn: 189709
2013-08-31 00:22:48 +00:00
Fariborz Jahanian d0fbf6cebd ObjectiveC migrator: If we find a method that returns a C pointer
of some sort (but not an object, block pointer or CF pointers), 
and is not annotated with the objc_returns_inner_pointer attribute, 
we should suggest NS_RETURNS_INNER_POINTER annotation for these methods. 

llvm-svn: 189707
2013-08-30 23:52:08 +00:00
DeLesley Hutchins 5a715c4f00 Consumed analysis: add 'consumable' class attribute.
Patch by chris.wailes@gmail.com

Adds the 'consumable' attribute that can be attached to classes.  This replaces
the previous method of scanning a class's methods to see if any of them have
consumed analysis attributes attached to them.  If consumed analysis attributes
are attached to methods of a class that isn't marked 'consumable' a warning
is generated.

llvm-svn: 189702
2013-08-30 22:56:34 +00:00
Jordan Rose e600025528 [analyzer] Treat the rvalue of a forward-declared struct as Unknown.
This will never happen in the analyzed code code, but can happen for checkers
that over-eagerly dereference pointers without checking that it's safe.
UnknownVal is a harmless enough value to get back.

Fixes an issue added in r189590, caught by our internal buildbot.

llvm-svn: 189688
2013-08-30 19:17:26 +00:00
Fariborz Jahanian ff3476e499 ObjectiveC migrator: infer NS_ENUM even when user
specified NSUInteger as the followup typedef.
With this change, NS_OPTIONS is only inferred
based on looking up how enumerators are speficied
(if they her hexadecimal, power of 2, or have
 bitwise constant expressions).

llvm-svn: 189682
2013-08-30 17:46:01 +00:00
Samuel Benzaquen 998cda23b9 Reduce the number of symbols by changing how templates are instantiated per function bound in the registry.
Summary:
Reduce the number of symbols by changing how templates are instantiated per function bound in the registry.
This change reduces the number of sections in Registry.cpp.o by a little over 10%.

Reviewers: klimek

CC: cfe-commits, revane

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

llvm-svn: 189676
2013-08-30 15:09:52 +00:00
Benjamin Kramer ffecc84583 Add support for -march=slm, aka Intel Atom Silvermont.
llvm-svn: 189670
2013-08-30 14:05:34 +00:00
Hans Wennborg d024c1c803 clang-cl: Pass -incremental:no to linker when using ASan
llvm-svn: 189664
2013-08-30 10:50:52 +00:00
Daniel Jasper 8ddfa8489b clang-format: Enable formatting of protocol buffer definitions.
Almost by accident, clang-format seems to be able to format protocol
buffer definitions (https://code.google.com/p/protobuf/).

The only change is that a space is required between numeric constants
and opening square brackets (for default values). While this might in
theory be used for array subscripts (int val = 4[MyArray]), I have not
seen this pattern in practice much. If this is wrong, we can make this
smarter in the future.

llvm-svn: 189663
2013-08-30 10:36:58 +00:00
Daniel Jasper b715087278 clang-format: Improve recovery from enums with errors.
Before:
  namespace n {
  enum Type {
    One,
    Two, // missing };
    int i;
  } void g() {
  }

After:
  namespace n {
  enum Type {
    One,
    Two, // missing };
    int i;
  }
  void g() {}

llvm-svn: 189662
2013-08-30 10:10:19 +00:00
Hans Wennborg 1cc6cce9a6 Revert r188531: "Windows ToolChain: add VS bin dir to PogramPaths"
This never really worked. Even if we find and execute link.exe in the VS bin dir
this way, link.exe wouldn't find the DLLs it needs, libraries, etc.

It also causes trouble when the user has multiple versions of VS installed,
one of them is in the path, but this code finds the other one (PR17041).

Revert until we can fix this properly.

> Windows ToolChain: add VS bin dir to PogramPaths
>
> We have a lot of fancy logic to find Visual Studio, which is currently used
> to set the system header include paths.
>
> Use the same code to set the ProgramPaths, which is used for finding programs
> such as link.exe. Previously, Clang would just search PATH for link.exe,
> but now it should find it if it's able to find Visual Studio.

llvm-svn: 189661
2013-08-30 09:42:06 +00:00
Yunzhong Gao 0ebf1bb150 Revert r189649 because it was breaking sanitizer bots.
llvm-svn: 189660
2013-08-30 08:53:09 +00:00
Pavel Labath 58934986f2 Sema: avoid reuse of Exprs when synthesizing operator=
Summary:
Previously, Sema was reusing parts of the AST when synthesizing an assignment
operator, turning it into a AS-dag. This caused problems for the static
analyzer, which assumed an expression appears in the tree only once.

Here I make sure to always create a fresh Expr, when inserting something into
the AST, fixing PR16745 in the process.

Reviewers: doug.gregor

CC: cfe-commits, jordan_rose

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

llvm-svn: 189659
2013-08-30 08:52:28 +00:00
Daniel Jasper f79b0b1562 clang-format: Fix incorrect indentation.
Before:
aaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
               dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
    dddddddddddddddddddddddddddddd));

After:
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
    dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
    dddddddddddddddddddddddddddddd));

This was overlooked when interducing the new builder-type call
detection in r189337. Also, some minor reorganization of a test.

llvm-svn: 189658
2013-08-30 08:29:25 +00:00
Daniel Jasper 2cf664fb86 clang-format: Don't indent builders relative to "return".
While this looks kind of nice, it wastes horizontal space and does not
seem to be common in the LLVM codebase.

Before:
  return llvm::StringSwitch<Reference::Kind>(name)
      .StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
      .StartsWith(".eh_frame", ORDER_EH_FRAME)
      .StartsWith(".init", ORDER_INIT)
      .StartsWith(".fini", ORDER_FINI)
      .StartsWith(".hash", ORDER_HASH)
      .Default(ORDER_TEXT);

After:
  return llvm::StringSwitch<Reference::Kind>(name)
             .StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
             .StartsWith(".eh_frame", ORDER_EH_FRAME)
             .StartsWith(".init", ORDER_INIT)
             .StartsWith(".fini", ORDER_FINI)
             .StartsWith(".hash", ORDER_HASH)
             .Default(ORDER_TEXT);

llvm-svn: 189657
2013-08-30 07:27:13 +00:00
Daniel Jasper f8151e9bc1 clang-format: Fix corner case in builder-type calls.
Before:
  aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()->aaaaaaaaaaaaaae(
                                                 0)->aaaaaaaaaaaaaaa();

After:
  aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()
      ->aaaaaaaaaaaaaae(0)
      ->aaaaaaaaaaaaaaa();

llvm-svn: 189655
2013-08-30 07:12:40 +00:00
Yunzhong Gao be8d7ba93a Fixing a bug where debug info for a local variable gets emitted at file scope.
The patch was discussed in Phabricator. See:
http://llvm-reviews.chandlerc.com/D1281

llvm-svn: 189649
2013-08-30 05:37:02 +00:00
Richard Smith 99bc1b99d3 Mention in AST dump whether a class declaration is a definition.
llvm-svn: 189647
2013-08-30 05:32:29 +00:00
Richard Smith a4ba74c5f5 Don't eagerly load all conversion operators when loading a class declaration
from a PCH/module.

llvm-svn: 189646
2013-08-30 04:46:40 +00:00
Charles Davis b5a214e4f3 Add ms_abi and sysv_abi attribute handling.
Based on a patch by Benno Rice!

llvm-svn: 189644
2013-08-30 04:39:01 +00:00
Richard Smith 9dd9f036c6 Map from local decl IDs to global decl IDs when lazily deserializing friend decl chains.
llvm-svn: 189629
2013-08-30 00:23:29 +00:00
Fariborz Jahanian a23f4fb5c9 ObjectiveC migrator: User of hexadecimal enumerator
should infer migration to NS_OPTIONS.

llvm-svn: 189628
2013-08-30 00:10:37 +00:00
Richard Smith 676c404dec Be lazier when loading KeyFunctions from PCH/modules. We don't need to load
these in eagerly if we're not actually processing a translation unit. The added
laziness here also avoids us loading in parts of a CXXRecordDecl earlier than an
upcoming class template specialization merging patch would like.

Ideally, we should mark the vtable as used when we see a definition for the key
function, rather than having a separate pass over dynamic classes at the end of
the TU. The existing approach is pretty bad for PCH/modules, since it forcibly
loads the declarations of all key functions in all imported modules, whether or
not those key functions are defined.

llvm-svn: 189627
2013-08-29 23:59:27 +00:00
Eli Friedman 0718591771 Adjust clang for change to APFloat::toString.
I changed the diagnostic printing code because it's probably better
to cut off a digit from DBL_MAX than to print something like
1.300000001 when the user wrote 1.3.

llvm-svn: 189625
2013-08-29 23:44:43 +00:00
Manman Ren e0064d8c24 Debug Info: generate a unique identifier for C++ struct, class, union, and enum.
We use CXX mangler to generate unique identifier for external C++ struct,
union, class and enum. Types with unique identifier are added to retained
types by DIBuilder.

Testing cases are updated to reflect the unique identifier generated for types.
The order of MDNodes is changed because of retained types and testing cases
are updated accordingly.

Testing case debug-info-uuid.cpp now emits error with Itanium mangler, since
uuid is not yet handled in Itanium mangler. And it will check for the error
message.

llvm-svn: 189622
2013-08-29 23:19:58 +00:00
DeLesley Hutchins b570c13574 Consumed analysis: track function parameters.
Patch by chris.wailes@gmail.com.

llvm-svn: 189616
2013-08-29 22:36:05 +00:00
DeLesley Hutchins 7fa60edb47 Consumed analysis: non-const methods no longer transfer an object into an
unknown state.  Patch by chris.wailes@gmail.com.

llvm-svn: 189612
2013-08-29 21:17:25 +00:00
Manman Ren f801f808ba Debug Info: this reverts commit r189600.
We had further discussions on how to retain types, whether to do it in front end
or in DIBuilder. And we agree to do it in DIBuilder so front ends
generating unique identifier do not need to worry about retaining them.

llvm-svn: 189609
2013-08-29 20:48:48 +00:00
Aaron Ballman a21f4b8ddd Silencing the warning from r189605 in a more conformant manner.
llvm-svn: 189606
2013-08-29 20:36:09 +00:00
Aaron Ballman 130db36d80 Silencing a rather spurious warning from MSVC 11 about not all control paths returning a value (hint: they do).
llvm-svn: 189605
2013-08-29 20:25:14 +00:00
Manman Ren 035c4b029f Debug Info: generate a unique identifier for C++ struct, class, union, and enum.
We use CXX mangler to generate unique identifier for external C++ struct,
union, class and enum. Types with unique identifier are added to RetainedTypes
to make sure they are treated as used even when all uses are replaced with
the identifiers.

A single type can be added to RetainedTypes multiple times. For example, both 
createForwardDecl and createLimitedType can add the same type to RetainedTypes.
A set is used to avoid duplication when updating AllRetainTypes in DIBuilder.

Testing cases are updated to reflect the unique identifier generated for types.
The order of MDNodes is changed because of retained types and testing cases
are updated accordingly.

Testing case debug-info-uuid.cpp now emits error with Itanium mangler, since
uuid is not yet handled in Itanium mangler.

We choose to update RetainedTypes in clang, then at finalize(), we update
AllRetainTypes in DIBuilder. The other choice is to update AllRetainTypes
in DIBuilder when creating a DICompositeType with unique identifier. This
option requires using ValueHandle for AllRetainTypes in DIBuilder since
the created DICompositeType can be modified later on by setContainingType etc.

llvm-svn: 189600
2013-08-29 18:51:51 +00:00
Eric Christopher f8a1baab9d Fix warning about anonymous structs in anonymous unions.
llvm-svn: 189596
2013-08-29 18:00:58 +00:00
Alexander Kornienko d7b837e78d Better support for multiline string literals (including C++11 raw string literals).
Summary:
Calculate characters in the first and the last line correctly so that
we only break before the literal when needed.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

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

llvm-svn: 189595
2013-08-29 17:32:57 +00:00
DeLesley Hutchins 5533ec5c55 Consumed analysis: improve handling of conditionals.
Patch by chris.wailes@gmail.com.

* The TestedVarsVisitor was folded into the ConsumedStmtVisitor.
* The VarTestResult class was updated to allow these changes.
* The PropagationInfo class was updated for the same reasons.
* Correctly handle short-circuiting of Boolean operations.
* Blocks are now marked as unreachable when we can statically prove we will
  never branch to them.
* Unreachable blocks are skipped by the analysis.

llvm-svn: 189594
2013-08-29 17:26:57 +00:00
Fariborz Jahanian 4ccdc73f44 ObjectiveC migrator: remove dead code.
llvm-svn: 189592
2013-08-29 16:22:26 +00:00
Pavel Labath 2c65dfaab5 [analyzer] Fix handling of "empty" structs with base classes
Summary:
RegionStoreManager had an optimization which replaces references to empty
structs with UnknownVal. Unfortunately, this check didn't take into account
possible field members in base classes.

To address this, I changed this test to "is empty and has no base classes". I
don't consider it worth the trouble to go through base classes and check if all
of them are empty.

Reviewers: jordan_rose

CC: cfe-commits

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

llvm-svn: 189590
2013-08-29 16:06:04 +00:00
Manuel Klimek 31c85921b2 Fixes various problems with accounting for tabs in the original code.
We now count the original token's column directly when lexing the
tokens, where we already have all knowledge about where lines start.

Before this patch, formatting:
 void f() {
 \tg();
 \th();
 }
would incorrectly count the \t's as 1 character if only the line
containing h() was reformatted, and thus indent h() at offset 1.

llvm-svn: 189585
2013-08-29 15:21:40 +00:00
Alexander Kornienko 37d6b18633 Use new UnicodeCharSet interface.
Summary: This is a Clang part of http://llvm-reviews.chandlerc.com/D1534

Reviewers: jordan_rose, klimek, rsmith

Reviewed By: rsmith

CC: cfe-commits

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

llvm-svn: 189583
2013-08-29 12:12:31 +00:00
Serge Pavlov 0ccd3f61b1 Removed useless default branch of switch statement.
The problem was caught by sanitizer build.

llvm-svn: 189575
2013-08-29 08:20:07 +00:00
Serge Pavlov 9929209dfb Change return type of Sema::DiagnoseAmbiguousLookup from bool to void.
The function always returned true value, which was never used.

llvm-svn: 189571
2013-08-29 07:23:24 +00:00
Craig Topper b78e9d9b2f Make getDiagnosticsInGroup helper method a static function in the cpp file and move the WarningOption struct into an anonymous namespace instead of clang namespace since it no longer needs to be forward declared in the header.
llvm-svn: 189569
2013-08-29 06:06:18 +00:00
Craig Topper da7cf8ab2b Move individual group name strings from the OptionTable into one big char array. Then only store offsets into it in the OptionTable. Saves about 4K from the clang binary and removes 400 relocation entries from DiagnosticIDs.o.
llvm-svn: 189568
2013-08-29 05:18:04 +00:00
Peter Collingbourne 6c77e72659 Two more definitions required by libsupc++ (_sleb128_t and _uleb128_t)
Differential Revision: http://llvm-reviews.chandlerc.com/D1542

llvm-svn: 189558
2013-08-29 01:56:22 +00:00
Eli Friedman 80e45b8cd4 Properly escape filenames in line directives.
Fixes PR17018.  Only partial test coverage because I don't want
to try to write a test which generates a file whose name contains a newline.

llvm-svn: 189557
2013-08-29 01:42:42 +00:00