]> granicus.if.org Git - clang/log
clang
5 years agoRevert "Try to update the test to fix the breakage With the new warning, we are showi...
Adam Nemet [Fri, 14 Dec 2018 00:43:36 +0000 (00:43 +0000)]
Revert "Try to update the test to fix the breakage With the new warning, we are showing one more output in the test."

This reverts commit r349064.

This wasn't updating the right test.  Causing (not the different line number
from the previous revert):

======================================================================
FAIL: test_diagnostic_warning (tests.cindex.test_diagnostics.TestDiagnostics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/bindings/python/tests/cindex/test_diagnostics.py", line 18, in test_diagnostic_warning
    self.assertEqual(len(tu.diagnostics), 2)
AssertionError: 1 != 2

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349118 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "Make -Wstring-plus-int warns even if when the result is not out of bounds"
Adam Nemet [Fri, 14 Dec 2018 00:43:34 +0000 (00:43 +0000)]
Revert "Make -Wstring-plus-int warns even if when the result is not out of bounds"

This reverts commit r349054.

It's causing:

FAILED: tools/clang/bindings/python/tests/CMakeFiles/check-clang-python
FAIL: test_diagnostic_range (tests.cindex.test_diagnostics.TestDiagnostics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/bindings/python/tests/cindex/test_diagnostics.py",
  line 55, in test_diagnostic_range
      self.assertEqual(len(tu.diagnostics), 1)
      AssertionError: 2 != 1

======================================================================
FAIL: test_diagnostic_warning (tests.cindex.test_diagnostics.TestDiagnostics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/bindings/python/tests/cindex/test_diagnostics.py",
  line 18, in test_diagnostic_warning
      self.assertEqual(len(tu.diagnostics), 2)
      AssertionError: 1 != 2

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349117 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Builltins][X86] Provide implementations of __lzcnt16, __lzcnt, __lzcnt64 for MS...
Craig Topper [Fri, 14 Dec 2018 00:21:02 +0000 (00:21 +0000)]
[Builltins][X86] Provide implementations of __lzcnt16, __lzcnt, __lzcnt64 for MS compatibility. Remove declarations from intrin.h and implementations from lzcntintrin.h

intrin.h had forward declarations for these and lzcntintrin.h had implementations that were only available with -mlzcnt or a -march that supported the lzcnt feature.

For MS compatibility we should always have these builtins available regardless of X86 being the target or the CPU support the lzcnt instruction. The backends should be able to gracefully fallback to something support even if its just shifts and bit ops.

Unfortunately, gcc also implements 2 of the 3 function names here on X86 when lzcnt feature is enabled.

This patch adds builtins for these for MSVC compatibility and drops the forward declarations from intrin.h. To keep the gcc compatibility the two intrinsics that collided have been turned into macros that use the X86 specific builtins with the lzcnt feature check. These macros are only defined when _MSC_VER is not defined. Without them being macros we can get a redefinition error because -ms-extensions doesn't seem to set _MSC_VER but does make the MS builtins available.

Should fix PR40014

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349098 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CUDA] Make all host-side shadows of device-side variables undef.
Artem Belevich [Thu, 13 Dec 2018 21:43:04 +0000 (21:43 +0000)]
[CUDA] Make all host-side shadows of device-side variables undef.

The host-side code can't (and should not) access the values that may
only exist on the device side. E.g. address of a __device__ function
does not exist on the host side as we don't generate the code for it there.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349087 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAttempt to fix code completion test to handle LLP64 platforms
Reid Kleckner [Thu, 13 Dec 2018 21:41:07 +0000 (21:41 +0000)]
Attempt to fix code completion test to handle LLP64 platforms

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349086 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix test after -Wstring-plus-int warning was enabled
Reid Kleckner [Thu, 13 Dec 2018 21:24:08 +0000 (21:24 +0000)]
Fix test after -Wstring-plus-int warning was enabled

Use array indexing instead of addition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349085 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix debug-info-abspath.c on Windows by removing /tmp/t.o line
Reid Kleckner [Thu, 13 Dec 2018 21:18:16 +0000 (21:18 +0000)]
Fix debug-info-abspath.c on Windows by removing /tmp/t.o line

This object seemed unused, so I believe we can just remove this compiler
invocation without losing any test coverage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349083 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoUpdate the scan-build to generate SARIF.
Aaron Ballman [Thu, 13 Dec 2018 20:55:34 +0000 (20:55 +0000)]
Update the scan-build to generate SARIF.

This updates the scan-build perl script to allow outputting to sarif in a more natural fashion by specifying -sarif as a command line argument, similar to how -plist is already supported.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349082 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReinstate DW_AT_comp_dir support after D55519.
Adrian Prantl [Thu, 13 Dec 2018 17:53:29 +0000 (17:53 +0000)]
Reinstate DW_AT_comp_dir support after D55519.

The DIFile used by the CU is special and distinct from the main source
file. Its directory part specifies what becomes the DW_AT_comp_dir
(the compilation directory), even if the source file was specified
with an absolute path.

To support the .dwo workflow, a valid DW_AT_comp_dir is necessary even
if source files were specified with an absolute path.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349065 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoTry to update the test to fix the breakage
Sylvestre Ledru [Thu, 13 Dec 2018 17:39:02 +0000 (17:39 +0000)]
Try to update the test to fix the breakage
With the new warning, we are showing one more output in the test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349064 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeComplete] Adhere to LLVM naming style in CodeCompletionTest. NFC
Ilya Biryukov [Thu, 13 Dec 2018 17:32:38 +0000 (17:32 +0000)]
[CodeComplete] Adhere to LLVM naming style in CodeCompletionTest. NFC

