]> granicus.if.org Git - clang/log
clang
7 years agoclang-format: [JS] correcly format object literal methods.
Martin Probst [Tue, 7 Feb 2017 16:33:13 +0000 (16:33 +0000)]
clang-format: [JS] correcly format object literal methods.

Summary:
In JavaScript, object literals can contain methods:

   var x = {
     a() { return 1; },
   };

Previously, clang-format always parsed nested {} inside a braced list as
further braced lists. Special case this logic for JavaScript to try
parsing as a braced list, but fall back to parsing as a child block.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

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

7 years ago[OpenCL] Accept logical NOT for pointer types in CL1.1
Anastasia Stulova [Tue, 7 Feb 2017 16:09:41 +0000 (16:09 +0000)]
[OpenCL] Accept logical NOT for pointer types in CL1.1

Fix for bug 30217 - incorrect error given for logical
NOT operation with a pointer type: corrected sema check
and improved related tests.

Review: D29038

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

7 years agoclang-format: [JS] exclaim preceding regex literals.
Martin Probst [Tue, 7 Feb 2017 14:08:03 +0000 (14:08 +0000)]
clang-format: [JS] exclaim preceding regex literals.

Summary:
Regex detection would incorrectly classify a trailing `!` operator
(nullability cast) followed by a `/` as the start of a regular
expression literal. This fixes code such as:

    var foo = x()! / 10;

Which would previously parse a regexp all the way to the end of the
source file (or next `/`).

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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

7 years agoclang-format: [JS] handle parenthesized class expressions.
Martin Probst [Tue, 7 Feb 2017 14:05:30 +0000 (14:05 +0000)]
clang-format: [JS] handle parenthesized class expressions.

