Commit Graph

75491 Commits

Author SHA1 Message Date
Fangrui Song f7868ec25b Revert "[ASTMatchers] Fix DynamicASTMatchersTests again"
This reverts commit 8a6631a983ec9c1d22cc77c5f55a524a651740f0.

The last fix seems good in Debug mode.

llvm-svn: 343738
2018-10-03 22:56:26 +00:00
Artem Dergachev 31f81399bd [analyzer] [tests] [quickfix] Make more test more resilient for non-defaut -std.
It is important to specify the version of the standard because tests should
test the same thing regardless of the current default version of the standard.

llvm-svn: 343736
2018-10-03 22:48:00 +00:00
George Karpenkov 0550dac3ed [analyzer] Do not crash if the assumption added in TrustNonNullChecker is enough to make the state unfeasible
rdar://43541814

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

llvm-svn: 343735
2018-10-03 22:31:09 +00:00
Fangrui Song f8c4f4e6e7 [ASTMatchers] Fix DynamicASTMatchersTests again
llvm-svn: 343722
2018-10-03 21:00:44 +00:00
Fangrui Song e154d4cbf5 [test] Fix -Wunused-variable in rC343665
llvm-svn: 343721
2018-10-03 20:53:53 +00:00
Stephen Kelly c5ae32a226 Remove stray character from docs
llvm-svn: 343720
2018-10-03 20:53:02 +00:00
Stephen Kelly 719b9f3c58 Update documentation for correctness
llvm-svn: 343719
2018-10-03 20:52:57 +00:00
Stephen Kelly 5834d52d1c Add matchers missing from dynamic AST registry
llvm-svn: 343717
2018-10-03 20:52:51 +00:00
Stephen Kelly 5da85abfa1 Sort list of matchers
llvm-svn: 343716
2018-10-03 20:52:45 +00:00
George Karpenkov 61e48e12b5 [analyzer] [tests] [quickfix] Make the test more resilient for a non-defaut std configuration
llvm-svn: 343715
2018-10-03 20:46:50 +00:00
Patrick Lyster 6bdf63bd32 [OPENMP] Add reverse_offload clause to requires directive
llvm-svn: 343711
2018-10-03 20:07:58 +00:00
Matthew Voss 2016536304 Add template type and value parameter metadata nodes to template variable specializations
Summary: Add an optional attribute referring to a tuple of type and value template parameter nodes to the DIGlobalVariable node. This allows us to record the parameters of template variable specializations.

Reviewers: dblaikie, aprantl, probinson, JDevlieghere, clayborg, jingham

Reviewed By: JDevlieghere

Subscribers: cfe-commits

Tags: #debug-info

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

llvm-svn: 343707
2018-10-03 18:45:04 +00:00
Martin Storsjo ed9688db30 [test] Use --sysroot instead of -B in print-multi-directory.c
This avoids finding a similar matching GCC installation outside
of the test directory tree in the surrounding environment, which
would make the test fail. (This happened on Ubuntu 16.04.)

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

llvm-svn: 343702
2018-10-03 18:24:05 +00:00
Mandeep Singh Grang aef87980a9 [COFF, ARM64] Add _ReadWriteBarrier intrinsic
Reviewers: rnk, mstorsjo, compnerd, TomTan, haripul, javed.absar

Reviewed By: rnk

Subscribers: kristof.beyls, chrib, jfb, cfe-commits

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

llvm-svn: 343699
2018-10-03 17:24:21 +00:00
Aaron Puchert 7146b0032f Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr
Summary:
When people are really sure they'll get the lock they sometimes use
__builtin_expect. It's also used by some assertion implementations.
Asserting that try-lock succeeded is basically the same as asserting
that the lock is not held by anyone else (and acquiring it).

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Subscribers: kristina, cfe-commits

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

