]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] MallocChecker: Fix one more bug category.
Artem Dergachev [Thu, 8 Feb 2018 23:28:29 +0000 (23:28 +0000)]
[analyzer] MallocChecker: Fix one more bug category.

Even though most of the inconsistencies in MallocChecker's bug categories were
fixed in r302016, one more was introduced in r301913 which was later missed.

Patch by Henry Wong!

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

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

6 years agoAdd Rest of Targets Support to ValidCPUList (enabling march notes)
Erich Keane [Thu, 8 Feb 2018 23:16:55 +0000 (23:16 +0000)]
Add Rest of Targets Support to ValidCPUList (enabling march notes)

A followup to: https://reviews.llvm.org/D42978

Most of the rest of the Targets were pretty rote, so this
patch knocks them all out at once.

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

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

6 years agoAdd NVPTX Support to ValidCPUList (enabling march notes)
Erich Keane [Thu, 8 Feb 2018 23:16:00 +0000 (23:16 +0000)]
Add NVPTX Support to ValidCPUList (enabling march notes)

A followup to: https://reviews.llvm.org/D42978
This patch adds NVPTX support for
enabling the march notes.

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

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

6 years agoAdd X86 Support to ValidCPUList (enabling march notes)
Erich Keane [Thu, 8 Feb 2018 23:15:02 +0000 (23:15 +0000)]
Add X86 Support to ValidCPUList (enabling march notes)

A followup to: https://reviews.llvm.org/D42978
This patch adds X86 and X86_64 support for
enabling the march notes.

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

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

6 years agoMake march/target-cpu print a note with the list of valid values for ARM
Erich Keane [Thu, 8 Feb 2018 23:14:15 +0000 (23:14 +0000)]
Make march/target-cpu print a note with the list of valid values for ARM

When rejecting a march= or target-cpu command line parameter,
the message is quite lacking. This patch adds a note that prints
all possible values for the current target, if the target supports it.

This adds support for the ARM/AArch64 targets (more to come!).

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

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

6 years ago[CFG] Add extra context to C++ constructor statement elements.
Artem Dergachev [Thu, 8 Feb 2018 22:58:15 +0000 (22:58 +0000)]
[CFG] Add extra context to C++ constructor statement elements.

This patch adds a new CFGStmt sub-class, CFGConstructor, which replaces
the regular CFGStmt with CXXConstructExpr in it whenever the CFG has additional
information to provide regarding what sort of object is being constructed.

It is useful for figuring out what memory is initialized in client of the
CFG such as the Static Analyzer, which do not operate by recursive AST
traversal, but instead rely on the CFG to provide all the information when they
need it. Otherwise, the statement that triggers the construction and defines
what memory is being initialized would normally occur after the
construct-expression, and the client would need to peek to the next CFG element
or use statement parent map to understand the necessary facts about
the construct-expression.

As a proof of concept, CFGConstructors are added for new-expressions
and the respective test cases are provided to demonstrate how it works.

For now, the only additional data contained in the CFGConstructor element is
the "trigger statement", such as new-expression, which is the parent of the
constructor. It will be significantly expanded in later commits. The additional
data is organized as an auxiliary structure - the "construction context",
which is allocated separately from the CFGElement.

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

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

6 years ago[analyzer] Self-debug: Dump the core's internal state traits to the egraph.
Artem Dergachev [Thu, 8 Feb 2018 22:32:38 +0000 (22:32 +0000)]
[analyzer] Self-debug: Dump the core's internal state traits to the egraph.

It is useful for debugging problems with C++ operator new() or temporaries.

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

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

6 years ago[analyzer] Self-debug: Dump environment frame-by-frame.
Artem Dergachev [Thu, 8 Feb 2018 22:24:38 +0000 (22:24 +0000)]
[analyzer] Self-debug: Dump environment frame-by-frame.

It makes it easier to discriminate between values of similar expressions
in different stack frames.

It also makes the separate backtrace section in ExplodedGraph dumps redundant.

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

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

6 years ago[analyzer] [tests] Test different projects concurrently
George Karpenkov [Thu, 8 Feb 2018 21:22:42 +0000 (21:22 +0000)]
[analyzer] [tests] Test different projects concurrently

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

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

6 years agoPR36307: Consume the #pragma options align annotation token after
Alex Lorenz [Thu, 8 Feb 2018 21:20:43 +0000 (21:20 +0000)]
PR36307: Consume the #pragma options align annotation token after
semantic analysis to prevent incorrect -Wpragma-pack warning for an included
file

rdar://37354951

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

6 years ago[X86] Replace kortest intrinsics with native IR.
Craig Topper [Thu, 8 Feb 2018 20:16:17 +0000 (20:16 +0000)]
[X86] Replace kortest intrinsics with native IR.

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

6 years agoFix improper indentation issue in CodeGenModule [NFC]
Erich Keane [Thu, 8 Feb 2018 20:04:22 +0000 (20:04 +0000)]
Fix improper indentation issue in CodeGenModule [NFC]

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

6 years agoFix crash on array initializer with non-0 alloca addrspace
Matt Arsenault [Thu, 8 Feb 2018 19:37:09 +0000 (19:37 +0000)]
Fix crash on array initializer with non-0 alloca addrspace

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

6 years ago[clang-format] Do not break Objective-C string literals inside array literals
Ben Hamilton [Thu, 8 Feb 2018 16:07:25 +0000 (16:07 +0000)]
[clang-format] Do not break Objective-C string literals inside array literals

Summary:
Concatenating Objective-C string literals inside an array literal
raises the warning -Wobjc-string-concatenation (which is enabled by default).

clang-format currently splits and concatenates string literals like
the following:

  NSArray *myArray = @[ @"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ];

into:

  NSArray *myArray =
        @[ @"aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
           @"aaaaaaaaa" ];

which raises the warning. This is https://bugs.llvm.org/show_bug.cgi?id=36153 .

The options I can think of to fix this are:

1) Have clang-format disable Wobjc-string-concatenation by emitting
pragmas around the formatted code
2) Have clang-format wrap the string literals in a macro (which
disables the warning)
3) Disable string splitting for Objective-C string literals inside
array literals

