]> granicus.if.org Git - clang/log
clang
7 years ago[clang-format] Use number of unwrapped lines for short namespace
Krasimir Georgiev [Thu, 2 Mar 2017 09:54:44 +0000 (09:54 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296736 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: [JS] Properly format object literals with shorthands.
Daniel Jasper [Wed, 1 Mar 2017 19:47:28 +0000 (19:47 +0000)]
clang-format: [JS] Properly format object literals with shorthands.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296664 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: [JS/TS] Properly understand cast expressions.
Daniel Jasper [Wed, 1 Mar 2017 19:26:12 +0000 (19:26 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296659 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[PCH] Avoid VarDecl emission attempt if no owning module avaiable
Bruno Cardoso Lopes [Wed, 1 Mar 2017 19:18:42 +0000 (19:18 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296656 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoIntroduce an 'external_source_symbol' attribute that describes the origin
Alex Lorenz [Wed, 1 Mar 2017 18:06:25 +0000 (18:06 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296649 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Test] NFC: Fixed typo in comments
Charles Li [Wed, 1 Mar 2017 17:55:03 +0000 (17:55 +0000)]
[Test] NFC: Fixed typo in comments

Changed "declerations" to "declarations"

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296648 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[analyzer] pr32088: Don't destroy the temporary if its initializer causes return.
Devin Coughlin [Wed, 1 Mar 2017 17:48:39 +0000 (17:48 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296646 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[clang-format] Don't add namespace end comments for unbalanced right braces after...
Krasimir Georgiev [Wed, 1 Mar 2017 16:38:08 +0000 (16:38 +0000)]
[clang-format] Don't add namespace end comments for unbalanced right braces after namespace end

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296638 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[clang-format] Add a new flag FixNamespaceComments to FormatStyle
Krasimir Georgiev [Wed, 1 Mar 2017 15:35:39 +0000 (15:35 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296632 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoIntroducing clang::tooling::AtomicChange for refactoring tools.
Eric Liu [Wed, 1 Mar 2017 13:14:01 +0000 (13:14 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296616 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoFix r296605 so that stuff in #ifndef SWIG blocks is still formatted.
Daniel Jasper [Wed, 1 Mar 2017 11:10:11 +0000 (11:10 +0000)]
Fix r296605 so that stuff in #ifndef SWIG blocks is still formatted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296608 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: Ignore contents of #ifdef SWIG .. #endif blocks.
Daniel Jasper [Wed, 1 Mar 2017 10:47:52 +0000 (10:47 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296605 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Sema] Improve side effect checking for unused-lambda-capture warning
Malcolm Parsons [Wed, 1 Mar 2017 10:23:38 +0000 (10:23 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296602 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Sema] Add variable captured by a block to the enclosing lambda's
Akira Hatanaka [Wed, 1 Mar 2017 06:11:25 +0000 (06:11 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296584 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAdd warning for inconsistent overrides on destructor.
Richard Trieu [Wed, 1 Mar 2017 03:07:55 +0000 (03:07 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296572 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Analyzer] Fix crash in ObjCPropertyChecker on protocol property
Devin Coughlin [Wed, 1 Mar 2017 01:47:37 +0000 (01:47 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296562 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[PS4] Set our default dialect to C++11. NFC for other targets.
Paul Robinson [Wed, 1 Mar 2017 01:01:10 +0000 (01:01 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296554 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Test] Make Lit tests C++11 compatible - IR ordering
Charles Li [Wed, 1 Mar 2017 00:10:00 +0000 (00:10 +0000)]
[Test] Make Lit tests C++11 compatible - IR ordering

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296549 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ODRHash] Add basic support for CXXRecordDecl
Richard Trieu [Tue, 28 Feb 2017 21:24:38 +0000 (21:24 +0000)]
[ODRHash] Add basic support for CXXRecordDecl

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296521 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAllow attributes before union definition
Erich Keane [Tue, 28 Feb 2017 20:44:39 +0000 (20:44 +0000)]
Allow attributes before union definition

permits typedef union __attribute__((transparent_union)) {...}

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296518 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: [Java] Fix bug in enum formatting.
Daniel Jasper [Tue, 28 Feb 2017 18:28:15 +0000 (18:28 +0000)]
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) {}
  }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296499 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoMigrate all of aarch64-linux-gnu to \01_mcount instead of just when passing along...
Eric Christopher [Tue, 28 Feb 2017 17:22:05 +0000 (17:22 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296490 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoDriver: Update devtoolset usage for RHEL
Tom Stellard [Tue, 28 Feb 2017 16:46:19 +0000 (16:46 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296485 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Sema] Detect more array index out of bounds when C++ overloaded operators are used
Daniel Marjamaki [Tue, 28 Feb 2017 14:53:50 +0000 (14:53 +0000)]
[Sema] Detect more array index out of bounds when C++ overloaded operators are used

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296477 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoBlacklist arbitrary @\\w+ JSDoc tags from wrapping.
Martin Probst [Tue, 28 Feb 2017 11:08:24 +0000 (11:08 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296467 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang/test/Format/inplace.cpp: Avoid using wildcard.
NAKAMURA Takumi [Tue, 28 Feb 2017 10:05:56 +0000 (10:05 +0000)]
clang/test/Format/inplace.cpp: Avoid using wildcard.

MSYS' tools don't do globbing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296460 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ARM] Don't pass -arm-execute-only to cc1as
Christof Douma [Tue, 28 Feb 2017 09:09:53 +0000 (09:09 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296454 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[clang-format] Fix test failure caused by "rm" on some buildbots.
Haojian Wu [Tue, 28 Feb 2017 09:03:07 +0000 (09:03 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296453 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoSet ABIs correctly for OpenBSD/arm; soft float and aapcs-linux.
Brad Smith [Tue, 28 Feb 2017 03:20:26 +0000 (03:20 +0000)]
Set ABIs correctly for OpenBSD/arm; soft float and aapcs-linux.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296430 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRevert "Reland: [analyzer] NFC: Update test infrastructure to support multiple constr...
Dominic Chen [Tue, 28 Feb 2017 01:50:23 +0000 (01:50 +0000)]
Revert "Reland: [analyzer] NFC: Update test infrastructure to support multiple constraint managers"

This reverts commit 1b28d0b10e1c8feccb971abb6ef7a18bee589830.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296422 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoReland: [analyzer] NFC: Update test infrastructure to support multiple constraint...
Dominic Chen [Tue, 28 Feb 2017 00:02:36 +0000 (00:02 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296414 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded
Nico Weber [Mon, 27 Feb 2017 22:59:58 +0000 (22:59 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296408 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoPR32042: Create inlined debug info for EmitInlinedInheritingCXXConstructorCall.
Adrian Prantl [Mon, 27 Feb 2017 21:30:05 +0000 (21:30 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296388 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoUBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not...
Nico Weber [Mon, 27 Feb 2017 21:27:07 +0000 (21:27 +0000)]
UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not catch UB.

https://reviews.llvm.org/D27455

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296387 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRemove unused variable
David Blaikie [Mon, 27 Feb 2017 21:14:42 +0000 (21:14 +0000)]
Remove unused variable

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296386 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ubsan] Factor out logic to emit a range check. NFC.
Vedant Kumar [Mon, 27 Feb 2017 19:46:19 +0000 (19:46 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296374 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoenable -flto=thin in clang-cl
Bob Haarman [Mon, 27 Feb 2017 19:40:19 +0000 (19:40 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296373 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[clang-format] Add a NamespaceEndCommentsFixer
Krasimir Georgiev [Mon, 27 Feb 2017 13:28:36 +0000 (13:28 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296341 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: [JS] whitespace after async in arrow functions.
Martin Probst [Mon, 27 Feb 2017 11:15:53 +0000 (11:15 +0000)]
clang-format: [JS] whitespace after async in arrow functions.

Summary:
Async arrow functions should be marked with a whitespace after the async keyword, before the parameter list:
    x = async () => foo();

Before:
    x = async() => foo();

This makes it easier to tell apart an async arrow function from a call to a function called async.

Reviewers: bkramer

Subscribers: cfe-commits, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296330 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[analyzer] clarify 'result is garbage value' when it is out of bounds
Daniel Marjamaki [Mon, 27 Feb 2017 10:44:24 +0000 (10:44 +0000)]
[analyzer] clarify 'result is garbage value' when it is out of bounds

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296326 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[GeneratePCHAction] If preprocessor option 'AllowPCHWithCompilerErrors' is enabled...
Argyrios Kyrtzidis [Mon, 27 Feb 2017 03:52:36 +0000 (03:52 +0000)]
[GeneratePCHAction] If preprocessor option 'AllowPCHWithCompilerErrors' is enabled, don't delete the produced PCH file if error diagnostics occurred.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296320 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRevert "[analyzer] NFC: Update test infrastructure to support multiple constraint...
Dominic Chen [Mon, 27 Feb 2017 03:29:25 +0000 (03:29 +0000)]
Revert "[analyzer] NFC: Update test infrastructure to support multiple constraint managers"

This reverts commit 8e7780b9e59ddaad1800baf533058d2c064d4787.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296317 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[analyzer] NFC: Update test infrastructure to support multiple constraint managers
Dominic Chen [Mon, 27 Feb 2017 02:36:15 +0000 (02:36 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296312 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAdd a cc1 flag for setting the existing Preprocessor option 'AllowPCHWithCompilerErrors'.
Argyrios Kyrtzidis [Mon, 27 Feb 2017 02:06:18 +0000 (02:06 +0000)]
Add a cc1 flag for setting the existing Preprocessor option 'AllowPCHWithCompilerErrors'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296306 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[X86] DAZ Macros Relocation
Oren Ben Simhon [Sun, 26 Feb 2017 11:58:15 +0000 (11:58 +0000)]
[X86] DAZ Macros Relocation

The DAZ feature introduces the denormal zero support for x86.
Currently the definitions are located under SSE3 header, however there are some SSE2 targets that support the feature as well.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296296 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[index] Add 'Parameter' symbol kind and 'Local' symbol property to distinguish functi...
Argyrios Kyrtzidis [Sun, 26 Feb 2017 05:37:56 +0000 (05:37 +0000)]
[index] Add 'Parameter' symbol kind and 'Local' symbol property to distinguish function-local symbols

Parameters have a 'child' relation to their function/method.
Also add an option '-include-locals' to 'c-index-test core' to enable indexing of function-local symbols.

Original patch from Nathan Hawes with some changes by me.
https://reviews.llvm.org/D30304

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296282 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoUpdate cxx_dr_status page.
Richard Smith [Sat, 25 Feb 2017 23:54:18 +0000 (23:54 +0000)]
Update cxx_dr_status page.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296276 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoC++ DR1611, 1658, 2180: implement "potentially constructed subobject" rules for speci...
Richard Smith [Sat, 25 Feb 2017 23:53:05 +0000 (23:53 +0000)]
C++ DR1611, 1658, 2180: implement "potentially constructed subobject" rules for special member functions.

Essentially, as a base class constructor does not construct virtual bases, such
a constructor for an abstract class does not need the corresponding base class
construction to be valid, and likewise for destructors.

This creates an awkward situation: clang will sometimes generate references to
the complete object and deleting destructors for an abstract class (it puts
them in the construction vtable for a derived class). But we can't generate a
"correct" version of these because we can't generate references to base class
constructors any more (if they're template specializations, say, we might not
have instantiated them and can't assume any other TU will emit a copy).
Fortunately, we don't need to, since no correct program can ever invoke them,
so instead emit symbols that just trap.

We should stop emitting references to these symbols, but still need to emit
definitions for compatibility.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296275 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[test] Disable test/Index/pch-from-libclang.c for non-darwin systems.
Argyrios Kyrtzidis [Sat, 25 Feb 2017 19:17:11 +0000 (19:17 +0000)]
[test] Disable test/Index/pch-from-libclang.c for non-darwin systems.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296267 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[test] Use cc1 -triple for test/Index/pch-from-libclang.c.
Argyrios Kyrtzidis [Sat, 25 Feb 2017 18:55:32 +0000 (18:55 +0000)]
[test] Use cc1 -triple for test/Index/pch-from-libclang.c.

Note quite sure why driver -target has no effect.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296265 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[test] Add target to test/Index/pch-from-libclang.c.
Argyrios Kyrtzidis [Sat, 25 Feb 2017 18:35:53 +0000 (18:35 +0000)]
[test] Add target to test/Index/pch-from-libclang.c.

Attempt to fix the failing bots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296263 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[driver] Pass a resource dir without the '/../' part.
Argyrios Kyrtzidis [Sat, 25 Feb 2017 18:14:35 +0000 (18:14 +0000)]
[driver] Pass a resource dir without the '/../' part.

This get the resource dir string to match with the one from libclang (which is not adding '/../'),
and allows clang to accept a modules-enabled PCH that was created by libclang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296262 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[modules] For -module-file-info, print out the resource dir path, since it is include...
Argyrios Kyrtzidis [Sat, 25 Feb 2017 18:14:31 +0000 (18:14 +0000)]
[modules] For -module-file-info, print out the resource dir path, since it is included in the module hash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296261 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAlso test OpenBSD/powerpc here for the various types expected to be the same across...
Brad Smith [Sat, 25 Feb 2017 16:35:18 +0000 (16:35 +0000)]
Also test OpenBSD/powerpc here for the various types expected to be the same across archs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296256 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoWeaken test/Profile/c-ternary.c
Vedant Kumar [Sat, 25 Feb 2017 07:21:23 +0000 (07:21 +0000)]
Weaken test/Profile/c-ternary.c

There is a bot which doesn't use '%1' as the IR name of the first
argument to a function:

http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/2050/steps/test-stage1-compiler/logs/stdio

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296248 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoSuppress uninteresting warnings in test/CoverageMapping, NFC.
Vedant Kumar [Sat, 25 Feb 2017 07:05:41 +0000 (07:05 +0000)]
Suppress uninteresting warnings in test/CoverageMapping, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296247 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoFix -Wparentheses warning
Vedant Kumar [Sat, 25 Feb 2017 06:47:00 +0000 (06:47 +0000)]
Fix -Wparentheses warning

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296246 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRetry: [profiling] Fix profile counter increment when emitting selects (PR32019)
Vedant Kumar [Sat, 25 Feb 2017 06:35:45 +0000 (06:35 +0000)]
Retry: [profiling] Fix profile counter increment when emitting selects (PR32019)

2nd attempt: the first was in r296231, but it had a use after lifetime
bug.

Clang has logic to lower certain conditional expressions directly into llvm
select instructions. However, it does not emit the correct profile counter
increment as it does this: it emits an unconditional increment of the counter
for the 'then branch', even if the value selected is from the 'else branch'
(this is PR32019).

That means, given the following snippet, we would report that "0" is selected
twice, and that "1" is never selected:

  int f1(int x) {
    return x ? 0 : 1;
               ^2  ^0
  }

  f1(0);
  f1(1);

Fix the problem by using the instrprof_increment_step intrinsic to do the
proper increment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296245 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[analyzer] Refactor and simplify SimpleConstraintManager
Dominic Chen [Sat, 25 Feb 2017 04:51:31 +0000 (04:51 +0000)]
[analyzer] Refactor and simplify SimpleConstraintManager

Summary: SimpleConstraintManager is difficult to use, and makes assumptions about capabilities of the constraint manager. This patch refactors out those portions into a new RangedConstraintManager, and also fixes some issues with camel case, formatting, and confusing naming.

Reviewers: zaks.anna, dcoughlin

Subscribers: mgorny, xazax.hun, NoQ, rgov, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296242 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAMDGPU: export s_sendmsg{halt} instrinsics
Jan Vesely [Sat, 25 Feb 2017 04:20:24 +0000 (04:20 +0000)]
AMDGPU: export s_sendmsg{halt} instrinsics

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296241 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAMDGPU: export l1 cache invalidation intrinsics
Jan Vesely [Sat, 25 Feb 2017 04:20:22 +0000 (04:20 +0000)]
AMDGPU: export l1 cache invalidation intrinsics

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296240 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAMDGPU: export s_waitcnt builtin
Jan Vesely [Sat, 25 Feb 2017 04:20:20 +0000 (04:20 +0000)]
AMDGPU: export s_waitcnt builtin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296239 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRevert r296166, "clang-format: Don't leave behind temp files in -i mode on Windows...
NAKAMURA Takumi [Sat, 25 Feb 2017 03:45:49 +0000 (03:45 +0000)]
Revert r296166, "clang-format: Don't leave behind temp files in -i mode on Windows, PR26125", and r296171.

(MemoryBuffer)Code.reset() was too early.

  ==26912== Invalid read of size 1
  ==26912==    at 0x437E1D: llvm::MemoryBuffer::init(char const*, char const*, bool) (MemoryBuffer.cpp:47)
  ==26912==    by 0x438013: (anonymous namespace)::MemoryBufferMem::MemoryBufferMem(llvm::StringRef, bool) (MemoryBuffer.cpp:86)
  ==26912==    by 0x438128: llvm::MemoryBuffer::getMemBuffer(llvm::StringRef, llvm::StringRef, bool) (MemoryBuffer.cpp:112)
  ==26912==    by 0x4E189D: clang::vfs::detail::(anonymous namespace)::InMemoryFileAdaptor::getBuffer(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:443)
  ==26912==    by 0x4DF5BA: clang::vfs::FileSystem::getBufferForFile(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:94)
  ==26912==    by 0x4B72EC: clang::FileManager::getBufferForFile(clang::FileEntry const*, bool, bool) (FileManager.cpp:443)
  ==26912==    by 0x4C1F81: clang::SrcMgr::ContentCache::getBuffer(clang::DiagnosticsEngine&, clang::SourceManager const&, clang::SourceLocation, bool*) const (SourceManager.cpp:98)
  ==26912==    by 0x4C50E5: clang::SourceManager::getBufferData(clang::FileID, bool*) const (SourceManager.cpp:689)
  ==26912==    by 0x58E794: clang::Rewriter::getEditBuffer(clang::FileID) (Rewriter.cpp:230)
  ==26912==    by 0x407297: clang::format::format(llvm::StringRef) (ClangFormat.cpp:311)
  ==26912==    by 0x4078D7: main (ClangFormat.cpp:363)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296237 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRevert "[profiling] Fix profile counter increment when emitting selects (PR32019)"
Vedant Kumar [Sat, 25 Feb 2017 02:59:47 +0000 (02:59 +0000)]
Revert "[profiling] Fix profile counter increment when emitting selects (PR32019)"

This reverts commit r296231. It causes an assertion failure on 32-bit
machines

clang: /export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/lib/IR/Instructions.cpp:263: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5fbfa)
llvm::sys::RunSignalHandlers() (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5dc7e)
SignalHandler(int) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1c5dde2)
__restore_rt (/lib64/libpthread.so.0+0x3f1d00efa0)
__GI_raise /home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
__GI_abort /home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/stdlib/abort.c:92:0
__assert_fail_base /home/glibctest/rpmbuild/BUILD/glibc-2.17-c758a686/assert/assert.c:92:0
(/lib64/libc.so.6+0x3f1c82e622)
llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1804e3a)
clang::CodeGen::CodeGenPGO::emitCounterIncrement(clang::CodeGen::CGBuilderTy&, clang::Stmt const*, llvm::Value*) (/export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/./bin/clang+0x1ec7891)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296234 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[profiling] Fix profile counter increment when emitting selects (PR32019)
Vedant Kumar [Sat, 25 Feb 2017 02:30:03 +0000 (02:30 +0000)]
[profiling] Fix profile counter increment when emitting selects (PR32019)

Clang has logic to lower certain conditional expressions directly into
llvm select instructions. However, it does not emit the correct profile
counter increment as it does this: it emits an unconditional increment
of the counter for the 'then branch', even if the value selected is from
the 'else branch' (this is PR32019).

That means, given the following snippet, we would report that "0" is
selected twice, and that "1" is never selected:

  int f1(int x) {
    return x ? 0 : 1;
               ^2  ^0
  }

  f1(0);
  f1(1);

Fix the problem by using the instrprof_increment_step intrinsic to do
the proper increment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296231 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ODRHash] Move inherited visitor call to end of function.
Richard Trieu [Sat, 25 Feb 2017 01:29:34 +0000 (01:29 +0000)]
[ODRHash] Move inherited visitor call to end of function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296221 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRevert r296209, still one more test to go.
Paul Robinson [Sat, 25 Feb 2017 00:50:34 +0000 (00:50 +0000)]
Revert r296209, still one more test to go.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296216 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ubsan] Detect signed overflow UB in remainder operations
Vedant Kumar [Sat, 25 Feb 2017 00:43:39 +0000 (00:43 +0000)]
[ubsan] Detect signed overflow UB in remainder operations

Teach ubsan to diagnose remainder operations which have undefined
behavior due to signed overflow (e.g INT_MIN % -1).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296214 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)
Vedant Kumar [Sat, 25 Feb 2017 00:43:36 +0000 (00:43 +0000)]
[ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

C requires the operands of arithmetic expressions to be promoted if
their types are smaller than an int. Ubsan emits overflow checks when
this sort of type promotion occurs, even if there is no way to actually
get an overflow with the promoted type.

This patch teaches clang how to omit the superflous overflow checks
(addressing PR20193).

Testing: check-clang and check-ubsan.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296213 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[PS4] Set our default dialect to C++11. NFC for other targets.
Paul Robinson [Sat, 25 Feb 2017 00:15:45 +0000 (00:15 +0000)]
[PS4] Set our default dialect to C++11. NFC for other targets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296209 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ODRHash] Finish FieldDecl support by handling mutable and initializers.
Richard Trieu [Fri, 24 Feb 2017 23:35:37 +0000 (23:35 +0000)]
[ODRHash] Finish FieldDecl support by handling mutable and initializers.

https://reviews.llvm.org/rL296170

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296198 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Test] Make Lit tests C++11 compatible #10
Charles Li [Fri, 24 Feb 2017 23:23:53 +0000 (23:23 +0000)]
[Test] Make Lit tests C++11 compatible #10

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296193 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Test] Make Lit tests C++11 compatible #9
Charles Li [Fri, 24 Feb 2017 22:22:05 +0000 (22:22 +0000)]
[Test] Make Lit tests C++11 compatible #9

[Test] Make Lit tests C++11 compatible #9

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296184 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoFactor out more commonality between handling of deletion and exception specifications...
Richard Smith [Fri, 24 Feb 2017 21:18:47 +0000 (21:18 +0000)]
Factor out more commonality between handling of deletion and exception specifications for special member functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296173 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoTry to unbreak tests after r296166
Nico Weber [Fri, 24 Feb 2017 21:01:43 +0000 (21:01 +0000)]
Try to unbreak tests after r296166

Looks like %T isn't per-test but per-test-directory, and
the rm was deleting temp files written by other tests in
test/Format.  Limit the rm's scope a bit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296171 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ODRHash] Add handling of bitfields
Richard Trieu [Fri, 24 Feb 2017 20:59:28 +0000 (20:59 +0000)]
[ODRHash] Add handling of bitfields

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296170 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: Don't leave behind temp files in -i mode on Windows, PR26125
Nico Weber [Fri, 24 Feb 2017 20:49:00 +0000 (20:49 +0000)]
clang-format: Don't leave behind temp files in -i mode on Windows, PR26125

Fix and analysis by Wei Mao <weimao1@gmail.com> (see bug), test by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296166 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: Enable include sorting for style=Chromium
Nico Weber [Fri, 24 Feb 2017 19:13:59 +0000 (19:13 +0000)]
clang-format: Enable include sorting for style=Chromium

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296161 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoclang-format: Fix many Objective-C formatting regressions from r289428
Nico Weber [Fri, 24 Feb 2017 19:10:12 +0000 (19:10 +0000)]
clang-format: Fix many Objective-C formatting regressions from r289428

r289428 added a separate language kind for Objective-C, but kept many
"Language == LK_Cpp" checks untouched.  This introduced a "IsCpp()"
method that returns true for both C++ and Objective-C++, and replaces
all comparisons of Language with LK_Cpp with calls to this new method.

Also add a lot more test coverge for formatting things in LK_ObjC mode,
by having FormatTest's verifyFormat() test for LK_ObjC everything that's
being tested for LK_Cpp at the moment.

Fixes PR32060 and many other things.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296160 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma
Alex Lorenz [Fri, 24 Feb 2017 17:45:16 +0000 (17:45 +0000)]
[Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma
in macro argument pre-expansion mode when skipping a function body

This commit fixes a token caching problem that currently occurs when clang is
skipping a function body (e.g. when looking for a code completion token) and at
the same time caching the tokens for _Pragma when lexing it in macro argument
pre-expansion mode.

When _Pragma is being lexed in macro argument pre-expansion mode, it caches the
tokens so that it can avoid interpreting the pragma immediately (as the macro
argument may not be used in the macro body), and then either backtracks over or
commits these tokens. The problem is that, when we're backtracking/committing in
such a scenario, there's already a previous backtracking position stored in
BacktrackPositions (as we're skipping the function body), and this leads to a
situation where the cached tokens from the pragma (like '(' 'string_literal'
and ')') will remain in the cached tokens array incorrectly even after they're
consumed (in the case of backtracking) or just ignored (in the case when they're
committed). Furthermore, what makes it even worse, is that because of a previous
backtracking position, the logic that deals with when should we call
ExitCachingLexMode in CachingLex no longer works for us in this situation, and
more tokens in the macro argument get cached, to the point where the EOF token
that corresponds to the macro argument EOF is cached. This problem leads to all
sorts of issues in code completion mode, where incorrect errors get presented
and code completion completely fails to produce completion results.

rdar://28523863

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296140 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoMade test more target agnostic
Serge Pavlov [Fri, 24 Feb 2017 13:15:08 +0000 (13:15 +0000)]
Made test more target agnostic

Recommits r295975 (Added regression tests), reverted in r295975,
because it did not work on non-X86 targets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296116 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoFix crash when an incorrect redeclaration only differs in __unaligned type-qualifier
Roger Ferrer Ibanez [Fri, 24 Feb 2017 08:41:09 +0000 (08:41 +0000)]
Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

Fix an assertion that is hit when a redeclaration with differing types only
differs in the unaligned type-qualifier.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296099 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoAdd clazy to external Clang examples page
Kevin Funk [Fri, 24 Feb 2017 08:29:46 +0000 (08:29 +0000)]
Add clazy to external Clang examples page

Reviewers: silvas, rizsotto.mailinglist, sergio.martins

Reviewed By: rizsotto.mailinglist

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296098 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Driver] Enable SafeStack for Fuchsia targets
Petr Hosek [Fri, 24 Feb 2017 03:17:41 +0000 (03:17 +0000)]
[Driver] Enable SafeStack for Fuchsia targets

The runtime support is provided directly by the Fuchsia system C
library.

Patch by Roland McGrath

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296082 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[ODRHash] Add handling of TypedefType and DeclarationName
Richard Trieu [Fri, 24 Feb 2017 02:59:12 +0000 (02:59 +0000)]
[ODRHash] Add handling of TypedefType and DeclarationName

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296078 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRepresent pass_object_size attrs in ExtParameterInfo
George Burgess IV [Fri, 24 Feb 2017 02:49:47 +0000 (02:49 +0000)]
Represent pass_object_size attrs in ExtParameterInfo

The goal of this is to fix a bug in modules where we'd merge
FunctionDecls that differed in their pass_object_size attributes. Since
we can overload on the presence of pass_object_size attributes, this
behavior is incorrect.

We don't represent `N` in `pass_object_size(N)` as part of
ExtParameterInfo, since it's an error to overload solely on the value of
N. This means that we have a bug if we have two modules that declare
functions that differ only in their pass_object_size attrs, like so:

// In module A, from a.h
void foo(char *__attribute__((pass_object_size(0))));

// In module B, from b.h
void foo(char *__attribute__((pass_object_size(1))));

// In module C, in main.c
#include "a.h"
#include "b.h"

At the moment, we'll merge the foo decls, when we should instead emit a
diagnostic about an invalid overload. We seem to have similar (silent)
behavior if we overload only on the return type of `foo` instead; I'll
try to find a good place to put a FIXME (or I'll just file a bug) soon.

This patch also fixes a bug where we'd not output the proper extended
parameter info for declarations with pass_object_size attrs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296076 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoFactor out some common code between SpecialMemberExceptionSpecInfo and SpecialMemberD...
Richard Smith [Fri, 24 Feb 2017 02:07:20 +0000 (02:07 +0000)]
Factor out some common code between SpecialMemberExceptionSpecInfo and SpecialMemberDeletionInfo.

To simplify this, convert SpecialMemberOverloadResult to a value type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296073 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoSimplify and pass a more useful source location when computing an exception
Richard Smith [Fri, 24 Feb 2017 01:36:58 +0000 (01:36 +0000)]
Simplify and pass a more useful source location when computing an exception
specification for an implicit special member.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296068 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRefactor computation of exception specification for special members to remove
Richard Smith [Fri, 24 Feb 2017 01:29:42 +0000 (01:29 +0000)]
Refactor computation of exception specification for special members to remove
some of the repetition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296067 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRecently a change was made to this test in r294639 which fails when the
Douglas Yung [Fri, 24 Feb 2017 01:25:02 +0000 (01:25 +0000)]
Recently a change was made to this test in r294639 which fails when the
compiler is run in a mode where the default C++ standard is newer than C++03.
The reason is because one of the warnings checked is only produced when the
compiler is using C++03 or lower.

This change fixes this problem as well as adds explicit run lines to run the
test in C++03 and C++11 modes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296066 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoRevert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin"
Hans Wennborg [Fri, 24 Feb 2017 01:16:34 +0000 (01:16 +0000)]
Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin"

It caused PR31864. There is a patch in progress to fix that, but let's
revert in the meantime.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296063 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[profiling] PR31992: Don't skip interesting non-base constructors
Vedant Kumar [Fri, 24 Feb 2017 01:15:19 +0000 (01:15 +0000)]
[profiling] PR31992: Don't skip interesting non-base constructors

Fix the fact that we don't assign profile counters to constructors in
classes with virtual bases, or constructors with variadic parameters.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296062 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[Driver] Move architecture-specific free helper functions to their own files.
David L. Jones [Fri, 24 Feb 2017 00:28:01 +0000 (00:28 +0000)]
[Driver] Move architecture-specific free helper functions to their own files.

This patch moves helper functions that are CPU-specific out of Driver.cpp and to
separate implementation files. The new files are named for the architecture,
e.g. ARMArch.cpp.

The next step after this will be to move OS-specific code, which I expect will
include many of the tool implementations, to similarly separate files.

Some CPU-specific functions are not being moved just yet. In cases where the
only caller is the platform-specific tools, I plan to move them together. An
example is Hexagon, where the only caller of the architecture-specific functions
are the tools themselves. (I'm happy to revise this choice, it just seems like
less churn to me.)

This does mean that some functions which were previously static are now exposed
through the library header Driver.h.

Reviewers: rsmith, javed.absar

Subscribers: aemerson, danalbert, srhines, dschuff, jyknight, nemanjai, mgorny, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296056 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoNFC, Remove commented out block of code from CGBlocks.cpp
Alex Lorenz [Fri, 24 Feb 2017 00:21:20 +0000 (00:21 +0000)]
NFC, Remove commented out block of code from CGBlocks.cpp

This is a preparation clean-up commit around the code that emits
block copy/dispose routines.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296054 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoNFC, Add a test that ensures that we don't emit helper code in copy/dispose
Alex Lorenz [Fri, 24 Feb 2017 00:09:30 +0000 (00:09 +0000)]
NFC, Add a test that ensures that we don't emit helper code in copy/dispose
routines for objects that are captured with the __unsafe_unretained
ownership qualifier

This is a preparation commit that improves code-coverage in code that emits
block copy/dispose routines.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296048 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoNFC, Add a test that ensure that we don't emit helper code in copy/dispose
Alex Lorenz [Thu, 23 Feb 2017 23:41:50 +0000 (23:41 +0000)]
NFC, Add a test that ensure that we don't emit helper code in copy/dispose
routines for variables that are const-captured

This is a preparation commit that improves code-coverage in code that emits
block copy/dispose routines.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296040 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[CodeGen] Silence unused variable warning in Release builds.
Benjamin Kramer [Thu, 23 Feb 2017 22:47:56 +0000 (22:47 +0000)]
[CodeGen] Silence unused variable warning in Release builds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296034 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoPR32044: Fix some cases where we would confuse a transparent init-list expression...
Richard Smith [Thu, 23 Feb 2017 22:41:47 +0000 (22:41 +0000)]
PR32044: Fix some cases where we would confuse a transparent init-list expression with an aggregate init.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296033 91177308-0d34-0410-b5e6-96231b3b80d8

7 years agoTighten up a regex in a test
George Burgess IV [Thu, 23 Feb 2017 22:14:55 +0000 (22:14 +0000)]
Tighten up a regex in a test

...If we're trying to match "this function has only two arguments", `.*`
probably isn't the best thing to use. :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296027 91177308-0d34-0410-b5e6-96231b3b80d8

7 years ago[CodeGen] Fix ExtParameterInfo bugs in C++ CodeGen code.
George Burgess IV [Thu, 23 Feb 2017 22:07:35 +0000 (22:07 +0000)]
[CodeGen] Fix ExtParameterInfo bugs in C++ CodeGen code.

This patch makes use of the prefix/suffix ABI argument distinction that
was introduced in r295870, so that we now emit ExtParameterInfo at the
correct offset for member calls that have added ABI arguments. I don't
see a good way to test the generated param info, since we don't actually
seem to use it in CGFunctionInfo outside of Swift. Any
suggestions/thoughts for how to better test this are welcome. :)

This patch also fixes a small bug with inheriting constructors: if we
decide not to pass args into an base class ctor, we would still
generate ExtParameterInfo as though we did. The added test-case is for
that behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296024 91177308-0d34-0410-b5e6-96231b3b80d8