Commit Graph

67755 Commits

Author SHA1 Message Date
Nemanja Ivanovic e96e697294 [PowerPC] Enable -fomit-frame-pointer by default for PPC
As is the case on platforms like Mips, X86 and SystemZ, the -fomit-frame-pointer
should be enabled by default on PPC when optimizing at -O1 and above. This
brings the behaviour of LLVM on PPC in line with GCC.

Committing on behalf of Hiroshi Inoue.

Differential Revision: https://reviews.llvm.org/D29750

llvm-svn: 296861
2017-03-03 09:49:17 +00:00
Dave Bartolomeo 8ffce2ade3 Fix msc-version.c test to handle _MSC_VER=1910
Previously, VC++ has always set _MSC_VER to a four-digit value with the two least significant digits set to zero. Visual Studio 2017, however, sets _MSC_VER=1910, and we expect to update the least significant digit as we release major updates for VS 2017. This patch fixes the msc-version.c test to handle non-zero values in the two least significant digits of _MSC_VER.

llvm-svn: 296843
2017-03-03 00:08:55 +00:00
Dominic Chen 09d66f7528 Revert "Reland 3: [analyzer] NFC: Update test infrastructure to support multiple constraint managers"
This reverts commit ea36f1406e1f36bf456c3f3929839b024128e468.

llvm-svn: 296841
2017-03-02 23:30:53 +00:00
Dominic Chen feaf9ff5ee Reland 3: [analyzer] NFC: Update test infrastructure to support multiple constraint managers
Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952.

Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin

Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits

Differential Revision: https://reviews.llvm.org/D30373

llvm-svn: 296837
2017-03-02 23:05:45 +00:00
Dominic Chen 4a90bf8c3f Revert "Reland 2: [analyzer] NFC: Update test infrastructure to support multiple constraint managers"
This reverts commit f93343c099fff646a2314cc7f4925833708298b1.

llvm-svn: 296836
2017-03-02 22:58:06 +00:00
Dominic Chen 1cb0256a3c Reland 2: [analyzer] NFC: Update test infrastructure to support multiple constraint managers
Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952.

Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin

Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits

Differential Revision: https://reviews.llvm.org/D30373

llvm-svn: 296835
2017-03-02 22:45:24 +00:00
John McCall 5ad740756f Promote ConstantInitBuilder to be a public CodeGen API; it's
a generally useful utility for other frontends.  NFC.

llvm-svn: 296806
2017-03-02 20:04:19 +00:00
Vassil Vassilev 3dd966b0ce Add coding and shebang.
Reviewed by Artem Dergachev (D26030)!

llvm-svn: 296781
2017-03-02 18:47:22 +00:00
Vassil Vassilev b27106804a Mark function as llvm dump method.
llvm-svn: 296779
2017-03-02 18:13:19 +00:00
Adrian Prantl 5db6a947a2 Document that code inlined into a nodebug function also won't get any
debug info.

Suggested by Paul Robinson in feedback on r296488, thanks!

llvm-svn: 296776
2017-03-02 18:06:51 +00:00
Saleem Abdulrasool 97d25552ed Serialization: use the PCH chain to check PCH mode
When we are deciding whether we are creating a PCH or a module, we would
check if the ModuleMgr had any elements to switch into PCH mode.
However, when creating a module, the size may be 1.  This would result
in us going down the wrong path.

This was found by cross-compiling the swift standard library.  Use the
PCH chain length instead to identify the PCH mode.

Unfortunately, I have not yet been able to create a simple test case for
this, but have verified that this fixes the swift standard library
construction.

Thanks to Adrian Prantl for help and discussions with this change!