I think 1) has no precedent, and I couldn't find a good
identity() macro for 2). So, this diff implements 3).

Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, stephanemoore, djasper

Reviewed By: jolesiak

Subscribers: klimek, cfe-commits

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

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

6 years ago[Parser][FixIt] Better diagnostics for "typedef" instead of "typename" typo
Jan Korous [Thu, 8 Feb 2018 14:37:58 +0000 (14:37 +0000)]
[Parser][FixIt] Better diagnostics for "typedef" instead of "typename" typo

rdar://problem/10214588

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

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

6 years agoFix for #31362 - ms_abi is implemented incorrectly for values >=16 bytes.
Alexander Ivchenko [Thu, 8 Feb 2018 11:15:21 +0000 (11:15 +0000)]
Fix for #31362 - ms_abi is implemented incorrectly for values >=16 bytes.

Summary:
This patch is a fix for following issue:
https://bugs.llvm.org/show_bug.cgi?id=31362 The problem was caused by front end
lowering C calling conventions without taking into account calling conventions
enforced by attribute. In this case win64cc was no correctly lowered on targets
other than Windows.

Reviewed By: rnk (Reid Kleckner)

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

Author: belickim <mateusz.belicki@intel.com>

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

6 years ago[clang-format] Do not break before long string literals in protos
Krasimir Georgiev [Thu, 8 Feb 2018 10:47:12 +0000 (10:47 +0000)]
[clang-format] Do not break before long string literals in protos

Summary:
This patch is a follow-up to r323319 (which disables string literal breaking for
text protos) and it disables breaking before long string literals.

For example this:
```
keyyyyy: "long string literal"
```
used to get broken into:
```
keyyyyy:
    "long string literal"
```

While at it, I also enabled it for LK_Proto and fixed a bug in the mustBreak code.

Reviewers: djasper, sammccall

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Set ObjCBinPackProtocolList to Never for google style
Ben Hamilton [Thu, 8 Feb 2018 01:49:10 +0000 (01:49 +0000)]
[clang-format] Set ObjCBinPackProtocolList to Never for google style

Summary:
This is split off from D42650, and sets ObjCBinPackProtocolList
to Never for the google style.

Depends On D42650

Test Plan: New tests added. make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, jolesiak, stephanemoore

Reviewed By: krasimir, jolesiak, stephanemoore

Subscribers: klimek, cfe-commits, hokein, Wizard

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

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

6 years agoAdd a testcase for PR36268.
Rafael Espindola [Thu, 8 Feb 2018 01:17:26 +0000 (01:17 +0000)]
Add a testcase for PR36268.

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

6 years ago[NFCi] Replace a couple of usages of const StringRef& with StringRef
Erich Keane [Wed, 7 Feb 2018 23:04:38 +0000 (23:04 +0000)]
[NFCi] Replace a couple of usages of const StringRef& with StringRef

No sense passing these by reference when a copy is about as free, and
saves on potential indirection later.

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

6 years agoDon't try to use copy relocations with tls variables.
Rafael Espindola [Wed, 7 Feb 2018 23:04:06 +0000 (23:04 +0000)]
Don't try to use copy relocations with tls variables.

Should fix the lldb bot.

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

6 years agoPR36055: fix computation of *-dependence in nested initializer lists.
Richard Smith [Wed, 7 Feb 2018 22:25:16 +0000 (22:25 +0000)]
PR36055: fix computation of *-dependence in nested initializer lists.

When we synthesize an implicit inner initializer list when analyzing an outer
initializer list, we add it to the outer list immediately, and then fill in the
inner list. This gives the outer list no chance to update its *-dependence bits
with those of the completed inner list. To fix this, re-add the inner list to
the outer list once it's completed.

Note that we do not recompute the *-dependence bits from scratch when we
complete an outer list; this would give the wrong result for the case where a
designated initializer overwrites a dependent initializer with a non-dependent
one. The resulting list in that case should still be dependent, even though all
traces of the dependence were removed from the semantic form.

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

6 years agoRecommit r324107 again.
Rafael Espindola [Wed, 7 Feb 2018 22:15:33 +0000 (22:15 +0000)]
Recommit r324107 again.

The difference from the previous try is that we no longer directly
access function declarations from position independent executables. It
should work, but currently doesn't with some linkers.

It now includes a fix to not mark available_externally definitions as
dso_local.

Original message:

Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

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

6 years ago[clang-import-test] Run clang-format, NFC
Vedant Kumar [Wed, 7 Feb 2018 21:17:22 +0000 (21:17 +0000)]
[clang-import-test] Run clang-format, NFC

I ran across clang-import-test while looking into testing for lldb.
There shouldn't be any harm in running clang-format over it.

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

6 years ago[PR36008] Avoid -Wsign-compare warning for enum constants in
Alex Lorenz [Wed, 7 Feb 2018 20:45:39 +0000 (20:45 +0000)]
[PR36008] Avoid -Wsign-compare warning for enum constants in
typeof expressions

This commit looks through typeof type at the original expression when diagnosing
-Wsign-compare to avoid an unfriendly diagnostic.

rdar://36588828

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

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

6 years agoRevert [DebugInfo] Improvements to representation of enumeration types (PR36168)"
Momchil Velikov [Wed, 7 Feb 2018 19:57:04 +0000 (19:57 +0000)]
Revert [DebugInfo] Improvements to representation of enumeration types (PR36168)"

Revert due to breaking buildbots (LLDB tests)

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

6 years ago[analyzer] [NFC] Factor out generating path diagnostics for a statement into a function
George Karpenkov [Wed, 7 Feb 2018 19:56:52 +0000 (19:56 +0000)]
[analyzer] [NFC] Factor out generating path diagnostics for a statement into a function

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

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

6 years agoRevert "Recommit r324107."
Rafael Espindola [Wed, 7 Feb 2018 19:44:15 +0000 (19:44 +0000)]
Revert "Recommit r324107."

This reverts commit r324500.

The bots found two failures:

    ThreadSanitizer-x86_64 :: Linux/pie_no_aslr.cc
    ThreadSanitizer-x86_64 :: pie_test.cc

when using gold. The issue is a limitation in gold when building pie
binaries. I will investigate how to work around it.

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

