Commit Graph

78387 Commits

Author SHA1 Message Date
Chris Bieneman a971003e46 Revert Refactor constant evaluation of typeid(T) to track a symbolic type_info object rather than tracking the originating expression.
This reverts r360974 (git commit 7ee4307bd4)

llvm-svn: 360988
2019-05-17 05:46:03 +00:00
Chris Bieneman a5a4124c49 Revert [c++20] P1327R1: Support for typeid applied to objects of polymorphic class type in constant evaluation.
This reverts r360977 (git commit f51dc8d2f9)

llvm-svn: 360987
2019-05-17 05:45:57 +00:00
Chris Bieneman 876e39937e Re-land: Add Clang shared library with C++ exports
Summary:
This patch adds a libClang_shared library on *nix systems which exports the entire C++ API. In order to support this on Windows we should really refactor llvm-shlib and share code between the two.

This also uses a slightly different method for generating the shared library, which I should back-port to llvm-shlib. Instead of linking the static archives and passing linker flags to force loading the whole libraries, this patch creates object libraries for every library (which has no cost in the build system), and link the object libraries.

llvm-svn: 360985
2019-05-17 04:20:01 +00:00
Ben Dunbobbin 1d16515fb4 [ELF] Implement Dependent Libraries Feature
This patch implements a limited form of autolinking primarily designed to allow
either the --dependent-library compiler option, or "comment lib" pragmas (
https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=vs-2017) in
C/C++ e.g. #pragma comment(lib, "foo"), to cause an ELF linker to automatically
add the specified library to the link when processing the input file generated
by the compiler.

Currently this extension is unique to LLVM and LLD. However, care has been taken
to design this feature so that it could be supported by other ELF linkers.

The design goals were to provide:

- A simple linking model for developers to reason about.
- The ability to to override autolinking from the linker command line.
- Source code compatibility, where possible, with "comment lib" pragmas in other
  environments (MSVC in particular).

Dependent library support is implemented differently for ELF platforms than on
the other platforms. Primarily this difference is that on ELF we pass the
dependent library specifiers directly to the linker without manipulating them.
This is in contrast to other platforms where they are mapped to a specific
linker option by the compiler. This difference is a result of the greater
variety of ELF linkers and the fact that ELF linkers tend to handle libraries in
a more complicated fashion than on other platforms. This forces us to defer
handling the specifiers to the linker.

In order to achieve a level of source code compatibility with other platforms
we have restricted this feature to work with libraries that meet the following
"reasonable" requirements:

1. There are no competing defined symbols in a given set of libraries, or
   if they exist, the program owner doesn't care which is linked to their
   program.
2. There may be circular dependencies between libraries.

The binary representation is a mergeable string section (SHF_MERGE,
SHF_STRINGS), called .deplibs, with custom type SHT_LLVM_DEPENDENT_LIBRARIES
(0x6fff4c04). The compiler forms this section by concatenating the arguments of
the "comment lib" pragmas and --dependent-library options in the order they are
encountered. Partial (-r, -Ur) links are handled by concatenating .deplibs
sections with the normal mergeable string section rules. As an example, #pragma
comment(lib, "foo") would result in:

.section ".deplibs","MS",@llvm_dependent_libraries,1
         .asciz "foo"

For LTO, equivalent information to the contents of a the .deplibs section can be
retrieved by the LLD for bitcode input files.

LLD processes the dependent library specifiers in the following way:

1. Dependent libraries which are found from the specifiers in .deplibs sections
   of relocatable object files are added when the linker decides to include that
   file (which could itself be in a library) in the link. Dependent libraries
   behave as if they were appended to the command line after all other options. As
   a consequence the set of dependent libraries are searched last to resolve
   symbols.
2. It is an error if a file cannot be found for a given specifier.
3. Any command line options in effect at the end of the command line parsing apply
   to the dependent libraries, e.g. --whole-archive.
4. The linker tries to add a library or relocatable object file from each of the
   strings in a .deplibs section by; first, handling the string as if it was
   specified on the command line; second, by looking for the string in each of the
   library search paths in turn; third, by looking for a lib<string>.a or
   lib<string>.so (depending on the current mode of the linker) in each of the
   library search paths.
5. A new command line option --no-dependent-libraries tells LLD to ignore the
   dependent libraries.

Rationale for the above points:

