Commit Graph

78059 Commits

Author SHA1 Message Date
Owen Pan 108cbbc262 [clang-format] Fix bug in reflow of block comments containing CR/LF
Fix PR36119

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

llvm-svn: 359029
2019-04-23 20:29:46 +00:00
Teresa Johnson 867bc3951b [ThinLTO] Pass down opt level to LTO backend and handle -O0 LTO in new PM
Summary:
The opt level was not being passed down to the ThinLTO backend when
invoked via clang (for distributed ThinLTO).

This exposed an issue where the new PM was asserting if the Thin or
regular LTO backend pipelines were invoked with -O0 (not a new issue,
could be provoked by invoking in-process *LTO backends via linker using
new PM and -O0). Fix this similar to the old PM where -O0 only does the
necessary lowering of type metadata (WPD and LowerTypeTest passes) and
then quits, rather than asserting.

Reviewers: xur

Subscribers: mehdi_amini, inglorion, eraman, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits, pcc

Tags: #clang, #llvm

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

llvm-svn: 359025
2019-04-23 18:56:19 +00:00
Joel E. Denny 3234887fe2 [APSInt][OpenMP] Fix isNegative, etc. for unsigned types
Without this patch, APSInt inherits APInt::isNegative, which merely
checks the sign bit without regard to whether the type is actually
signed.  isNonNegative and isStrictlyPositive call isNegative and so
are also affected.

This patch adjusts APSInt to override isNegative, isNonNegative, and
isStrictlyPositive with implementations that consider whether the type
is signed.

A large set of Clang OpenMP tests are affected.  Without this patch,
these tests assume that `true` is not a valid argument for clauses
like `collapse`.  Indeed, `true` fails APInt::isStrictlyPositive but
not APSInt::isStrictlyPositive.  This patch adjusts those tests to
assume `true` should be accepted.

This patch also adds tests revealing various other similar fixes due
to APSInt::isNegative calls in Clang's ExprConstant.cpp and
SemaExpr.cpp: `++` and `--` overflow in `constexpr`, evaluated object
size based on `alloc_size`, `<<` and `>>` shift count validation, and
OpenMP array section validation.

Reviewed By: lebedev.ri, ABataev, hfinkel

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

llvm-svn: 359012
2019-04-23 17:04:15 +00:00
Nico Weber 27df409203 MS ABI: Support mangling op<=> now that MSVC 2019 has a mangling
llvm-svn: 359009
2019-04-23 16:37:42 +00:00
Simon Pilgrim 6b1825081d Fix "-Wimplicit-fallthrough" warning. NFCI.
llvm-svn: 358973
2019-04-23 11:45:28 +00:00
Adam Balogh d2e2e20de3 [Analyzer] Second fix for last commit for IteratorChecker
A variable was redeclared instead of assigned in an internal
block, leaving the original uninitialized. This is fixed now.

llvm-svn: 358971
2019-04-23 11:18:50 +00:00
Rafael Stahl 850361f6c1 [analyzer][CrossTU] Extend CTU to VarDecls with initializer
Summary:
The existing CTU mechanism imports `FunctionDecl`s where the definition is available in another TU. This patch extends that to VarDecls, to bind more constants.

- Add VarDecl importing functionality to CrossTranslationUnitContext
- Import Decls while traversing them in AnalysisConsumer
- Add VarDecls to CTU external mappings generator
- Name changes from "external function map" to "external definition map"

Reviewers: NoQ, dcoughlin, xazax.hun, george.karpenkov, martong

Reviewed By: xazax.hun

Subscribers: Charusso, baloghadamsoftware, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, george.karpenkov, mgorny, whisperity, szepet, rnkovacs, a.sidorin, cfe-commits

Tags: #clang

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

llvm-svn: 358968
2019-04-23 11:04:41 +00:00
Adam Balogh 8f8827014d [Analyzer] Fix for previous commit
A compilation warning was in my previous commit which broke the buildbot
because it is using `-Werror` for compilation. This patch fixes this
issue.

llvm-svn: 358955
2019-04-23 07:45:10 +00:00
Fangrui Song fb2783f680 [PowerPC] Fix test with -fno-discard-value-names after rC358949
For the clang driver, -DLLVM_ENABLE_ASSERTIONS=off builds default to discard value names.

llvm-svn: 358953
2019-04-23 07:39:23 +00:00
Adam Balogh 54976e76e6 [Analyzer] Instead of recording comparisons in interator checkers do an eager state split
Currently iterator checkers record comparison of iterator positions
and process them for keeping track the distance between them (e.g.
whether a position is the same as the end position). However this
makes some processing unnecessarily complex and it is not needed at
all: we only need to keep track between the abstract symbols stored
in these iterator positions. This patch changes this and opens the
path to comparisons to the begin() and end() symbols between the
container (e.g. size, emptiness) which are stored as symbols, not
iterator positions. The functionality of the checker is unchanged.

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