6 years agoFix r324498: the commit removed the '-' before the disable-llvm-verifier flag
Eric Fiselier [Wed, 7 Feb 2018 19:17:03 +0000 (19:17 +0000)]
Fix r324498: the commit removed the '-' before the disable-llvm-verifier flag

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

6 years agoRecommit r324107.
Rafael Espindola [Wed, 7 Feb 2018 19:16:49 +0000 (19:16 +0000)]
Recommit r324107.

It now includes a fix to not mark available_externally definitions as
dso_local.

Original message:

Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

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

6 years agoDon't pass ForDefinition_t in places it is redundant.
Rafael Espindola [Wed, 7 Feb 2018 19:04:41 +0000 (19:04 +0000)]
Don't pass ForDefinition_t in places it is redundant.

I found this while looking at the ppc failures caused by the dso_local
change.

The issue was that the patch would produce the wrong answer for
available_externally. Having ForDefinition_t available in places where
the code can just check the linkage is a bit of a foot gun.

This patch removes the ForDefiniton_t argument in places where the
linkage is already know.

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

6 years ago[Driver] Add option to manually control discarding value names in LLVM IR.
Eric Fiselier [Wed, 7 Feb 2018 18:36:51 +0000 (18:36 +0000)]
[Driver] Add option to manually control discarding value names in LLVM IR.

Summary:
Currently, assertion-disabled Clang builds emit value names when generating LLVM IR. This is controlled by the `NDEBUG` macro, and is not easily overridable. In order to get IR output containing names from a release build of Clang, the user must manually construct the CC1 invocation w/o the `-discard-value-names` option. This is less than ideal.

For example, Godbolt uses a release build of Clang, and so when asked to emit LLVM IR the result lacks names, making it harder to read. Manually invoking CC1 on Compiler Explorer is not feasible.

This patch adds the driver options `-fdiscard-value-names` and `-fno-discard-value-names` which allow the user to override the default behavior. If neither is specified, the old behavior remains.

Reviewers: erichkeane, aaron.ballman, lebedev.ri

Reviewed By: aaron.ballman

Subscribers: bogner, cfe-commits

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

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

6 years ago[DebugInfo] Improvements to representation of enumeration types (PR36168)
Momchil Velikov [Wed, 7 Feb 2018 16:52:02 +0000 (16:52 +0000)]
[DebugInfo] Improvements to representation of enumeration types (PR36168)

This patch:

* fixes an incorrect sign-extension of unsigned values, when emitting
  debug info metadata for enumerators
* the enumerators metadata is created with a flag, which determines
  interpretation of the value bits (signed or unsigned)
* the enumerations metadata contains the underlying integer type and a
  flag, indicating whether this is a C++ "fixed enum"

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

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

6 years ago[clang-format] Fix ObjC message arguments formatting.
Jacek Olesiak [Wed, 7 Feb 2018 10:35:08 +0000 (10:35 +0000)]
[clang-format] Fix ObjC message arguments formatting.

Summary:
Fixes formatting of ObjC message arguments when inline block is a first
argument.

Having inline block as a first argument when method has multiple parameters is
discouraged by Apple:
"It’s best practice to use only one block argument to a method. If the
method also needs other non-block arguments, the block should come last"
(https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW7),
it should be correctly formatted nevertheless.

Current formatting:
```
[object blockArgument:^{
  a = 42;
}
    anotherArg:42];
```

Fixed (colon alignment):
```
[object
  blockArgument:^{
    a = 42;
  }
     anotherArg:42];
```

Test Plan: make -j12 FormatTests && tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, benhamilton

Reviewed By: krasimir, benhamilton

Subscribers: benhamilton, klimek, cfe-commits

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

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

6 years agoAST: support SwiftCC on MS ABI
Saleem Abdulrasool [Wed, 7 Feb 2018 01:55:08 +0000 (01:55 +0000)]
AST: support SwiftCC on MS ABI

Microsoft has reserved the identifier 'S' as the swift calling
convention.  Decorate the symbols appropriately.  This enables swift on
Windows.

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

6 years agoSupport `#pragma comment(lib, "name")` in the frontend for ELF
Saleem Abdulrasool [Wed, 7 Feb 2018 01:46:46 +0000 (01:46 +0000)]
Support `#pragma comment(lib, "name")` in the frontend for ELF

This adds the frontend support required to support the use of the
comment pragma to enable auto linking on ELFish targets. This is a
generic ELF extension supported by LLVM. We need to change the handling
for the "dependentlib" in order to accommodate the previously discussed
encoding for the dependent library descriptor. Without the custom
handling of the PCK_Lib directive, the -l prefixed option would be
encoded into the resulting object (which is treated as a frontend
error).

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

6 years ago[NFC] Change odd cast-through-unknown behavior to an Optional
Erich Keane [Wed, 7 Feb 2018 00:37:19 +0000 (00:37 +0000)]
[NFC] Change odd cast-through-unknown behavior to an Optional

This bit of code in the driver uses '~0U' as a sentinel value.
The result is an odd mishmash of casts just to work.  This replaces
it with an optional,  which is a little less crazy looking.
--ehis line, and those below, will be ignored--

M    lib/Driver/Driver.cpp

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

6 years ago[NFC] Correct a typo'ed comment and reworded, since it is awkward.
Erich Keane [Wed, 7 Feb 2018 00:19:58 +0000 (00:19 +0000)]
[NFC] Correct a typo'ed comment and reworded, since it is awkward.

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

6 years ago[Sema][ObjC] Use SmallSetVector to fix a failing test on the reverse
Akira Hatanaka [Tue, 6 Feb 2018 23:44:40 +0000 (23:44 +0000)]
[Sema][ObjC] Use SmallSetVector to fix a failing test on the reverse
iteration bot.

This commit reverts r315639, which was causing clang to print
diagnostics that weren't printed before. Instead, it declares
OverrideSearch::Overridden as a SmallSetVector to fix the
non-deterministic behavior r315639 was trying to fix.

rdar://problem/36445528

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

6 years ago[Myriad] Define __ma2x5x and __ma2x8x
Walter Lee [Tue, 6 Feb 2018 22:39:47 +0000 (22:39 +0000)]
[Myriad] Define __ma2x5x and __ma2x8x