llvm-svn: 343681
2018-10-03 11:58:19 +00:00
Stephen Kelly 7c787b8adf Allow comments with '#' in dynamic AST Matchers
Summary: This is necessary for clang-query to be able to handle comments.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 343665
2018-10-03 07:56:43 +00:00
Fangrui Song 65ebd13f41 [Frontend] Delete -print-decl-contexts
Summary: Its job is covered by -ast-dump. The option is rarely used and lacks many AST nodes which will lead to llvm_unreachable() crash.

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: jfb, cfe-commits

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

llvm-svn: 343660
2018-10-03 03:50:44 +00:00
Matt Arsenault a01151294a OpenCL: Mark printf format string argument
Fixes not warning on format string errors.

llvm-svn: 343653
2018-10-03 02:01:19 +00:00
Petr Hosek ed8311da5a [CMake][Fuchsia] Use libc++ ABIv2 for Fuchsia toolchain
We don't need to provide stable ABI and hence we can use the v2.

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

llvm-svn: 343652
2018-10-03 01:27:00 +00:00
George Karpenkov d3b0846e7a [analyzer] [tests] Hotfix: missing space
llvm-svn: 343643
2018-10-02 22:31:44 +00:00
Reid Kleckner c6fbfd84ad Remove spurious assertion in -Wdocumentation
Some code in OpenCV uses interesting doxygen directives that make it so
we don't see any tokens inside a @note, despite there definitely being
non-whitespace characters there. The consistency check isn't needed.
ParagraphComment supports receiving an empty list of comments.

Fixes PR39007

llvm-svn: 343641
2018-10-02 22:23:27 +00:00
George Karpenkov ac98683423 [analyzer] [tests] Allow specifying entire -analyze-config on the command line, make sure it's always propagated
Differential Revision: https://reviews.llvm.org/D52801

llvm-svn: 343636
2018-10-02 21:19:23 +00:00
George Karpenkov c1ac80820e [analyzer] Fix crash in exploded graph dumping
By allocating new DeclStmt to ASTContext

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

llvm-svn: 343635
2018-10-02 21:19:01 +00:00
Artem Dergachev e602dfbc62 [analyzer] Promote StdCLibraryFunctionsChecker to the apiModeling category.
Because all our languages are C-based, there's no reason to
enable this checker only on UNIX targets.

Patch by Donát Nagy!

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

llvm-svn: 343632
2018-10-02 20:50:40 +00:00
Artem Dergachev d807f9065b [analyzer] Fix symbol discovery in nonloc::LocAsInteger values.
Doesn't do much despite sounding quite bad, but fixes an exotic test case where
liveness of a nonloc::LocAsInteger array index is now evaluated correctly.

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

llvm-svn: 343631
2018-10-02 20:48:12 +00:00
Zachary Turner be6edb3a70 [cl-compat] Change /JMC from unsupported to ignored.
A tracking bug for actually implementing this in clang-cl is at
https://bugs.llvm.org/show_bug.cgi?id=39156.

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

llvm-svn: 343629
2018-10-02 20:42:36 +00:00
Kristof Umann 40271e4fde [analyzer][NFC] Refactor functions in PlistDiagnostics to take AnalyzerOptions as parameter
I intend to add a new flag macro-expnasions-as-events, and unfortunately
I'll only be able to convert the macro piece into an event one once I'm
about to emit it, due to the lack of an avaible Preprocessor object in
the BugReporter.

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

llvm-svn: 343620
2018-10-02 19:27:34 +00:00
Jonas Hahnfeld 3ca4701d35 [OpenMP][NVPTX] Simplify codegen for orphaned parallel, NFCI.
Worker threads fork off to the compiler generated worker function
directly after entering the kernel function. Hence, there is no
need to check whether the current thread is the master if we are
outside of a parallel region (neither SPMD nor parallel_level > 0).

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

llvm-svn: 343618
2018-10-02 19:12:54 +00:00
Jonas Hahnfeld 5aaaecea7c [OpenMP] Simplify code for reductions on distribute directives, NFC.
Only need to care about the 'distribute simd' case, all other composite
directives are handled elsewhere. This was already reflected in the
outer 'if' condition, so all other inner conditions could never be true.

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