llvm-svn: 358951
2019-04-23 07:15:55 +00:00
Qiu Chaofan 19828e399b [PowerPC] [Clang] Port MMX intrinsics and basic test cases to Power
Port mmintrin.h which include x86 MMX intrinsics implementation to PowerPC platform (using Altivec).

To make the include process correct, PowerPC's toolchain class is overrided to insert new headers directory (named ppc_wrappers) into the path. Basic test cases for several intrinsic functions are added.

The header is mainly developed by Steven Munroe, with contributions from Paul Clarke, Bill Schmidt, Jinsong Ji and Zixuan Wu.

Reviewed By: Jinsong Ji

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

llvm-svn: 358949
2019-04-23 05:50:24 +00:00
Artem Dergachev 727d6ca3f0 [analyzer] Unbreak body farms in presence of multiple declarations.
When growing a body on a body farm, it's essential to use the same redeclaration
of the function that's going to be used during analysis. Otherwise our
ParmVarDecls won't match the ones that are used to identify argument regions.

This boils down to trusting the reasoning in AnalysisDeclContext. We shouldn't
canonicalize the declaration before farming the body because it makes us not
obey the sophisticated decision-making process of AnalysisDeclContext.

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

llvm-svn: 358946
2019-04-23 02:56:00 +00:00
Artem Dergachev e2a8e43160 [analyzer] PR41335: Fix crash when no-store event is in a body-farmed function.
Stuffing invalid source locations (such as those in functions produced by
body farms) into path diagnostics causes crashes.

Fix a typo in a nearby function name.

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

llvm-svn: 358945
2019-04-23 02:50:38 +00:00
Artem Dergachev 8c6119a442 [analyzer] PR41269: Add a bit of C++ smart pointer modeling.
Implement cplusplus.SmartPtrModeling, a new checker that doesn't
emit any warnings but models methods of smart pointers more precisely.

For now the only thing it does is make `(bool) P` return false when `P`
is a freshly moved pointer. This addresses a false positive in the
use-after-move-checker.

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

llvm-svn: 358944
2019-04-23 02:45:42 +00:00
Petr Hosek fbcce9fe9d [CMake] Replace the sanitizer support in runtimes build with multilib
This is a more generic solution; while the sanitizer support can be used
only for sanitizer instrumented builds, the multilib support can be used
to build other variants such as noexcept which is what we would like to use
in Fuchsia.

The name CMake target name uses the target name, same as for the regular
runtimes build and the name of the multilib, concatenated with '+'. The
libraries are installed in a subdirectory named after the multilib.

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

llvm-svn: 358935
2019-04-22 23:31:39 +00:00
Richard Smith e181de7f4f [c++2a] Implement semantic restrictions for 'export' declarations.
llvm-svn: 358932
2019-04-22 22:50:11 +00:00
Joel E. Denny 906b264251 [VerifyDiagnosticConsumer] Document -verify=<prefixes> in doxygen
Previously, it was only documented by `-cc1 -help`, so people weren't
aware of it, as discussed in D60732.

Reviewed By: Charusso, NoQ

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

llvm-svn: 358917
2019-04-22 20:25:06 +00:00
Ben Hamilton a282bde69e [ASTMatchers] Introduce Objective-C matchers `isClassMessage`, `isClassMethod`, and `isInstanceMethod`
Summary:
isClassMessage is an equivalent to isInstanceMessage for ObjCMessageExpr, but matches message expressions to classes.

isClassMethod and isInstanceMethod check whether a method declaration (or definition) is for a class method or instance method (respectively).

Contributed by @mywman!

Reviewers: benhamilton, klimek, mwyman

Reviewed By: benhamilton, mwyman

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 358904
2019-04-22 17:54:11 +00:00
Matt Davis 55043e2336 [sema][objc] Minor refactor to OverrideSearch. NFCI.
Summary:
* Removed a member that was only used during construction.
* Use range-based for iteration when accessing the result of the search.
* Require an `ObjCMethodDecl` reference upon construction of an
* Constify.

Reviewers: rjmccall

Reviewed By: rjmccall

Subscribers: llvm-commits

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

llvm-svn: 358898
2019-04-22 16:04:44 +00:00
Bruno Ricci af3e50ad40 [Sema] ADL: Associated namespaces for class types and enumeration types (CWG 1691)
CWG 1691 changed the definition of the namespaces associated with a class
type or enumeration type.

