]> granicus.if.org Git - clang/log
clang
6 years ago[WebAssembly] Add mem.* builtin functions.
Dan Gohman [Tue, 23 Jan 2018 17:04:04 +0000 (17:04 +0000)]
[WebAssembly] Add mem.* builtin functions.

This corresponds to r323222 in LLVM. The new names are not yet
finalized, so use them at your own risk.

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

6 years agoclang-format: Support formatting Java 8 interface default methods.
Nico Weber [Tue, 23 Jan 2018 16:30:56 +0000 (16:30 +0000)]
clang-format: Support formatting Java 8 interface default methods.

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

6 years agoFix Driver/solaris-ld.c test on Windows
Fedor Sergeev [Tue, 23 Jan 2018 13:59:11 +0000 (13:59 +0000)]
Fix Driver/solaris-ld.c test on Windows

Fixing failure introduced with r323193.

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

6 years ago[Tooling] Added a VFS parameter to ClangTool
Ilya Biryukov [Tue, 23 Jan 2018 12:30:02 +0000 (12:30 +0000)]
[Tooling] Added a VFS parameter to ClangTool

Summary:
The parameter overrides the underlying vfs used by ClangTool for
filesystem operations.

Patch by Vladimir Plyashkun.

Reviewers: alexfh, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, cfe-commits

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

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

6 years ago[Solaris] Make RHEL devtoolsets handling Linux-specific
Fedor Sergeev [Tue, 23 Jan 2018 12:24:01 +0000 (12:24 +0000)]
[Solaris] Make RHEL devtoolsets handling Linux-specific

Summary:
This patch is meant to address the last outstanding review comment on the already approved
(but not yet commited) https://reviews.llvm.org/D35755, namely making the handling of the RHEL
devtoolsets Linux-specific.

Don't know if it's best integrated into the former or applied subsequently.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

Reviewers: fedor.sergeev, tstellar, jyknight

Reviewed By: fedor.sergeev

Subscribers: cfe-commits

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

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

6 years ago[Solaris] gcc toolchain handling revamp
Fedor Sergeev [Tue, 23 Jan 2018 12:23:52 +0000 (12:23 +0000)]
[Solaris] gcc toolchain handling revamp

Summary:
General idea is to utilize generic (mostly Generic_GCC) code
and get rid of Solaris-specific handling as much as possible.

In particular:
- scanLibDirForGCCTripleSolaris was removed, relying on generic
  CollectLibDirsAndTriples

- findBiarchMultilibs is now properly utilized to switch between
   m32 and m64 include & lib paths on Solaris

- C system include handling copied from Linux (bar multilib hacks)

Fixes PR24606.

Reviewers: dlj, rafael, jyknight, theraven, tstellar

Reviewed By: jyknight

Subscribers: aaron.ballman, mgorny, krytarowski, ro, joerg, cfe-commits

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

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

6 years ago[clang-format] Ignore UnbreakableTailLength sometimes during breaking
Krasimir Georgiev [Tue, 23 Jan 2018 11:26:19 +0000 (11:26 +0000)]
[clang-format] Ignore UnbreakableTailLength sometimes during breaking

Summary:
This patch fixes an issue where the UnbreakableTailLength would be counted towards
the length of a token during breaking, even though we can break after the token.

For example, this proto text with column limit 20
```
# ColumnLimit: 20  V
foo: {
  bar: {
    bazoo: "aaaaaaa"
  }
}
```
was broken:
```
# ColumnLimit: 20  V
foo: {
  bar: {
    bazoo:
        "aaaaaaa"
  }
}
```
because the 2 closing `}` were counted towards the string literal's `UnbreakableTailLength`.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

6 years ago[ARM] Pass _Float16 as int or float
Sjoerd Meijer [Tue, 23 Jan 2018 10:13:49 +0000 (10:13 +0000)]
[ARM] Pass _Float16 as int or float

Pass and return _Float16 as if it were an int or float for ARM, but with the
top 16 bits unspecified, similarly like we already do for __fp16.

We will implement proper half-precision function argument lowering in the ARM
backend soon, but want to use this workaround in the mean time.

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

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

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Tue, 23 Jan 2018 05:50:06 +0000 (05:50 +0000)]
[NFC] fix trivial typos in comments

"the the" -> "the"

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

6 years agoNewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.
David Blaikie [Tue, 23 Jan 2018 01:25:24 +0000 (01:25 +0000)]
NewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.

Using a new extension point in the new PM, register GCOV at the start of
the pipeline rather than the end.

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

6 years agoAdd hasTrailingReturn AST matcher
Julie Hockett [Mon, 22 Jan 2018 22:45:23 +0000 (22:45 +0000)]
Add hasTrailingReturn AST matcher

Adds AST matcher for a FunctionDecl that has a trailing return type.

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

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

6 years ago[ASTMatchers] [NFC] Fix code examples
Fangrui Song [Mon, 22 Jan 2018 22:34:15 +0000 (22:34 +0000)]
[ASTMatchers] [NFC] Fix code examples

Subscribers: klimek, cfe-commits

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

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

6 years agoReland "[CodeGen] Fix crash when a function taking transparent union is redeclared."
Volodymyr Sapsai [Mon, 22 Jan 2018 22:29:24 +0000 (22:29 +0000)]
Reland "[CodeGen] Fix crash when a function taking transparent union is redeclared."

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

Now the fix is in converting from ABIArgInfo type to VarDecl type and using
argument demotion when necessary.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak

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

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

6 years agoIntroduce the "retpoline" x86 mitigation technique for variant #2 of the speculative...
Chandler Carruth [Mon, 22 Jan 2018 22:05:25 +0000 (22:05 +0000)]
Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target Injection", and is one of the two halves to Spectre..