Also reuses the same var for multiple to reduce the chance of
accidentally referecing the previous test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349063 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeComplete] Temporarily disable failing assertion
Ilya Biryukov [Thu, 13 Dec 2018 17:23:48 +0000 (17:23 +0000)]
[CodeComplete] Temporarily disable failing assertion

Found the case in the clang codebase where the assertion fires.
To avoid crashing assertion-enabled builds before I re-add the missing
operation.
Will restore the assertion alongside the upcoming fix.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349061 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix CodeCompleteTest.cpp for older gcc plus ccache builds
David Green [Thu, 13 Dec 2018 17:20:06 +0000 (17:20 +0000)]
Fix CodeCompleteTest.cpp for older gcc plus ccache builds

Some versions of gcc, especially when invoked through ccache (-E), can have
trouble with raw string literals inside macros. This moves the string out of
the macro.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349059 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMake -Wstring-plus-int warns even if when the result is not out of bounds
Sylvestre Ledru [Thu, 13 Dec 2018 16:06:23 +0000 (16:06 +0000)]
Make -Wstring-plus-int warns even if when the result is not out of bounds

Summary: Patch by Arnaud Bienner

Reviewers: sylvestre.ledru, thakis

Reviewed By: thakis

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349054 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeComplete] Fill preferred type on binary expressions
Ilya Biryukov [Thu, 13 Dec 2018 16:06:11 +0000 (16:06 +0000)]
[CodeComplete] Fill preferred type on binary expressions

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: arphaman, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349053 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeComplete] Set preferred type to bool on conditions
Ilya Biryukov [Thu, 13 Dec 2018 15:36:32 +0000 (15:36 +0000)]
[CodeComplete] Set preferred type to bool on conditions

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349050 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Add generic AS to 'this' pointer
Mikael Nilsson [Thu, 13 Dec 2018 10:15:27 +0000 (10:15 +0000)]
[OpenCL] Add generic AS to 'this' pointer

Address spaces are cast into generic before invoking the constructor.

Added support for a trailing Qualifiers object in FunctionProtoType.

Note: This recommits the previously reverted patch,
      but now it is commited together with a fix for lldb.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349019 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[asan] Don't check ODR violations for particular types of globals
Vitaly Buka [Thu, 13 Dec 2018 09:47:39 +0000 (09:47 +0000)]
[asan] Don't check ODR violations for particular types of globals

Summary:
private and internal: should not trigger ODR at all.
unnamed_addr: current ODR checking approach fail and rereport false violation if
a linker merges such globals
linkonce_odr, weak_odr: could cause similar problems and they are already not
instrumented for ELF.

Reviewers: eugenis, kcc

Subscribers: kubamracek, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349015 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoPortable Python script across Python version
Serge Guelton [Thu, 13 Dec 2018 07:45:55 +0000 (07:45 +0000)]
Portable Python script across Python version

SocketServer has been renamed socketserver in Python3.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349010 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoPortable Python script across Python version
Serge Guelton [Thu, 13 Dec 2018 07:44:19 +0000 (07:44 +0000)]
Portable Python script across Python version

Queue module as been renamed into queue in Python3

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349009 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoPortable Python script across Python version
Serge Guelton [Thu, 13 Dec 2018 07:42:30 +0000 (07:42 +0000)]
Portable Python script across Python version

Use higher-level and more compatible threading module to start a new thread.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349008 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] Add AST matcher for block expressions 🔍
Stephane Moore [Thu, 13 Dec 2018 03:35:10 +0000 (03:35 +0000)]
[clang] Add AST matcher for block expressions 🔍

Summary:
This change adds a new AST matcher for block expressions.

Test Notes:
Ran the clang unit tests.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349004 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove unused Args parameter from EmitFunctionBody, NFC
Reid Kleckner [Thu, 13 Dec 2018 01:33:20 +0000 (01:33 +0000)]
Remove unused Args parameter from EmitFunctionBody, NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349001 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] RunLoopAutoreleaseLeakChecker: Come up with a test for r348822.
Artem Dergachev [Thu, 13 Dec 2018 01:30:47 +0000 (01:30 +0000)]
[analyzer] RunLoopAutoreleaseLeakChecker: Come up with a test for r348822.

Statement memoization was removed in r348822 because it was noticed to cause
memory corruption. This was happening because a reference to an object
in a DenseMap was used after being invalidated by inserting a new key
into the map.

This test case crashes reliably under ASan (i.e., when Clang is built with
-DLLVM_USE_SANITIZER="Address") on at least some machines before r348822
and doesn't crash after it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349000 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoEmit a proper diagnostic when attempting to forward inalloca arguments
Reid Kleckner [Wed, 12 Dec 2018 23:46:06 +0000 (23:46 +0000)]
Emit a proper diagnostic when attempting to forward inalloca arguments

The previous assertion was relatively easy to trigger, and likely will
be easy to trigger going forward. EmitDelegateCallArg is relatively
popular.

This cleanly diagnoses PR28299 while I work on a proper solution.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348991 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "Declares __cpu_model as dso local"
Haibo Huang [Wed, 12 Dec 2018 22:39:51 +0000 (22:39 +0000)]
Revert "Declares __cpu_model as dso local"