1. Adding the dependent libraries last makes the process simple to understand
   from a developers perspective. All linkers are able to implement this scheme.
2. Error-ing for libraries that are not found seems like better behavior than
   failing the link during symbol resolution.
3. It seems useful for the user to be able to apply command line options which
   will affect all of the dependent libraries. There is a potential problem of
   surprise for developers, who might not realize that these options would apply
   to these "invisible" input files; however, despite the potential for surprise,
   this is easy for developers to reason about and gives developers the control
   that they may require.
4. This algorithm takes into account all of the different ways that ELF linkers
   find input files. The different search methods are tried by the linker in most
   obvious to least obvious order.
5. I considered adding finer grained control over which dependent libraries were
   ignored (e.g. MSVC has /nodefaultlib:<library>); however, I concluded that this
   is not necessary: if finer control is required developers can fall back to using
   the command line directly.

RFC thread: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html.

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

llvm-svn: 360984
2019-05-17 03:44:15 +00:00
Richard Smith f51dc8d2f9 [c++20] P1327R1: Support for typeid applied to objects of polymorphic
class type in constant evaluation.

llvm-svn: 360977
2019-05-17 02:16:45 +00:00
Richard Smith 7ee4307bd4 Refactor constant evaluation of typeid(T) to track a symbolic type_info
object rather than tracking the originating expression.

This is groundwork for supporting polymorphic typeid expressions. (Note
that this somewhat regresses our support for DR1968, but it turns out
that that never actually worked anyway, at least in non-trivial cases.)

llvm-svn: 360974
2019-05-17 01:46:05 +00:00
Nico Weber 457d7caac8 Revert r360946 "Add Clang shared library with C++ exports"
It breaks LLVM_ENABLE_PIC=OFF builds, and it's not clear
if the object library approach doesn't impact the normal
clang binary.

llvm-svn: 360973
2019-05-17 01:42:37 +00:00
Eric Fiselier 06b6a2ef41 Remove unneeded alignment spec from builtin_FUNCTION.cpp test
llvm-svn: 360951
2019-05-16 23:07:45 +00:00
Eric Fiselier fe331a67a5 Fix failing source location test on Windows
llvm-svn: 360947
2019-05-16 22:21:42 +00:00
Chris Bieneman 10fba12e50 Add Clang shared library with C++ exports
Summary:
This patch adds a libClang_shared library on *nix systems which exports the entire C++ API. In order to support this on Windows we should really refactor llvm-shlib and share code between the two.

This also uses a slightly different method for generating the shared library, which I should back-port to llvm-shlib. Instead of linking the static archives and passing linker flags to force loading the whole libraries, this patch creates object libraries for every library (which has no cost in the build system), and link the object libraries.

Reviewers: tstellar, winksaville

Subscribers: mgorny, cfe-commits

Tags: #clang

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

llvm-svn: 360946
2019-05-16 22:06:07 +00:00
Eric Fiselier b42c73de3d Fix PCC test failures for source location builtins
llvm-svn: 360943
2019-05-16 21:51:39 +00:00
David L. Jones 9adabefdce [clang/test] Add missing dependency on llvm-cxxfilt.
This tool is needed by clang/test/CodeGen/Output/ppc-mmintrin.c.

llvm-svn: 360939
2019-05-16 21:13:59 +00:00
Kristina Brooks bd97484241 Reland "[Clang][PP] Add the __FILE_NAME__ builtin macro"
This relands commit rL360833 which caused issues on Win32
bots due to path handling/normalization differences. Now
this uses `sys::path::filename` which should handle
additional edge cases on Win32.

Original commit:

"[Clang][PP] Add the __FILE_NAME__ builtin macro" 

This patch adds the __FILE_NAME__ macro that expands to the
last component of the path, similar to __FILE__ except with
a guarantee that only the last path component (without the
separator) will be rendered.

I intend to follow through with discussion of this with WG14
as a potential inclusion in the C standard or failing that,
try to discuss this with GCC developers since this extension
is desired by GCC and Clang users/developers alike.

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