llvm-svn: 296769
2017-03-02 17:37:11 +00:00
Nico Weber 3ffedcdfa3 Don't write to LLVMStyle.JavaScriptQuotes twice. No behavior change.
llvm-svn: 296749
2017-03-02 14:51:54 +00:00
Krasimir Georgiev 9163fe2aba [clang-format] Use number of unwrapped lines for short namespace
Summary:
This patch makes the namespace comment fixer use the number of unwrapped lines
that a namespace spans to detect it that namespace is short, thus not needing
end comments to be added.
This is needed to ensure clang-format is idempotent. Previously, a short namespace
was detected by the original source code lines. This has the effect of requiring two
runs for this example:
```
namespace { class A; }
```
after first run:
```
namespace {
class A;
}
```
after second run:
```
namespace {
class A;
} // namespace
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D30528

llvm-svn: 296736
2017-03-02 09:54:44 +00:00
Daniel Jasper 893b8adca2 clang-format: [JS] Properly format object literals with shorthands.
Before:
  return {
    a,
    b: 'b', c,
  };

After:
  return {
    a,
    b: 'b',
    c,
  };

llvm-svn: 296664
2017-03-01 19:47:28 +00:00
Daniel Jasper 01b8783a05 clang-format: [JS/TS] Properly understand cast expressions.
Many things were wrong:
- We didn't always allow wrapping after "as", which can be necessary.
- We used to Undestand the identifier after "as" as a start of a name.
- We didn't properly parse the structure of the expression with "as"
  having the precedence of relational operators

llvm-svn: 296659
2017-03-01 19:26:12 +00:00
Bruno Cardoso Lopes 84df6e99b8 [PCH] Avoid VarDecl emission attempt if no owning module avaiable
This is a stopgap fix for PR31863, a regression introduced in r276159.

Consider this snippet:

struct FVector;
struct FVector {};
struct FBox {
  FVector Min;
  FBox(int);
};
namespace {
FBox InvalidBoundingBox(0);
}

While parsing the DECL_VAR for 'struct FBox', clang recursively read all the
dep decls until it finds the DECL_CXX_RECORD forward declaration for 'struct
FVector'. Then, it resumes all the way up back to DECL_VAR handling in
`ReadDeclRecord`, where it checks if `isConsumerInterestedIn` for the decl.

One of the condition for `isConsumerInterestedIn` to return false is if the
VarDecl is imported from a module `D->getImportedOwningModule()`, because it
will get emitted when we import the relevant module. However, before checking
if it comes from a module, clang checks if `Ctx.DeclMustBeEmitted(D)`, which
triggers the emission of 'struct FBox'. Since one of its fields is still
incomplete, it crashes.

Instead, check if `D->getImportedOwningModule()` is true before calling
`Ctx.DeclMustBeEmitted(D)`.

Differential Revision: https://reviews.llvm.org/D29753

rdar://problem/30173654

llvm-svn: 296656
2017-03-01 19:18:42 +00:00
Alex Lorenz d5d27e16d4 Introduce an 'external_source_symbol' attribute that describes the origin
and the nature of a declaration

This commit adds an external_source_symbol attribute to Clang. This attribute
specifies that a declaration originates from an external source and describes
the nature of that source. This attribute will be used to improve IDE features
like 'jump-to-definition' for mixed-language projects or project that use
auto-generated code.

rdar://30423368

Differential Revision: https://reviews.llvm.org/D29819

llvm-svn: 296649
2017-03-01 18:06:25 +00:00
Charles Li ceccf2d738 [Test] NFC: Fixed typo in comments
Changed "declerations" to "declarations"

llvm-svn: 296648
2017-03-01 17:55:03 +00:00
Devin Coughlin bfa8e28dbb [analyzer] pr32088: Don't destroy the temporary if its initializer causes return.
In the following code involving GNU statement-expression extension:
  struct S {
    ~S();
  };

  void foo() {
    const S &x = ({ return; S(); });
  }
function 'foo()' returns before reference x is initialized. We shouldn't call
the destructor for the temporary object lifetime-extended by 'x' in this case,
because the object never gets constructed in the first place.

The real problem is probably in the CFG somewhere, so this is a quick-and-dirty
hotfix rather than the perfect solution.

A patch by Artem Dergachev!

rdar://problem/30759076

Differential Revision: https://reviews.llvm.org/D30499

llvm-svn: 296646
2017-03-01 17:48:39 +00:00
Krasimir Georgiev 85c3704c0d [clang-format] Don't add namespace end comments for unbalanced right braces after namespace end
llvm-svn: 296638
2017-03-01 16:38:08 +00:00
Krasimir Georgiev 32eaa864e3 [clang-format] Add a new flag FixNamespaceComments to FormatStyle
Summary:
This patch enables namespace end comments under a new flag FixNamespaceComments,
which is enabled for the LLVM and Google styles.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D30405

llvm-svn: 296632
2017-03-01 15:35:39 +00:00
Eric Liu 9e745b7292 Introducing clang::tooling::AtomicChange for refactoring tools.
Summary:
An AtomicChange is used to create and group a set of source edits, e.g.
replacements or header insertions. Edits in an AtomicChange should be related,
e.g. replacements for the same type reference and the corresponding header
insertion/deletion.

An AtomicChange is uniquely identified by a key position and will either be
fully applied or not applied at all. The key position should be the location
of the key syntactical element that is being changed, e.g. the call to a
refactored method.

Next step: add a tool that applies AtomicChange.

Reviewers: klimek, djasper

Reviewed By: klimek

Subscribers: alexshap, cfe-commits, djasper, mgorny

Differential Revision: https://reviews.llvm.org/D27054

llvm-svn: 296616
2017-03-01 13:14:01 +00:00
Daniel Jasper 62703eb8a7 Fix r296605 so that stuff in #ifndef SWIG blocks is still formatted.
llvm-svn: 296608
2017-03-01 11:10:11 +00:00
Daniel Jasper eab6cd474c clang-format: Ignore contents of #ifdef SWIG .. #endif blocks.
Those blocks are used if C++ code is SWIG-wrapped (see swig.org) and
usually do not contain C++ code. Also cleanup the implementation of for #if 0
and #if false a bit.

llvm-svn: 296605
2017-03-01 10:47:52 +00:00
Malcolm Parsons ded2306208 [Sema] Improve side effect checking for unused-lambda-capture warning
Summary:
Don't warn about unused lambda captures that involve copying a
value of a type that cannot be trivially copied and destroyed.

Fixes PR31977

Reviewers: rsmith, aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D30327

llvm-svn: 296602
2017-03-01 10:23:38 +00:00
Akira Hatanaka 7cbbb88f23 [Sema] Add variable captured by a block to the enclosing lambda's
potential capture list.

Fix Sema::getCurLambda() to return the innermost lambda scope when there
is a block enclosed in the lambda. Previously, the method would return a
nullptr in such cases, which would prevent a variable captured by the
enclosed block to be added to the lambda scope's potential capture list.

rdar://problem/28412462

Differential Revision: https://reviews.llvm.org/D25556

llvm-svn: 296584
2017-03-01 06:11:25 +00:00
Richard Trieu 07c9338841 Add warning for inconsistent overrides on destructor.
The exisiting warning for inconsistent overrides does not include the destructor
as it was noted in review that it was too noisy.  Instead, add to a separate
warning group that is off by default for users who want consistent warnings
between methods and destructors.

llvm-svn: 296572
2017-03-01 03:07:55 +00:00
Devin Coughlin 1bf65c8c0d [Analyzer] Fix crash in ObjCPropertyChecker on protocol property
Fix a crash in the ObjCPropertyChecker when analyzing a 'copy' property of an
NSMutable* type in a protocol.

rdar://problem/30766684

Differential Revision: https://reviews.llvm.org/D30482

llvm-svn: 296562
2017-03-01 01:47:37 +00:00
Paul Robinson 18c12d534d [PS4] Set our default dialect to C++11. NFC for other targets.
Reapplies r296209 now that r296549 has fixed what really seems to be
the last problematic test.

llvm-svn: 296554
2017-03-01 01:01:10 +00:00
Charles Li f22a68714f [Test] Make Lit tests C++11 compatible - IR ordering
Differential Revision: https://reviews.llvm.org/D30430

llvm-svn: 296549
2017-03-01 00:10:00 +00:00
Richard Trieu 48143749f8 [ODRHash] Add basic support for CXXRecordDecl
llvm-svn: 296521
2017-02-28 21:24:38 +00:00
Erich Keane 2fe684bb14 Allow attributes before union definition
permits typedef union __attribute__((transparent_union)) {...}

Differential Revision: https://reviews.llvm.org/D28266

llvm-svn: 296518
2017-02-28 20:44:39 +00:00
Daniel Jasper e154020dc5 clang-format: [Java] Fix bug in enum formatting.
Before:
  public enum VeryLongEnum {
    ENUM_WITH_MANY_PARAMETERS("aaaaaaaaaaaaaaaaaaaaaa",
                              "bbbbbbbbbbbbbbbbbbbbbbbbbbb",
                              "ccccccccccccccccccc")
    ,
    SECOND_ENUM("a", "b", "c");

    private VeryLongEnum(String a, String b, String c) {}
  }

After:
  public enum VeryLongEnum {
    ENUM_WITH_MANY_PARAMETERS("aaaaaaaaaaaaaaaaaaaaaa",
                              "bbbbbbbbbbbbbbbbbbbbbbbbbbb",
                              "ccccccccccccccccccc") ,
    SECOND_ENUM("a", "b", "c");

    private VeryLongEnum(String a, String b, String c) {}
  }

llvm-svn: 296499
2017-02-28 18:28:15 +00:00
Eric Christopher fb834a8278 Migrate all of aarch64-linux-gnu to \01_mcount instead of just when passing along gnueabi as this matches both gcc and what the kernel expects.
More of PR27311

llvm-svn: 296490
2017-02-28 17:22:05 +00:00
Tom Stellard d088de6116 Driver: Update devtoolset usage for RHEL
- remove path to dts-1.x (corresponds to gcc 4.7)
- add path to dts-6 (corresponds to 6.x)

Patch By: Maria Gottschalk

Differential Revision: https://reviews.llvm.org/D29855

llvm-svn: 296485
2017-02-28 16:46:19 +00:00
Daniel Marjamaki 20a209e453 [Sema] Detect more array index out of bounds when C++ overloaded operators are used
Differential Revision: https://reviews.llvm.org/D30192

llvm-svn: 296477
2017-02-28 14:53:50 +00:00
Martin Probst bb46a7dd2a Blacklist arbitrary @\\w+ JSDoc tags from wrapping.
Summary:
Also limits the blacklisting to only apply when the tag is actually
followed by a parameter in curly braces.

    /** @mods {long.type.must.not.wrap} */

vs

    /** @const this is a long description that may wrap. */

Reviewers: djasper

Subscribers: klimek, krasimir, cfe-commits

Differential Revision: https://reviews.llvm.org/D30452

llvm-svn: 296467
2017-02-28 11:08:24 +00:00
NAKAMURA Takumi d6fc6730ce clang/test/Format/inplace.cpp: Avoid using wildcard.
MSYS' tools don't do globbing.

llvm-svn: 296460
2017-02-28 10:05:56 +00:00
Christof Douma 8723946e91 [ARM] Don't pass -arm-execute-only to cc1as
The option -mexecute-only is translated into the backend option
-arm-execute-only. But this option only makes sense for the compiler and
the assembler does not recognize it. This patch stops clang from passing
this option to the assembler.

Change-Id: I4f4cb1162c13cfd50a0a36702a4ecab1bc0324ba
Review: https://reviews.llvm.org/D30414
llvm-svn: 296454
2017-02-28 09:09:53 +00:00
Haojian Wu 44038f176b [clang-format] Fix test failure caused by "rm" on some buildbots.
The begining command "rm" will return 1 when there is not such file to
delete.

This patch is to remove it, as it's not needed for the test.

llvm-svn: 296453
2017-02-28 09:03:07 +00:00
Brad Smith 3d648b357a Set ABIs correctly for OpenBSD/arm; soft float and aapcs-linux.
llvm-svn: 296430
2017-02-28 03:20:26 +00:00
Dominic Chen 00355a51d0 Revert "Reland: [analyzer] NFC: Update test infrastructure to support multiple constraint managers"
This reverts commit 1b28d0b10e1c8feccb971abb6ef7a18bee589830.

llvm-svn: 296422
2017-02-28 01:50:23 +00:00
Dominic Chen 59cd893320 Reland: [analyzer] NFC: Update test infrastructure to support multiple constraint managers
Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952.

Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin

Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits

Differential Revision: https://reviews.llvm.org/D30373

llvm-svn: 296414
2017-02-28 00:02:36 +00:00
Nico Weber 65da45763e clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded
Second attempt after http://llvm.org/viewvc/llvm-project?rev=296166&view=rev

In the first attempt, Code (the memory buffer backing the input file) was reset
before overwriteChangedFiles() was called, but overwriteChangedFiles() still
reads from it.  This time, load the whole input file into memory instead of
using mmap when formatting in-place.

(Since the test is identical to what was in the repo before chapuni's revert,
svn diff doesn't show it – see the above link for the test.)

https://reviews.llvm.org/D30385

llvm-svn: 296408
2017-02-27 22:59:58 +00:00
Adrian Prantl b7acfc0139 PR32042: Create inlined debug info for EmitInlinedInheritingCXXConstructorCall.
When clang emits an inheriting C++ constructor it may inline code
during the CodeGen phase. This patch ensures that any debug info in
this inlined code gets a proper inlined location. Otherwise we can end
up with invalid debug info metadata, since all inlined local variables
and function arguments would be reparented into the call site.

Analogous to ApplyInlineLocation this patch introduces a
ApplyInlineDebugLocation scoped helper to facilitate entering an
inlined scope and cleaning up afterwards.

This fixes one of the issues discovered in PR32042.

rdar://problem/30679307

llvm-svn: 296388
2017-02-27 21:30:05 +00:00
Nico Weber 614e60de1c UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not catch UB.
https://reviews.llvm.org/D27455

llvm-svn: 296387
2017-02-27 21:27:07 +00:00
David Blaikie 0de6a87ef3 Remove unused variable
llvm-svn: 296386
2017-02-27 21:14:42 +00:00
Vedant Kumar 5a97265351 [ubsan] Factor out logic to emit a range check. NFC.
This is a readability improvement, but it will also help prep an
upcoming patch to detect UB loads from bitfields.

llvm-svn: 296374
2017-02-27 19:46:19 +00:00
Bob Haarman aaf5191364 enable -flto=thin in clang-cl
Summary: This enables LTO to be used with the clang-cl frontend.

Reviewers: rnk, hans

Reviewed By: hans

Subscribers: pcc, cfe-commits, mehdi_amini, Prazek

Differential Revision: https://reviews.llvm.org/D30239

llvm-svn: 296373
2017-02-27 19:40:19 +00:00
Krasimir Georgiev 7cb267af75 [clang-format] Add a NamespaceEndCommentsFixer
Summary:
This patch adds a NamespaceEndCommentsFixer TokenAnalyzer for clang-format,
which fixes end namespace comments.
It currently supports inserting and updating existing wrong comments.

Example source:
```
namespace A {
int i;
}

namespace B {
int j;
} // namespace A
```

after formatting:
```
namespace A {
int i;
} // namespace A

namespace B {
int j;
} // namespace B
```

Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: klimek, mgorny

Differential Revision: https://reviews.llvm.org/D30269

llvm-svn: 296341
2017-02-27 13:28:36 +00:00