This reverts r348978

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348982 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDeclares __cpu_model as dso local
Haibo Huang [Wed, 12 Dec 2018 22:04:12 +0000 (22:04 +0000)]
Declares __cpu_model as dso local

__builtin_cpu_supports and __builtin_cpu_is use information in __cpu_model to decide cpu features. Before this change, __cpu_model was not declared as dso local. The generated code looks up the address in GOT when reading __cpu_model. This makes it impossible to use these functions in ifunc, because at that time GOT entries have not been relocated. This change makes it dso local.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348978 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AST] Store "UsesADL" information in CallExpr.
Eric Fiselier [Wed, 12 Dec 2018 21:50:55 +0000 (21:50 +0000)]
[AST] Store "UsesADL" information in CallExpr.

Summary:
Currently the Clang AST doesn't store information about how the callee of a CallExpr was found. Specifically if it was found using ADL.

However, this information is invaluable to tooling. Consider a tool which renames usages of a function. If the originally CallExpr was formed using ADL, then the tooling may need to additionally qualify the replacement.
Without information about how the callee was found, the tooling is left scratching it's head. Additionally, we want to be able to match ADL calls as quickly as possible, which means avoiding computing the answer on the fly.

This patch changes `CallExpr` to store whether it's callee was found using ADL. It does not change the size of any AST nodes.

Reviewers: fowles, rsmith, klimek, shafik

Reviewed By: rsmith

Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348977 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoTeach __builtin_unpredictable to work through implicit casts.
Erich Keane [Wed, 12 Dec 2018 20:30:53 +0000 (20:30 +0000)]
Teach __builtin_unpredictable to work through implicit casts.

The __builtin_unpredictable implementation is confused by any implicit
casts, which happen in C++.  This patch strips those off so that
if/switch statements now work with it in C++.

Change-Id: I73c3bf4f1775cd906703880944f4fcdc29fffb0a

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348969 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoChange CallGraph print to show the fully qualified name
Erich Keane [Wed, 12 Dec 2018 18:11:36 +0000 (18:11 +0000)]
Change CallGraph print to show the fully qualified name

CallGraph previously would just show the normal name of a function,
which gets really confusing when using it on large C++ projects.  This
patch switches the printName call to a printQualifiedName, so that the
namespaces are included.

