Richard Smith [Thu, 3 Oct 2019 00:39:35 +0000 (00:39 +0000)]
For P0784R7: support placement new-expressions in constant evaluation.
For now, we restrict this support to use from within the standard
library implementation, since we're required to make parts of the
standard library that use placement new work, but not permitted to
make uses of placement new from user code work.
will product an ELF binary with visible symbols populated. Visibility attributes
and -fvisibility can be used to control what gets populated.
* Adding ToolChain support for clang Driver IFS Merge Phase
* Implementing a default InterfaceStubs Merge clang Tool, used by ToolChain
* Adds support for the clang Driver to involve llvm-ifs on ifs files.
* Adds -emit-merged-ifs flag, to tell llvm-ifs to emit a merged ifs text file
instead of the final object format (normally ELF)
The static analyzer is warning about potential null dereferences, but we should be able to use castAs<RecordType> directly and if not assert will fire for us.
The static analyzer is warning about potential null dereferences, but we should be able to use cast<>/castAs<> directly and if not assert will fire for us.
Alexey Bataev [Wed, 2 Oct 2019 18:19:02 +0000 (18:19 +0000)]
[OPENMP50]Add parsing/sema analysis for declare variant score.
Context selectors may include optional score clause in format
`score(<expr>):`, where `<expr>` must be a constant integer expression.
Added parsing/sema analysis only.
Simon Pilgrim [Wed, 2 Oct 2019 16:03:36 +0000 (16:03 +0000)]
Type - silence static analyzer getAs<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<VectorType> directly and if not assert will fire for us.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.
Sam McCall [Wed, 2 Oct 2019 09:50:40 +0000 (09:50 +0000)]
[ClangFormat] Future-proof Standard option, allow floating or pinning to arbitrary lang version
Summary:
The historical context:
- clang-format was written when C++11 was current,
and the main language-version concern was >> vs > > template-closers.
An option was added to allow selection of the 03/11 behavior, or auto-detection.
- there was no option to choose simply "latest standard" so anyone who didn't
ever want 03 behavior or auto-detection specified Cpp11.
- In r185149 this option started to affect lexer mode.
- no options were added to cover c++14, as parsing/formatting
didn't change that much. The usage of Cpp11 to mean "latest" became
codified e.g. in r206263
- c++17 added some new constructs. These were mostly backwards-compatible and so
not used in old programs, so having no way to turn them off was OK.
- c++20 added some new constructs and keywords (e.g. co_*) that changed the
meaning of existing programs, and people started to complain that
the c++20 parsing couldn't be turned off.
New plan:
- Default ('Auto') behavior remains unchanged: parse as latest, format
template-closers based on input.
- Add new 'Latest' option that more clearly expresses the intent "use
modern features" that many projects have chosen for their .clang-format files.
- Allow pinning to *any* language version, using the same name as clang -std:
c++03, c++11, c++14 etc. These set precise lexer options, and any
clang-format code depending on these can use a >= check.
- For backwards compatibility, `Cpp11` is an alias for `Latest`, not `c++11`.
This matches the historical documented semantics of this option.
This spelling (and `Cpp03`) are deprecated.
Richard Trieu [Wed, 2 Oct 2019 02:32:15 +0000 (02:32 +0000)]
Revert r368237 - Update fix-it hints for std::move warnings.
r368237 attempted to improve fix-its for move warnings, but introduced some
regressions to -Wpessimizing-move. Revert that change and add the missing
test cases to the pessimizing move test to prevent future regressions.
John McCall [Wed, 2 Oct 2019 01:02:27 +0000 (01:02 +0000)]
Remove TypeNodes.def from the modulemap.
We currently just look for files named in the modulemap in its
associated source directory. This means that we can't name
generated files, like TypeNodes.def now is, which means we can't
explicitly mark it as textual. But fortunately that's okay
because (as I understand it) the most important purpose of naming
the header in the modulemap is to ensure that it's not treated as
public, and the search for public headers also only considers
files in the associated source directory. This isn't an elegant
solution, since among other things it means that a build which
wrote the generated files directly into the source directory would
result in something that wouldn't build as a module, but that's
a problem for all our other generated files as well.
John McCall [Tue, 1 Oct 2019 23:13:03 +0000 (23:13 +0000)]
Emit TypeNodes.def with tblgen.
The primary goal here is to make the type node hierarchy available to
other tblgen backends, although it should also make it easier to generate
more selective x-macros in the future.
Because tblgen doesn't seem to allow backends to preserve the source
order of defs, this is not NFC because it significantly re-orders IDs.
I've fixed the one (fortunately obvious) place where we relied on
the old order. Unfortunately, I wasn't able to share code with the
existing AST-node x-macro generators because the x-macro schema we use
for types is different in a number of ways. The main loss is that
subclasses aren't ordered together, which doesn't seem important for
types because the hierarchy is generally very shallow with little
clustering.
The static analyzer is warning about potential null dereferences, but we should be able to use castAs<FunctionProtoType> directly and if not assert will fire for us.
Paul Hoad [Tue, 1 Oct 2019 20:20:22 +0000 (20:20 +0000)]
[clang-format] [PR43372] - clang-format shows replacements in DOS files when no replacement is needed
Summary:
This is a patch to fix PR43372 (https://bugs.llvm.org/show_bug.cgi?id=43372) - clang-format can't format file with includes, ( which really keep providing replacements for already sorted headers.)
A similar issue was addressed by @krasimir in {D60199}, however, this seemingly only prevented the issue when the files being formatted did not contain windows line endings (\r\n)
It's possible this is related to https://twitter.com/StephanTLavavej/status/1176722938243895296 given who @STL_MSFT works for!
As people often used the existence of replacements to determine if a file needs clang-formatting, this is probably pretty important for windows users
There may be a better way of comparing 2 strings and ignoring \r (which appear in both Results and Code), I couldn't choose between this idiom or the copy_if approach, but I'm happy to change it to whatever people consider more performant.
Teresa Johnson [Tue, 1 Oct 2019 18:08:29 +0000 (18:08 +0000)]
[ThinLTO] Enable index-only WPD from clang
Summary:
To trigger the index-only Whole Program Devirt support added to LLVM, we
need to be able to specify -fno-split-lto-unit in conjunction with
-fwhole-program-vtables. Keep the default for -fwhole-program-vtables as
-fsplit-lto-unit, but don't error on that option combination.
Kadir Cetinkaya [Tue, 1 Oct 2019 14:08:51 +0000 (14:08 +0000)]
[clang] Make handling of unnamed template params similar to function params
Summary:
Clang uses the location identifier should be inserted for declarator
decls when a decl is unnamed. But for type template and template template
paramaters it uses the location of "typename/class" keyword, which makes it hard
for tooling to insert/change parameter names.
This change tries to unify these two cases by making template parameter
parsing and sourcerange operations similar to function params/declarator decls.
Raphael Isemann [Tue, 1 Oct 2019 11:53:20 +0000 (11:53 +0000)]
[clang] Ignore builtin namespaces in test/Import/cxx-anon-namespace
Some platforms (e.g. AArch64) put __va_list in the 'std' namespace which might
end up being the first namespace we match in this test. Instead let
the first namespace match via file name/line so that we skip the
builtin namespaces.
Sylvestre Ledru [Tue, 1 Oct 2019 07:52:42 +0000 (07:52 +0000)]
Decrease the verbosity of the -ftime-trace option
And move the relevant information in the doc.
Summary:
Currently, building a large software like Firefox shows
'Use chrome://tracing or Speedscope App (https://www.speedscope.app) for flamegraph visualization'
for each file.
Richard Smith [Tue, 1 Oct 2019 00:47:41 +0000 (00:47 +0000)]
[c++20] Add a C++20 version of the existing turing machine test.
Unlike the C++11 version, this one uese mutable state and dynamic
allocation instead of a carefully balanced and ever-accumulating pile of
temporaries.
Erich Keane [Mon, 30 Sep 2019 20:45:12 +0000 (20:45 +0000)]
Fix failure caused by r373247
I incorrectly thought that the 'isLambda' check never fired, so when
splitting up a helper function, I lost the 'nullptr' return value.
ClangD Hover functionality apparently uses this, so the Unittest caught
that.
This patch correctly propogates the nullptr from the helper function.
Erich Keane [Mon, 30 Sep 2019 19:12:29 +0000 (19:12 +0000)]
Teach CallGraph to look into Generic Lambdas.
CallGraph visited LambdaExpr by getting the Call Operator from
CXXRecordDecl (LambdaExpr::getCallOperator calls
CXXRecordDecl::getLambdaCallOperator), which replaced generic lambda
call operators with the non-instantiated FunctionDecl. The result was
that the CallGraph would only pick up non-dependent calls.
This patch does a few things:
1- Extend CXXRecordDecl to have a getDependentLambdaCallOperator, which
will get the FunctionTemplateDecl, rather than immediately getting the
TemplateDecl.
2- Define getLambdaCallOperator and getDependentLambdaCallOperator in
terms of a common function.
3- Extend LambdaExpr with a getDependentCallOperator, which just calls
the above function.
4- Changes CallGraph to handle Generic LambdaExprs.
Teresa Johnson [Mon, 30 Sep 2019 17:26:48 +0000 (17:26 +0000)]
Fix buildbot failure from r373217 (don't match metadata id exactly)
Fix this failure by ignoring the id of the metadata being checked:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/3046/consoleFull#-21332887158254eaf0-7326-4999-85b0-388101f2d404
Teresa Johnson [Mon, 30 Sep 2019 15:05:35 +0000 (15:05 +0000)]
[Clang] Use -main-file-name for source filename if not set
-main-file-name is currently used to set the source name used in debug
information.
If the source filename is "-" and -main-file-name is set, then use the
filename also for source_filename and ModuleID of the output.
The argument is generally used outside the internal clang calls when
running clang in a wrapper like icecc which gives the source via stdin
but still wants to get a object file with the original source filename
both in debug info and IR code.
This header is included by C code so the functions need to have a prototype. Also, fix the function definitions so that they have C linkage rather than C++ linkage.
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
[lldb][clang][modern-type-lookup] Use ASTImporterSharedState in ExternalASTMerger
Summary:
The ExternalASTMerger should use the ASTImporterSharedState. This allows it to
handle std::pair in LLDB (but the rest of libc++ is still work in progress).
Richard Smith [Sun, 29 Sep 2019 06:22:54 +0000 (06:22 +0000)]
For now, disallow lifetime-extended temporaries with non-trivial (but
constexpr) destructors from being used in the values of constexpr
variables.
The standard rules here are unclear at best, so rejecting the
problematic cases seems prudent. Prior to this change, we would fail to
run the destructors for these temporaries, even if they had
side-effects, which is certainly not the right behavior.
Richard Smith [Sun, 29 Sep 2019 05:58:31 +0000 (05:58 +0000)]
Fix checking for permitted results of constant expressions.
In the presence of mutable state, we need to check whether temporaries
involved in a constant expression have permissible values at the end of
the overall evaluation, rather than at the end of the evaluation of the
initializer of the temporary.
Richard Smith [Sun, 29 Sep 2019 05:08:46 +0000 (05:08 +0000)]
For P0784R7: compute whether a variable has constant destruction if it
has a constexpr destructor.
For constexpr variables, reject if the variable does not have constant
destruction. In all cases, do not emit runtime calls to the destructor
for variables with constant destruction.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.
Driver tests: set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`
When testing clang that has been compiled with `-DDEFAULT_SYSROOT` set to some path,
some tests would fail. Override sysroot to be empty string for the tests to succeed
when clang is configured with `DEFAULT_SYSROOT`.
[Clang][OpenMP Offload] Create start/end symbols for the offloading entry table with a help of a linker
Linker automatically provides __start_<section name> and __stop_<section name> symbols to satisfy unresolved references if <section name> is representable as a C identifier (see https://sourceware.org/binutils/docs/ld/Input-Section-Example.html for details). These symbols indicate the start address and end address of the output section respectively. Therefore, renaming OpenMP offload entries section name from ".omp.offloading_entries" to "omp_offloading_entries" to use this feature.
This is the first part of the patch for eliminating OpenMP linker script (please see https://reviews.llvm.org/D64943).
[libTooling] Transformer: refine `SourceLocation` specified as anchor of changes.
Summary: Every change triggered by a rewrite rule is anchored at a particular
location in the source code. This patch refines how that location is chosen and
defines it as an explicit function so it can be shared by other Transformer
implementations.
This patch was inspired by a bug found by a clang tidy, wherein two changes were
anchored at the same location (the expansion loc of the macro) resulting in the
discarding of the second change.
Martin Storsjo [Fri, 27 Sep 2019 12:25:19 +0000 (12:25 +0000)]
[clang] [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode
This matches how GCC handles it, see e.g. https://gcc.godbolt.org/z/HPplnl.
GCC documents the gnu_inline attribute with "In C++, this attribute does
not depend on extern in any way, but it still requires the inline keyword
to enable its special behavior."
The previous behaviour of gnu_inline in C++, without the extern
keyword, can be traced back to the original commit that added
support for gnu_inline, SVN r69045.
Richard Smith [Fri, 27 Sep 2019 05:36:16 +0000 (05:36 +0000)]
Fix use-after-free found in Clang's testsuite.
We need to discard all remaining cleanups if an earlier cleanup failed,
otherwise we may try to rerun the remaining cleanups later, potentially
after the scope containing the object is destroyed. (This can happen
when checking a potential constant expression.)
Michael Kruse [Thu, 26 Sep 2019 22:53:01 +0000 (22:53 +0000)]
[OpenMP 5.0] Fix user-defined mapper lookup in sema
This patches fixes the case when a user-defined mapper is attached to
the elements of an array, and to report error when a mapper is used for
types other than struct, class, and union.
Alex Lorenz [Thu, 26 Sep 2019 19:28:51 +0000 (19:28 +0000)]
[clang-scan-deps] Allow continuation line backslashes followed by whitespace
in the dependency source minimizer
Clang allows continuations that have whitespace between the backslash and the newline.
This patch ensures that the dependency source minimizer can handle the whitespace between
the backslash and the newline when looking for a line continuation.
Only pass -coverage-notes-file when emitting coverage
The only functional change here is that -coverage-notes-file is not
passed to -cc1 in some situations.
This code appears to be trying to put the gcno and gcda output next to
the final object file, but it's doing that in a really convoluted way
that needs to be re-examined. It looks for -c or -S in the original
command, and then looks at the -o argument if present in order to handle
the -fno-integrated-as case. However, this doesn't work if this is a
link command with multiple inputs. I looked into fixing this, but the
check-profile test suite has a lot of dependencies on this behavior, so
I left it all alone.
Un-XFAIL coverage_no_integrated_as.c test on Windows
You can't use -fno-integrated-as for *-msvc triples because no usable
standalone assembler exists. Perhaps we could teach clang to emit a .s
and then reinvoke itself, but that's a bit silly.
Anyway, fix the test by using an Itanium ABI triple, which will become
mingw, which will assume gnu as is a usable assembler.
David Zarzycki [Thu, 26 Sep 2019 08:19:44 +0000 (08:19 +0000)]
[Testing] Workaround libcxx bug when OS is "none"
If clang is configured to use libcxx as the default C++ standard
library, then using "none" for the OS in the target triple will cause
libcxx to #error needlessly. Passing -nostdinc++ is a workaround for
these tests. See also: https://reviews.llvm.org/D68075
Please note: this workaround will probably exist for a few years until
the installed version of libcxx is updated.