For a class type, the associated namespaces are the innermost enclosing
namespaces of the associated classes. For an enumeration type, the associated
namespace is the innermost enclosing namespace of its declaration.

This also fixes CWG 1690 and CWG 1692.

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

Reviewed By: rjmccall, rsmith

llvm-svn: 358882
2019-04-22 12:19:00 +00:00
Bruno Ricci 1f30dba14d [Sema][NFC] Add more tests for the behavior of argument-dependent name lookup
The goal here is to exercise each rule in [basic.lookup.argdep] at least once.
These new tests expose what I believe are 2 issues:

1. CWG 1691 needs to be implemented (p2:  [...] Its associated namespaces are
   the innermost enclosing namespaces of its associated classes [...]) The
   corresponding tests are adl_class_type::X2 and adl_class_type::X5.

2. The end of paragraph 2 ([...] Additionally, if the aforementioned set of
   overloaded functions is named with a template-id, its associated classes
   and namespaces also include those of its type template-arguments and its
   template template-arguments.) is not implemented. Closely related, the
   restriction on non-dependent parameter types in this same paragraph needs
   to be removed. The corresponding tests are in adl_overload_set (both issues
   are from CWG 997).

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

Reviewed By: riccibruno, Quuxplusone

llvm-svn: 358881
2019-04-22 11:40:31 +00:00
Kristof Umann 4aa387212b [analyzer][www] Moving MoveChecker out of alpha is no longer an open project.
llvm-svn: 358877
2019-04-22 09:20:23 +00:00
Nico Weber 18cfd9fdaf Attempt to fix LLVM_ENABLE_THREADS=OFF build after r358665
llvm-svn: 358858
2019-04-21 19:18:41 +00:00
Bruno Ricci ba7ffae0c5 [Sema][MSVC] Fix bogus microsoft-pure-definition warning on member function of class template
Clang emits a warning when using a pure specifier =0 in a function definition
at class scope (a MS-specific construct), when using -fms-extensions.
However, to detect this, it was using FD->isCanonicalDecl() on function
declaration, which was also detecting out-of-class definition of member
functions of class templates. Fix this by using !FD->isOutOfLine() instead.

Fixes PR21334.

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

Reviewed By: riccibruno

Reviewers: rnk, riccibruno

Patch By: Rudy Pons

llvm-svn: 358849
2019-04-21 13:12:10 +00:00
Kristof Umann 85e0ff752c [analyzer] Move UninitializedObjectChecker out of alpha
Moved UninitializedObjectChecker from the 'alpha.cplusplus' to the
'optin.cplusplus' package.

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

llvm-svn: 358797
2019-04-19 23:33:50 +00:00
David Blaikie 07489f9ccf Modules: Adopt template parameters for variable templates to set their decl context correctly
Exposed by a related bug about visibility of default arguments of nested
templates - without the correct decl context, default template
parameters of variable templates nested in classes would have incorrect
visibility computed.

llvm-svn: 358796
2019-04-19 23:04:05 +00:00
David Blaikie aa3bf6ce72 Modules: Search for a visible definition of the decl context when computing visibility of a default template parameter
The code is/was already correct for the case where a parameter is a
parameter of its enclosing lexical DeclContext (functions and classes).
But for other templates (alias and variable templates) they don't create
their own scope to be members of - in those cases, they parameter should
be considered visible if any definition of the lexical decl context is
visible.

[this should cleanup the failure on the libstdc++ modules buildbot]
[this doesn't actually fix the variable template case for a
secondary/compounding reason (its lexical decl context is incorrectly
considered to be the translation unit)]

Test covers all 4 kinds of templates with default args, including a
regression test for the still broken variable template case.

Reviewers: rsmith

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

llvm-svn: 358795
2019-04-19 23:02:30 +00:00
Amy Huang c774f687b6 [MS] Emit S_HEAPALLOCSITE debug info
Summary:
This emits labels around heapallocsite calls and S_HEAPALLOCSITE debug
info in codeview. Currently only changes FastISel, so emitting labels still
needs to be implemented in SelectionDAG.

Reviewers: hans, rnk

Subscribers: aprantl, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 358783
2019-04-19 21:09:11 +00:00
Artem Dergachev 0a7dd5a2a4 Reapply "[analyzer] Introduce a simplified API for adding custom path notes."
This reapplies commit r357323, fixing memory leak found by LSan.

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

llvm-svn: 358781
2019-04-19 20:23:29 +00:00
Martin Storsjo 93f7d83b36 [MSVC] If unable to find link.exe from a MSVC installation, look for link.exe next to cl.exe
Previously, if the MSVC installation isn't detected properly, clang
will later just fail to execute link.exe.