Change-Id: Ie086d863f6b2251be92109ea1b0946825b28b49a

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348950 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.
Michael Kruse [Wed, 12 Dec 2018 17:32:52 +0000 (17:32 +0000)]
[Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.

When multiple loop transformation are defined in a loop's metadata, their order of execution is defined by the order of their respective passes in the pass pipeline. For instance, e.g.

    #pragma clang loop unroll_and_jam(enable)
    #pragma clang loop distribute(enable)

is the same as

    #pragma clang loop distribute(enable)
    #pragma clang loop unroll_and_jam(enable)

and will try to loop-distribute before Unroll-And-Jam because the LoopDistribute pass is scheduled after UnrollAndJam pass. UnrollAndJamPass only supports one inner loop, i.e. it will necessarily fail after loop distribution. It is not possible to specify another execution order. Also,t the order of passes in the pipeline is subject to change between versions of LLVM, optimization options and which pass manager is used.

This patch adds 'followup' attributes to various loop transformation passes. These attributes define which attributes the resulting loop of a transformation should have. For instance,

    !0 = !{!0, !1, !2}
    !1 = !{!"llvm.loop.unroll_and_jam.enable"}
    !2 = !{!"llvm.loop.unroll_and_jam.followup_inner", !3}
    !3 = !{!"llvm.loop.distribute.enable"}

defines a loop ID (!0) to be unrolled-and-jammed (!1) and then the attribute !3 to be added to the jammed inner loop, which contains the instruction to distribute the inner loop.

Currently, in both pass managers, pass execution is in a fixed order and UnrollAndJamPass will not execute again after LoopDistribute. We hope to fix this in the future by allowing pass managers to run passes until a fixpoint is reached, use Polly to perform these transformations, or add a loop transformation pass which takes the order issue into account.

For mandatory/forced transformations (e.g. by having been declared by #pragma omp simd), the user must be notified when a transformation could not be performed. It is not possible that the responsible pass emits such a warning because the transformation might be 'hidden' in a followup attribute when it is executed, or it is not present in the pipeline at all. For this reason, this patche introduces a WarnMissedTransformations pass, to warn about orphaned transformations.

Since this changes the user-visible diagnostic message when a transformation is applied, two test cases in the clang repository need to be updated.

To ensure that no other transformation is executed before the intended one, the attribute `llvm.loop.disable_nonforced` can be added which should disable transformation heuristics before the intended transformation is applied. E.g. it would be surprising if a loop is distributed before a #pragma unroll_and_jam is applied.

With more supported code transformations (loop fusion, interchange, stripmining, offloading, etc.), transformations can be used as building blocks for more complex transformations (e.g. stripmining+stripmining+interchange -> tiling).

Reviewed By: hfinkel, dmgreen

Differential Revision: https://reviews.llvm.org/D49281
Differential Revision: https://reviews.llvm.org/D55288

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348944 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Driver] Add support for -fembed-bitcode for assembly file
Steven Wu [Wed, 12 Dec 2018 17:30:16 +0000 (17:30 +0000)]
[Driver] Add support for -fembed-bitcode for assembly file

Summary:
Handle -fembed-bitcode for assembly inputs. When the input file is
assembly, write a marker as "__LLVM,__asm" section.

Fix llvm.org/pr39659

Reviewers: compnerd, dexonsmith

Reviewed By: compnerd

Subscribers: rjmccall, dblaikie, jkorous, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348943 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMake clang::CallGraph look into template instantiations
Erich Keane [Wed, 12 Dec 2018 17:22:52 +0000 (17:22 +0000)]
Make clang::CallGraph look into template instantiations

Clang's CallGraph analysis doesn't use the RecursiveASTVisitor's setting
togo into template instantiations.  The result is that anything wanting
to do call graph analysis ends up missing any template function calls.

Change-Id: Ib4af44ed59f15d43f37af91622a203146a3c3189

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348942 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoBasic: make `int_least64_t` and `int_fast64_t` match on Darwin
Saleem Abdulrasool [Wed, 12 Dec 2018 17:05:20 +0000 (17:05 +0000)]
Basic: make `int_least64_t` and `int_fast64_t` match on Darwin

The Darwin targets use `int64_t` and `uint64_t` to define the `int_least64_t`
and `int_fast64_t` types.  The underlying type is actually a `long long`.  Match
the types to allow the printf specifiers to work properly and have the compiler
vended macros match the implementation on the target.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348939 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element types
Hubert Tong [Wed, 12 Dec 2018 16:53:43 +0000 (16:53 +0000)]
[ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element types

Summary:
`memchr` and `memcmp` operate upon the character units of the object
representation; that is, the `size_t` parameter expresses the number of
character units. The constant folding implementation is updated in this
patch to account for multibyte element types in the arrays passed to
`memchr`/`memcmp` and, in the case of `memcmp`, to account for the
possibility that the arrays may have differing element types (even when
they are byte-sized).

Actual inspection of the object representation is not implemented.
Comparisons are done only between elements with the same object size;
that is, `memchr` will fail when inspecting at least one character unit
of a multibyte element. The integer types are assumed to have two's
complement representation with 0 for `false`, 1 for `true`, and no
padding bits.

`memcmp` on multibyte elements will only be able to fold in cases where
enough elements are equal for the answer to be 0.

Various tests are added to guard against incorrect folding for cases
that miscompile on some system or other prior to this patch. At the same
time, the unsigned 32-bit `wchar_t` testing in
`test/SemaCXX/constexpr-string.cpp` is restored.

Reviewers: rsmith, aaron.ballman, hfinkel

Reviewed By: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348938 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[mips] Enable using of integrated assembler in all cases.
Simon Atanasyan [Wed, 12 Dec 2018 15:32:25 +0000 (15:32 +0000)]
[mips] Enable using of integrated assembler in all cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348935 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove TODO leftover from my devleopment branch
Erich Keane [Wed, 12 Dec 2018 15:13:00 +0000 (15:13 +0000)]
Remove TODO leftover from my devleopment branch

Accidentially checked in a TODO line from r348899. This removes it.

Change-Id: I74b59c0ecfe147af8a08dd7fd10893a4ca351d6d

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348932 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[OpenCL] Add generic AS to 'this' pointer"
Mikael Nilsson [Wed, 12 Dec 2018 15:06:16 +0000 (15:06 +0000)]
Revert "[OpenCL] Add generic AS to 'this' pointer"

Reverting because the patch broke lldb.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348931 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CUDA][OPENMP][NVPTX]Improve logic of the debug info support.
Alexey Bataev [Wed, 12 Dec 2018 14:52:27 +0000 (14:52 +0000)]
[CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

Summary:
Added support for the -gline-directives-only option + fixed logic of the
debug info for CUDA devices. If optimization level is O0, then options
--[no-]cuda-noopt-device-debug do not affect the debug info level. If
the optimization level is >O0, debug info options are used +
--no-cuda-noopt-device-debug is used or no --cuda-noopt-device-debug is
used, the optimization level for the device code is kept and the
emission of the debug directives is used.
If the opt level is > O0, debug info is requested +
--cuda-noopt-device-debug option is used, the optimization is disabled
for the device code + required debug info is emitted.

Reviewers: tra, echristo

Subscribers: aprantl, guansong, JDevlieghere, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348930 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-fuzzer] Add explicit dependency on clangSerialization for clangHandleCXX after...
Alex Bradbury [Wed, 12 Dec 2018 14:33:24 +0000 (14:33 +0000)]
[clang-fuzzer] Add explicit dependency on clangSerialization for clangHandleCXX after rC348907

This library was breaking my -DBUILD_SHARED_LIBS=1 build. rC348915 seemed to miss this case.

As this seems an "obvious" fix, I am committing without pre-commit review as
per the LLVM developer policy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348929 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Add generic AS to 'this' pointer
Mikael Nilsson [Wed, 12 Dec 2018 14:11:59 +0000 (14:11 +0000)]
[OpenCL] Add generic AS to 'this' pointer

Address spaces are cast into generic before invoking the constructor.

Added support for a trailing Qualifiers object in FunctionProtoType.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348927 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Remove import of definition from GetAlreadyImportedOrNull
Gabor Marton [Wed, 12 Dec 2018 11:22:55 +0000 (11:22 +0000)]
[ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

Summary: a_sidorin

Reviewers: a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348923 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Fix for TBAA information of pointer after addresspacecast
Andrew Savonichev [Wed, 12 Dec 2018 09:51:23 +0000 (09:51 +0000)]
[OpenCL] Fix for TBAA information of pointer after addresspacecast

Summary: When addresspacecast is generated resulting pointer should preserve TBAA information from original value.

Reviewers: rjmccall, yaxunl, Anastasia

Reviewed By: rjmccall

Subscribers: asavonic, kosarev, cfe-commits, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348919 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd explicit dependency on clangSerialization for a bunch of components to fix -DBUIL...
Fangrui Song [Wed, 12 Dec 2018 08:02:18 +0000 (08:02 +0000)]
Add explicit dependency on clangSerialization for a bunch of components to fix -DBUILD_SHARED_LIBS=on build

This is a more thorough fix of rC348911.
The story about -DBUILD_SHARED_LIBS=on build after rC348907 (Move PCHContainerOperations from Frontend to Serialization) is:

1. libclangSerialization.so defines PCHContainerReader dtor, ...
2. clangFrontend and clangTooling define classes inheriting from PCHContainerReader, thus their DSOs have undefined references on PCHContainerReader dtor
3. Components depending on either clangFrontend or clangTooling cannot be linked unless they have explicit dependency on clangSerialization due to the default linker option -z defs. The explicit dependency could be avoided if libclang{Frontend,Tooling}.so had these undefined references.

This patch adds the explicit dependency on clangSerialization to make them build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348915 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeGen] Fix -DBUILD_SHARED_LIBS=on build after rC348907
Fangrui Song [Wed, 12 Dec 2018 06:07:33 +0000 (06:07 +0000)]
[CodeGen] Fix -DBUILD_SHARED_LIBS=on build after rC348907

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348911 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMove PCHContainerOperations from Frontend to Serialization
Richard Trieu [Wed, 12 Dec 2018 02:53:59 +0000 (02:53 +0000)]
Move PCHContainerOperations from Frontend to Serialization

Fix a layering violation.  Frontend depends on Serialization, so anything used
by both should be in Serialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348907 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReplace Const-Member checking with non-recursive version.
Erich Keane [Tue, 11 Dec 2018 21:54:52 +0000 (21:54 +0000)]
Replace Const-Member checking with non-recursive version.

As reported in PR39946, these two implementations cause stack overflows
to occur when a type recursively contains itself.  While this only
happens when an incomplete version of itself is used by membership (and
thus an otherwise invalid program), the crashes might be surprising.

The solution here is to replace the recursive implementation with one
that uses a std::vector as a queue.  Old values are kept around to
prevent re-checking already checked types.

Change-Id: I582bb27147104763d7daefcfee39d91f408b9fa8

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348899 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert r348889; it fails some tests.
Aaron Ballman [Tue, 11 Dec 2018 19:42:04 +0000 (19:42 +0000)]
Revert r348889; it fails some tests.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/40784

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348892 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoStop stripping comments from AST matcher example code.
Aaron Ballman [Tue, 11 Dec 2018 19:30:49 +0000 (19:30 +0000)]
Stop stripping comments from AST matcher example code.

The AST matcher documentation dumping script was being a bit over-zealous about stripping comment markers, which ended up causing comments in example code to stop being comments. Fix that by only stripping comments at the start of a line, rather than removing any forward slash (which also impacts prose text).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348891 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoEmit -Wformat properly for bit-field promotions.
Aaron Ballman [Tue, 11 Dec 2018 19:18:01 +0000 (19:18 +0000)]
Emit -Wformat properly for bit-field promotions.

Only explicitly look through integer and floating-point promotion where the result type is actually a promotion, which is not always the case for bit-fields in C.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348889 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][CStringChecker] evaluate explicit_bzero
David Carlier [Tue, 11 Dec 2018 18:57:07 +0000 (18:57 +0000)]
[analyzer][CStringChecker] evaluate explicit_bzero