Summary:
First, we need to explain the core of the vulnerability. Note that this
is a very incomplete description, please see the Project Zero blog post
for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative execution
of the processor to some "gadget" of executable code by poisoning the
prediction of indirect branches with the address of that gadget. The
gadget in turn contains an operation that provides a side channel for
reading data. Most commonly, this will look like a load of secret data
followed by a branch on the loaded value and then a load of some
predictable cache line. The attacker then uses timing of the processors
cache to determine which direction the branch took *in the speculative
execution*, and in turn what one bit of the loaded value was. Due to the
nature of these timing side channels and the branch predictor on Intel
processors, this allows an attacker to leak data only accessible to
a privileged domain (like the kernel) back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In many
cases, the compiler can simply use directed conditional branches and
a small search tree. LLVM already has support for lowering switches in
this way and the first step of this patch is to disable jump-table
lowering of switches and introduce a pass to rewrite explicit indirectbr
sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as
a trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures the
processor predicts the return to go to a controlled, known location. The
retpoline then "smashes" the return address pushed onto the stack by the
call with the desired target of the original indirect call. The result
is a predicted return to the next instruction after a call (which can be
used to trap speculative execution within an infinite loop) and an
actual indirect branch to an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this device.
For 32-bit ABIs there isn't a guaranteed scratch register and so several
different retpoline variants are introduced to use a scratch register if
one is available in the calling convention and to otherwise use direct
stack push/pop sequences to pass the target address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the retpoline
thunk by the compiler to allow for custom thunks if users want them.
These are particularly useful in environments like kernels that
routinely do hot-patching on boot and want to hot-patch their thunk to
different code sequences. They can write this custom thunk and use
`-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
case, on x86-64 thu thunk names must be:
```
  __llvm_external_retpoline_r11
```
or on 32-bit:
```
  __llvm_external_retpoline_eax
  __llvm_external_retpoline_ecx
  __llvm_external_retpoline_edx
  __llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are from