Summary: Add architecture defines for ma2x5x and ma2x8x.

Reviewers: jyknight

Subscribers: fedor.sergeev, MartinO

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

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

6 years ago[Lex] Fix handling numerical literals ending with ' and signed exponent.
Volodymyr Sapsai [Tue, 6 Feb 2018 22:39:25 +0000 (22:39 +0000)]
[Lex] Fix handling numerical literals ending with ' and signed exponent.

For input `0'e+1` lexer tokenized as numeric constant only `0'e`. Later
NumericLiteralParser skipped 0 and ' as digits and parsed `e+1` as valid
exponent going past the end of the token. Because it didn't mark numeric
literal as having an error, it continued parsing and tried to expandUCNs
with StringRef of length -2.

The fix is not to parse exponent when we reached the end of token.

Discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4588

rdar://problem/36076719

Reviewers: rsmith, t.p.northover

Reviewed By: rsmith

Subscribers: cfe-commits, jkorous-apple

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

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

6 years agoPass around function pointers as CGCallees, not bare llvm::Value*s.
John McCall [Tue, 6 Feb 2018 18:52:44 +0000 (18:52 +0000)]
Pass around function pointers as CGCallees, not bare llvm::Value*s.

The intention here is to make it easy to write frontend-assisted CFI
systems by propagating extra information in the CGCallee.

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

6 years ago[clang-format] Add more tests for Objective-C 2.0 generic alignment
Ben Hamilton [Tue, 6 Feb 2018 18:01:47 +0000 (18:01 +0000)]
[clang-format] Add more tests for Objective-C 2.0 generic alignment

Summary:
In r236412, @djasper added a comment:

    // FIXME: We likely want to do this for more combinations of brackets.
    // Verify that it is wanted for ObjC, too.

In D42650, @stephanemoore asked me to confirm this.

This followup to D42650 adds more tests to verify the relative
alignment behavior for Objective-C 2.0 generics passed to functions
and removes the second half of the FIXME comment.

Test Plan:
  make -j12 FormatTests && \
  ./tools/clang/unittests/Format/FormatTests --gtest_filter=FormatTestObjC.\*

Reviewers: stephanemoore, jolesiak, djasper

Reviewed By: jolesiak

Subscribers: klimek, cfe-commits, djasper, stephanemoore, krasimir

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

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

6 years ago[analyzer] [tests] Show function name in CmpRuns output
George Karpenkov [Tue, 6 Feb 2018 17:22:09 +0000 (17:22 +0000)]
[analyzer] [tests] Show function name in CmpRuns output

Combined with enabled flag for stable filenames, this greatly simplifies
finding the offending report.

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

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

6 years ago[Solaris] Silence -pthread warning on Solaris
Fedor Sergeev [Tue, 6 Feb 2018 13:21:12 +0000 (13:21 +0000)]
[Solaris] Silence -pthread warning on Solaris

Summary:
During make check-all on Solaris, I see several instances of this warning:

clang-6.0: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]

Since Solaris 10, libpthread has been folded into libc, so there's nothing to do.  gcc
just ignores -pthread here.  Darwin claims the option to silence the warning, and
this patch follows that lead.

Reviewers: rsmith, fedor.sergeev

Reviewed By: fedor.sergeev

Subscribers: cfe-commits, fedor.sergeev

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

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

6 years agoUnittests misc. typos
Sylvestre Ledru [Tue, 6 Feb 2018 13:12:29 +0000 (13:12 +0000)]
Unittests misc. typos

By luz.paz

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

6 years agoTest commit - fixing a comment.
Jacek Olesiak [Tue, 6 Feb 2018 12:12:00 +0000 (12:12 +0000)]
Test commit - fixing a comment.

Summary: A test commit.

Reviewers: krasimir, benhamilton

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Adds space around angle brackets in text protos
Krasimir Georgiev [Tue, 6 Feb 2018 11:34:34 +0000 (11:34 +0000)]
[clang-format] Adds space around angle brackets in text protos

Summary:
This patch adds spaces around angle brackets in text proto Google style.
Previously these were detected as template openers and closers, which happened
to have the expected effect. Now we detect them as scope openers and closers
similarly to the way braces are handled in this context.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years agoFix crash on invalid.
Richard Trieu [Tue, 6 Feb 2018 02:58:21 +0000 (02:58 +0000)]
Fix crash on invalid.

Don't call a method when the pointer is null.

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

6 years agoFix test/Driver/sanitizer-ld.c broken by D40903
Alex Shlyapnikov [Tue, 6 Feb 2018 00:50:18 +0000 (00:50 +0000)]
Fix test/Driver/sanitizer-ld.c broken by D40903

Differential revision: https://reviews.llvm.org/D40903

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

6 years ago[Sanitizers] Basic Solaris sanitizer support (PR 33274)
Alex Shlyapnikov [Mon, 5 Feb 2018 23:59:13 +0000 (23:59 +0000)]
[Sanitizers] Basic Solaris sanitizer support (PR 33274)