- explicit_bzero has limited scope/usage only for security/crypto purposes but is non-optimisable version of memset/0 and bzero.
- explicit_memset has similar signature and semantics as memset but is also a non-optimisable version.

Reviewers: NoQ

Reviewed By: NoQ

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348884 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove CGDebugInfo::getOrCreateFile() and use TheCU->getFile() directly.
Adrian Prantl [Tue, 11 Dec 2018 16:58:46 +0000 (16:58 +0000)]
Remove CGDebugInfo::getOrCreateFile() and use TheCU->getFile() directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348866 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReuse code from CGDebugInfo::getOrCreateFile() when creating the file
Adrian Prantl [Tue, 11 Dec 2018 16:58:43 +0000 (16:58 +0000)]
Reuse code from CGDebugInfo::getOrCreateFile() when creating the file
for the DICompileUnit.

This addresses post-commit feedback for D55085. Without this patch, a
main source file with an absolute paths may appear in different
DIFiles, once with the absolute path and once with the common prefix
between the absolute path and the current working directory.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348865 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoPass PartialOverloading argument to the correct corresponding parameter
Eric Fiselier [Tue, 11 Dec 2018 16:53:25 +0000 (16:53 +0000)]
Pass PartialOverloading argument to the correct corresponding parameter

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348864 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASan] Minor documentation fix: clarify static linking limitation.
Max Moroz [Tue, 11 Dec 2018 16:47:12 +0000 (16:47 +0000)]
[ASan] Minor documentation fix: clarify static linking limitation.

Summary:
ASan does not support statically linked binaries, but ASan runtime itself can
be statically linked into a target binary executable.

Reviewers: eugenis, kcc

Reviewed By: eugenis