precompiled runtimes (such as crt0.o and similar). The ones we have
found are not really attackable, and so we have not focused on them
here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z retpolineplt`
(or use similar functionality from some other linker). We strongly
recommend also using `-z now` as non-lazy binding allows the
retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typical workloads, and relatively minor hits (approximately 2%)
even for extremely syscall-heavy applications. This is largely due to
the small number of indirect branches that occur in performance
sensitive paths of the kernel.

When using these patches on statically linked applications, especially
C++ applications, you should expect to see a much more dramatic
performance hit. For microbenchmarks that are switch, indirect-, or
virtual-call heavy we have seen overheads ranging from 10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically reduce
the impact of hot indirect calls (by speculatively promoting them to
direct calls) and allow optimized search trees to be used to lower
switches. If you need to deploy these techniques in C++ applications, we
*strongly* recommend that you ensure all hot call targets are statically
linked (avoiding PLT indirection) and use both PGO and ThinLTO. Well
tuned servers using all of these techniques saw 5% - 10% overhead from
the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality available
as soon as possible. Happy for more code review, but we'd really like to
get these patches landed and backported ASAP for obvious reasons. We're
planning to backport this to both 6.0 and 5.0 release streams and get
a 5.0 release with just this cherry picked ASAP for distros and vendors.

This patch is the work of a number of people over the past month: Eric, Reid,
Rui, and myself. I'm mailing it out as a single commit due to the time
sensitive nature of landing this and the need to backport it. Huge thanks to
everyone who helped out here, and everyone at Intel who helped out in
discussions about how to craft this. Also, credit goes to Paul Turner (at
Google, but not an LLVM contributor) for much of the underlying retpoline
design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

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

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

6 years ago[CodeComplete] Omit templated constructors from member list too.
Sam McCall [Mon, 22 Jan 2018 20:44:47 +0000 (20:44 +0000)]
[CodeComplete] Omit templated constructors from member list too.

Also avoid printing a 'void' return type for constructor expressions.

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

6 years ago[analyzer] Protect against dereferencing a null pointer
Alexander Shaposhnikov [Mon, 22 Jan 2018 20:18:42 +0000 (20:18 +0000)]
[analyzer] Protect against dereferencing a null pointer

The check (inside StackHintGeneratorForSymbol::getMessage)
if (!N)
    return getMessageForSymbolNotFound()
is moved to the beginning of the function.

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

Test plan: make check-all

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

6 years ago[CodeComplete] Fix completion in the middle of idents in macro calls
Ilya Biryukov [Mon, 22 Jan 2018 17:18:28 +0000 (17:18 +0000)]
[CodeComplete] Fix completion in the middle of idents in macro calls

Summary:
This patch removes IdentifierInfo from completion token after remembering
the identifier in the preprocessor.

Prior to this patch, completion token had the IdentifierInfo set to null when
completing at the start of identifier and to the II for completion prefix
when in the middle of identifier.

This patch unifies how code completion token is handled when it is insterted
before the identifier and in the middle of the identifier.

The actual IdentifierInfo can still be obtained from the Preprocessor.

Reviewers: bkramer, arphaman

Reviewed By: bkramer

Subscribers: cfe-commits

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

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

6 years ago[DOCS] Mention OpenMP Tools Interface in runtime library
Jonas Hahnfeld [Mon, 22 Jan 2018 15:27:45 +0000 (15:27 +0000)]
[DOCS] Mention OpenMP Tools Interface in runtime library

Also list supported configurations (architectures + operating
systems).

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

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

6 years ago[modules] Correctly overload getModule in the MultiplexExternalSemaSource
Raphael Isemann [Mon, 22 Jan 2018 15:27:25 +0000 (15:27 +0000)]
[modules] Correctly overload getModule in the MultiplexExternalSemaSource

Summary:
The MultiplexExternalSemaSource doesn't correctly overload the `getModule` function,
causing the multiplexer to not forward this call as intended.

Reviewers: v.g.vassilev

Reviewed By: v.g.vassilev

Subscribers: cfe-commits

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

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

6 years ago[analyzer] Model and check unrepresentable left shifts
Gabor Horvath [Mon, 22 Jan 2018 13:32:10 +0000 (13:32 +0000)]
[analyzer] Model and check unrepresentable left shifts

Patch by: Reka Nikolett Kovacs

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

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

6 years ago[NFC] fix trivial typos in comments
Hiroshi Inoue [Mon, 22 Jan 2018 07:44:38 +0000 (07:44 +0000)]
[NFC] fix trivial typos in comments

"the the" -> "the"

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

6 years ago[analyzer] Provide a check name when MallocChecker enables CStringChecker
Devin Coughlin [Sat, 20 Jan 2018 23:11:17 +0000 (23:11 +0000)]
[analyzer] Provide a check name when MallocChecker enables CStringChecker

Fix an assertion failure caused by a missing CheckName. The malloc checker
enables "basic" support in the CStringChecker, which causes some CString
bounds checks to be enabled. In this case, make sure that we have a
valid CheckName for the BugType.

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

6 years ago[cmake] Use CLANG_BINARY_DIR to determine the build directory.
Vassil Vassilev [Sat, 20 Jan 2018 21:43:35 +0000 (21:43 +0000)]
[cmake] Use CLANG_BINARY_DIR to determine the build directory.

The patch puts the ClangConfig.cmake in the expected location  when clang is
embedded into a framework.

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

6 years ago[X86] Add rdpid command line option and intrinsics.
Craig Topper [Sat, 20 Jan 2018 18:36:52 +0000 (18:36 +0000)]
[X86] Add rdpid command line option and intrinsics.

Summary: This patch adds -mrdpid/-mno-rdpid and the rdpid intrinsic. The corresponding LLVM commit has already been made.

Reviewers: RKSimon, spatel, zvi, AndreiGrischenko

Reviewed By: RKSimon

Subscribers: cfe-commits

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

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

6 years ago[X86] Put the code that defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 for the preproces...
Craig Topper [Sat, 20 Jan 2018 18:36:06 +0000 (18:36 +0000)]
[X86] Put the code that defines __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 for the preprocessor with the other __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* defines. NFC

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

6 years agoLink sanitized programs on NetBSD with -lkvm
Kamil Rytarowski [Sat, 20 Jan 2018 01:03:45 +0000 (01:03 +0000)]
Link sanitized programs on NetBSD with -lkvm

Summary:
kvm - kernel memory interface

The kvm(3) functions like kvm_open(), kvm_getargv() or kvm_getenvv()
are used in programs that can request information about a kernel and
its processes. The LLVM sanitizers will make use of them on NetBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, dvyukov

Reviewed By: vitalybuka

Subscribers: llvm-commits, cfe-commits, #sanitizers

Tags: #sanitizers

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

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

6 years ago[Lex] Fix crash on code completion in comment in included file.
Volodymyr Sapsai [Fri, 19 Jan 2018 23:41:47 +0000 (23:41 +0000)]
[Lex] Fix crash on code completion in comment in included file.

This fixes PR32732 by updating CurLexerKind to reflect available lexers.
We were hitting null pointer in Preprocessor::Lex because CurLexerKind
was CLK_Lexer but CurLexer was null. And we set it to null in
Preprocessor::HandleEndOfFile when exiting a file with code completion
point.

To reproduce the crash it is important for a comment to be inside a
class specifier. In this case in Parser::ParseClassSpecifier we improve
error recovery by pushing a semicolon token back into the preprocessor
and later on try to lex a token because we haven't reached the end of
file.

Also clang crashes only on code completion in included file, i.e. when
IncludeMacroStack is not empty. Though we reset CurLexer even if include
stack is empty. The difference is that during pushing back a semicolon
token, preprocessor calls EnterCachingLexMode which decides it is
already in caching mode because various lexers are null and
IncludeMacroStack is not empty. As the result, CurLexerKind remains
CLK_Lexer instead of updating to CLK_CachingLexer.

rdar://problem/34787685

Reviewers: akyrtzi, doug.gregor, arphaman

Reviewed By: arphaman

Subscribers: cfe-commits, kfunk, arphaman, nemanjai, kbarton

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

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

6 years ago[AArch64] Add ARMv8.2-A FP16 scalar intrinsics
Abderrazek Zaafrani [Fri, 19 Jan 2018 23:11:18 +0000 (23:11 +0000)]
[AArch64] Add ARMv8.2-A FP16 scalar intrinsics

https://reviews.llvm.org/D41792

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

6 years agoAllow BlockDecl in CXXRecord scope to have no access specifier.
Richard Trieu [Fri, 19 Jan 2018 20:46:19 +0000 (20:46 +0000)]
Allow BlockDecl in CXXRecord scope to have no access specifier.

Using a BlockDecl in a default member initializer causes it to be attached to
CXXMethodDecl without its access specifier being set.  This prevents a crash
where getAccess is called on this BlockDecl, since that method expects any
Decl in CXXRecord scope to have an access specifier.

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

6 years ago[X86] Add goldmont to test/Driver/x86-march.c
Craig Topper [Fri, 19 Jan 2018 19:43:36 +0000 (19:43 +0000)]
[X86] Add goldmont to test/Driver/x86-march.c

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

6 years ago[cmake] Also pass CMAKE_ASM_COMPILER_ID to next stage when bootstrapping
Don Hinton [Fri, 19 Jan 2018 18:31:12 +0000 (18:31 +0000)]
[cmake] Also pass CMAKE_ASM_COMPILER_ID to next stage when bootstrapping

Summary:
When setting CMAKE_ASM_COMPILER=clang, we also need to set
CMAKE_ASM_COMPILER_ID=Clang.

This is needed because cmake won't set CMAKE_ASM_COMPILER_ID if
CMAKE_ASM_COMPILER is already set.

Without CMAKE_ASM_COMPILER_ID, cmake can't set
CMAKE_ASM_COMPILER_OPTIONS_TARGET either, which means
CMAKE_ASM_COMPILER_TARGET is ignored, causing cross compiling to fail,
i.e., `--target=${CMAKE_ASM_COMPILER_TARGET}` isn't passed.

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

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

6 years ago[WebAssembly] Add target flags for sign-ext opcodes.
Dan Gohman [Fri, 19 Jan 2018 17:16:32 +0000 (17:16 +0000)]
[WebAssembly] Add target flags for sign-ext opcodes.

Add -msign-ext and -mno-sign-ext to control the new sign-ext target
feature.

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

6 years agoChange memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Daniel Neilson [Fri, 19 Jan 2018 17:12:54 +0000 (17:12 +0000)]
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).

Summary:
  Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.

  The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.

 This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.

 For example, code which used to read:
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)

 At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.

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

6 years ago[clang-format] Adds a canonical delimiter to raw string formatting
Krasimir Georgiev [Fri, 19 Jan 2018 16:18:47 +0000 (16:18 +0000)]
[clang-format] Adds a canonical delimiter to raw string formatting

Summary:
This patch adds canonical delimiter support to the raw string formatting.
This allows matching delimiters to be updated to the canonical one.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

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

6 years ago[clang-format] Fix shortening blocks in macros causing merged next line
Krasimir Georgiev [Fri, 19 Jan 2018 16:12:37 +0000 (16:12 +0000)]
[clang-format] Fix shortening blocks in macros causing merged next line

Summary:
This patch addresses bug 36002, where a combination of options causes the line
following a short block in macro to be merged with that macro.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

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

6 years ago[CodeGenCXX] annotate a GEP to a derived class with 'inbounds' (PR35909)
Sanjay Patel [Fri, 19 Jan 2018 15:14:51 +0000 (15:14 +0000)]
[CodeGenCXX] annotate a GEP to a derived class with 'inbounds' (PR35909)

The standard says:
[expr.static.cast] p11: "If the prvalue of type “pointer to cv1 B” points to a B
that is actually a subobject of an object of type D, the resulting pointer points
to the enclosing object of type D. Otherwise, the behavior is undefined."

Therefore, the GEP must be inbounds.

This should solve the failure to optimize away a null check shown in PR35909:
https://bugs.llvm.org/show_bug.cgi?id=35909

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

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

6 years ago[Fuchsia] Tests for the Fuzzer support in Fuchsia driver
Petr Hosek [Fri, 19 Jan 2018 04:08:06 +0000 (04:08 +0000)]
[Fuchsia] Tests for the Fuzzer support in Fuchsia driver

This adds driver tests for the Fuzzer support.

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

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

6 years ago[Refactor] Use enum instead of magic number in handleX86ForceAlignArgPointerAttr...
Hongbin Zheng [Fri, 19 Jan 2018 03:07:00 +0000 (03:07 +0000)]
[Refactor] Use enum instead of magic number in handleX86ForceAlignArgPointerAttr, NFC

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

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

6 years ago[Fuchsia] Enable Fuzzer as a supported sanitizer on Fuchsia
Petr Hosek [Fri, 19 Jan 2018 01:58:26 +0000 (01:58 +0000)]
[Fuchsia] Enable Fuzzer as a supported sanitizer on Fuchsia

libFuzzer has been ported to Fuchsia so enable it in the driver.

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

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

6 years ago[X86] Add missing check for RDSEED to ICL, CNL, SKX sections of test/Preprocessor...
Craig Topper [Fri, 19 Jan 2018 00:28:42 +0000 (00:28 +0000)]
[X86] Add missing check for RDSEED to ICL, CNL, SKX sections of test/Preprocessor/predefined-arch-macros.c

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

6 years agoRemove TautologicalInRangeCompare from Extra and TautologicalCompare.
Nico Weber [Thu, 18 Jan 2018 21:40:27 +0000 (21:40 +0000)]
Remove TautologicalInRangeCompare from Extra and TautologicalCompare.

This removes the following (already default-off) warnings from -Wextra:
  -Wtautological-type-limit-compare,
  -Wtautological-unsigned-zero-compare
  -Wtautological-unsigned-enum-zero-compare

On the thread "[cfe-dev] -Wtautological-constant-compare issues", clang
code owners Richard Smith, John McCall, and Reid Kleckner as well as
libc++ code owner Marshall Clow stated that these new warnings are not
yet ready for prime time and shouldn't be part of -Wextra.

Furthermore, Vedant Kumar (Apple), Peter Hosek (Fuchsia), and me (Chromium)
expressed the same concerns (Vedant on that thread, Peter on
https://reviews.llvm.org/D39462, me on https://reviews.llvm.org/D41512).

So remove them from -Wextra, and remove TautologicalInRangeCompare from
TautologicalCompare too until they're usable with real-world code.

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

6 years agoc-index-test: small fix to CXString handling and disposal
Steve O'Brien [Thu, 18 Jan 2018 20:21:07 +0000 (20:21 +0000)]
c-index-test: small fix to CXString handling and disposal

Summary: (Separating some unrelated changes out of D42043)

Reviewers: vsk, benlangmuir, akyrtzi

Subscribers: cfe-commits

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

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

6 years agoConvert comment to C-style to prevent warning
Sam Clegg [Thu, 18 Jan 2018 19:31:33 +0000 (19:31 +0000)]
Convert comment to C-style to prevent warning

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

6 years ago[ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google style
Ben Hamilton [Thu, 18 Jan 2018 18:37:16 +0000 (18:37 +0000)]
[ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google style

Summary:
The Google style guide is neutral on whether there should be a
space before the protocol list in an Objective-C @interface or
@implementation.

The majority of Objective-C code in both Apple's public
header files and Google's open-source uses a space before
the protocol list, so this changes the google style to
default ObjCSpaceBeforeProtocolList to true.

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

Reviewers: krasimir, djasper, klimek

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

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

6 years ago[OpenMP] Correct generation of offloading entries
Jonas Hahnfeld [Thu, 18 Jan 2018 15:38:03 +0000 (15:38 +0000)]
[OpenMP] Correct generation of offloading entries

Firstly, each offloading entry must have a unique name or the
linker will complain if there are multiple files with target
regions. Secondly, the compiler must not introduce padding so
mark the struct with a PackedAttr.

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

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

6 years ago[Frontend] Allow to use PrecompiledPreamble without calling CanReuse
Ilya Biryukov [Thu, 18 Jan 2018 15:16:53 +0000 (15:16 +0000)]
[Frontend] Allow to use PrecompiledPreamble without calling CanReuse

Summary:
The new method 'OverridePreamble' allows to override the preamble of
any source file without checking if preamble bounds or dependencies
were changed.

This is used for completion in clangd.

Reviewers: bkramer, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

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

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

6 years agoFix MSVC "uninitialized variable" warning.
Simon Pilgrim [Thu, 18 Jan 2018 13:28:54 +0000 (13:28 +0000)]
Fix MSVC "uninitialized variable" warning.

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

6 years ago[ASTMatcher] Add isScoped matcher for enumDecl.
Haojian Wu [Thu, 18 Jan 2018 09:47:57 +0000 (09:47 +0000)]
[ASTMatcher] Add isScoped matcher for enumDecl.

Summary:

Reviewers: bkramer, aaron.ballman

Subscribers: aaron.ballman, cfe-commits, klimek

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

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

6 years agoRevert rC322769: [RISCV] Propagate -mabi and -march values to GNU assembler.
Hiroshi Inoue [Thu, 18 Jan 2018 06:13:25 +0000 (06:13 +0000)]
Revert rC322769: [RISCV] Propagate -mabi and -march values to GNU assembler.

Temporarily revert rC322769 due to buildbot failurs.

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

6 years agoFix Scope::dump()
Richard Trieu [Thu, 18 Jan 2018 04:28:56 +0000 (04:28 +0000)]
Fix Scope::dump()

The dump function for Scope only has 20 out of the 24 flags.  Since it looped
until no flags were left, having an unknown flag lead to an infinite loop.
That loop has been changed to a single pass for each flag, plus an assert to
alert if new flags are added.

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

6 years ago[analyzer] a few helper methods for getting and comparing symbolic values
George Karpenkov [Thu, 18 Jan 2018 03:18:36 +0000 (03:18 +0000)]
[analyzer] a few helper methods for getting and comparing symbolic values

API calls should express intent, and that's a motivation behind this patch.

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

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

6 years agoUpdate for llvm change.
Rafael Espindola [Thu, 18 Jan 2018 02:08:38 +0000 (02:08 +0000)]
Update for llvm change.

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

6 years ago[analyzer] NFC: Remove unused method - BugReporter::RemoveUnneededCalls().
Artem Dergachev [Thu, 18 Jan 2018 01:40:31 +0000 (01:40 +0000)]
[analyzer] NFC: Remove unused method - BugReporter::RemoveUnneededCalls().

Patch by Henry Wong!

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

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

6 years ago[analyzer] NFC: RetainCount: Protect from dumping raw region to path notes.
Artem Dergachev [Thu, 18 Jan 2018 01:01:56 +0000 (01:01 +0000)]
[analyzer] NFC: RetainCount: Protect from dumping raw region to path notes.

MemRegion::getString() is a wrapper around MemRegion::dump(), which is not
user-friendly and should never be used for diagnostic messages.

Actual cases where raw dumps were reaching the user were unintentionally fixed
in r315736; these were noticed accidentally and shouldn't be reproducible
anymore. For now RetainCountChecker only tracks pointers through variable
regions, and for those dumps are "fine". However, we should still use a less
dangerous method for producing our path notes.

This patch replaces the dump with printing a variable name, asserting that this
is indeed a variable.

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

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

6 years ago[analyzer] NFC: Use "= default" for default ProgramPoint constructors.
Artem Dergachev [Thu, 18 Jan 2018 00:55:29 +0000 (00:55 +0000)]
[analyzer] NFC: Use "= default" for default ProgramPoint constructors.

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

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

6 years ago[analyzer] operator new: Fix callback order for CXXNewExpr.
Artem Dergachev [Thu, 18 Jan 2018 00:53:50 +0000 (00:53 +0000)]
[analyzer] operator new: Fix callback order for CXXNewExpr.

PreStmt<CXXNewExpr> was never called.

Additionally, under c++-allocator-inlining=true, PostStmt<CXXNewExpr> was
called twice when the allocator was inlined: once after evaluating the
new-expression itself, once after evaluating the allocator call which, for the
lack of better options, uses the new-expression as the call site.

This patch fixes both problems.

Differential Revision: https://reviews.llvm.org/D41934
rdar://problem/12180598

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

6 years ago[analyzer] operator new: Add a new ProgramPoint for check::NewAllocator.
Artem Dergachev [Thu, 18 Jan 2018 00:50:19 +0000 (00:50 +0000)]
[analyzer] operator new: Add a new ProgramPoint for check::NewAllocator.

Add PostAllocatorCall program point to represent the moment in the analysis
between the operator new() call and the constructor call. Pointer cast from
"void *" to the correct object pointer type has already happened by this point.

The new program point, unlike the previously used PostImplicitCall, contains a
reference to the new-expression, which allows adding path diagnostics over it.

Differential Revision: https://reviews.llvm.org/D41800
rdar://problem/12180598

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

6 years ago[analyzer] Suppress "this" pointer escape during construction.
Artem Dergachev [Thu, 18 Jan 2018 00:44:41 +0000 (00:44 +0000)]
[analyzer] Suppress "this" pointer escape during construction.

Pointer escape event notifies checkers that a pointer can no longer be reliably
tracked by the analyzer. For example, if a pointer is passed into a function
that has no body available, or written into a global, MallocChecker would
no longer report memory leaks for such pointer.

In case of operator new() under -analyzer-config c++-allocator-inlining=true,
MallocChecker would start tracking the pointer allocated by operator new()
only to immediately meet a pointer escape event notifying the checker that the
pointer has escaped into a constructor (assuming that the body of the
constructor is not available) and immediately stop tracking it. Even though
it is theoretically possible for such constructor to put "this" into
a global container that would later be freed, we prefer to preserve the old
behavior of MallocChecker, i.e. a memory leak warning, in order to
be able to find any memory leaks in C++ at all. In fact, c++-allocator-inlining
*reduces* the amount of false positives coming from this-pointers escaping in
constructors, because it'd be able to inline constructors in some cases.

With other checkers working similarly, we simply suppress the escape event for
this-value of the constructor, regardless of analyzer options.

Differential Revision: https://reviews.llvm.org/D41797
rdar://problem/12180598

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

6 years agoUse an enum value instead of a string.
Rafael Espindola [Thu, 18 Jan 2018 00:20:03 +0000 (00:20 +0000)]
Use an enum value instead of a string.

The old StringSwitch use was also broken. It assumed that a
StringSwitch returns Optional<T> instead of T and was missing a
.Default.

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

6 years ago[analyzer] operator new: Fix path diagnostics around the operator call.
Artem Dergachev [Thu, 18 Jan 2018 00:10:21 +0000 (00:10 +0000)]
[analyzer] operator new: Fix path diagnostics around the operator call.

Implements finding appropriate source locations for intermediate diagnostic
pieces in path-sensitive bug reports that need to descend into an inlined
operator new() call that was called via new-expression. The diagnostics have
worked correctly when operator new() was called "directly".

Differential Revision: https://reviews.llvm.org/D41409
rdar://problem/12180598

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

6 years ago[analyzer] NFC: operator new: Fix new(nothrow) definition in tests.
Artem Dergachev [Thu, 18 Jan 2018 00:03:43 +0000 (00:03 +0000)]
[analyzer] NFC: operator new: Fix new(nothrow) definition in tests.

Fix the const qualifier so that the operator defined in the tests indeed does
override the default global nothrow version of new.

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

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

6 years ago[analyzer] operator new: Add a new checker callback, check::NewAllocator.
Artem Dergachev [Wed, 17 Jan 2018 23:46:13 +0000 (23:46 +0000)]
[analyzer] operator new: Add a new checker callback, check::NewAllocator.

The callback runs after operator new() and before the construction and allows
the checker to access the casted return value of operator new() (in the
sense of r322780) which is not available in the PostCall callback for the
allocator call.

Update MallocChecker to use the new callback instead of PostStmt<CXXNewExpr>,
which gets called after the constructor.

Differential Revision: https://reviews.llvm.org/D41406
rdar://problem/12180598

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

6 years ago[ASTMatchers] Support generating docs for single-line matchers
Benjamin Kramer [Wed, 17 Jan 2018 23:14:49 +0000 (23:14 +0000)]
[ASTMatchers] Support generating docs for single-line matchers

clang-format likes this format. PR35989.

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

6 years ago[analyzer] operator new: Fix ambigious type name.
Artem Dergachev [Wed, 17 Jan 2018 23:03:25 +0000 (23:03 +0000)]
[analyzer] operator new: Fix ambigious type name.

Hopefully fixes an MSVC buildbot failure.

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

6 years ago[analyzer] operator new: Fix memory space for the returned region.
Artem Dergachev [Wed, 17 Jan 2018 22:58:35 +0000 (22:58 +0000)]
[analyzer] operator new: Fix memory space for the returned region.

Make sure that with c++-allocator-inlining=true we have the return value of
conservatively evaluated operator new() in the correct memory space (heap).
This is a regression/omission that worked well in c++-allocator-inlining=false.

Heap regions are superior to regular symbolic regions because they have
stricter aliasing constraints: heap regions do not alias each other or global
variables.

Differential Revision: https://reviews.llvm.org/D41266
rdar://problem/12180598

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

6 years ago[Sema] Allow conversion between long double and __float128.
Benjamin Kramer [Wed, 17 Jan 2018 22:56:57 +0000 (22:56 +0000)]
[Sema] Allow conversion between long double and __float128.

We should only ban this if long double is a double double. x86's 80 bit
long double is fine and supported by the backend.

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

6 years ago[DOXYGEN] Fix doxygen and content issues in xmmintrin.h
Douglas Yung [Wed, 17 Jan 2018 22:53:15 +0000 (22:53 +0000)]
[DOXYGEN] Fix doxygen and content issues in xmmintrin.h

- Fix inaccurate instruction listings.
- Fix small issues in _mm_getcsr and _mm_setcsr.
- Fix description of NaN handling in comparison intrinsics.
- Fix inaccurate description of _mm_movemask_pi8.
- Fix inaccurate instruction mappings.
- Fix typos.
- Clarify wording on some descriptions.
- Fix bit ranges in return value.
- Fix typo in _mm_move_ms intrinsic instruction since it operates on singe-precision values, not double.
- This patch was made by Craig Flores

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

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

6 years ago[analyzer] operator new: Model the cast of returned pointer into object type.
Artem Dergachev [Wed, 17 Jan 2018 22:51:19 +0000 (22:51 +0000)]
[analyzer] operator new: Model the cast of returned pointer into object type.

According to [basic.stc.dynamic.allocation], the return type of any C++
overloaded operator new() is "void *". However, type of the new-expression
"new T()" and the type of "this" during construction of "T" are both "T *".

Hence an implicit cast, which is not present in the AST, needs to be performed
before the construction. This patch adds such cast in the case when the
allocator was indeed inlined. For now, in the case where the allocator was *not*
inlined we still use the same symbolic value (which is a pure SymbolicRegion of
type "T *") because it is consistent with how we represent the casts and causes
less surprise in the checkers after switching to the new behavior.

The better approach would be to represent that value as a cast over a
SymbolicRegion of type "void *", however we have technical difficulties
conjuring such region without any actual expression of type "void *" present in
the AST.

Differential Revision: https://reviews.llvm.org/D41250
rdar://problem/12180598

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

6 years ago[analyzer] NFC: Forbid array elements of void type.
Artem Dergachev [Wed, 17 Jan 2018 22:40:36 +0000 (22:40 +0000)]
[analyzer] NFC: Forbid array elements of void type.

Represent the symbolic value for results of pointer arithmetic on void pointers
in a different way: instead of making void-typed element regions, make
char-typed element regions.

Add an assertion that ensures that no void-typed regions are ever constructed.

This is a refactoring of internals that should not immediately affect
the analyzer's (default) behavior.

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

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

6 years ago[analyzer] operator new: Use the correct region for the constructor.
Artem Dergachev [Wed, 17 Jan 2018 22:34:23 +0000 (22:34 +0000)]
[analyzer] operator new: Use the correct region for the constructor.

The -analyzer-config c++-allocator-inlining experimental option allows the
analyzer to reason about C++ operator new() similarly to how it reasons about
regular functions. In this mode, operator new() is correctly called before the
construction of an object, with the help of a special CFG element.

However, the subsequent construction of the object was still not performed into
the region of memory returned by operator new(). The patch fixes it.

Passing the value from operator new() to the constructor and then to the
new-expression itself was tricky because operator new() has no call site of its
own in the AST. The new expression itself is not a good call site because it
has an incorrect type (operator new() returns 'void *', while the new expression
is a pointer to the allocated object type). Additionally, lifetime of the new
expression in the environment makes it unsuitable for passing the value.
For that reason, an additional program state trait is introduced to keep track
of the return value.

Finally this patch relaxes restrictions on the memory region class that are
required for inlining the constructor. This change affects the old mode as well
(c++-allocator-inlining=false) and seems safe because these restrictions were
an overkill compared to the actual problems observed.

Differential Revision: https://reviews.llvm.org/D40560
rdar://problem/12180598

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

6 years ago[RISCV] Propagate -mabi and -march values to GNU assembler.
Ana Pazos [Wed, 17 Jan 2018 22:09:58 +0000 (22:09 +0000)]
[RISCV] Propagate -mabi and -march values to GNU assembler.

When using -fno-integrated-as flag, the gnu assembler produces code
with some default march/mabi which later causes linker failure due
to incompatible mabi/march.

In this patch we explicitly propagate -mabi and -march flags to the
GNU assembler.

In this patch we explicitly propagate -mabi and -march flags to the GNU assembler.

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

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

6 years ago[analyzer] introduce getSVal(Stmt *) helper on ExplodedNode, make sure the helper...
George Karpenkov [Wed, 17 Jan 2018 20:27:29 +0000 (20:27 +0000)]
[analyzer] introduce getSVal(Stmt *) helper on ExplodedNode, make sure the helper is used consistently

In most cases using
`N->getState()->getSVal(E, N->getLocationContext())`
is ugly, verbose, and also opens up more surface area for bugs if an
inconsistent location context is used.

This patch introduces a helper on an exploded node, and ensures
consistent usage of either `ExplodedNode::getSVal` or
`CheckContext::getSVal` across the codebase.
As a result, a large number of redundant lines is removed.

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

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

6 years ago[analyzer] Make isSubRegionOf reflexive
George Karpenkov [Wed, 17 Jan 2018 20:27:26 +0000 (20:27 +0000)]
[analyzer] Make isSubRegionOf reflexive

All usages of isSubRegionOf separately check for reflexive case, and in
any case, set theory tells us that each set is a subset of itself.

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

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

6 years ago[analyzer] Better UI in html reports for displaying shortcuts help
George Karpenkov [Wed, 17 Jan 2018 20:06:26 +0000 (20:06 +0000)]
[analyzer] Better UI in html reports for displaying shortcuts help

Make the help window accessible, but don't show by default.
Use a different CSS class from macro.

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

6 years ago[clang-format] Replace unordered_set with an array
Krasimir Georgiev [Wed, 17 Jan 2018 20:01:02 +0000 (20:01 +0000)]
[clang-format] Replace unordered_set with an array

Summary: This replaces an unordered_set from r322690 with an array and binary search.

Reviewers: bkramer, benhamilton

Reviewed By: bkramer, benhamilton

Subscribers: jolesiak, benhamilton, klimek, cfe-commits

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

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

6 years ago[ASTMatchers] Add isNoReturn() match narrower for FunctionDeclarations
Roman Lebedev [Wed, 17 Jan 2018 19:40:55 +0000 (19:40 +0000)]
[ASTMatchers] Add isNoReturn() match narrower for FunctionDeclarations

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: dblaikie, klimek, cfe-commits

Tags: #clang

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

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

6 years ago[DeclPrinter] Fix two cases that crash clang -ast-print.
Artem Belevich [Wed, 17 Jan 2018 19:29:39 +0000 (19:29 +0000)]
[DeclPrinter] Fix two cases that crash clang -ast-print.

Both are related to handling anonymous structures.
* clang didn't handle () around an anonymous struct variable.
* clang also crashed on syntax errors that could lead to other
  syntactic constructs following the declaration of an
  anonymous struct. While the code is invalid, that's not
  a good reason to panic compiler.

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

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

6 years ago[Parse] Forward brace locations to TypeConstructExpr
Vedant Kumar [Wed, 17 Jan 2018 18:53:51 +0000 (18:53 +0000)]
[Parse] Forward brace locations to TypeConstructExpr

When parsing C++ type construction expressions with list initialization,
forward the locations of the braces to Sema.

Without these locations, the code coverage pass crashes on the given test
case, because the pass relies on getLocEnd() returning a valid location.

Here is what this patch does in more detail:

  - Forwards init-list brace locations to Sema (ParseExprCXX),
  - Builds an InitializationKind with these locations (SemaExprCXX), and
  - Uses these locations for constructor initialization (SemaInit).

The remaining changes fall out of introducing a new overload for
creating direct-list InitializationKinds.

Testing: check-clang, and a stage2 coverage-enabled build of clang with
asserts enabled.

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

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

6 years ago[Index] Fix GCC warning again :-(
Sam McCall [Wed, 17 Jan 2018 18:20:57 +0000 (18:20 +0000)]
[Index] Fix GCC warning again :-(

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

6 years ago[Tooling] Don't deduplicate tool results in the All-TUs executor.
Eric Liu [Wed, 17 Jan 2018 17:37:11 +0000 (17:37 +0000)]
[Tooling] Don't deduplicate tool results in the All-TUs executor.

Summary:
As result deduplication or reduction is not supported in the framework,
we should leave the deplication to tools (if needed) until the framework supports it.

Reviewers: bkramer

Subscribers: klimek, cfe-commits

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

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

6 years ago[Format] Improve ObjC header guessing heuristic
Ben Hamilton [Wed, 17 Jan 2018 17:33:08 +0000 (17:33 +0000)]
[Format] Improve ObjC header guessing heuristic

Summary:
This improves upon the previous Objective-C header guessing heuristic
from rC320479.

Now, we run the lexer on C++ header files and look for Objective-C
keywords and syntax. We also look for Foundation types.

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

Reviewers: jolesiak, krasimir

Reviewed By: jolesiak

Subscribers: klimek, cfe-commits

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

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

6 years agoUpdate dump_ast_matchers for many recent changes.
Benjamin Kramer [Wed, 17 Jan 2018 16:50:14 +0000 (16:50 +0000)]
Update dump_ast_matchers for many recent changes.

The html file hasn't been updated in a long time so there are quite a
few changes in there. No matchers were removed though.

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

6 years ago[clang-format] adds enclosing function detection to raw string formatting
Krasimir Georgiev [Wed, 17 Jan 2018 16:17:26 +0000 (16:17 +0000)]
[clang-format] adds enclosing function detection to raw string formatting

Summary: This patch adds enclosing function detection to raw string formatting.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

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

6 years agoAttempt to fix test/Driver/masm.c on the ARM bots.
Nico Weber [Wed, 17 Jan 2018 16:03:08 +0000 (16:03 +0000)]
Attempt to fix test/Driver/masm.c on the ARM bots.

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

6 years ago[Index] Fix GCC warning. This is silly, but no llvm_unreachable and no C99.
Sam McCall [Wed, 17 Jan 2018 15:57:14 +0000 (15:57 +0000)]
[Index] Fix GCC warning. This is silly, but no llvm_unreachable and no C99.

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

6 years ago[Sema] Add visited contexts to CodeCompleteContext
Haojian Wu [Wed, 17 Jan 2018 14:29:25 +0000 (14:29 +0000)]
[Sema] Add visited contexts to CodeCompleteContext

Summary:
This would allow code completion clients to know which context is visited during Sema code completion.

Also some changes:
 * add `EnteredContext` callback in VisibleDeclConsumer.
 * add a simple unittest for sema code completion (only for visited contexts at the moment).

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: mgorny, bkramer, cfe-commits

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

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

6 years ago[clang-cl] Let /FA output use intel assembly.
Nico Weber [Wed, 17 Jan 2018 13:34:20 +0000 (13:34 +0000)]
[clang-cl] Let /FA output use intel assembly.

cl's assembly output is in intel syntax, so clang-cl's should be too, PR35031.
https://reviews.llvm.org/D42157

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

6 years ago[clang-format] Reorganize RawStringFormat based on language
Krasimir Georgiev [Wed, 17 Jan 2018 12:24:59 +0000 (12:24 +0000)]
[clang-format] Reorganize RawStringFormat based on language

Summary:
This patch changes the structure for raw string formatting options by making it
language based (enumerate delimiters per language) as opposed to delimiter-based
(specify the language for a delimiter). The raw string formatting now uses an
appropriate style from the .clang-format file, if exists.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

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

6 years ago[CodeGen] Fix a crash on mangling multiversioned functions
George Burgess IV [Wed, 17 Jan 2018 04:46:04 +0000 (04:46 +0000)]
[CodeGen] Fix a crash on mangling multiversioned functions

`multiVersionSortPriority` expects features to have no prefix. We
currently carry them around in the format "+${feature}".

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

6 years ago[analyzer] support a mode to only show relevant lines in HTML diagnostics
George Karpenkov [Wed, 17 Jan 2018 02:59:11 +0000 (02:59 +0000)]
[analyzer] support a mode to only show relevant lines in HTML diagnostics

HTML diagnostics can be an overwhelming blob of pages of code.
This patch adds a checkbox which filters this list down to only the
lines *relevant* to the counterexample by e.g. skipping branches which
analyzer has assumed to be infeasible at a time.

The resulting amount of output is much smaller, and often fits on one
screen, and also provides a much more readable diagnostics.

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

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

6 years agoMake DiagnosticsEngine() take DiagOpts as DiagnosticsEngine.
Nico Weber [Wed, 17 Jan 2018 02:55:27 +0000 (02:55 +0000)]
Make DiagnosticsEngine() take DiagOpts as DiagnosticsEngine.

No behavior change, but makes it a bit clearer that DiagnosticsEngine adds a
ref to DiagOpts.

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

6 years agoAdd context to why test was disabled on Windows
Richard Trieu [Tue, 16 Jan 2018 19:53:06 +0000 (19:53 +0000)]
Add context to why test was disabled on Windows

test/Modules/odr_hash-Friend.cpp triggers an assertion in MicrosoftMangle.cpp
This has been reported in PR35939

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

6 years agoMove target MV resolver to COMDAT
Erich Keane [Tue, 16 Jan 2018 19:49:52 +0000 (19:49 +0000)]
Move target MV resolver to COMDAT

As reported here: https://bugs.llvm.org/show_bug.cgi?id=35921
The resolver functions should be in their own
COMDAT regions. This patch sets that up.

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

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

6 years ago[DOCS] Updated current status of OpenMP support, NFC.
Alexey Bataev [Tue, 16 Jan 2018 19:22:49 +0000 (19:22 +0000)]
[DOCS] Updated current status of OpenMP support, NFC.

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

6 years ago[OPENMP] Add support for `depend` clauses on `target teams distribute
Alexey Bataev [Tue, 16 Jan 2018 19:18:24 +0000 (19:18 +0000)]
[OPENMP] Add support for `depend` clauses on `target teams distribute
parallel for simd` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute parallel for simd` directives.

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

6 years ago[OPENMP] Add support for `depend` on `target teams distribute parallel
Alexey Bataev [Tue, 16 Jan 2018 19:02:33 +0000 (19:02 +0000)]
[OPENMP] Add support for `depend` on `target teams distribute parallel
for` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute parallel for` directives.

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

6 years ago[OPENMP] Add support for `depend` clauses on `target parallel for simd`
Alexey Bataev [Tue, 16 Jan 2018 17:55:15 +0000 (17:55 +0000)]
[OPENMP] Add support for `depend` clauses on `target parallel for simd`
directives.

Added codegen for `depend` clauses on `#pragma omp target parallel for
simd` directives.

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

6 years ago[OPENMP] Add support for `depend` clauses on `target parallel for`
Alexey Bataev [Tue, 16 Jan 2018 17:41:04 +0000 (17:41 +0000)]
[OPENMP] Add support for `depend` clauses on `target parallel for`
directives.

Added codegen for `depend` clause on `#pragma omp target parallel for`
directives.

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

6 years ago[OPENMP] Add support for `depend` clauses on `target teams distribute
Alexey Bataev [Tue, 16 Jan 2018 17:22:50 +0000 (17:22 +0000)]
[OPENMP] Add support for `depend` clauses on `target teams distribute
simd` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute simd` directives.

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

6 years agoAdd va_start()/va_copy()/va_end to Builtins.def
Nico Weber [Tue, 16 Jan 2018 16:55:41 +0000 (16:55 +0000)]
Add va_start()/va_copy()/va_end to Builtins.def

That way, clang suggests including stdarg.h when these are used in C files.
https://reviews.llvm.org/D42085

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