Summary:
This patch (on top of https://reviews.llvm.org/D35755) provides the clang side necessary
to enable the Solaris port of the sanitizers implemented by https://reviews.llvm.org/D40898,
https://reviews.llvm.org/D40899, and https://reviews.llvm.org/D40900).

A few features of note:

* While compiler-rt cmake/base-config-ix.cmake (COMPILER_RT_OS_DIR) places
  the runtime libs in a tolower(CMAKE_SYSTEM_NAME) directory, clang defaults to
  the OS part of the target triplet (solaris2.11 in the case at hand).  The patch makes
  them agree on compiler-rt's idea.

* While Solaris ld accepts a considerable number of GNU ld options for compatibility,
  it only does so for the double-dash forms.  clang unfortunately is inconsistent here
  and sometimes uses the double-dash form, sometimes the single-dash one that
  confuses the hell out of Solaris ld.  I've changed the affected places to use the double-dash
  form that should always work.

* As described in https://reviews.llvm.org/D40899, Solaris ld doesn't create the
  __start___sancov_guards/__stop___sancov_guards labels gld/gold/lld do, so I'm
  including additional runtime libs into the link that provide them.

* One test uses -fstack-protector, but unlike other systems libssp hasn't been folded
  into Solaris libc, but needs to be linked with separately.

* For now, only 32-bit x86 asan is enabled on Solaris.  64-bit x86 should follow, but
  sparc (which requires additional compiler-rt changes not yet submitted) fails miserably
  due to a llvmsparc backend limitation:

fatal error: error in backend: Function "_ZN7testing8internal16BoolFromGTestEnvEPKcb": over-aligned dynamic alloca not supported.

  However, inside the gcc tree, Solaris/sparc asan works almost as well as x86.

Reviewers: rsmith, alekseyshl

Reviewed By: alekseyshl

Subscribers: jyknight, fedor.sergeev, cfe-commits

Tags: #sanitizers

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

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

6 years agoIRGen: Move vtable load after argument evaluation.
Peter Collingbourne [Mon, 5 Feb 2018 23:09:13 +0000 (23:09 +0000)]
IRGen: Move vtable load after argument evaluation.

This change reduces the live range of the loaded function pointer,
resulting in a slight code size decrease (~10KB in clang), and also
improves the security of CFI for virtual calls by making it less
likely that the function pointer will be spilled, and ensuring that
it is not spilled across a function call boundary.

Fixes PR35353.

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

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

6 years agoAdd support for attribute 'trivial_abi'.
Akira Hatanaka [Mon, 5 Feb 2018 20:23:22 +0000 (20:23 +0000)]
Add support for attribute 'trivial_abi'.

The 'trivial_abi' attribute can be applied to a C++ class, struct, or
union. It makes special functions of the annotated class (the destructor
and copy/move constructors) to be trivial for the purpose of calls and,
as a result, enables the annotated class or containing classes to be
passed or returned using the C ABI for the underlying type.

When a type that is considered trivial for the purpose of calls despite
having a non-trivial destructor (which happens only when the class type
or one of its subobjects is a 'trivial_abi' class) is passed to a
function, the callee is responsible for destroying the object.

For more background, see the discussions that took place on the mailing
list:

http://lists.llvm.org/pipermail/cfe-dev/2017-November/055955.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180101/thread.html#214043

rdar://problem/35204524

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

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

6 years ago[Options] Make --cuda-path-ignore-env a Flag, NFCI.
Jonas Hahnfeld [Mon, 5 Feb 2018 18:19:40 +0000 (18:19 +0000)]
[Options] Make --cuda-path-ignore-env a Flag, NFCI.

This option doesn't take an argument!

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

6 years ago[clang-format] Re-land: Fixup #include guard indents after parseFile()
Mark Zeren [Mon, 5 Feb 2018 15:59:00 +0000 (15:59 +0000)]
[clang-format] Re-land: Fixup #include guard indents after parseFile()

Summary:
When a preprocessor indent closes after the last line of normal code we do not
correctly fixup include guard indents. For example:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  int i;
  #  define A 0
  #endif
  #endif

incorrectly reformats to:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  int i;
  #    define A 0
  #  endif
  #endif

To resolve this issue we must fixup levels after parseFile(). Delaying
the fixup introduces a new state, so consolidate include guard search
state into an enum.

Reviewers: krasimir, klimek

Subscribers: cfe-commits

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

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

6 years agoRevert "[clang-format] Fixup #include guard indents after parseFile()"
Mark Zeren [Mon, 5 Feb 2018 14:47:04 +0000 (14:47 +0000)]
Revert "[clang-format] Fixup #include guard indents after parseFile()"

This reverts r324238 | mzeren-vmw | 2018-02-05 06:35:54 -0800 (Mon, 05 Feb 2018) | 35 lines

Incorrect version pushed upstream.

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

6 years ago[clang-format] Fixup #include guard indents after parseFile()
Mark Zeren [Mon, 5 Feb 2018 14:35:54 +0000 (14:35 +0000)]
[clang-format] Fixup #include guard indents after parseFile()

Summary:
When a preprocessor indent closes after the last line of normal code we do not
correctly fixup include guard indents. For example:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  int i;
  #  define A 0
  #endif
  #endif

incorrectly reformats to:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  int i;
  #    define A 0
  #  endif
  #endif

To resolve this issue we must fixup levels after parseFile(). Delaying
the fixup introduces a new state, so consolidate include guard search
state into an enum.

Reviewers: krasimir, klimek

Reviewed By: krasimir

Subscribers: cfe-commits

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

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

6 years agoRecommit rL323890: [AMDGPU] Add ds_fadd, ds_fmin, ds_fmax builtins functions
Daniil Fukalov [Sun, 4 Feb 2018 22:32:07 +0000 (22:32 +0000)]
Recommit rL323890: [AMDGPU] Add ds_fadd, ds_fmin, ds_fmax builtins functions

Fixed asserts in tests.

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

6 years agoRecommit rL323952: [DebugInfo] Enable debug information for C99 VLA types.
Sander de Smalen [Sat, 3 Feb 2018 13:55:59 +0000 (13:55 +0000)]
Recommit rL323952: [DebugInfo] Enable debug information for C99 VLA types.

Fixed build issue when building with g++-4.8 (specialization after instantiation).

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

6 years ago[RISCV] Create a LinuxTargetInfo when targeting Linux
Alex Bradbury [Sat, 3 Feb 2018 11:56:11 +0000 (11:56 +0000)]
[RISCV] Create a LinuxTargetInfo when targeting Linux

Previously, RISCV32TargetInfo or RISCV64TargetInfo were created
unconditionally. Use LinuxTargetInfo<RISCV??TargetInfo> to ensure that the
proper OS-specific defines are present.

This patch only adds logic to instantiate LinuxTargetInfo and leaves a TODO,
as I'm reluctant to add logic for other targets (e.g. FreeBSD, RTEMS) until
I've produced and tested at least one binary for that OS+target combo.

Thanks to @mgrang to reporting the issue.

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

6 years agoRevert r324166 "[analyzer] Add a checker for mmap()...".
Artem Dergachev [Sat, 3 Feb 2018 03:57:32 +0000 (03:57 +0000)]
Revert r324166 "[analyzer] Add a checker for mmap()...".

Due to Buildbot failures - most likely that's because target triples were not
specified in the tests, even though the checker behaves differently with
different target triples.

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

6 years ago[analyzer] Add a checker for mmap()s which are both writable and executable.
Artem Dergachev [Sat, 3 Feb 2018 02:33:42 +0000 (02:33 +0000)]
[analyzer] Add a checker for mmap()s which are both writable and executable.

This is a security check which is disabled by default but will be enabled
whenever the user consciously enables the security package. If mmap()ed memory
is both writable and executable, it makes it easier for the attacker to execute
arbitrary code when contents of this memory are compromised. Some applications
require such mmap()s though, such as different sorts of JIT.

Patch by David Carlier!

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

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

6 years ago[hwasan] Add a paragraph on stack instrumentation.
Evgeniy Stepanov [Sat, 3 Feb 2018 01:06:21 +0000 (01:06 +0000)]
[hwasan] Add a paragraph on stack instrumentation.

Reviewers: kcc

Subscribers: cfe-commits

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

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

6 years ago[analyzer] Do not infer nullability inside function-like macros, even when macro...
George Karpenkov [Sat, 3 Feb 2018 00:55:21 +0000 (00:55 +0000)]
[analyzer] Do not infer nullability inside function-like macros, even when macro is explicitly returning NULL

We already suppress such reports for inlined functions, we should then
get the same behavior for macros.
The underlying reason is that the same macro, can be called from many
different contexts, and nullability can only be expected in _some_ of
them.
Assuming that the macro can return null in _all_ of them sometimes leads
to a large number of false positives.

E.g. consider the test case for the dynamic cast implementation in
macro: in such cases, the bug report is unwanted.

Tracked in rdar://36304776

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

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

6 years agoFix crash when trying to pack-expand a GNU statement expression.
Richard Smith [Sat, 3 Feb 2018 00:44:57 +0000 (00:44 +0000)]
Fix crash when trying to pack-expand a GNU statement expression.

We could in principle support such pack expansion, using techniques similar to
what we do for pack expansion of lambdas, but it's not clear it's worthwhile.
For now at least, cleanly reject these cases rather than crashing.

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

6 years agoAdd missing direct-init / parameter-declaration-clause disambiguation when
Richard Smith [Fri, 2 Feb 2018 22:24:54 +0000 (22:24 +0000)]
Add missing direct-init / parameter-declaration-clause disambiguation when
parsing a trailing-return-type of a (function pointer) variable declaration.

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

6 years agoMore documentation cleanup for Decl.h.
James Dennett [Fri, 2 Feb 2018 21:38:22 +0000 (21:38 +0000)]
More documentation cleanup for Decl.h.

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

6 years agoMake __has_unique_object_representations reject empty union types.
Eric Fiselier [Fri, 2 Feb 2018 20:30:39 +0000 (20:30 +0000)]
Make __has_unique_object_representations reject empty union types.

Summary:
Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`.

@erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible.

Reviewers: erichkeane, rsmith, aaron.ballman, majnemer

Reviewed By: erichkeane

Subscribers: cfe-commits, erichkeane

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

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

6 years agoDocumentation cleanup, no functional change.
James Dennett [Fri, 2 Feb 2018 20:22:29 +0000 (20:22 +0000)]
Documentation cleanup, no functional change.

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

6 years ago[clang-proto-to-cxx] Accept protobufs with missing fields.
Matt Morehouse [Fri, 2 Feb 2018 20:22:20 +0000 (20:22 +0000)]
[clang-proto-to-cxx] Accept protobufs with missing fields.

libprotobuf-mutator accepts protobufs with missing fields, which means
clang-proto-fuzzer does as well.  clang-proto-to-cxx should match this
behavior.

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

6 years ago[clang-format] New format param ObjCBinPackProtocolList
Ben Hamilton [Fri, 2 Feb 2018 20:15:14 +0000 (20:15 +0000)]
[clang-format] New format param ObjCBinPackProtocolList

Summary:
This is an alternative approach to D42014 after some
investigation by stephanemoore@ and myself.

Previously, the format parameter `BinPackParameters` controlled both
C function parameter list bin-packing and Objective-C protocol conformance
list bin-packing.

We found in the Google style, some teams were changing
`BinPackParameters` from its default (`true`) to `false` so they could
lay out Objective-C protocol conformance list items one-per-line
instead of bin-packing them into as few lines as possible.

To allow teams to use one-per-line Objective-C protocol lists without
changing bin-packing for other areas like C function parameter lists,
this diff introduces a new LibFormat parameter
`ObjCBinPackProtocolList` to control the behavior just for ObjC
protocol conformance lists.

The new parameter is an enum which defaults to `Auto` to keep the
previous behavior (delegating to `BinPackParameters`).

Depends On D42649

Test Plan: New tests added. make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, stephanemoore, djasper

Reviewed By: stephanemoore

Subscribers: Wizard, hokein, cfe-commits, klimek

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

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

6 years ago Emit label names according to -discard-value-names.
Eric Fiselier [Fri, 2 Feb 2018 19:58:34 +0000 (19:58 +0000)]
 Emit label names according to -discard-value-names.

Summary:
Previously, Clang only emitted label names in assert builds.
However there is a CC1 option -discard-value-names that should have been used to control emission instead.

This patch removes the NDEBUG preprocessor block and instead allows LLVM to handle removing the names in accordance with the option.

Reviewers: erichkeane, aaron.ballman, majnemer

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

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

6 years ago[analyzer] [tests] Fix crash in SATestBuild.py
George Karpenkov [Fri, 2 Feb 2018 18:27:14 +0000 (18:27 +0000)]
[analyzer] [tests] Fix crash in SATestBuild.py

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

6 years ago[Tooling] Returns non-zero status code when files are skipped.
Eric Liu [Fri, 2 Feb 2018 18:19:22 +0000 (18:19 +0000)]
[Tooling] Returns non-zero status code when files are skipped.

Reviewers: hokein, bkramer

Reviewed By: bkramer

Subscribers: bkramer, klimek, cfe-commits

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

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

6 years agoRevert "Start setting dso_local in clang."
Rafael Espindola [Fri, 2 Feb 2018 17:29:22 +0000 (17:29 +0000)]
Revert "Start setting dso_local in clang."

This reverts commit r324107.

I will have to test it on OS X.

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

6 years agoStart setting dso_local in clang.
Rafael Espindola [Fri, 2 Feb 2018 17:17:39 +0000 (17:17 +0000)]
Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

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

6 years ago[AMDGPU] Switch to the new addr space mapping by default
Yaxun Liu [Fri, 2 Feb 2018 16:08:24 +0000 (16:08 +0000)]
[AMDGPU] Switch to the new addr space mapping by default

This requires corresponding llvm change.

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

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

6 years ago[CodeGen][va_args] Correct Vector Struct va-arg 'in_reg' code gen
Erich Keane [Fri, 2 Feb 2018 15:53:35 +0000 (15:53 +0000)]
[CodeGen][va_args] Correct Vector Struct va-arg 'in_reg' code gen

When trying to track down a different bug, we discovered
that calling __builtin_va_arg on a vec3f type caused
the SROA pass to issue a warning that there was an illegal
access.

Further research showed that the vec3f type is
alloca'ed as size '12', but the _builtin_va_arg code
on x86_64 was always loading this out of registers as
{double, double}. Thus, the 2nd store into the vec3f
was storing in bytes 12-15!

This patch alters the original implementation which always
assumed {double, double} to use the actual coerced type
instead, so the LLVM-IR generated is a load/GEP/store of
a <2 x float> and a float, rather than a double and a double.

Tests were added for all combinations I could think of that
would fit in 2 FP registers, and all work exactly as expected.

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

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

6 years ago[Index] fix USR generation for namespace{extern{X}}
Sam McCall [Fri, 2 Feb 2018 14:13:37 +0000 (14:13 +0000)]
[Index] fix USR generation for namespace{extern{X}}

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

6 years ago[AST] namespace ns { extern "C" { int X; }} prints as "ns::X", not as "X"
Sam McCall [Fri, 2 Feb 2018 13:34:47 +0000 (13:34 +0000)]
[AST] namespace ns { extern "C" { int X; }} prints as "ns::X", not as "X"

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

6 years ago[Sema] Add implicit members even for invalid CXXRecordDecls
Ilya Biryukov [Fri, 2 Feb 2018 08:40:08 +0000 (08:40 +0000)]
[Sema] Add implicit members even for invalid CXXRecordDecls

Summary:
It should be safe, since other code paths are already generating
implicit members even in invalid CXXRecordDecls (e.g. lookup).

If we don't generate implicit members on CXXRecordDecl's completion,
they will be generated by next lookup of constructors. This causes a
crash when the following conditions are met:
  - a CXXRecordDecl is invalid,
  - it is provided via ExternalASTSource (e.g. from PCH),
  - it has inherited constructors (they create ShadowDecls),
  - lookup of its constructors was not run before ASTWriter serialized
    it.

This may require the ShadowDecls created for inherited constructors to
be removed from the class, but that's no longer possible since class is
provided by ExternalASTSource.

See provided lit test for an example.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

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

6 years ago[MinGW] Emit typeinfo locally for dllimported classes without key functions
Martin Storsjo [Fri, 2 Feb 2018 06:22:35 +0000 (06:22 +0000)]
[MinGW] Emit typeinfo locally for dllimported classes without key functions

This fixes building Qt as shared libraries with clang in MinGW
mode; previously subclasses of the QObjectData class (in other
DLLs than the base DLL) failed to find the typeinfo symbols
(that neither were emitted in the base DLL nor in the DLL
containing the subclass).

If the virtual destructor in the newly added testcase wouldn't
be pure (or if there'd be another non-pure virtual method),
it'd be a key function and things would work out even before this
change. Make sure to locally emit the typeinfo for these classes
as well.

This matches what GCC does in this specific testcase.

This fixes the root issue that spawned PR35146. (The difference
to GCC that is initially described in that bug still is present
though.)

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

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

6 years ago[analyzer] Fix transitions in check::PreStmt<MemberExpr> checker callback.
Artem Dergachev [Fri, 2 Feb 2018 02:23:37 +0000 (02:23 +0000)]
[analyzer] Fix transitions in check::PreStmt<MemberExpr> checker callback.

No in-tree checkers use this callback so far, hence no tests. But better fix
this now than remember to fix this when the checkers actually appear.

Patch by Henry Wong!

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

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

6 years ago[analyzer] Expose return statement from CallExit program point
George Karpenkov [Fri, 2 Feb 2018 02:19:43 +0000 (02:19 +0000)]
[analyzer] Expose return statement from CallExit program point

If the return statement is stored, we might as well allow querying
against it.
Also fix the bug where the return statement is not stored
if there is no return value.
This change un-merges two ExplodedNodes during call exit when the state
is otherwise identical - the CallExitBegin node itself and the "Bind
Return Value"-tagged node.
And expose the return statement through
getStatement helper function.

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

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

6 years agoRemove the change which accidentally crept in into the cherry-pick
George Karpenkov [Fri, 2 Feb 2018 02:14:33 +0000 (02:14 +0000)]
Remove the change which accidentally crept in into the cherry-pick

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

6 years ago[analyzer] Expose exploration strategy through analyzer options.
George Karpenkov [Fri, 2 Feb 2018 02:01:55 +0000 (02:01 +0000)]
[analyzer] Expose exploration strategy through analyzer options.

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

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

6 years ago[analyzer] Fix yet-another-crash in body-farming std::call_once
George Karpenkov [Fri, 2 Feb 2018 01:44:07 +0000 (01:44 +0000)]
[analyzer] Fix yet-another-crash in body-farming std::call_once

Crash occurs when parameters to the callback and to std::call_once
mismatch, and C++ is supposed to auto-construct an argument.

Filed by Alexander Kornienko in
https://bugs.llvm.org/show_bug.cgi?id=36149

rdar://37034403

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

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

6 years ago[coroutines] Fix application of NRVO to Coroutine "Gro" or return object.
Eric Fiselier [Thu, 1 Feb 2018 23:47:54 +0000 (23:47 +0000)]
[coroutines] Fix application of NRVO to Coroutine "Gro" or return object.

Summary:
Fix NRVO for Gro variable.

Previously, we only marked the GRO declaration as an NRVO variable
when its QualType and the function return's QualType matched exactly
(using operator==). However, this was incorrect for two reasons:

1. We were marking non-class types, such as ints, as being NRVO variables.

2. We failed to  handle cases where the canonical types were the same, but the actual `QualType` objects were different. For example, if  one was represented by a typedef. (Example: https://godbolt.org/g/3UFgsL)

This patch fixes these bugs by marking the Gro variable as supporting NRVO only
when `BuildReturnStmt` marks the Gro variable as a coroutine candidate.

Reviewers: rsmith, GorNishanov, nicholas

Reviewed By: GorNishanov

Subscribers: majnemer, cfe-commits

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

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

6 years ago[analyzer] [tests] [NFC] Remove dead code from CmpRuns
George Karpenkov [Thu, 1 Feb 2018 22:40:01 +0000 (22:40 +0000)]
[analyzer] [tests] [NFC] Remove dead code from CmpRuns

Indeed, "CHANGE" is not a thing yet, and we should probably not carry
around dead code which does not do anything apart from confusing the
reader.

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

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

6 years ago[analyzer] [tests] Add an option to show the histogram of path differences between...
George Karpenkov [Thu, 1 Feb 2018 22:25:18 +0000 (22:25 +0000)]
[analyzer] [tests] Add an option to show the histogram of path differences between the analyzer runs

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

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

6 years ago[analyzer] Don't communicate evaluation failures through memregion hierarchy.
Artem Dergachev [Thu, 1 Feb 2018 22:17:05 +0000 (22:17 +0000)]
[analyzer] Don't communicate evaluation failures through memregion hierarchy.

We use CXXTempObjectRegion exclusively as a bailout value for construction
targets when we are unable to find the correct construction region.
Sometimes it works correctly, but rather accidentally than intentionally.

Now that we want to increase the amount of situations where it works correctly,
the first step is to introduce a different way of communicating our failure
to find the correct construction region. EvalCallOptions are introduced
for this purpose.

For now EvalCallOptions are communicating two kinds of problems:
- We have been completely unable to find the correct construction site.
- We have found the construction site correctly, and there's more than one of
  them (i.e. array construction which we currently don't support).

Accidentally find and fix a test in which the new approach to communicating
failures produces better results.

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

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

6 years agoPR36157: When injecting an implicit function declaration in C89, find the right
Richard Smith [Thu, 1 Feb 2018 20:01:49 +0000 (20:01 +0000)]
PR36157: When injecting an implicit function declaration in C89, find the right
DeclContext rather than injecting it wherever we happen to be.

This avoids creating functions whose DeclContext is a struct or similar.

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

6 years agoMark fallthrough with LLVM_FALLTHROUGH
Adrian Prantl [Thu, 1 Feb 2018 18:10:20 +0000 (18:10 +0000)]
Mark fallthrough with LLVM_FALLTHROUGH

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

6 years agoReverting patch rL323952 due to build errors that I
Sander de Smalen [Thu, 1 Feb 2018 12:27:13 +0000 (12:27 +0000)]
Reverting patch rL323952 due to build errors that I
haven't encountered in local builds.

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

6 years ago[DebugInfo] Enable debug information for C99 VLA types
Sander de Smalen [Thu, 1 Feb 2018 11:25:10 +0000 (11:25 +0000)]
[DebugInfo] Enable debug information for C99 VLA types

Summary:
This patch enables debugging of C99 VLA types by generating more precise
LLVM Debug metadata, using the extended DISubrange 'count' field that
takes a DIVariable.

This should implement:
  Bug 30553: Debug info generated for arrays is not what GDB expects (not as good as GCC's)
https://bugs.llvm.org/show_bug.cgi?id=30553

Reviewers: echristo, aprantl, dexonsmith, clayborg, pcc, kristof.beyls, dblaikie

Reviewed By: aprantl

Subscribers: jholewinski, schweitz, davide, fhahn, JDevlieghere, cfe-commits

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

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

6 years ago[CodeGen] Fix an assertion failure in CGRecordLowering.
Akira Hatanaka [Thu, 1 Feb 2018 03:04:15 +0000 (03:04 +0000)]
[CodeGen] Fix an assertion failure in CGRecordLowering.

This patch fixes a bug in CGRecordLowering::accumulateBitFields where it
unconditionally starts a new run and emits a storage field when it sees
a zero-sized bitfield, which causes an assertion in insertPadding to
fail when -fno-bitfield-type-align is used.

It shouldn't emit new storage if UseZeroLengthBitfieldAlignment and
UseBitFieldTypeAlignment are both false.

rdar://problem/36762205

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

6 years ago[analyzer] [tests] Show the number of removed/added bug reports
George Karpenkov [Thu, 1 Feb 2018 02:38:42 +0000 (02:38 +0000)]
[analyzer] [tests] Show the number of removed/added bug reports

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

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

6 years agoPR36181: Teach CodeGen to properly ignore requests to emit dependent entities.
Richard Smith [Thu, 1 Feb 2018 00:28:36 +0000 (00:28 +0000)]
PR36181: Teach CodeGen to properly ignore requests to emit dependent entities.

Previously, friend function definitions within class templates slipped through
the gaps and caused the MS mangler to assert.

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

6 years ago[PR32482] Fix bitfield layout for -mms-bitfield and pragma pack
Alex Lorenz [Wed, 31 Jan 2018 21:59:02 +0000 (21:59 +0000)]
[PR32482] Fix bitfield layout for -mms-bitfield and pragma pack

The patch ensures that a new storage unit is created when the new bitfield's
size is wider than the available bits.

rdar://36343145

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

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

6 years ago[clang-format] Align preprocessor comments with #
Mark Zeren [Wed, 31 Jan 2018 20:05:50 +0000 (20:05 +0000)]
[clang-format] Align preprocessor comments with #

Summary:
r312125, which introduced preprocessor indentation, shipped with a known
issue where "indentation of comments immediately before indented
preprocessor lines is toggled on each run". For example these two forms
toggle:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  // comment
  #   define A 0
  #endif
  #endif

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
     // comment
  #   define A 0
  #endif
  #endif

This happens because we check vertical alignment against the '#' yet
indent to the level of the 'define'. This patch resolves this issue by
aligning against the '#'.

Reviewers: krasimir, klimek, djasper

Reviewed By: krasimir

Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D42408

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