Subscribers: cfe-commits, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348863 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Tue, 11 Dec 2018 16:34:59 +0000 (16:34 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for expressions in C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348860 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[PowerPC] Make no-PIC default to match GCC - CLANG"
Stefan Pintilie [Tue, 11 Dec 2018 15:47:57 +0000 (15:47 +0000)]
Revert "[PowerPC] Make no-PIC default to match GCC - CLANG"

This reverts commit rL348299.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348858 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Fix a minor typo.
Gabor Horvath [Tue, 11 Dec 2018 14:40:48 +0000 (14:40 +0000)]
[analyzer] Fix a minor typo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348848 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland r348741 "[Sema] Further improvements to to static_assert diagnostics."
Clement Courbet [Tue, 11 Dec 2018 08:39:11 +0000 (08:39 +0000)]
Reland r348741 "[Sema] Further improvements to to static_assert diagnostics."

Fix a dangling reference to temporary, never return nullptr.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348834 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert r348830 "[Sema]improve static_assert(!expr)"
Clement Courbet [Tue, 11 Dec 2018 07:28:00 +0000 (07:28 +0000)]
Revert r348830 "[Sema]improve static_assert(!expr)"

Submitted the wrong change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348831 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema]improve static_assert(!expr)
Clement Courbet [Tue, 11 Dec 2018 07:04:49 +0000 (07:04 +0000)]
[Sema]improve static_assert(!expr)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348830 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMove CodeGenOptions from Frontend to Basic
Richard Trieu [Tue, 11 Dec 2018 03:18:39 +0000 (03:18 +0000)]
Move CodeGenOptions from Frontend to Basic

Basic uses CodeGenOptions and should not depend on Frontend.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348827 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Remove memoization from RunLoopAutoreleaseLeakChecker
George Karpenkov [Tue, 11 Dec 2018 01:14:17 +0000 (01:14 +0000)]
[analyzer] Remove memoization from RunLoopAutoreleaseLeakChecker

Memoization dose not seem to be necessary, as other statement visitors
run just fine without it,
and in fact seems to be causing memory corruptions.
Just removing it instead of investigating the root cause.

rdar://45945002

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348822 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Hack for backwards compatibility for options for RetainCountChecker.
George Karpenkov [Tue, 11 Dec 2018 01:13:58 +0000 (01:13 +0000)]
[analyzer] Hack for backwards compatibility for options for RetainCountChecker.

To be removed once the clients update.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348821 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Display a diagnostics when an inlined function violates its os_consumed...
George Karpenkov [Tue, 11 Dec 2018 01:13:40 +0000 (01:13 +0000)]
[analyzer] Display a diagnostics when an inlined function violates its os_consumed summary

This is currently a diagnostics, but might be upgraded to an error in the future,
especially if we introduce os_return_on_success attributes.

rdar://46359592

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348820 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Resolve another bug where the name of the leaked object was not printed...
George Karpenkov [Tue, 11 Dec 2018 01:13:20 +0000 (01:13 +0000)]
[analyzer] Resolve another bug where the name of the leaked object was not printed properly

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348819 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoUpdate test for instcombine change
Matt Arsenault [Mon, 10 Dec 2018 23:02:40 +0000 (23:02 +0000)]
Update test for instcombine change

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348809 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "Change InitListExpr dump to label and pointer"
Stephen Kelly [Mon, 10 Dec 2018 21:20:05 +0000 (21:20 +0000)]
Revert "Change InitListExpr dump to label and pointer"

This reverts commit r348794.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348799 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix nits
Stephen Kelly [Mon, 10 Dec 2018 21:04:04 +0000 (21:04 +0000)]
Fix nits

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348798 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRe-order content of template parameter dumps
Stephen Kelly [Mon, 10 Dec 2018 21:03:00 +0000 (21:03 +0000)]
Re-order content of template parameter dumps

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348797 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRe-order content in OMPDeclareReductionDecl dump
Stephen Kelly [Mon, 10 Dec 2018 20:53:39 +0000 (20:53 +0000)]
Re-order content in OMPDeclareReductionDecl dump

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348795 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoChange InitListExpr dump to label and pointer
Stephen Kelly [Mon, 10 Dec 2018 20:53:32 +0000 (20:53 +0000)]
Change InitListExpr dump to label and pointer

Summary: Don't add a child just for the label.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348794 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd an explicit triple to this test to fix failing test bots.
Aaron Ballman [Mon, 10 Dec 2018 19:18:11 +0000 (19:18 +0000)]
Add an explicit triple to this test to fix failing test bots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348790 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[constexpr][c++2a] Try-catch blocks in constexpr functions
Bruno Cardoso Lopes [Mon, 10 Dec 2018 19:03:12 +0000 (19:03 +0000)]
[constexpr][c++2a] Try-catch blocks in constexpr functions

Implement support for try-catch blocks in constexpr functions, as
proposed in http://wg21.link/P1002 and voted in San Diego for c++20.

The idea is that we can still never throw inside constexpr, so the catch
block is never entered. A try-catch block like this:

try { f(); } catch (...) { }

is then morally equivalent to just

{ f(); }

Same idea should apply for function/constructor try blocks.

rdar://problem/45530773

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348789 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdding tests for -ast-dump; NFC.
Aaron Ballman [Mon, 10 Dec 2018 18:37:47 +0000 (18:37 +0000)]
Adding tests for -ast-dump; NFC.

