Commit Graph

78040 Commits

Author SHA1 Message Date
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
Gheorghe-Teodor Bercea 411a62403f [OpenMP] Add checks for requires and target directives.
Summary: The requires directive containing target related clauses must appear before any target region in the compilation unit.

Reviewers: ABataev, AlexEichenberger, caomhin

Reviewed By: ABataev

Subscribers: guansong, jfb, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 358709
2019-04-18 19:53:43 +00:00
Yitzhak Mandelbaum f1f0b5f791 [LibTooling] Fix build breakage from commit 7b7ce6683ee.
On configurations with -Werror,-Wmissing-field-initializers, the commit does not compile. This commit fixes the offending line.

Original Differential Revision: https://reviews.llvm.org/D60408

llvm-svn: 358705
2019-04-18 19:19:01 +00:00
Yitzhak Mandelbaum fa1552e8c9 [LibTooling] Extend Transformer to support multiple simultaneous changes.
Summary: This revision allows users to specify independent changes to multiple (related) sections of the input.  Previously, only a single section of input could be selected for replacement.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: jfb, cfe-commits

Tags: #clang

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

llvm-svn: 358697
2019-04-18 17:52:24 +00:00
Sam McCall 3a75330f57 [CodeComplete] Remove obsolete isOutputBinary().
Summary:
It's never set to true. Its only effect would be to set stdout to binary mode.
Hopefully we have better ways of doing this by now :-)

Reviewers: hokein

Subscribers: jkorous, arphaman, kadircet, llvm-commits

Tags: #llvm

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

llvm-svn: 358696
2019-04-18 17:35:55 +00:00
Kristof Umann 640f7b5875 [analyzer][NFC] Prefer binary searches in CheckerRegistry
Differential Revision: https://reviews.llvm.org/D59459

llvm-svn: 358695
2019-04-18 17:34:45 +00:00
Kristof Umann a57d4ea33f [analyzer][NFC] Clang-format CheckerRegistry
Differential Revision: https://reviews.llvm.org/D59458

llvm-svn: 358694
2019-04-18 17:32:51 +00:00
Yitzhak Mandelbaum e955f8bac4 [LibTooling] Add Stencil library for format-string style codegen.
Summary:
This file defines the *Stencil* abstraction: a code-generating object, parameterized by named references to (bound) AST nodes.  Given a match result, a stencil can be evaluated to a string of source code.

A stencil is similar in spirit to a format string: it is composed of a series of raw text strings, references to nodes (the parameters) and helper code-generation operations.

See thread on cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling" for background.

Reviewers: sbenza

Reviewed By: sbenza

Subscribers: ilya-biryukov, mgorny, jfb, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 358691
2019-04-18 17:23:01 +00:00
Krasimir Georgiev bda8482aba [clang-format] Fix indent of trailing raw string param after newline
Summary:
Currently clang-format uses ContinuationIndent to indent the contents of a raw
string literal that is the last parameter of the function call. This is to
achieve formatting similar to trailing:
```
f(1, 2, R"pb(
    x: y)pb");
```
However this had the unfortunate consequence of producing format like this:
```
fffffff(1, 2,
        R"pb(
    a: b
        )pb");
```

This patch makes clang-format consider indenting a trailing raw string param
after a newline based off the start of the format delimiter, producing:
```
fffffff(1, 2,
        R"pb(
          a: b
        )pb");
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 358689
2019-04-18 17:14:05 +00:00
Bruno Ricci 9f1a40c24f [Sema][NFC] Mark DR1563 as done (List-initialization and overloaded function disambiguation)
It has been supported since at least clang 3.1 so just mark it as done.

llvm-svn: 358679
2019-04-18 15:45:08 +00:00
Bruno Ricci 0e37bebaee [Sema][NFC] Mark DR705 (Suppressing argument-dependent lookup via parentheses) as done
It was supported since at least clang 3 so just mark it as done.

llvm-svn: 358678
2019-04-18 15:34:03 +00:00
Kristof Umann b9bc7ec304 [analyzer][NFC] Use capital variable names, move methods out-of-line, rename some in CheckerRegistry
There are barely any lines I haven't changed in these files, so I think I could
might as well leave it in an LLVM coding style conforming state. I also renamed
2 functions and moved addDependency out of line to ease on followup patches.

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

llvm-svn: 358676
2019-04-18 15:19:16 +00:00
Bruno Ricci 2751b69dd3 [Serialization] Stable serialization order for OpenCLTypeExtMap and OpenCLDeclExtMap
Sort the elements of Sema::OpenCLTypeExtMap and Sema::OpenCLDeclExtMap
by TypeIDs and DeclIDs to guarantee a stable serialization order.

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

Reviewed By: Anastasia

Reviewers: Anastasia, lebedev.ri
llvm-svn: 358674
2019-04-18 15:13:27 +00:00
Haojian Wu 8bbbd31cdd [clang-tidy] Address post-commit comments
Summary:
Also add a test to verify clang-tidy only apply the first alternative
fix.

Reviewers: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 358666
2019-04-18 14:18:14 +00:00
Kadir Cetinkaya b8f82ca1b2 [clang][CIndex] Use llvm::set_thread_priority
Reviewers: jkorous, gribozavr

Subscribers: dexonsmith, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 358665
2019-04-18 13:49:20 +00:00
Martin Storsjo 4cfc8d6afc [MSVC] Use the correct casing of HostX64/HostX86
If accessing the MSVC installation root directly on a case sensitive
filesystem, these details matter.

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

llvm-svn: 358662
2019-04-18 13:27:31 +00:00
Fangrui Song 0b826f193f [Sema] Delete unused parameters/variables
llvm-svn: 358661
2019-04-18 12:35:02 +00:00
Evgeny Mankov 88aa3d7237 [CUDA][Windows] Restrict long double device functions declarations to Windows
As agreed in D60220, make long double declarations unobservable on non-windows platforms.

[Testing]
{Windows 10, Ubuntu 16.04.5}/{Visual C++ 2017 15.9.11 & 2019 16.0.1, gcc+ 5.4.0}/CUDA {8.0, 9.0, 9.1, 9.2, 10.0, 10.1}

Reviewed by: Artem Belevich

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

llvm-svn: 358654
2019-04-18 10:08:55 +00:00
Richard Smith b7bdb8cf33 Split out modules-specific declaration handling from SemaDecl.cpp into a
new SemaModule.cpp.

llvm-svn: 358633
2019-04-18 00:57:02 +00:00
Richard Smith 77e53cbe84 Add '#pragma clang __debug module_map module.name' to dump the module
map being used for the module 'module.name'.

llvm-svn: 358632
2019-04-18 00:57:01 +00:00