llvm-svn: 343617
2018-10-02 19:12:47 +00:00
Yaxun Liu 9767089d00 [HIP] Support early finalization of device code for -fno-gpu-rdc
This patch renames -f{no-}cuda-rdc to -f{no-}gpu-rdc and keeps the original
options as aliases. When -fgpu-rdc is off,
clang will assume the device code in each translation unit does not call
external functions except those in the device library, therefore it is possible
to compile the device code in each translation unit to self-contained kernels
and embed them in the host object, so that the host object behaves like
usual host object which can be linked by lld.

The benefits of this feature is: 1. allow users to create static libraries which
can be linked by host linker; 2. amortized device code linking time.

This patch modifies HIP action builder to insert actions for linking device
code and generating HIP fatbin, and pass HIP fatbin to host backend action.
It extracts code for constructing command for generating HIP fatbin as
a function so that it can be reused by early finalization. It also modifies
codegen of HIP host constructor functions to embed the device fatbin
when it is available.

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

llvm-svn: 343611
2018-10-02 17:48:54 +00:00
Francois Ferrand 6f40e21a16 clang-format: better handle statement macros
Summary:
Some macros are used in the body of function, and actually contain the trailing semicolon: they should thus be automatically followed by a new line, and not get merged with the next line. This is for example the case with Qt's Q_UNUSED macro:

  void foo(int a, int b) {
    Q_UNUSED(a)
    return b;
  }

This patch deals with these cases by introducing a new option to specify list of statement macros. This re-uses the system already in place for foreach macros, to ensure there is no impact on performance.

Reviewers: krasimir, djasper, klimek

Reviewed By: krasimir

Subscribers: acoomans, mgrang, alexfh, klimek, cfe-commits

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

llvm-svn: 343602
2018-10-02 16:37:51 +00:00
Haojian Wu 714e971540 [Preprocesssor] Filename should fall back to the written name when typo correction fails.
Summary:
The test is added in  Testcase is at https://reviews.llvm.org/D52775. I tried to add the test to clang's code
completion test, it doesn't reproduce the crash.

Reviewers: sammccall, kristina

Reviewed By: sammccall

Subscribers: kristina, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

llvm-svn: 343592
2018-10-02 14:42:51 +00:00
Haojian Wu dea577191c [Preprocessor] Hide include typo correction behind SpellChecking.
Summary:
Similar to Sema typo correction, the Preprocessor typo correction should
also be hidden behind the SpellChecking flag.

Reviewers: sammccall

Subscribers: cfe-commits

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