This adds tests for expressions in C.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348786 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoComputeLineNumbers: delete SSE2 vectorization
Fangrui Song [Mon, 10 Dec 2018 18:10:35 +0000 (18:10 +0000)]
ComputeLineNumbers: delete SSE2 vectorization

Summary:
SSE2 vectorization was added in 2012, but it is 2018 now and I can't
observe any performance boost (testing clang -E [all Sema/* CodeGen/* with proper -I options]) with the existing _mm_movemask_epi8+countTrailingZeros or the following SSE4.2 (compiling with -msse4.2):

  __m128i C = _mm_setr_epi8('\r','\n',0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  _mm_cmpestri(C, 2, Chunk, 16, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_POSITIVE_POLARITY | _SIDD_LEAST_SIGNIFICANT)

Delete the vectorization to simplify the code.

Also simplify the code a bit and don't check the line ending sequence \n\r

Reviewers: bkramer, #clang

Reviewed By: bkramer

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348777 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libclang] Revert removal of tidy plugin support from libclang introduced in r347496
Ivan Donchevskii [Mon, 10 Dec 2018 15:58:50 +0000 (15:58 +0000)]
[libclang] Revert removal of tidy plugin support from libclang introduced in r347496

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348764 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoUse zip_longest for iterator range comparisons. NFC.
Michael Kruse [Mon, 10 Dec 2018 15:16:37 +0000 (15:16 +0000)]
Use zip_longest for iterator range comparisons. NFC.

Use zip_longest in two locations that compare iterator ranges.
zip_longest allows the iteration using a range-based for-loop and to be
symmetric over both ranges instead of prioritizing one over the other.
In that latter case code have to handle the case that the first is
longer than the second, the second is longer than the first, and both
are of the same length, which must partially be checked after the loop.

With zip_longest, this becomes an element comparison within the loop
like the comparison of the elements themselves. The symmetry makes it
clearer that neither the first and second iterators are handled
differently. The iterators are not event used directly anymore, just
the ranges.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348762 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMisc typos fixes in ./lib folder
Raphael Isemann [Mon, 10 Dec 2018 12:37:46 +0000 (12:37 +0000)]
Misc typos fixes in ./lib folder

Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned`

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348755 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL][CodeGen] Fix replacing memcpy with addrspacecast
Andrew Savonichev [Mon, 10 Dec 2018 12:03:00 +0000 (12:03 +0000)]
[OpenCL][CodeGen] Fix replacing memcpy with addrspacecast

Summary:
If a function argument is byval and RV is located in default or alloca address space
an optimization of creating addrspacecast instead of memcpy is performed. That is
not correct for OpenCL, where that can lead to a situation of address space casting
from __private * to __global *. See an example below:

```
typedef struct {
  int x;
} MyStruct;

void foo(MyStruct val) {}

kernel void KernelOneMember(__global MyStruct* x) {
  foo (*x);
}
```

for this code clang generated following IR:
...
%0 = load %struct.MyStruct addrspace(1)*, %struct.MyStruct addrspace(1)**
%x.addr, align 4
%1 = addrspacecast %struct.MyStruct addrspace(1)* %0 to %struct.MyStruct*
...

So the optimization was disallowed for OpenCL if RV is located in an address space
different than that of the argument (0).

Reviewers: yaxunl, Anastasia

Reviewed By: Anastasia

Subscribers: cfe-commits, asavonic

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348752 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert r348741 "[Sema] Further improvements to to static_assert diagnostics."
Clement Courbet [Mon, 10 Dec 2018 08:53:17 +0000 (08:53 +0000)]
Revert r348741 "[Sema] Further improvements to to static_assert diagnostics."

Seems to break build bots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348742 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Further improvements to to static_assert diagnostics.
Clement Courbet [Mon, 10 Dec 2018 08:19:38 +0000 (08:19 +0000)]
[Sema] Further improvements to to static_assert diagnostics.

Summary:
We're now handling cases like `static_assert(!expr)` and
static_assert(!(expr))`.

Reviewers: aaron.ballman, Quuxplusone

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348741 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Remove the addcarry builtins. Leaving only the addcarryx builtins since that...
Craig Topper [Mon, 10 Dec 2018 06:07:59 +0000 (06:07 +0000)]
[X86] Remove the addcarry builtins. Leaving only the addcarryx builtins since that matches gcc.

The addcarry and addcarryx builtins do the same thing. The only difference is that addcarryx previously required adx feature.

This commit removes the adx feature check from addcarryx and removes the addcarry builtin. This matches the builtins that gcc has. We don't guarantee compatibility in builtins, but we generally try to be consistent if its not a burden.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348738 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMove the make_const_ptr trait into STLExtras; use add_pointer where possible; NFC.
Aaron Ballman [Sun, 9 Dec 2018 19:53:24 +0000 (19:53 +0000)]
Move the make_const_ptr trait into STLExtras; use add_pointer where possible; NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348730 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoNFC: Rename TemplateDecl dump utilities
Stephen Kelly [Sun, 9 Dec 2018 13:33:30 +0000 (13:33 +0000)]
NFC: Rename TemplateDecl dump utilities

There is a clang::TemplateDecl AST type, so a method called
VisitTemplateDecl looks like it should 'override' the method from the
base visitor, but it does not because of the extra parameters it takes.

In reality, these methods are utilities, so name them like utilities.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348720 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoNFC: Move dump of individual comment nodes to NodeDumper
Stephen Kelly [Sun, 9 Dec 2018 13:30:17 +0000 (13:30 +0000)]
NFC: Move dump of individual comment nodes to NodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348719 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "Introduce optional labels to dumpStmt"
Stephen Kelly [Sun, 9 Dec 2018 13:24:40 +0000 (13:24 +0000)]
Revert "Introduce optional labels to dumpStmt"

This reverts commit 933402caa09963792058198578522a95f013c69c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348718 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoIntroduce optional labels to dumpStmt
Stephen Kelly [Sun, 9 Dec 2018 13:23:07 +0000 (13:23 +0000)]
Introduce optional labels to dumpStmt

If the label is present, it is added as a child, with the statement a
child of the label.  This preserves behavior of the InitListExpr dump
output.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348717 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoInline hasNodes into only caller
Stephen Kelly [Sun, 9 Dec 2018 13:20:43 +0000 (13:20 +0000)]
Inline hasNodes into only caller

It is easier to refactor with fewer utility methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348716 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoInline dumpFullComment into callers
Stephen Kelly [Sun, 9 Dec 2018 13:18:55 +0000 (13:18 +0000)]
Inline dumpFullComment into callers

It causes confusion over whether it or dumpComment is the more
important. It is easier to refactor with fewer utility methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348715 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRe-order content from InitListExpr
Stephen Kelly [Sun, 9 Dec 2018 13:15:18 +0000 (13:15 +0000)]
Re-order content from InitListExpr

Summary:
This causes no change in the output of ast-dump-stmt.cpp due to the way
child nodes are printed with a delay.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348714 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix InitListExpr test
Stephen Kelly [Sun, 9 Dec 2018 13:13:41 +0000 (13:13 +0000)]
Fix InitListExpr test

Wrong case of Check meant this has no effect.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348713 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoSourceManager: insert(make_pair(..)) -> try_emplace. NFC
Fangrui Song [Sun, 9 Dec 2018 01:46:01 +0000 (01:46 +0000)]
SourceManager: insert(make_pair(..)) -> try_emplace. NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348709 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoConvert some ObjC msgSends to runtime calls.
Pete Cooper [Sat, 8 Dec 2018 05:13:50 +0000 (05:13 +0000)]
Convert some ObjC msgSends to runtime calls.

It is faster to directly call the ObjC runtime for methods such as alloc/allocWithZone instead of sending a message to those functions.

This patch adds support for converting messages to alloc/allocWithZone to their equivalent runtime calls.

Tests included for the positive case of applying this transformation, negative tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and also a driver test to ensure we enable this only for supported runtime versions.

Reviewed By: rjmccall

https://reviews.llvm.org/D55349

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348687 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMove diagnostic enums into Basic.
Richard Trieu [Sat, 8 Dec 2018 05:05:03 +0000 (05:05 +0000)]
Move diagnostic enums into Basic.

Move enums from */*Diagnostic.h to Basic/Diagnostic*.h.  Basic/AllDiagnostics.h
needs all the enums and moving the sources to Basic prevents a Basic->*->Basic
dependency loop.  This also allows each Basic/Diagnostics*Kinds.td to have a
header at Basic/Diagnostic*.h (except for Common).  The old headers are kept in place since other packages are still using them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348685 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoStop tracking retain count of OSObject after escape to void * / other primitive types
George Karpenkov [Sat, 8 Dec 2018 01:18:40 +0000 (01:18 +0000)]
Stop tracking retain count of OSObject after escape to void * / other primitive types

Escaping to void * / uint64_t / others non-OSObject * should stop tracking,
as such functions can have heterogeneous semantics depending on context,
and can not always be annotated.

rdar://46439133

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348675 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[tests] Fix the FileManagerTest getVirtualFile test on Windows
Stella Stamenova [Fri, 7 Dec 2018 23:50:05 +0000 (23:50 +0000)]
[tests] Fix the FileManagerTest getVirtualFile test on Windows

Summary: The test passes on Windows only when it is executed on the C: drive. If the build and tests run on a different drive, the test is currently failing.

Reviewers: kadircet, asmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348665 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CUDA] Added missing 'inline' for functions defined in a header.
Artem Belevich [Fri, 7 Dec 2018 22:20:53 +0000 (22:20 +0000)]
[CUDA] Added missing 'inline' for functions defined in a header.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348662 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Preprocessor] Don't avoid entering included files after hitting a fatal error.
Volodymyr Sapsai [Fri, 7 Dec 2018 20:29:54 +0000 (20:29 +0000)]
[Preprocessor] Don't avoid entering included files after hitting a fatal error.

Change in r337953 violated the contract for `CXTranslationUnit_KeepGoing`:

> Do not stop processing when fatal errors are encountered.

Use different approach to fix long processing times with multiple inclusion
cycles. Instead of stopping preprocessing for fatal errors, do this after
reaching the max allowed include depth and only for the files that were
processed already. It is likely but not guaranteed those files cause a cycle.

rdar://problem/46108547

Reviewers: erik.pilkington, arphaman

Reviewed By: erik.pilkington

Subscribers: jkorous, dexonsmith, ilya-biryukov, Dmitry.Kozhevnikov

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348641 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Move out tracking retain count for OSObjects into a separate checker
George Karpenkov [Fri, 7 Dec 2018 20:21:51 +0000 (20:21 +0000)]
[analyzer] Move out tracking retain count for OSObjects into a separate checker

Allow enabling and disabling tracking of ObjC/CF objects
separately from tracking of OS objects.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348638 91177308-0d34-0410-b5e6-96231b3b80d8