Commit Graph

59948 Commits

Author SHA1 Message Date
Mikhail Maltsev 8cc842a950 [clang][Sema] Use enumerator instead of hard-coded constant
Sema::DiagnoseSwiftName uses the constant 12 instead of the
corresponding enumerator ExpectedFunctionWithProtoType. This is
fragile and will fail if a new value gets added in the middle of the
enum.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D88164
2020-09-24 10:24:22 +01:00
Amy Kwan 6b136b19cb [Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.
This patch implements custom codegen for the vec_replace_elt and
vec_replace_unaligned builtins.

These builtins map to the @llvm.ppc.altivec.vinsw and @llvm.ppc.altivec.vinsd
intrinsics depending on the arguments. The main motivation for doing custom
codegen for these intrinsics is because there are float and double versions of
the builtin. Normally, the converting the float to an integer would be done via
fptoui in the IR. This is incorrect as fptoui truncates the value and we must
ensure the value is not truncated. Therefore, we provide custom codegen to utilize
bitcast instead as bitcasts do not truncate.

Differential Revision: https://reviews.llvm.org/D83500
2020-09-23 22:55:25 -05:00
Craig Topper d9717d8ee7 [X86] Add a memory clobber to the bittest intrinsic inline asm. Get default clobbers from the target
I believe the inline asm emitted here should have a memory clobber since it writes to memory.

It was also missing the dirflag clobber that we use by default along with flags and fpsr. To avoid missing defaults in the future, get the default list from the target

Differential Revision: https://reviews.llvm.org/D88121
2020-09-23 14:54:39 -07:00
Yaxun (Sam) Liu 8e780a1653 Recommit [NFC] Refactor DiagnosticBuilder and PartialDiagnostic
This recommits 829d14ee0a.

The patch was reverted due to a regression in some CUDA app
which was thought to be caused by this patch. However, investigation
showed that the regression was due to some other issues, therefore
recommit this patch.
2020-09-23 16:55:00 -04:00
Amy Kwan 2e7117f847 [PowerPC] Implement the 128-bit vec_[all|any]_[eq | ne | lt | gt | le | ge] builtins in Clang/LLVM
This patch implements the vec_[all|any]_[eq | ne | lt | gt | le | ge] builtins for vector signed/unsigned __int128.

Differential Revision: https://reviews.llvm.org/D87910
2020-09-23 16:49:40 -04:00
Albion Fung 88cdbeab41 [PowerPC] Implement Vector signed/unsigned __int128 overloads for the comparison builtins
This patch implements Vector signed/unsigned __int128 overloads for the comparison builtins.

Differential Revision: https://reviews.llvm.org/D87804
2020-09-23 16:49:40 -04:00
Aaron Ballman af1d3e6559 Allow init_priority values <= 100 and > 65535 within system headers.
This also adds some bare-bones documentation for the attribute rather
than leaving it undocumented.
2020-09-23 15:26:50 -04:00
Stanislav Mekhanoshin 59691dc874 [AMDGPU] Make ds fp atomics overloadable
Differential Revision: https://reviews.llvm.org/D87947
2020-09-23 11:39:50 -07:00
Sriraman Tallam 7d0bbe4090 Re-apply https://reviews.llvm.org/D87921, was reverted to triage a PPC bot failure.
D87921 was reverted in commit b89059a313
as it was causing an unknown llvm PPC bot failure.  Reapplying the patch
after confirming that this is not responsible. Build bot failure:
https://reviews.llvm.org/D87921#2286644  which caused the revert.

The wrong placement of add pass with optimizations led to
-funique-internal-linkage-names being disabled.

Fixed the placement of the MPM.addpass for UniqueInternalLinkageNames to make it
work correctly with -O2 and new pass manager. Updated the tests to explicitly
check O0 and O1.

Differential Revision: https://reviews.llvm.org/D87921
2020-09-23 10:28:40 -07:00
Dmitry Antipov d882ca7f1f [Driver] Check whether Gentoo-specific configuration directory exists
Check whether /etc/env.d/gcc exists before trying to read from any
file from there. This saves a few OS calls on a non-Gentoo system.

Differential Revision: https://reviews.llvm.org/D87143
2020-09-23 20:25:23 +03:00
Aaron Ballman 819ff6b945 Improve dynamic AST matching diagnostics for conversion errors
Currently, when marshaling a dynamic AST matchers, we check for the type
and value validity of matcher arguments at the same time for some matchers.
For instance, when marshaling hasAttr("foo"), the argument is first type
checked to ensure it's a string and then checked to see if that string can
locate an attribute with that name. Similar happens for other enumeration
conversions like cast kinds or unary operator kinds. If the type is
correct but the value cannot be looked up, we make a best-effort attempt
to find a nearby name that the user might have meant, but if one cannot
be found, we throw our hands up and claim the types don't match.

This has an unfortunate behavior that when the user enters something of
the correct type but a best guess cannot be located, you get confusing
error messages like:
Incorrect type for arg 1. (Expected = string) != (Actual = String).

This patch splits the argument check into two parts: if the types don't
match, give a type diagnostic. If the type matches but the value cannot
be converted, give a best guess diagnostic or a value could not be
located diagnostic. This addresses PR47057.
2020-09-23 12:13:36 -04:00
Yaxun (Sam) Liu e90343ada3 Fix regressioin in test dwp-separate-debug-file.cpp 2020-09-23 11:49:59 -04:00
Yaxun (Sam) Liu e6d50b4f22 recommit [HIP] Fix -gsplit-dwarf option
recommit e50465ecef with fix for
regression in lldb tests.

Two issues:

1. the directory part of original .dwo file was dropped
2. if the stem of the .dwo file contains '.', the last dot
and strings after that were removed

This recommit fixes those two issues.
2020-09-23 11:20:29 -04:00
Yaxun (Sam) Liu 301e23305d [CUDA][HIP] Fix static device var used by host code only
A static device variable may be accessed in host code through
cudaMemCpyFromSymbol etc. Currently clang does not
emit the static device variable if it is only referenced by
host code, which causes host code to fail at run time.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D88115
2020-09-23 08:18:19 -04:00
Gabor Marton 11d2e63ab0 [analyzer][StdLibraryFunctionsChecker] Separate the signature from the summaries
The signature should not be part of the summaries as many FIXME comments
suggests. By separating the signature, we open up the way to a generic
matching implementation which could be used later under the hoods of
CallDescriptionMap.

Differential Revision: https://reviews.llvm.org/D88100
2020-09-23 10:59:34 +02:00
Gabor Marton d63a945a13 [analyzer][StdLibraryFunctionsChecker] Fix getline/getdelim signatures
It is no longer needed to add summaries of 'getline' for different
possible underlying types of ssize_t. We can just simply lookup the
type.

Differential Revision: https://reviews.llvm.org/D88092
2020-09-23 10:48:14 +02:00
Albion Fung d7eb917a7c [PowerPC] Implementation of 128-bit Binary Vector Mod and Sign Extend builtins
This patch implements 128-bit Binary Vector Mod and Sign Extend builtins for PowerPC10.

Differential: https://reviews.llvm.org/D87394#inline-815858
2020-09-23 01:18:14 -05:00
Jan Korous 47e6851423 [Analyzer][WebKit] Use tri-state types for relevant predicates
Some of the predicates can't always be decided - for example when a type
definition isn't available. At the same time it's necessary to let
client code decide what to do about such cases - specifically we can't
just use true or false values as there are callees with
conflicting strategies how to handle this.

This is a speculative fix for PR47276.

Differential Revision: https://reviews.llvm.org/D88133
2020-09-22 21:57:24 -07:00
Leonard Chan 15d94a7d0f Revert "Canonicalize declaration pointers when forming APValues."
This reverts commit 905b9ca26c.

Reverting because this strips `weak` attributes off function
declarations, leading to the linker error we see at
https://ci.chromium.org/p/fuchsia/builders/ci/clang_toolchain.fuchsia-arm64-debug-subbuild/b8868932035091473008.

See https://reviews.llvm.org/rG905b9ca26c94 for reproducer details.
2020-09-22 17:40:53 -07:00
Mircea Trofin cf112382dd [ThinLTO] Option to bypass function importing.
This completes the circle, complementing -lto-embed-bitcode
(specifically, post-merge-pre-opt). Using -thinlto-assume-merged skips
function importing. The index file is still needed for the other data it
contains.

Differential Revision: https://reviews.llvm.org/D87949
2020-09-22 13:12:11 -07:00
Sriraman Tallam b89059a313 Revert "The wrong placement of add pass with optimizations led to -funique-internal-linkage-names being disabled."
This reverts commit 6950db36d3.
2020-09-22 12:32:43 -07:00
Haojian Wu 16ca711803 [clang] Fix a typo-correction crash
We leave a dangling TypoExpr when typo-correction is performed
successfully in `checkArgsForPlaceholders`, which leads a crash in the
later TypoCorrection.

This code was added in 1586782767,
and it didn't seem to have enough test coverage.
The fix is to remove this part, and no failuer tests.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D87815
2020-09-22 20:21:21 +02:00
Jan Korous 8a64689e26 [Analyzer][WebKit] UncountedLocalVarsChecker
Differential Review: https://reviews.llvm.org/D83259
2020-09-22 11:05:04 -07:00
Sam McCall 6257618256 [ASTMatchers] Avoid recursion in ancestor matching to save stack space.
A recent change increased the stack size of memoizedMatchesAncestorOfRecursively
leading to stack overflows on real code involving large fold expressions.
It's not totally unreasonable to choke on very deep ASTs, but as common
infrastructure it's be nice if ASTMatchFinder is more robust.
(It already uses data recursion for the regular "downward" traversal.)

Differential Revision: https://reviews.llvm.org/D86964
2020-09-22 19:43:41 +02:00
Amy Kwan 079757b551 [PowerPC] Implement Vector String Isolate Builtins in Clang/LLVM
This patch implements the vector string isolate (predicate and non-predicate
versions) builtins. The predicate builtins are custom selected within PPCISelDAGToDAG.

Differential Revision: https://reviews.llvm.org/D87671
2020-09-22 11:31:44 -05:00
Amy Kwan b3147058de [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in Clang/LLVM
This patch implements the 128-bit vector divide extended builtins in Clang/LLVM.
These builtins map to the vdivesq and vdiveuq instructions respectively.

Differential Revision: https://reviews.llvm.org/D87729
2020-09-22 11:31:44 -05:00
Saleem Abdulrasool 9bb5ecf1f7 Sema: introduce `__attribute__((__swift_name__))`
This introduces the new `swift_name` attribute that allows annotating
APIs with an alternate spelling for Swift.  This is used as part of the
importing mechanism to allow interfaces to be imported with a new name
into Swift.  It takes a parameter which is the Swift function name.
This parameter is validated to check if it matches the possible
transformed signature in Swift.

This is based on the work of the original changes in
8afaf3aad2

Differential Revision: https://reviews.llvm.org/D87534
Reviewed By: Aaron Ballman, Dmitri Gribenko
2020-09-22 15:32:23 +00:00
David Tenty e8fb4eba4f [AIX][clang][driver] Make sure crti[_64].o is linked in C++ mode
since crti is required for functional static initialization.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D87927
2020-09-22 09:55:06 -04:00
Abhina Sreeskantharajan 0fb97fd6a4 [SystemZ][z/OS] Set default wchar_t type for zOS
Set the default wchar_t type on z/OS, and unsigned as the default.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D87624
2020-09-22 08:03:03 -04:00
Eduardo Caldas 66bcb14312 [SyntaxTree][Synthesis] Fix: `deepCopy` -> `deepCopyExpandingMacros`.
There can be Macros that are tagged with `modifiable`. Thus verifying
`canModifyAllDescendants` is not sufficient to avoid macros when deep
copying.

We think the `TokenBuffer` could inform us whether a `Token` comes from
a macro. We'll look into that when we can surface this information
easily, for instance in unit tests for `ComputeReplacements`.

Differential Revision: https://reviews.llvm.org/D88034
2020-09-22 09:15:21 +00:00
Martin Storsjö 3fec6ddc27 Reapply: [clang-cl] Always interpret the LIB env var as separated with semicolons
When cross compiling with clang-cl, clang splits the INCLUDE env
variable around semicolons (clang/lib/Driver/ToolChains/MSVC.cpp,
MSVCToolChain::AddClangSystemIncludeArgs) and lld splits the
LIB variable similarly (lld/COFF/Driver.cpp,
LinkerDriver::addLibSearchPaths). Therefore, the consensus for
cross compilation with clang-cl and lld-link seems to be to use
semicolons, despite path lists normally being separated by colons
on unix and EnvPathSeparator being set to that.

Therefore, handle the LIB variable similarly in Clang, when
handling lib file arguments when driving linking via Clang.

This fixes commands like "clang-cl test.c -Fetest.exe kernel32.lib" in
a cross compilation setting. Normally, most users call (lld-)link
directly, but meson happens to use this command syntax for
has_function() tests.

Reapply: Change Program.h to define procid_t as ::pid_t. When included
in lldb/unittests/Host/NativeProcessProtocolTest.cpp, it is included
after an lldb namespace containing an lldb::pid_t typedef, followed
later by a "using namespace lldb;". Previously, Program.h wasn't
included in this translation unit, but now it ends up included
transitively from Process.h.

Differential Revision: https://reviews.llvm.org/D88002
2020-09-22 10:51:25 +03:00
Eduardo Caldas af582c9b0f [SyntaxTree] Test `findFirstLeaf` and `findLastLeaf`
* Introduce `TreeTest.cpp` to unit test `Tree.h`
* Add `generateAllTreesWithShape` to generating test cases
* Add tests for `findFirstLeaf` and `findLastLeaf`
* Fix implementations of `findFirstLeaf` and `findLastLeaf` that had
been broken when empty `Tree` were present.

Differential Revision: https://reviews.llvm.org/D87779
2020-09-22 06:47:36 +00:00
Eduardo Caldas 1dc7836aed [SyntaxTree][Nit] Take `ArrayRef` instead of `std::vector` as argument for `createTree`
I also assured that there are no other functions unnecessarily using std::vector as argument.

Differential Revision: https://reviews.llvm.org/D88024
2020-09-22 06:47:36 +00:00
Nathan Ridge aa3c7638ba [clang] Traverse init-captures while indexing
Fixes https://github.com/clangd/clangd/issues/496

Differential Revision: https://reviews.llvm.org/D87257
2020-09-22 02:32:09 -04:00
Richard Smith 0f6facca97 Don't build a StringLiteral expression with reference type when
performing list-initialization of a char array reference from a braced
string literal of a smaller size.
2020-09-21 15:25:19 -07:00
shafik 6807f244fa [ASTImporter] Modifying ImportDeclContext(...) to ensure that we also handle the case when the FieldDecl is an ArrayType whose ElementType is a RecordDecl
When we fixed ImportDeclContext(...) in D71378 to make sure we complete each
FieldDecl of a RecordDecl when we are importing the definition we missed the
case where a FeildDecl was an ArrayType whose ElementType is a record.

This fix was motivated by a codegen crash during LLDB expression parsing. Since
we were not importing the definition we were crashing during layout which
required all the records be defined.

Differential Revision: https://reviews.llvm.org/D86660
2020-09-21 14:57:00 -07:00
Martin Storsjö 8c3ef08f8a Revert "[clang-cl] Always interpret the LIB env var as separated with semicolons"
This reverts commit 4d85444b31.

This commit broke building lldb's NativeProcessProtocolTest.cpp,
with errors like these:

In file included from include/llvm/Support/Process.h:32:0,
                 from tools/lldb/unittests/Host/NativeProcessProtocolTest.cpp:12:
include/llvm/Support/Program.h:39:11: error: reference to ‘pid_t’ is ambiguous
   typedef pid_t procid_t;

/usr/include/sched.h:38:17: note: candidates are: typedef __pid_t pid_t
 typedef __pid_t pid_t;

tools/lldb/include/lldb/lldb-types.h:85:18: note: typedef uint64_t lldb::pid_t
 typedef uint64_t pid_t;
2020-09-22 00:14:45 +03:00
Martin Storsjö 4d85444b31 [clang-cl] Always interpret the LIB env var as separated with semicolons
When cross compiling with clang-cl, clang splits the INCLUDE env
variable around semicolons (clang/lib/Driver/ToolChains/MSVC.cpp,
MSVCToolChain::AddClangSystemIncludeArgs) and lld splits the
LIB variable similarly (lld/COFF/Driver.cpp,
LinkerDriver::addLibSearchPaths). Therefore, the consensus for
cross compilation with clang-cl and lld-link seems to be to use
semicolons, despite path lists normally being separated by colons
on unix and EnvPathSeparator being set to that.

Therefore, handle the LIB variable similarly in Clang, when
handling lib file arguments when driving linking via Clang.

This fixes commands like "clang-cl test.c -Fetest.exe kernel32.lib" in
a cross compilation setting. Normally, most users call (lld-)link
directly, but meson happens to use this command syntax for
has_function() tests.

Differential Revision: https://reviews.llvm.org/D88002
2020-09-21 23:42:59 +03:00
Martin Storsjö ead7c3cdc3 [clang] [MinGW] Add an implicit .exe suffix even when crosscompiling
GCC 8 changed behaviour wrt this, and made it consistent for cross
compilation cases. While it's a change, it's a more sensible behaviour
going forward.

Differential Revision: https://reviews.llvm.org/D88005
2020-09-21 23:42:59 +03:00
Chris Hamilton 2697d138a6 [Analyzer] GNU named variadic macros in Plister
Added support for GNU named variadic macros in
macro expansion for plist generation.

Fix for https://bugs.llvm.org/show_bug.cgi?id=44493

Reviewed By: Szelethus

Differential Revision: https://reviews.llvm.org/D87942
2020-09-21 15:38:28 -05:00
Zequan Wu 9caa3fbe03 [Coverage] Add empty line regions to SkippedRegions
Differential Revision: https://reviews.llvm.org/D84988
2020-09-21 12:42:53 -07:00
Reid Kleckner 3b3a165485 [MS] On x86_32, pass overaligned, non-copyable arguments indirectly
This updates the C++ ABI argument classification code to use the logic
from D72114, fixing an ABI incompatibility with MSVC.

Part of PR44395.

Differential Revision: https://reviews.llvm.org/D87923
2020-09-21 11:49:17 -07:00
David Tenty d854042741 [AIX][Clang][Driver] Add handling of shared option
Reviewed By: jasonliu

Differential Revision: https://reviews.llvm.org/D87914
2020-09-21 14:03:08 -04:00
Sriraman Tallam 6950db36d3 The wrong placement of add pass with optimizations led to -funique-internal-linkage-names being disabled.
Fixed the placement of the MPM.addpass for UniqueInternalLinkageNames to make
it work correctly with -O2 and new pass manager. Updated the tests to
explicitly check O0 and O2.

Previously, the addPass was placed before BackendUtil.cpp#L1373 which is wrong
as MPM gets assigned at this point and any additions to the pass vector before
this is wrong. This change just moves it after MPM is assigned and places it at
a point where O0 and O0+ can share it.

Differential Revision: https://reviews.llvm.org/D87921
2020-09-21 10:00:12 -07:00
Raul Tambre f91f28c350 [Sema] Split special builtin type lookups into a separate function
In case further such cases appear in the future we've got a generic function to add them to.
Additionally changed the ObjC special case to check the language and the identifier builtin ID instead of the name.

Addresses the cleanup suggestion from D87917.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D87983
2020-09-21 19:12:29 +03:00
Igor Kudrin 474d527c28 [clang] Fix a misleading variable name. NFC.
The variable is true when frame pointers should be omitted in leaf
functions, not kept.

Differential Revision: https://reviews.llvm.org/D88021
2020-09-21 22:59:34 +07:00
Gabor Marton 0c4f91f84b [analyzer][solver] Fix issue with symbol non-equality tracking
We should track non-equivalency (disequality) in case of greater-then or
less-then assumptions.

Differential Revision: https://reviews.llvm.org/D88019
2020-09-21 16:59:18 +02:00
David Tenty 699089f2a9 [AIX][Clang][Driver] Add handling of nostartfiles option
Reviewed By: jasonliu

Differential Revision: https://reviews.llvm.org/D87904
2020-09-21 10:42:46 -04:00
Raphael Isemann 7c4575e15f [ASTImporter] Refactor IsStructurallyEquivalent's Decl overloads to be more consistent
There are several `::IsStructurallyEquivalent` overloads for Decl subclasses
that are used for comparing declarations. There is also one overload that takes
just two Decl pointers which ends up queuing the passed Decls to be later
compared in `CheckKindSpecificEquivalence`.

`CheckKindSpecificEquivalence` implements the dispatch logic for the different
Decl subclasses. It is supposed to hand over the queued Decls to the
subclass-specific `::IsStructurallyEquivalent` overload that will actually
compare the Decl instance. It also seems to implement a few pieces of actual
node comparison logic inbetween the dispatch code.

This implementation causes that the different overloads of
`::IsStructurallyEquivalent` do different (and sometimes no) comparisons
depending on which overload of `::IsStructurallyEquivalent` ends up being
called.

For example, if I want to compare two FieldDecl instances, then I could either
call the `::IsStructurallyEquivalent` with `Decl *` or with `FieldDecl *`
parameters. The overload that takes FieldDecls is doing a correct comparison.
However, the `Decl *` overload just queues the Decl pair.
`CheckKindSpecificEquivalence` has no dispatch logic for `FieldDecl`, so it
always returns true and never does any actual comparison.

On the other hand, if I try to compare two FunctionDecl instances the two
possible overloads of `::IsStructurallyEquivalent` have the opposite behaviour:
The overload that takes `FunctionDecl` pointers isn't comparing the names of the
FunctionDecls while the overload taking a plain `Decl` ends up comparing the
function names (as the comparison logic for that is implemented in
`CheckKindSpecificEquivalence`).

This patch tries to make this set of functions more consistent by making
`CheckKindSpecificEquivalence` a pure dispatch function without any
subclass-specific comparison logic. Also the dispatch logic is now autogenerated
so it can no longer miss certain subclasses.

The comparison code from `CheckKindSpecificEquivalence` is moved to the
respective `::IsStructurallyEquivalent` overload so that the comparison result
no longer depends if one calls the `Decl *` overload or the overload for the
specific subclass. The only difference is now that the `Decl *` overload is
queuing the parameter while the subclass-specific overload is directly doing the
comparison.

`::IsStructurallyEquivalent` is an implementation detail and I don't think the
behaviour causes any bugs in the current implementation (as carefully calling
the right overload for the different classes works around the issue), so the
test for this change is that I added some new code for comparing `MemberExpr`.
The new comparison code always calls the dispatching overload and it previously
failed as the dispatch didn't support FieldDecls.

Reviewed By: martong, a_sidorin

Differential Revision: https://reviews.llvm.org/D87619
2020-09-21 16:41:00 +02:00
Eduardo Caldas 87f0b51d68 [SyntaxTree][NFC] follow naming convention + remove auto on empty vector declaration
Differential Revision: https://reviews.llvm.org/D88004
2020-09-21 11:45:15 +00:00