Summary:
In JavaScript, classes are expressions, so they can appear e.g. in
argument lists.

    var C = foo(class {
      bar() {
        return 1;
      }
    };

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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

7 years agoRevert "Revert "[AVR] Allow specifying the CPU on the command line""
Dylan McKay [Tue, 7 Feb 2017 06:04:18 +0000 (06:04 +0000)]
Revert "Revert "[AVR] Allow specifying the CPU on the command line""

This reverts commit 7ac30e0f839fdab6d723ce2ef6a5b7a4cf03d150.

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

7 years agoAMDGPU: Add a test checking alignments of emitted globals/allocas
Matt Arsenault [Tue, 7 Feb 2017 04:28:02 +0000 (04:28 +0000)]
AMDGPU: Add a test checking alignments of emitted globals/allocas

Make sure the spec required type alignments are used in preparation
for a possible change which may break this.

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

7 years agoDriver: Do not link safestack with --whole-archive.
Peter Collingbourne [Tue, 7 Feb 2017 03:21:57 +0000 (03:21 +0000)]
Driver: Do not link safestack with --whole-archive.

This allows it to be used with the other sanitizers.

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

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

7 years agoP0091R3: Implement basic parsing support for C++17 deduction-guides.
Richard Smith [Tue, 7 Feb 2017 01:37:30 +0000 (01:37 +0000)]
P0091R3: Implement basic parsing support for C++17 deduction-guides.

We model deduction-guides as functions with a new kind of name that identifies
the template whose deduction they guide; the bulk of this patch is adding the
new name kind. This gives us a clean way to attach an extensible list of guides
to a class template in a way that doesn't require any special handling in AST
files etc (and we're going to need these functions we come to performing
deduction).

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

7 years ago[Lit Test] Make tests C++11 compatible - Microsoft diagnostics
Charles Li [Mon, 6 Feb 2017 19:32:38 +0000 (19:32 +0000)]
[Lit Test] Make tests C++11 compatible - Microsoft diagnostics

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

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

7 years ago[CMake] Add CLANG_INCLUDE_DIRS to CMake exports
Chris Bieneman [Mon, 6 Feb 2017 18:17:23 +0000 (18:17 +0000)]
[CMake] Add CLANG_INCLUDE_DIRS to CMake exports

This patch adds setting CLANG_INCLUDE_DIRS in the generated CMake package configuration files.

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

7 years ago[SystemZ] Provide predefined __ARCH__ and __VX__ macros
Ulrich Weigand [Mon, 6 Feb 2017 17:04:22 +0000 (17:04 +0000)]
[SystemZ] Provide predefined __ARCH__ and __VX__ macros

GCC 7 will predefine two new macros on s390x:

- __ARCH__ indicates the ISA architecture level
- __VX__ indicates that the vector facility is available

This adds those macros to clang as well to ensure continued
compatibility with GCC.

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

7 years ago[OpenMP] Remove fixme comment in regression test and related unnecessary statement
Carlo Bertolli [Mon, 6 Feb 2017 16:03:41 +0000 (16:03 +0000)]
[OpenMP] Remove fixme comment in regression test and related unnecessary statement

https://reviews.llvm.org/D29501

It looks like I forgot to remove a FIXME comment with the associated statement. The test does not need it and it gives the wrong impression of being an incomplete test.

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

7 years agoRevert "[AVR] Allow specifying the CPU on the command line"
Diana Picus [Mon, 6 Feb 2017 11:35:42 +0000 (11:35 +0000)]
Revert "[AVR] Allow specifying the CPU on the command line"

This reverts commit r294177. It seems to have broken some buildbots.

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

7 years agoclang-format: Fix bug with conflicting BreakBeforeBinaryOperations and AlignAfterOpen...
Daniel Jasper [Mon, 6 Feb 2017 10:55:49 +0000 (10:55 +0000)]
clang-format: Fix bug with conflicting BreakBeforeBinaryOperations and AlignAfterOpenBracket

Fix for the formatting options combination of
BreakBeforeBinaryOperators: All, AlignAfterOpenBracket: AlwaysBreak not
handling long templates correctly. This patch allows a break after an
opening left parenthesis, TemplateOpener, or bracket when both options
are enabled.

Patch by Daphne Pfister, thank you!

Fixes llvm.org/PR30304.

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

7 years ago[AVR] Allow specifying the CPU on the command line
Dylan McKay [Mon, 6 Feb 2017 09:07:56 +0000 (09:07 +0000)]
[AVR] Allow specifying the CPU on the command line

Summary:
This tells clang about all of the different AVR microcontrollers.

It also adds code to define the correct preprocessor macros for each
device.

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, cfe-commits

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

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

7 years ago[AVR] Add support for the full set of inline asm constraints
Dylan McKay [Mon, 6 Feb 2017 09:01:59 +0000 (09:01 +0000)]
[AVR] Add support for the full set of inline asm constraints

Summary:
Previously the method would simply return false, causing every single
inline assembly constraint to trigger a compile error.

This adds inline assembly constraint support for the AVR target.

This patch is derived from the code in
AVRISelLowering::getConstraintType.

More details can be found on the AVR-GCC reference wiki
http://www.nongnu.org/avr-libc/user-manual/inline_asm.html

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, ahatanak, saaadhu, cfe-commits

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

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

7 years agoBasic: match GCC behaviour for SuS macro
Saleem Abdulrasool [Sun, 5 Feb 2017 22:18:15 +0000 (22:18 +0000)]
Basic: match GCC behaviour for SuS macro

GCC does not generate `__unix` nor `unix` macros.  The latter already
intrudes into the user's namespace and should be avoided.  Use the
canonical spelling of `__unix__` across all the targets.

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

7 years ago[X86][MS]Adjacent comments within multi-line inline assembly statement
Coby Tayree [Sun, 5 Feb 2017 10:23:06 +0000 (10:23 +0000)]
[X86][MS]Adjacent comments within multi-line inline assembly statement

Allowing adjacent comments within MS inline assembly multi-line statement

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

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

7 years agoPR31846: Don't replace 'auto' type with a template parameter type in a generic lambda
Richard Smith [Sat, 4 Feb 2017 01:28:01 +0000 (01:28 +0000)]
PR31846: Don't replace 'auto' type with a template parameter type in a generic lambda
until after we've checked whether 'auto' is valid in the current language mode.

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

7 years agoDriver: Do not warn about unused -pthread when linking on darwin
Matthias Braun [Fri, 3 Feb 2017 23:09:31 +0000 (23:09 +0000)]
Driver: Do not warn about unused -pthread when linking on darwin

While there is nothing to do at link time to get pthreads support on
darwin, specifying the argument is fine and we should not warn about
unused arguments.

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

7 years ago[x86] fix tests with wrong dependency to pass because they broke with r294049
Sanjay Patel [Fri, 3 Feb 2017 22:03:47 +0000 (22:03 +0000)]
[x86] fix tests with wrong dependency to pass because they broke with r294049

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

7 years ago[OpenMP] Add missing regression test for pragma distribute, clause firstprivate
Carlo Bertolli [Fri, 3 Feb 2017 19:09:16 +0000 (19:09 +0000)]
[OpenMP] Add missing regression test for pragma distribute, clause firstprivate

https://reviews.llvm.org/D28243

The regression test was missing from the previous already accepted patch.

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

7 years ago[Lit Test] Make tests C++11 compatible - OpenMP constant expressions
Charles Li [Fri, 3 Feb 2017 18:58:34 +0000 (18:58 +0000)]
[Lit Test] Make tests C++11 compatible - OpenMP constant expressions

C++11 introduced constexpr, hence the change in diagnostics.

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

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

7 years agoclang-format: [JS] Fix bugs in parsing and aligning template strings.
Daniel Jasper [Fri, 3 Feb 2017 14:32:38 +0000 (14:32 +0000)]
clang-format: [JS] Fix bugs in parsing and aligning template strings.

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

7 years ago[Sema][ObjC++] Typo correction should handle ivars and properties
Alex Lorenz [Fri, 3 Feb 2017 14:22:33 +0000 (14:22 +0000)]
[Sema][ObjC++] Typo correction should handle ivars and properties

After r260016 and r260017 disabled typo correction for ivars and properties
clang didn't report errors about unresolved identifier in the base of ivar and
property ref expressions. This meant that clang invoked CodeGen on invalid AST
which then caused a crash.

This commit re-enables typo correction for ivars and properites, and fixes the
PR25113 & PR26486 (that were originally fixed in r260017 and r260016) in a
different manner by transforming the Objective-C ivar reference expression with
'IsFreeIvar' preserved.

rdar://30310772

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

7 years ago[clang-format] Re-align broken comment lines where appropriate.
Krasimir Georgiev [Fri, 3 Feb 2017 10:18:25 +0000 (10:18 +0000)]
[clang-format] Re-align broken comment lines where appropriate.

Summary:
The comment aligner was skipping over newly broken comment lines. This patch fixes that.

source:
```
int ab; // line
int a; // long long
```

format with column limit 15 before:
```
int ab; // line
int a;  // long
       // long
```

format with column limit 15 after:
```
int ab; // line
int a;  // long
        // long
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years agoclang-format: [Proto] Also supports implicit string literal concatenation
Daniel Jasper [Fri, 3 Feb 2017 08:29:02 +0000 (08:29 +0000)]
clang-format: [Proto] Also supports implicit string literal concatenation

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

7 years agoRevert "[Driver] Updated for Visual Studio 2017"
Reid Kleckner [Thu, 2 Feb 2017 19:36:22 +0000 (19:36 +0000)]
Revert "[Driver] Updated for Visual Studio 2017"

This reverts commit r293923. It causes test failures on Linux that need
time to debug.

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

7 years ago[Driver] Updated for Visual Studio 2017
Reid Kleckner [Thu, 2 Feb 2017 19:29:46 +0000 (19:29 +0000)]
[Driver] Updated for Visual Studio 2017

Summary:
The patch updates the MSVC ToolChain for the changes made in Visual
Studio 2017[1].

Other notable changes:
  - Path handling code has been centralised to make potential future
    changes less painful.
  - A compiler error is emitted if the driver is unable to locate a
    usable MSVC toolchain. (Previously it'd fail with a cryptic error
    such as "link.exe is not executable")
  - Support for the new Setup Config Server API[2] has been added,
    albeit block commented out with a preprocessor conditional. This can
    probably be re-evaluated when the API is officially released (it's
    currently at the RC stage), but it's left in to make it easy for
    anyone familiar with the API to give it a go with Clang.

Patch by Hamza Sood.

[1] https://blogs.msdn.microsoft.com/vcblog/2016/10/07/compiler-tools-layout-in-visual-studio-15/
[2] https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/

Reviewers: ruiu, hans, rnk

Reviewed By: rnk

Subscribers: awson, RKSimon, amccarth, cfe-commits

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

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

7 years agoPrevent ICE in dllexport class with _Atomic data member
Warren Ristow [Thu, 2 Feb 2017 17:53:34 +0000 (17:53 +0000)]
Prevent ICE in dllexport class with _Atomic data member

Guard against a null pointer dereference that caused Clang to crash
when processing a class containing an _Atomic qualified data member,
and that is tagged with 'dllexport'.

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

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

7 years ago[index] Provide a more general index::generateUSRForMacro() that doesn't depend on...
Argyrios Kyrtzidis [Thu, 2 Feb 2017 16:13:10 +0000 (16:13 +0000)]
[index] Provide a more general index::generateUSRForMacro() that doesn't depend on having a PreprocessingRecord.

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

7 years ago[clang-format] Don't reflow across comment pragmas.
Krasimir Georgiev [Thu, 2 Feb 2017 15:32:19 +0000 (15:32 +0000)]
[clang-format] Don't reflow across comment pragmas.

Summary:
The comment reflower wasn't taking comment pragmas as reflow stoppers. This patch fixes that.

source:
```
// long long long long
// IWYU pragma:
```
format with column limit  = 20 before:
```
// long long long
// long IWYU pragma:
```
format with column limit  = 20 after:
```
// long long long
// long
// IWYU pragma:
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years ago[clang-format] Fix breaking of comment sections in unwrapped lines containing newlines.
Krasimir Georgiev [Thu, 2 Feb 2017 14:36:50 +0000 (14:36 +0000)]
[clang-format] Fix breaking of comment sections in unwrapped lines containing newlines.

Summary:
The breaking of line comment sections was misaligning the case where the first comment line is on an unwrapped line containing newlines. In this case, the breaking column must be based on the source column of the last token that is preceded by a newline, not on the first token of the unwrapped line.

source:
```
enum A {
  a, // line 1
  // line 2
};
```
format before:
```
enum A {
  a, // line 1
     // line 2
};
```
format after:
```
enum A {
  a, // line 1
  // line 2
};
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years ago[clang-format] Don't reflow lines starting with TODO, FIXME or XXX.
Krasimir Georgiev [Thu, 2 Feb 2017 10:52:08 +0000 (10:52 +0000)]
[clang-format] Don't reflow lines starting with TODO, FIXME or XXX.

Summary: These lines commonly carry a special meaning.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years agoImprove docs: Add missing #pragma push directive.
Asiri Rathnayake [Thu, 2 Feb 2017 10:35:18 +0000 (10:35 +0000)]
Improve docs: Add missing #pragma push directive.

NFC.

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

7 years agoclang-format: Do not use two-argument/operand special case with no alignment
Daniel Jasper [Thu, 2 Feb 2017 08:30:21 +0000 (08:30 +0000)]
clang-format: Do not use two-argument/operand special case with no alignment

Without alignment, there is no clean separation between the arguments, even if
there are only two.

Before:
  aaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
          aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  aaaaaaaaaaaaaa(aaaaaaaaaaaa,
                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
                     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

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

7 years ago[analyzer] Fix an assertion fail in CStringSyntaxChecker.
Gabor Horvath [Thu, 2 Feb 2017 08:20:54 +0000 (08:20 +0000)]
[analyzer] Fix an assertion fail in CStringSyntaxChecker.

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

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

7 years agoFix typo. NFC
George Burgess IV [Thu, 2 Feb 2017 07:53:55 +0000 (07:53 +0000)]
Fix typo. NFC

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

7 years agoCodeGen: add a LLVM_FALLTHROUGH to a fallthrough (NFC)
Saleem Abdulrasool [Thu, 2 Feb 2017 05:45:43 +0000 (05:45 +0000)]
CodeGen: add a LLVM_FALLTHROUGH to a fallthrough (NFC)

Drive by cleanup noticed while investigating an IR verifier assertion.

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

7 years agoModules: Simplify CompilerInstance constructor, NFC
Duncan P. N. Exon Smith [Thu, 2 Feb 2017 05:09:51 +0000 (05:09 +0000)]
Modules: Simplify CompilerInstance constructor, NFC

Initialize fields directly in header.  Note that the ModuleManager field is an
IntrusiveRefCntPtr, so there's no need for explicit initialization.

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

7 years agoFix attribute name in diagnostic message to match actual attribute name.
Richard Smith [Thu, 2 Feb 2017 01:50:47 +0000 (01:50 +0000)]
Fix attribute name in diagnostic message to match actual attribute name.

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

7 years ago[CodeGen] Update test after recent changes in llvm (r293846).
Davide Italiano [Thu, 2 Feb 2017 00:47:53 +0000 (00:47 +0000)]
[CodeGen] Update test after recent changes in llvm (r293846).

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

7 years agoclang-format: Fix incorrect line breaks after forced operator wraps.
Daniel Jasper [Wed, 1 Feb 2017 23:27:37 +0000 (23:27 +0000)]
clang-format: Fix incorrect line breaks after forced operator wraps.

Before:
  bool x = aaaaa //
           ||
           bbbbb
           //
           || cccc;

After:
  bool x = aaaaa //
           || bbbbb
           //
           || cccc;

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

7 years agoChange debug-info-for-profiling from a TargetOption to a function attribute.
Dehao Chen [Wed, 1 Feb 2017 22:45:21 +0000 (22:45 +0000)]
Change debug-info-for-profiling from a TargetOption to a function attribute.

Summary: cfe change for https://reviews.llvm.org/D29203

Reviewers: echristo, dblaikie

Reviewed By: dblaikie

Subscribers: mehdi_amini, cfe-commits

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

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

7 years agoRepoint 'missing typename' diagnostic to the location where 'typename' should be...
Richard Smith [Wed, 1 Feb 2017 21:41:18 +0000 (21:41 +0000)]
Repoint 'missing typename' diagnostic to the location where 'typename' should be added.

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

7 years agoFix hole in our enforcement of rule requiring 'typename' prior to a dependent
Richard Smith [Wed, 1 Feb 2017 21:36:38 +0000 (21:36 +0000)]
Fix hole in our enforcement of rule requiring 'typename' prior to a dependent
name. If the dependent name happened to end in a template-id (X<T>::Y<U>), we
would fail to notice that the 'typename' keyword is missing when resolving it
to a type.

It turns out that GCC has a similar bug. If this shows up in much real code, we
can easily downgrade this to an ExtWarn.

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

7 years ago[CodeGen] Update test after recent changes in llvm (r293799).
Davide Italiano [Wed, 1 Feb 2017 20:43:28 +0000 (20:43 +0000)]
[CodeGen] Update test after recent changes in llvm (r293799).

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

7 years ago[Sema][ObjC] Don't pass a DeclRefExpr that doesn't reference a VarDecl
Akira Hatanaka [Wed, 1 Feb 2017 20:22:26 +0000 (20:22 +0000)]
[Sema][ObjC] Don't pass a DeclRefExpr that doesn't reference a VarDecl
to WeakObjectProfileTy's constructor.

This fixes an assertion failure in WeakObjectProfileTy's constructor.

rdar://problem/30112633

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

7 years agoDrop 'dllimport' when redeclaring inline function template without the attribute...
Hans Wennborg [Wed, 1 Feb 2017 18:52:53 +0000 (18:52 +0000)]
Drop 'dllimport' when redeclaring inline function template without the attribute (PR31695)

For non-template dllimport functions, MSVC allows providing an inline
definition without spelling out the attribute again. In the example below, f
remains a dllimport function.

  __declspec(dllimport) int f();
  inline int f() { return 42; }

  int useit() {
    return f();
  }

However, for a function template, not putting dllimport on the redeclaration
causes it to be dropped. In the example below, f is not dllimport.

  template <typename> __declspec(dllimport) int f();
  template <typename> inline int f() { return 42; }

  int useit() {
    return f<int>();
  }

This patch makes Clang match MSVC for the second example.

MSVC does not warn about the attribute being dropped in the example above, but
I think we should. (MSVC does warn if the inline keyword isn't used.)

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

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

7 years ago[CodeGen][ObjC] Avoid asserting on block pointer types in
Alex Lorenz [Wed, 1 Feb 2017 17:37:28 +0000 (17:37 +0000)]
[CodeGen][ObjC] Avoid asserting on block pointer types in
isPointerZeroInitializable

rdar://30111891

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

7 years agoRevert r293518 as it caused module linking error in clang-reorder-fields
Alex Lorenz [Wed, 1 Feb 2017 10:52:02 +0000 (10:52 +0000)]
Revert r293518 as it caused module linking error in clang-reorder-fields

This commit reverts "r293518 - [ASTMatchers] Sprinkle some constexpr on the
global matcher constructors" because after it a buildbot that builds clang
stage 2 with modules failed to link clang-reorder-fields.

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

7 years ago[clang-format] Fix regression about not aligning trailing comments in case they were...
Krasimir Georgiev [Wed, 1 Feb 2017 10:10:04 +0000 (10:10 +0000)]
[clang-format] Fix regression about not aligning trailing comments in case they were previously aligned, but at different indent.

Summary:
Comment reflower was adding untouchable tokens in case two consecutive comment lines are aligned in the source code. This disallows the whitespace manager to re-indent them later.

source:
```
int i = f(abc, // line 1
          d, // line 2
     // line 3
  b);
```
Since line 2 and line 3 are aligned, the reflower was marking line 3 as untouchable; however the three comment lines need to be re-aligned.
output before:
```
int i = f(abc, // line 1
          d,   // line 2
     // line 3
  b);
```
output after:
```
int i = f(abc, // line 1
          d,   // line 2
       // line 3
  b);
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: sammccall, cfe-commits, klimek

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

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

7 years agoFix Index test after recent clang-format change.
Daniel Jasper [Wed, 1 Feb 2017 10:00:10 +0000 (10:00 +0000)]
Fix Index test after recent clang-format change.

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

7 years agoclang-format: Don't force-wrap multiline RHSs for 2-operand experssions.
Daniel Jasper [Wed, 1 Feb 2017 09:23:39 +0000 (09:23 +0000)]
clang-format: Don't force-wrap multiline RHSs for 2-operand experssions.

This rows back on r288120, r291801 and r292110. I apologize in advance
for the churn. All of those revisions where meant to make the wrapping
of RHS expressions more consistent. However, now that they are
consistent, we seem to be a bit too eager.

The reasoning here is that I think it is generally correct that we want
to line-wrap before multiline RHS expressions (or multiline arguments to
a function call). However, if there are only two of such operands or
arguments, there is always a clear vertical separation between them and
the additional line break seems much less desirable.

Somewhat good examples are expressions like:

  EXPECT_EQ(2, someLongExpression(
                   orCall));

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

7 years agoDoxygen comments for prfchwintrin.h
Ekaterina Romanova [Wed, 1 Feb 2017 07:37:40 +0000 (07:37 +0000)]
Doxygen comments for prfchwintrin.h

Added doxygen comments to prfchwintrin.h's intrinsics.

Note: The doxygen comments are automatically generated based on Sony's intrinsic
s document.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

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

7 years agoRemove apparently-unnecessary copy of constructor lookup result.
Richard Smith [Wed, 1 Feb 2017 03:28:59 +0000 (03:28 +0000)]
Remove apparently-unnecessary copy of constructor lookup result.

Contrary to the comment, DeclContext intends to guarantee that the lookup
results for a particular name will be stable across non-AST-mutating
operations, so a copy here should not be necessary. Further, if a copy *is*
necessary, the other four instances of this pattern within this file would also
be wrong, and we have no evidence of any problems with them; if this change
unearths problems, we should fix all the instances of this pattern.

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

7 years agoFollow-up to r293732: add a proper triple to the test
Hans Wennborg [Wed, 1 Feb 2017 02:48:02 +0000 (02:48 +0000)]
Follow-up to r293732: add a proper triple to the test

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

7 years agoclang-cl: Evaluate arguments left-to-right in constructor call with initializer list...
Hans Wennborg [Wed, 1 Feb 2017 02:21:07 +0000 (02:21 +0000)]
clang-cl: Evaluate arguments left-to-right in constructor call with initializer list (PR31831)

clang-cl would evaluate the arguments right-to-left (see PR), and for
non-Windows targets I suppose we only got it because we were already
emitting left-to-right in CodeGenFunction::EmitCallArgs.

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

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

7 years agoFix modules codegen to be compatible with modules-ts
David Blaikie [Tue, 31 Jan 2017 21:28:19 +0000 (21:28 +0000)]
Fix modules codegen to be compatible with modules-ts

The Module::WithCodegen flag was only being set when the module was
parsed from a ModuleMap. Instead set it late, in the ASTWriter to match
the layer where the MODULAR_CODEGEN_DECLs list is determined (the
WithCodegen flag essentially means "are this module's decls in
MODULAR_CODEGEN_DECLs").

When simultaneous emission of AST file and modular object is implemented
this may need to change - the Module::WithCodegen flag will need to be
set earlier, and ideally the MODULAR_CODEGEN_DECLs gathering will
consult this flag (that's not possible right now since Decls destined
for an AST File don't have a Module - only if they're /read/ from a
Module is that true - I expect that would need to change as well).

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

7 years ago[Sema] Transform a templated name before looking it up in
Akira Hatanaka [Tue, 31 Jan 2017 19:53:32 +0000 (19:53 +0000)]
[Sema] Transform a templated name before looking it up in
FindInstantiatedDecl or passing it to RebuildMemberExpr.

This fixes PR30361.

rdar://problem/17341274

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

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

7 years agoExtend -Wcast-calling-convention to warn on declarations as well as definitions
Reid Kleckner [Tue, 31 Jan 2017 19:37:45 +0000 (19:37 +0000)]
Extend -Wcast-calling-convention to warn on declarations as well as definitions

My original warning was very conservative and I never revisited the
heuristics that were used.

This would have caught http://crbug.com/687251 at compile time.

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

7 years ago[windows] [asan] Fix tests failing after 293668.
Marcos Pividori [Tue, 31 Jan 2017 19:05:05 +0000 (19:05 +0000)]
[windows] [asan] Fix tests failing after 293668.

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

7 years agoKeep Chromium ObjC column limit at 80 for consistency with C++
Nico Weber [Tue, 31 Jan 2017 18:42:05 +0000 (18:42 +0000)]
Keep Chromium ObjC column limit at 80 for consistency with C++

https://reviews.llvm.org/D29337
Patch from Dan Beam <dbeam@chromium.org>!

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

7 years ago[windows] [asan] Add wholearchive flag when including static lib asan.
Marcos Pividori [Tue, 31 Jan 2017 18:31:38 +0000 (18:31 +0000)]
[windows] [asan] Add wholearchive flag when including static lib asan.

In Windows, when the sanitizer is implemented as a static library, we use
auxiliary static library dll_thunk that will be linked to the dlls that have
instrumentation, so they can refer to the runtime in the main executable.
It uses interception to get a pointer the function in the main executable and
override its function with that pointer.
Because of that, we need to ensure that the main executable exports all the
sanitizers' interface, otherwise the initialization in dll_thunk will fail.

In this commit we add the flag -wholearchive to clang driver to ensure that
the linker does not omit any object files from asan library.

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

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

7 years ago[X86] Teach Clang about -mfentry flag
Nirav Dave [Tue, 31 Jan 2017 17:00:35 +0000 (17:00 +0000)]
[X86] Teach Clang about -mfentry flag

Replace mcount calls with calls to fentry.

Reviewers: hfinkel, craig.topper

Subscribers: llvm-commits

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

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

7 years ago[clang-format] Fix regression about adding leading whitespace to the content of line...
Krasimir Georgiev [Tue, 31 Jan 2017 15:40:15 +0000 (15:40 +0000)]
[clang-format] Fix regression about adding leading whitespace to the content of line comments

Summary:
The reflower didn't measure precisely the line column of a line in the middle of
a line comment section that has a prefix that needs to be adapted.

source:
```
/// a
//b
```

format before:
```
/// a
 //b
```

format after:
```
/// a
// b
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: sammccall, cfe-commits, klimek

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

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

7 years agoclang-format: [JS] Indent expressions in ${} relative to their surrounding
Daniel Jasper [Tue, 31 Jan 2017 14:39:33 +0000 (14:39 +0000)]
clang-format: [JS] Indent expressions in ${} relative to their surrounding

This only affects expressions inside ${} scopes of template strings.
Here, we want to indent relative to the surrounding template string and
not the surrounding expression. Otherwise, this can create quite a mess.

Before:
  var f = `
    aaaaaaaaaaaaaaaaaa: ${someFunction(
      aaaaa +  //
      bbbb)}`;

After:
  var f = `
    aaaaaaaaaaaaaaaaaa: ${someFunction(
                              aaaaa +  //
                              bbbb)}`;

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

7 years ago[clang-format] Fix reflow in block comment lines with leading whitespace.
Krasimir Georgiev [Tue, 31 Jan 2017 14:31:44 +0000 (14:31 +0000)]
[clang-format] Fix reflow in block comment lines with leading whitespace.

Summary:
The reflower was not taking into account the additional  leading whitespace in block comment lines.

source:
```
{
/*
 * long long long long
 *   long
 * long long long long
 */
}
```

format (with column limit 20) before:
```
{
  /*
   * long long long
   * long long long long
   * long long
   */
}
```
format after:
```
{
  /*
   * long long long
   * long long long
   * long long long
   */
}
```

Reviewers: djasper, klimek

Reviewed By: djasper

Subscribers: cfe-commits, sammccall, klimek

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

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

7 years ago[cmake] Hint find_package() to prefer LLVM installed alongside clang
Michal Gorny [Tue, 31 Jan 2017 14:15:40 +0000 (14:15 +0000)]
[cmake] Hint find_package() to prefer LLVM installed alongside clang

Include a path hint for find_package() in ClangConfig.cmake to ensure
that CMake prefers LLVM installed alongside clang over the default
search path.

If two versions of LLVM are installed in the system, and one of them is
in PATH, CMake's find_package() magic prefers the CMake directory
alongside that install by default. Adding a relative hint makes it
possible to prioritize to the install from which find_package() is
called.

If you want to build e.g. LLDB against another install of LLVM, you can
pass LLVM_CONFIG override. In this case, LLDB queries the prefix from
llvm-config and uses the CMake files located there. However, when
including ClangConfig, the implicit find_package() nevertheless prefers
PATH-found LLVM over the one used previously by LLDB, and two versions
of LLVMConfig end up being loaded.

This could be fixed on LLDB end up by explicitly forcing custom package
search location. However, it seems simpler and safer to add a hint to
ClangConfig than to track every usage of ClangConfig.

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

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

7 years ago[clang-format] Fix regression merging comments across newlines.
Krasimir Georgiev [Tue, 31 Jan 2017 13:32:38 +0000 (13:32 +0000)]
[clang-format] Fix regression merging comments across newlines.

Summary:
This fixes a regression that causes example:
```
enum A {
  a, // line a

  // line b
  b
};
```
to be formatted as follows:
```
enum A {
  a, // line a
     // line b
  b
};
```

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: cfe-commits, sammccall, djasper, klimek

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

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

7 years agoclang-format: [JS] Properly set scopes inside template strings.
Daniel Jasper [Tue, 31 Jan 2017 13:03:07 +0000 (13:03 +0000)]
clang-format: [JS] Properly set scopes inside template strings.

Before:
  var f = `aaaaaaaaaaaaa:${aaaaaaa
              .aaaaa} aaaaaaaa
           aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa`;

After:
  var f = `aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa
           aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa`;

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

7 years agoclang-format: [JS] Fix incorrect line break in template strings.
Daniel Jasper [Tue, 31 Jan 2017 12:07:35 +0000 (12:07 +0000)]
clang-format: [JS] Fix incorrect line break in template strings.

Before:
  var f = `aaaa ${a ? 'a' : 'b'
                            }`;

After:
  var f = `aaaa ${a ? 'a' : 'b'}`;

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

7 years ago[clang-format] Don't reflow comment lines starting with '@'.
Krasimir Georgiev [Tue, 31 Jan 2017 11:38:02 +0000 (11:38 +0000)]
[clang-format] Don't reflow comment lines starting with '@'.

Summary:
This patch stops reflowing comment lines starting with '@', since they commonly
have a special meaning.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years ago[clang-format] Refactor WhitespaceManager and friends
Daniel Jasper [Tue, 31 Jan 2017 11:25:01 +0000 (11:25 +0000)]
[clang-format] Refactor WhitespaceManager and friends

The main motivation behind this is to cleanup the WhitespaceManager and
make it more extensible for future alignment etc. features.
Specifically, WhitespaceManager has started to copy more and more code
that is already present in FormatToken. Instead, I think it makes more
sense to actually store a reference to each FormatToken for each change.

This has as a consequence led to a change in the calculation of indent
levels. Now, we actually compute them for each Token ahead of time,
which should be more efficient as it removes an unsigned value for the
ParenState, which is used during the combinatorial exploration of the
solution space.

No functional changes intended.

Review: https://reviews.llvm.org/D29300

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

7 years agoRevert r293585 "Add better ODR checking for modules."
Sam McCall [Tue, 31 Jan 2017 08:24:40 +0000 (08:24 +0000)]
Revert r293585 "Add better ODR checking for modules."

We're seeing what we believe are false positives. (It's hard to tell with the
available diagnostics, and I'm not sure how to reduce them yet).
I'll send Richard reproduction details offline.

djasper/chandlerc suggested this should be a warning for now, to make rolling it
out feasible.

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

7 years ago[lsan] Enable LSan for x86 Linux
Maxim Ostapenko [Tue, 31 Jan 2017 07:00:23 +0000 (07:00 +0000)]
[lsan] Enable LSan for x86 Linux

This is a missed part of https://reviews.llvm.org/D28609.
Enable LSan for x86 Linux in clang driver.

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

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

7 years agoIn VirtualCallChecker, handle indirect calls
Sam McCall [Tue, 31 Jan 2017 05:23:20 +0000 (05:23 +0000)]
In VirtualCallChecker, handle indirect calls

Summary:
In VirtualCallChecker, handle indirect calls.

getDirectCallee() can be nullptr, and dyn_cast(nullptr) is UB

Reviewers: bkramer

Subscribers: cfe-commits

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

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

7 years agoAMDGPU: Add builtin for fmed3 intrinsic
Matt Arsenault [Tue, 31 Jan 2017 03:42:07 +0000 (03:42 +0000)]
AMDGPU: Add builtin for fmed3 intrinsic

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

7 years agoHandle ObjCEncodeExpr in extractStringLiteralCharacter.
Akira Hatanaka [Tue, 31 Jan 2017 02:31:39 +0000 (02:31 +0000)]
Handle ObjCEncodeExpr in extractStringLiteralCharacter.

This fixes an assertion failure that occurs later in the function when
an ObjCEncodeExpr is cast to StringLiteral.

rdar://problem/30111207

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

7 years agoImprove fix for PR28739
Richard Smith [Tue, 31 Jan 2017 02:23:02 +0000 (02:23 +0000)]
Improve fix for PR28739

Don't try to map an APSInt addend to an int64_t in pointer arithmetic before
bounds-checking it. This gives more consistent behavior (outside C++11, we
consistently use 2s complement semantics for both pointer and integer overflow
in constant expressions) and fixes some cases where in C++11 we would fail to
properly check for out-of-bounds pointer arithmetic (if the 2s complement
64-bit overflow landed us back in-bounds).

In passing, also fix some cases where we'd perform possibly-overflowing
arithmetic on CharUnits (which have a signed underlying type) during constant
expression evaluation.

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

7 years agoAdd better ODR checking for modules.
Richard Trieu [Tue, 31 Jan 2017 01:44:15 +0000 (01:44 +0000)]
Add better ODR checking for modules.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taked from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

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

7 years agoRe-apply "[ubsan] Sanity-check shift amounts before truncation"
Vedant Kumar [Mon, 30 Jan 2017 23:38:54 +0000 (23:38 +0000)]
Re-apply "[ubsan] Sanity-check shift amounts before truncation"

This re-applies r293343 (reverts commit r293475) with a fix for an
assertion failure caused by a missing integer cast. I tested this patch
by using the built compiler to compile X86FastISel.cpp.o with ubsan.

Original commit message:

Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.

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

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

7 years agoPR28739: Check that integer values fit into 64 bits before extracting them as 64...
Richard Smith [Mon, 30 Jan 2017 23:30:26 +0000 (23:30 +0000)]
PR28739: Check that integer values fit into 64 bits before extracting them as 64 bit values for pointer arithmetic.

This fixes various ways to tickle an assertion in constant expression
evaluation when using __int128. Longer term, we need to figure out what should
happen here: either any kind of overflow in offset calculation should result in
a non-constant value or we should truncate to 64 bits. In C++11 onwards, we're
effectively already checking for overflow because we strictly enforce array
bounds checks, but even there some forms of overflow can slip past undetected.

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

7 years agoSerialization: use range based for loop (NFC)
Saleem Abdulrasool [Mon, 30 Jan 2017 22:25:28 +0000 (22:25 +0000)]
Serialization: use range based for loop (NFC)

Just a small clean up noticed when doing post-commit review of Duncan's
previous change for ModuleFile memory ownership semantics.  NFC.

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

7 years ago[clang-format] Fix regression that breaks comments without a comment prefix
Krasimir Georgiev [Mon, 30 Jan 2017 21:00:01 +0000 (21:00 +0000)]
[clang-format] Fix regression that breaks comments without a comment prefix

Summary:
Consider formatting the following code fragment with column limit 20:
```
{
  // line 1
  // line 2\
  // long long long line
}
```
Before this fix the output is:
```
{
  // line 1
  // line 2\
  // long long
  long line
}
```
This patch fixes a regression that breaks the last comment line without
adding the '//' prefix.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years agoTowards P0091R3: parsing support for class template argument deduction in typename...
Richard Smith [Mon, 30 Jan 2017 20:39:26 +0000 (20:39 +0000)]
Towards P0091R3: parsing support for class template argument deduction in typename-specifiers.

This reinstates r293455, reverted in r293455, with a fix for cv-qualifier
handling on dependent typename-specifiers.

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

7 years ago[clang-format] Separate line comment sections after a right brace from comment sectio...
Krasimir Georgiev [Mon, 30 Jan 2017 19:18:55 +0000 (19:18 +0000)]
[clang-format] Separate line comment sections after a right brace from comment sections in the scope.

Summary:
The following two comment lines form a single comment section:
```
if (1) { // line 1
   // line 2
}
```
This is because the break of a comment section was based on the original column
of the first token of the previous line (in this case, the 'if').
This patch splits these two comment lines into different sections by taking into
account the original column of the right brace preceding the first line comment
where applicable.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

7 years ago[AST] Give TemplateArgumentLoc a constexpr ctor.
Benjamin Kramer [Mon, 30 Jan 2017 18:32:46 +0000 (18:32 +0000)]
[AST] Give TemplateArgumentLoc a constexpr ctor.

This removes the thread-safe static from
clang::TemplateTemplateParmDecl::getDefaultArgument() const::None

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

7 years ago[ASTMatchers] Sprinkle some constexpr on the global matcher constructors.
Benjamin Kramer [Mon, 30 Jan 2017 18:20:00 +0000 (18:20 +0000)]
[ASTMatchers] Sprinkle some constexpr on the global matcher constructors.

This dramatically reduces the size of the global constructors we emit
for those variables in debug mode.

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

7 years agoAdjust tests after folding inlining analysis into missed remarks
Adam Nemet [Mon, 30 Jan 2017 16:22:50 +0000 (16:22 +0000)]
Adjust tests after folding inlining analysis into missed remarks

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

7 years ago[AST] Make header standalone.
Benjamin Kramer [Mon, 30 Jan 2017 16:00:57 +0000 (16:00 +0000)]
[AST] Make header standalone.

Most implementations get ptrdiff_t transitively, some don't. Explicitly
include cstddef.

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

7 years ago[IRGen] Make header standalone.
Benjamin Kramer [Mon, 30 Jan 2017 15:39:18 +0000 (15:39 +0000)]
[IRGen] Make header standalone.

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

7 years agoRevert "r293343 - [ubsan] Sanity-check shift amounts before truncation
Alex Lorenz [Mon, 30 Jan 2017 11:37:18 +0000 (11:37 +0000)]
Revert "r293343 - [ubsan] Sanity-check shift amounts before truncation
(fixes PR27271)"

After r293343 clang fails to compile itself with -fsanitize=undefined (
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_build/).

rdar://30259929

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

7 years agoRevert r293455, which breaks v8 with a spurious error. Testcase added.
Sam McCall [Mon, 30 Jan 2017 10:44:11 +0000 (10:44 +0000)]
Revert r293455, which breaks v8 with a spurious error. Testcase added.

Summary: Revert r293455, which breaks v8 with a spurious error. Testcase added.

Reviewers: klimek

Subscribers: cfe-commits, rsmith

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

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

7 years ago[c-index-test] CMake: add missing reference to clangSerialization library.
Argyrios Kyrtzidis [Mon, 30 Jan 2017 07:11:27 +0000 (07:11 +0000)]
[c-index-test] CMake: add missing reference to clangSerialization library.

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

7 years agoclang-format: [JavaScript] Undo r291974 for JavaScript.
Daniel Jasper [Mon, 30 Jan 2017 07:08:40 +0000 (07:08 +0000)]
clang-format: [JavaScript] Undo r291974 for JavaScript.

This had significant negative consequences and I don't have a good
solution for it yet.

Before:
  var string =
      [
        'aaaaaa',
        'bbbbbb',
      ]
          .join('+');

After:
  var string = [
    'aaaaaa',
    'bbbbbb',
  ].join('+');

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

7 years ago[index] CMake: add missing reference to clangSerialization library.
Argyrios Kyrtzidis [Mon, 30 Jan 2017 06:48:27 +0000 (06:48 +0000)]
[index] CMake: add missing reference to clangSerialization library.

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

7 years agoReapply "DebugInfo: Omit class definitions even in the presence of available_external...
David Blaikie [Mon, 30 Jan 2017 06:36:08 +0000 (06:36 +0000)]
Reapply "DebugInfo: Omit class definitions even in the presence of available_externally vtables"

Accounts for a case that caused an assertion failure by attempting to
query for the vtable linkage of a non-dynamic type.t

This reverts commit r292801.

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

7 years ago[c-index-test] Provide capability to index module file imports and dump their input...
Argyrios Kyrtzidis [Mon, 30 Jan 2017 06:05:58 +0000 (06:05 +0000)]
[c-index-test] Provide capability to index module file imports and dump their input files.

This ensures the capability to index a module file using an existing ASTReader from a compiler instance or ASTUnit.

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

7 years agoTidy up codegen modules test & make it x86 specific since it relies on Itanium name...
David Blaikie [Mon, 30 Jan 2017 05:33:51 +0000 (05:33 +0000)]
Tidy up codegen modules test & make it x86 specific since it relies on Itanium name manglings

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