llvm-svn: 343591
2018-10-02 13:59:49 +00:00
Sven van Haastregt a3c6b407ec [OpenCL] Add block argument CodeGen test
r326937 ("[OpenCL] Remove block invoke function from emitted block
literal struct", 2018-03-07) broke block argument handling.  In
particular the commit was causing a crash during code generation, see
the discussion in https://reviews.llvm.org/D43783 .

The offending commit has just been reverted; add a test to avoid
breaking this again in the future.

llvm-svn: 343583
2018-10-02 13:02:27 +00:00
Sven van Haastregt da3b632057 Revert r326937 "[OpenCL] Remove block invoke function from emitted block literal struct"
This reverts r326937 as it broke block argument handling in OpenCL.
See the discussion on https://reviews.llvm.org/D43783 .

The next commit will add a test case that revealed the issue.

llvm-svn: 343582
2018-10-02 13:02:24 +00:00
Mikhail R. Gadelha 32ce136e80 [analyzer] Improvements to the SMT API
Summary:
Several improvements in preparation for the new backends.

Refactoring:

- Removed duplicated methods `fromBoolean`, `fromAPSInt`, `fromInt` and `fromAPFloat`. The methods `mkBoolean`, `mkBitvector` and `mkFloat` are now used instead.
- The names of the functions that convert BVs to FPs were swapped (`mkSBVtoFP`, `mkUBVtoFP`, `mkFPtoSBV`, `mkFPtoUBV`).
- Added a couple of comments in function calls.

Crosscheck encoding:

- Changed how constraints are encoded in the refutation manager so it doesn't start with (false OR ...). This change introduces one duplicated line (see file `BugReporterVisitors.cpp`, the `SMTConv::getRangeExpr is called twice, so I can remove this change if the duplication is a problem.

Reviewers: george.karpenkov, NoQ

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, Szelethus

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

llvm-svn: 343581
2018-10-02 12:55:48 +00:00
Bruno Ricci 26a2536f8b [AST] Pack the bit-fields of FunctionProtoType into Type.
Move the bit-fields of FunctionProtoType into FunctionTypeBitfields.
This cuts the size of FunctionProtoType by a pointer. Additionally use
llvm::TrailingObjects instead of manually doing the casts + arithmetic.

This patch is bigger then what could be expected for the following reasons:

1. As discussed before in D50631 it would be nice if there was some space left
   in FunctionTypeBitfields for future additions. This patch introduces an
   extra structure FunctionTypeExtraBitfields which is supposed to hold
   uncommon bits and is stored in a trailing object. The number of exception
   types NumExceptions is moved to this struct. As of this patch this trailing
   struct will only be allocated if we have > 0 types in a dynamic exception
   specification.

2. TrailingObjects cannot handle repeated types. Therefore the QualType
   representing an exception type is wrapped in a struct ExceptionType.
   The ExceptionType * is then reinterpret_cast'd to QualType *.

3. TrailingObjects needs the definition of the various trailing classes.
   Therefore ExtParameterInfo, ExceptionType and FunctionTypeExtraBitfields
   are put in FunctionType.

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

Reviewed By: rjmccall

llvm-svn: 343579
2018-10-02 11:46:38 +00:00
Eric Liu b91e08197c [CodeComplete] Re-fix accessibilty of protected members from base class.
Summary:
The initial fix (r337453) had bug and was partially reverted (r338255).
This simplies the original fix by explicitly passing the naming class to the
completion consumer.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 343575
2018-10-02 10:29:00 +00:00
Eric Liu b9e17124ea Revert untintentionally commited changes
llvm-svn: 343574
2018-10-02 10:28:54 +00:00
Eric Liu 09c34d77e0 [Lex] TokenConcatenation now takes const Preprocessor
Differential Revision: https://reviews.llvm.org/D52502

llvm-svn: 343573
2018-10-02 10:28:50 +00:00
Kadir Cetinkaya ae45d0a4fd [clang] Implement Override Suggestions in Sema.
Summary:
In clangd we had a new type of completion suggestions for cpp
class/struct/unions that will show override signatures for virtual methods in
base classes. This patch implements it in sema because it is hard to deduce more
info about completion token outside of Sema and handle itchy cases.

See the patch D50898 for more info on the functionality.

In addition to above patch this one also converts the suggestion into a
CK_Pattern with whole insertion text as the name of the suggestion and factors
out CodeCompletionString generation for declerations so that it can be re-used
by others.

Reviewers: ioeric, ilya-biryukov

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 343568
2018-10-02 09:42:31 +00:00
Oliver Stannard 8f996de629 [AArch64][v8.5A] Test clang option for the Memory Tagging Extension
The implementation of this is in TargetParser, so we only need to add a
test for it in clang.

Patch by Pablo Barrio!

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

llvm-svn: 343566
2018-10-02 09:38:59 +00:00
David Bolvansky cf7d2256d6 Added warning for unary minus used with unsigned type
Summary:
Inspired by MSVC, which found some occurrences of this expression on our code base.

Fixes PR38950

Reviewers: rsmith, craig.topper, spatel, RKSimon, aaron.ballman, thakis

Reviewed By: rsmith

Subscribers: joerg, Quuxplusone, lebedev.ri, craig.topper, RKSimon, cfe-commits

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

llvm-svn: 343560
2018-10-02 06:02:30 +00:00
Akira Hatanaka 9d34307788 [CodeGen] Before entering the loop that copies a non-trivial array field
of a non-trivial C struct, copy the preceding trivial fields that
haven't been copied.

This commit fixes a bug where the instructions used to copy the
preceding trivial fields were emitted inside the loop body.

rdar://problem/44185064

llvm-svn: 343556
2018-10-02 01:00:44 +00:00
Akira Hatanaka 8e57b07f66 Distinguish `__block` variables that are captured by escaping blocks
from those that aren't.

This patch changes the way __block variables that aren't captured by
escaping blocks are handled:

- Since non-escaping blocks on the stack never get copied to the heap
  (see https://reviews.llvm.org/D49303), Sema shouldn't error out when
  the type of a non-escaping __block variable doesn't have an accessible
  copy constructor.

- IRGen doesn't have to use the specialized byref structure (see
  https://clang.llvm.org/docs/Block-ABI-Apple.html#id8) for a
  non-escaping __block variable anymore. Instead IRGen can emit the
  variable as a normal variable and copy the reference to the block
  literal. Byref copy/dispose helpers aren't needed either.

This reapplies r343518 after fixing a use-after-free bug in function
Sema::ActOnBlockStmtExpr where the BlockScopeInfo was dereferenced after
it was popped and deleted.

rdar://problem/39352313

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

llvm-svn: 343542
2018-10-01 21:51:28 +00:00
Martin Storsjo f32a0fc80d [MinGW] Allow using ASan
Linking to ASan for MinGW is similar to MSVC, but MinGW always links
the MSVCRT dynamically, so there is only one of the MSVC cases to
consider.

When linking to a shared compiler runtime library on MinGW, the suffix
of the import library is .dll.a.

The existing case of .dll as suffix for windows in general doesn't
seem correct (since this is used for linking). As long as callers never
actually set the Shared flag, the default static suffix of .lib also
worked fine for import libraries as well.

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

llvm-svn: 343537
2018-10-01 20:53:25 +00:00
Akira Hatanaka 3197484701 Revert r343518.
Bots are still failing.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/24420
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/12958

llvm-svn: 343531
2018-10-01 20:29:34 +00:00
Stephen Kelly 97e0f52642 Update CMakeLists.txt snippet so that example compiles
Summary: Previous to this the example didn't work out of the box, it seems some cmake config changed between when this was written and now.

Author: Dan Zimmerman <daniel.zimmerman@me.com>

Reviewers: modocache, steveire

Reviewed By: steveire

Subscribers: smeenai, steveire, cfe-commits

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

llvm-svn: 343530
2018-10-01 20:28:07 +00:00
Akira Hatanaka 2bf09ccfd5 Distinguish `__block` variables that are captured by escaping blocks
from those that aren't.

This patch changes the way __block variables that aren't captured by
escaping blocks are handled:

- Since non-escaping blocks on the stack never get copied to the heap
  (see https://reviews.llvm.org/D49303), Sema shouldn't error out when
  the type of a non-escaping __block variable doesn't have an accessible
  copy constructor.

- IRGen doesn't have to use the specialized byref structure (see
  https://clang.llvm.org/docs/Block-ABI-Apple.html#id8) for a
  non-escaping __block variable anymore. Instead IRGen can emit the
  variable as a normal variable and copy the reference to the block
  literal. Byref copy/dispose helpers aren't needed either.

This reapplies r341754, which was reverted in r341757 because it broke a
couple of bots. r341754 was calling markEscapingByrefs after the call to
PopFunctionScopeInfo, which caused the popped function scope to be
cleared out when the following code was compiled, for example:

$ cat test.m
struct A {
  id data[10];
};

void foo() {
  __block A v;
  ^{ (void)v; };
}

This commit calls markEscapingByrefs before calling PopFunctionScopeInfo
to prevent that from happening.

rdar://problem/39352313

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

llvm-svn: 343518
2018-10-01 18:50:14 +00:00
Krasimir Georgiev be5cda81d5 [clang-format] Update comment, NFCI
The initializer of `ParameterCount` was updated from 1 to 0 in r175165,
but the comment was never touched:
9fc56f2636

llvm-svn: 343517
2018-10-01 18:41:21 +00:00