This improves using clang in msvc mode on linux, where one intentionally
might not want to point clang to the MSVC installation itself (which
isn't executable as such), but where a link.exe named wine wrapper is
available in the path next to a cl.exe named wine wrapper.

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

llvm-svn: 358778
2019-04-19 19:04:22 +00:00
Brad Smith 4fccc0cedd Enable frame pointer elimination for OpenBSD on powerpc.
llvm-svn: 358775
2019-04-19 18:41:40 +00:00
Alexey Bataev 1472e32cd7 [OPENMP][NVPTX] target [teams distribute] simd maybe run without
runtime.

target [teams distribute] simd costructs do not require full runtime for
the correct execution, we can run them without full runtime.

llvm-svn: 358766
2019-04-19 16:48:38 +00:00
Alina Sbirlea 6541e8e791 Update to use PipelineTuningOptions. Corresponds to llvm change: D59723.
llvm-svn: 358765
2019-04-19 16:32:08 +00:00
Sylvestre Ledru 5505ad34db Debian: Add two missing version code in sid
llvm-svn: 358758
2019-04-19 13:48:52 +00:00
Sylvestre Ledru 54a93a33ee Add support of the future Debian (Debian 11 - Bullseye)
https://wiki.debian.org/DebianBullseye

llvm-svn: 358757
2019-04-19 13:46:58 +00:00
Sylvestre Ledru 454014199d Add support of the next Ubuntu (Ubuntu 19.10 - Eoan EANIMAL)
llvm-svn: 358756
2019-04-19 13:43:28 +00:00
Florian Hahn b340497f76 [LTO] Add plumbing to save stats during LTO on Darwin.
Gold and ld on Linux already support saving stats, but the
infrastructure is missing on Darwin. Unfortunately it seems like the
configuration from lib/LTO/LTO.cpp is not used.

This patch adds a new LTOStatsFile option and adds plumbing in Clang to
use it on Darwin, similar to the way remarks are handled.

Currnetly the handling of LTO flags seems quite spread out, with a bunch
of duplication. But I am not sure if there is an easy way to improve
that?

Reviewers: anemet, tejohnson, thegameg, steven_wu

Reviewed By: steven_wu

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

llvm-svn: 358753
2019-04-19 12:36:41 +00:00
Kristof Umann b4788b26e2 [analyzer][NFC] Reimplement checker options
TL;DR:

* Add checker and package options to the TableGen files
* Added a new class called CmdLineOption, and both Package and Checker recieved
   a list<CmdLineOption> field.
* Added every existing checker and package option to Checkers.td.
* The CheckerRegistry class
  * Received some comments to most of it's inline classes
  * Received the CmdLineOption and PackageInfo inline classes, a list of
     CmdLineOption was added to CheckerInfo and PackageInfo
  * Added addCheckerOption and addPackageOption
  * Added a new field called Packages, used in addPackageOptions, filled up in
     addPackage

Detailed description:

In the last couple months, a lot of effort was put into tightening the
analyzer's command line interface. The main issue is that it's spectacularly
easy to mess up a lenghty enough invocation of the analyzer, and the user was
given no warnings or errors at all in that case.

We can divide the effort of resolving this into several chapters:

* Non-checker analyzer configurations:
    Gather every analyzer configuration into a dedicated file. Emit errors for
    non-existent configurations or incorrect values. Be able to list these
    configurations. Tighten AnalyzerOptions interface to disallow making such
    a mistake in the future.

* Fix the "Checker Naming Bug" by reimplementing checker dependencies:
    When cplusplus.InnerPointer was enabled, it implicitly registered
    unix.Malloc, which implicitly registered some sort of a modeling checker
    from the CStringChecker family. This resulted in all of these checker
    objects recieving the name "cplusplus.InnerPointer", making AnalyzerOptions
    asking for the wrong checker options from the command line:
      cplusplus.InnerPointer:Optimisic
    istead of
      unix.Malloc:Optimistic.
    This was resolved by making CheckerRegistry responsible for checker
    dependency handling, instead of checkers themselves.

* Checker options: (this patch included!)
    Same as the first item, but for checkers.

(+ minor fixes here and there, and everything else that is yet to come)

There were several issues regarding checker options, that non-checker
configurations didn't suffer from: checker plugins are loaded runtime, and they
could add new checkers and new options, meaning that unlike for non-checker
configurations, we can't collect every checker option purely by generating code.
Also, as seen from the "Checker Naming Bug" issue raised above, they are very
rarely used in practice, and all sorts of skeletons fell out of the closet while
working on this project.

They were extremely problematic for users as well, purely because of how long
they were. Consider the following monster of a checker option:

  alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=false

While we were able to verify whether the checker itself (the part before the
colon) existed, any errors past that point were unreported, easily resulting
in 7+ hours of analyses going to waste.

This patch, similarly to how dependencies were reimplemented, uses TableGen to
register checker options into Checkers.td, so that Checkers.inc now contains
entries for both checker and package options. Using the preprocessor,
Checkers.inc is converted into code in CheckerRegistry, adding every builtin
(checkers and packages that have an entry in the Checkers.td file) checker and
package option to the registry. The new addPackageOption and addCheckerOption
functions expose the same functionality to statically-linked non-builtin and
plugin checkers and packages as well.

Emitting errors for incorrect user input, being able to list these options, and
some other functionalies will land in later patches.

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

llvm-svn: 358752
2019-04-19 12:32:10 +00:00
Kristof Umann cd3f147439 [analyzer] Fix an assertion failure if plugins added dependencies
Ideally, there is no reason behind not being able to depend on checkers that
come from a different plugin (or on builtin checkers) -- however, this is only
possible if all checkers are added to the registry before resolving checker
dependencies. Since I used a binary search in my addDependency method, this also
resulted in an assertion failure (due to CheckerRegistry::Checkers not being
sorted), since the function used by plugins to register their checkers
(clang_registerCheckers) calls addDependency.

This patch resolves this issue by only noting which dependencies have to
established when addDependency is called, and resolves them at a later stage
when no more checkers are added to the registry, by which point
CheckerRegistry::Checkers is already sorted.

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

llvm-svn: 358750
2019-04-19 11:01:35 +00:00
Bjorn Pettersson 18b0442560 [LibTooling] Fix -Wsign-compare after r358697
llvm-svn: 358745
2019-04-19 09:10:42 +00:00
Richard Smith 96451e3a2c Fix overly-long line after r358731.
llvm-svn: 358733
2019-04-19 02:46:50 +00:00
Ali Tamur b6a8a6caa8 Fix typo in function name [NFC]
llvm-svn: 358731
2019-04-19 02:15:57 +00:00
Fangrui Song 9206335e9d [analyzer] Fix -Wunused-local-typedef after rC358695
llvm-svn: 358729
2019-04-19 01:54:36 +00:00
Ali Tamur 5377748d54 Add header guard to Reusables.h [NFC]
llvm-svn: 358724
2019-04-19 00:42:54 +00:00
Artem Dergachev 9b02a9b401 [analyzer] Make default bindings to variables actually work.
Default RegionStore bindings represent values that can be obtained by loading
from anywhere within the region, not just the specific offset within the region
that they are said to be bound to. For example, default-binding a character \0
to an int (eg., via memset()) means that the whole int is 0, not just
that its lower byte is 0.

Even though memset and bzero were modeled this way, it didn't work correctly
when applied to simple variables. Eg., in

  int x;
  memset(x, 0, sizeof(x));

we did produce a default binding, but were unable to read it later, and 'x'
was perceived as an uninitialized variable even after memset.

At the same time, if we replace 'x' with a variable of a structure or array
type, accessing fields or elements of such variable was working correctly,
which was enough for most cases. So this was only a problem for variables of
simple integer/enumeration/floating-point/pointer types.

Fix loading default bindings from RegionStore for regions of simple variables.

Add a unit test to document the API contract as well.

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

llvm-svn: 358722
2019-04-18 23:35:56 +00:00
Artem Dergachev 7cc87be4bb [analyzer] NFC: Make reusable unittest mocks reusable.
Put them in a header for other Analyzer unittests to include.

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

llvm-svn: 358720
2019-04-18 23:24:50 +00:00
Artem Dergachev 6b71e27c94 [analyzer] NFC: MoveChecker: Refactor tests to use -verify=prefix.
This -verify=prefix feature is quite underrated.

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

llvm-svn: 358719
2019-04-18 23:17:58 +00:00
Richard Smith a5bbbfef15 [c++2a] Add semantic support for private module fragments.
llvm-svn: 358713
2019-04-18 21:12:54 +00:00
Gheorghe-Teodor Bercea e94e0eb0c4 [OpenMP][NFC] Fix requires target test.
Summary:
Fix requires target test.


Reviewers: ABataev

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 358711
2019-04-18 20:34:43 +00:00
Owen Pan fb73b79a14 [clang-format] Fix incorrect formatting of keyword macro definition
See PR39719

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

llvm-svn: 358710
2019-04-18 20:17:08 +00:00