llvm-svn: 360938
2019-05-16 21:13:49 +00:00
Eric Fiselier 708afb56c1 Implement __builtin_LINE() et. al. to support source location capture.
Summary:
This patch implements the source location builtins `__builtin_LINE(), `__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These builtins are needed to implement [`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation).

With the exception of `__builtin_COLUMN`, GCC also implements these builtins, and Clangs behavior is intended to match as closely as possible. 

Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong

Reviewed By: rsmith

Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, hfinkel, cfe-commits

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

llvm-svn: 360937
2019-05-16 21:04:15 +00:00
Craig Topper 20040db9a6 [X86] Stop implicitly enabling avx512vl when avx512bf16 is enabled.
Previously we were doing this so that the 256 bit selectw builtin could be used in the implementation of the 512->256 bit conversion intrinsic.

After this commit we now use a masked convert builtin that will emit the intrinsic call and the 256-bit select from custom code in CGBuiltin. Then the header only needs to call that one intrinsic.

llvm-svn: 360924
2019-05-16 18:28:17 +00:00
Stephen Kelly 60bf24aa9d Update comments on enums
llvm-svn: 360922
2019-05-16 18:02:36 +00:00
Stephen Kelly d147cea3b9 Move TraversalKind enum to ast_type_traits
Summary:
Make it usable outside of ASTMatchFinder.  This will make it possible to
use this enum to control whether certain implicit nodes are skipped
while AST dumping for example.

Reviewers: klimek, aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 360920
2019-05-16 17:57:38 +00:00
Craig Topper 58964566e0 [X86] Update doxygen comments for AVX512BF16 to not refer to masks as 'immediates'. Refer to parameter names instead of 'src', 'src1', 'src2'. NFC
llvm-svn: 360918
2019-05-16 17:34:35 +00:00
Ilya Biryukov 600ec01b7e [CodeComplete] Complete enumerators when preferred type is an enum
Reviewers: kadircet

Reviewed By: kadircet

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 360912
2019-05-16 16:06:57 +00:00
Kristof Umann daa91492dd [analyzer] Add a test plugin for checker option handling
Differential Revision: https://reviews.llvm.org/D59465

llvm-svn: 360910
2019-05-16 15:55:07 +00:00
Alexandre Ganea 738e42efb3 ftime-trace as a CoreOption
Differential Revision: https://reviews.llvm.org/D61945

llvm-svn: 360907
2019-05-16 15:14:01 +00:00
Xing Xue 6dc363ecc1 Add AIX Version Macros
Summary:
- This patch checks the AIX version and defines the appropriate macros.
- Follow up to a comment on D59048.

Author: andusy

Reviewers: hubert.reinterpretcast, jasonliu, sfertile, xingxue

Reviewed By: sfertile

Subscribers: jsji, cfe-commits

Tags: #clang

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

llvm-svn: 360900
2019-05-16 14:22:37 +00:00
Adhemerval Zanella 0d9dcd7bf0 [clang] Handle lround/llround builtins
As for other floating-point rounding builtins that can be optimized
when build with -fno-math-errno, this patch adds support for lround
and llround.  It currently only optimize for AArch64 backend.

Reviewed By: efriedma

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

llvm-svn: 360896
2019-05-16 13:43:25 +00:00
Fangrui Song e183340c29 Recommit [Object] Change object::SectionRef::getContents() to return Expected<StringRef>
r360876 didn't fix 2 call sites in clang.

Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.

Follow-up of D61781.

llvm-svn: 360892
2019-05-16 13:24:04 +00:00
Kristof Umann 1b93a24c29 Reland "[analyzer] Add an example plugin for checker dependency handling"
Buildbots complained that they couldn't find the newly added plugins.

The solution was to move the check-clang cmake target closer to the bottom of
the file, after the new dependencies are added.

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

llvm-svn: 360891
2019-05-16 13:22:04 +00:00
Serge Guelton ab15546983 Fix isInSystemMacro in presence of macro and pasted token
When a warning is raised from the expansion of a system macro that
involves pasted token, there was still situations were they were not
skipped, as showcased by this issue:
https://bugzilla.redhat.com/show_bug.cgi?id=1472437

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

llvm-svn: 360885
2019-05-16 12:40:00 +00:00
Karl-Johan Karlsson 0e525a4d6b [builtin] Fixed definitions of builtins that rely on the int/long long type is 32/64 bits
Summary:
The definition of the builtins __builtin_bswap32, __builtin_bitreverse32, __builtin_rotateleft32 and __builtin_rotateright32 rely on that the int type is 32 bits wide on the target.
The defintions of the builtins __builtin_bswap64, __builtin_bitreverse64, __builtin_rotateleft64, and __builtin_rotateright64 rely on that the long long type is 64 bits wide.

On targets where this is not the case (e.g. AVR) clang will generate faulty code (wrong llvm assembler intrinsics).

This patch add support for using 'Z' (the int32_t type) in Bultins.def. The builtins above are changed to be based on the int32_t type instead of the int type, and the int64_t type instead of the long long type.

The AVR backend (experimental) have a native int type that is only 16 bits wide. The supplied testcase will therefore fail if running the testcase on trunk as clang will convert e.g. __builtin_bitreverse32 into llvm.bitreverse.i16 on AVR.

Reviewers: dylanmckay, spatel, rsmith, efriedma

Reviewed By: efriedma

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

llvm-svn: 360863
2019-05-16 07:18:02 +00:00
Kristina Brooks 9d65624bf6 Revert r360833 until I can work out the issue with Win32 bots
This reverts "r360833: [Clang][PP] Add the __FILE_NAME__ builtin macro."

The tests are failing on Windows bots, reverting the patchset until I can
work out why.

llvm-svn: 360842
2019-05-16 03:30:08 +00:00
Kristina Brooks 69e927662d Fix assumption about Win32 paths in r360833
Attempt to fix Windows buildbots due to differences in
path handling (caused by r360833).

llvm-svn: 360839
2019-05-16 02:46:12 +00:00
Richard Smith 3d09131aee Fix regression in r360311 caused by reversed bool arguments.
llvm-svn: 360837
2019-05-16 02:06:16 +00:00
Kristina Brooks 3acc1d1be3 [Clang][PP] Add the __FILE_NAME__ builtin macro.
This patch adds the `__FILE_NAME__` macro that expands to the
last component of the path, similar to `__FILE__` except with
a guarantee that only the last path component (without the
separator) will be rendered.

I intend to follow through with discussion of this with WG14
as a potential inclusion in the C standard or failing that,
try to discuss this with GCC developers since this extension
is desired by GCC and Clang users/developers alike.

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

llvm-svn: 360833
2019-05-16 00:52:41 +00:00
Richard Smith beda951d78 Make tentative parsing to detect template-argument-lists less aggressive
(and less wrong).

It's not correct to assume that X<something, Type> is always a
template-id; there are a few cases where the comma takes us into a
non-expression syntactic context in which 'Type' might be permissible.
Stop doing that.

This slightly regresses our error recovery on the cases where the
construct is intended to be a template-id. We typically do still manage
to diagnose a missing 'template' keyword, but we realize this too late
to properly recover from the error.

This fixes a regression introduced by r360308.

llvm-svn: 360827
2019-05-15 23:36:14 +00:00
David Bolvansky eef2060bd9 [clang-format] Fixed self assignment
Reviewers: MyDeveloperDay, RKSimon

Reviewed By: MyDeveloperDay

Subscribers: RKSimon, cfe-commits

Tags: #clang

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

llvm-svn: 360810
2019-05-15 20:29:33 +00:00
Gheorghe-Teodor Bercea 9392bd6987 [OpenMP][Bugfix] Move double and float versions of abs under c++ macro
Summary:
This is a fix for the reported bug:

[[ https://bugs.llvm.org/show_bug.cgi?id=41861 | 41861 ]]

abs functions need to be moved under the c++ macro to avoid conflicts with included headers.

Reviewers: tra, jdoerfert, hfinkel, ABataev, caomhin

Reviewed By: jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

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

llvm-svn: 360809
2019-05-15 20:28:23 +00:00
Richard Smith 7bd54ab586 [c++20] For P1327R1: support dynamic_cast in constant expression
evaluation.

llvm-svn: 360806
2019-05-15 20:22:21 +00:00
Kristof Umann 750a45fe25 Revert "[analyzer] Add a test for plugins using checker dependencies"
Buildbots don't seem to find the new plugin.

llvm-svn: 360805
2019-05-15 20:19:51 +00:00
Gheorghe-Teodor Bercea 7641f310d7 [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions
Summary: In OpenMP device offloading we must ensure that unde C++ 17, the inclusion of cstdlib will works correctly.

Reviewers: ABataev, tra, jdoerfert, hfinkel, caomhin

Reviewed By: jdoerfert

Subscribers: Hahnfeld, guansong, cfe-commits

Tags: #clang

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

llvm-svn: 360804
2019-05-15 20:18:21 +00:00
Erik Pilkington f6c645f9fd [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary
Any of these methods can be overridden, so we need to invoke these functions.

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

llvm-svn: 360802
2019-05-15 20:15:01 +00:00
Kristof Umann 47241aaff7 [analyzer] Add a test for plugins using checker dependencies
Also, I moved the existing analyzer plugin to test/ as well, in order not to
give the illusion that the analyzer supports plugins -- it's capable of handling
them, but does not _support_ them.

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

llvm-svn: 360799
2019-05-15 19:47:26 +00:00
Artem Dergachev 07c7257cdc [analyzer] RetainCount: Fix os_returns_retained_on_zero with weird return types.
The checker was crashing when it was trying to assume a structure
to be null or non-null so that to evaluate the effect of the annotation.

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

llvm-svn: 360790
2019-05-15 18:41:32 +00:00
Kevin Petit ad08ea284f Test commit
Remove stray space.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
llvm-svn: 360783
2019-05-15 16:39:28 +00:00
Gabor Marton 5ac6d49065 [ASTImporter] Use llvm::Expected and Error in the importer API
Summary:
This is the final phase of the refactoring towards using llvm::Expected
and llvm::Error in the ASTImporter API.
This involves the following:
- remove old Import functions which returned with a pointer,
- use the Import_New functions (which return with Err or Expected) everywhere
  and handle their return value
- rename Import_New functions to Import
This affects both Clang and LLDB.

Reviewers: shafik, teemperor, aprantl, a_sidorin, balazske, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits, lldb-commits

Tags: #clang, #lldb

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

llvm-svn: 360760
2019-05-15 10:29:48 +00:00
Artem Dergachev e41ae14581 [analyzer] MIGChecker: Fix redundant semicolon.
llvm-svn: 360739
2019-05-15 01:36:41 +00:00
Artem Dergachev 70b654fa9b [analyzer] MIGChecker: Add support for os_ref_retain().
Suppress MIG checker false positives that occur when the programmer increments
the reference count before calling a MIG destructor, and the MIG destructor
literally boils down to decrementing the reference count.

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

llvm-svn: 360737
2019-05-15 01:19:19 +00:00
Leonard Chan 048a97bca4 Fix bots by adding target triple to test.
llvm-svn: 360720
2019-05-14 22:37:34 +00:00
Leonard Chan 0cdd3b1d81 [NewPM] Port HWASan and Kernel HWASan
Port hardware assisted address sanitizer to new PM following the same guidelines as msan and tsan.

Changes:
- Separate HWAddressSanitizer into a pass class and a sanitizer class.
- Create new PM wrapper pass for the sanitizer class.
- Use the getOrINsert pattern for some module level initialization declarations.
- Also enable kernel-kwasan in new PM
- Update llvm tests and add clang test.

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

llvm-svn: 360707
2019-05-14 21:17:21 +00:00
Reid Kleckner dc2f5f9ff8 Fix ASTMerge/namespace/test.cpp after r360701
llvm-svn: 360705
2019-05-14 20:01:03 +00:00
Eric Christopher 030b17db66 Temporarily revert "Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)"
This affects users of older (pre 2.26) binutils in such a way that they can't necessarily
work around it as it doesn't support the compress option on the command line. Reverting
to unblock them and we can revisit whether to make this change now or fix how we want
to express the option.

This reverts commit bdb21337e6e1732c9895966449c33c408336d295/r360403.

llvm-svn: 360703
2019-05-14 19:40:42 +00:00
Reid Kleckner 2423b7dfd3 Update ASTMerge FileCheck test expectations
I belive many of these diagnostics changed from errors to warnings in
r357394. I've simply mechanically updated the tests, but whoever owns
this code should probably audit for unintented behavior changes. I
wasn't able to find a flag to make these warnings errors again.

llvm-svn: 360701
2019-05-14 19:02:39 +00:00
Reid Kleckner 0333dd9563 Restore test files accidentally deleted in r354839
I think there must be a bug in git-llvm causing parent directories to be
deleted when the diff deletes files in a subdirectory. Perhaps it is
Windows-only.

There has been a behavior change, so some of these tests now fail. I
have marked them XFAIL and will fix them in a follow-up to separate the
changes.

llvm-svn: 360699
2019-05-14 18:51:07 +00:00