Commit Graph

436 Commits

Author SHA1 Message Date
Chris Bieneman 26c695b789 Support macro deprecation #pragma clang deprecated
This patch adds `#pragma clang deprecated` to enable deprecation of
preprocessor macros.

The macro must be defined before `#pragma clang deprecated`. When
deprecating a macro a custom message may be optionally provided.

Warnings are emitted at the use site of a deprecated macro, and can be
controlled via the `-Wdeprecated` warning group.

This patch takes some rough inspiration and a few lines of code from
https://reviews.llvm.org/D67935.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D106732
2021-07-29 12:40:53 -05:00
Matheus Izvekov d6144c30fb [clang] add C++ feature test macro for P2266 simpler implicit move
The feature was implemented in D99005, but we forgot to add the test
macro.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D104984
2021-06-26 23:05:23 +02:00
Hans Wennborg 24037c37b6 Add support for #pragma system_header with -fms-extensions
Clang already supports the pragma prefixed by "GCC" or "clang".

MSVC has more recently added support for the pragma, but without any prefix; see
https://devblogs.microsoft.com/cppblog/broken-warnings-theory/#external-headers

Differential revision: https://reviews.llvm.org/D104770
2021-06-23 13:26:03 +02:00
Nathan Sidwell c1cd743519 [clang] p1099 using-enum feature macro & web page
This completes the series implementing p1099, by adding the feature
macro and updating the web page.

Differential Revision: https://reviews.llvm.org/D102242
2021-06-09 05:40:53 -07:00
Marco Elver 4fbc66cd6d [Clang] Enable __has_feature(coverage_sanitizer)
Like other sanitizers, enable __has_feature(coverage_sanitizer) if clang
has enabled at least one SanitizerCoverage instrumentation type.

Because coverage instrumentation selection is not handled via normal
-fsanitize= (and thus not in SanitizeSet), passing this information
through to LangOptions required propagating the already parsed
-fsanitize-coverage= options from CodeGenOptions through to LangOptions
in FixupInvocation().

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D103159
2021-05-27 18:24:21 +02:00
Richard Smith de6164ec4d PR50456: Properly handle multiple escaped newlines in a '*/'. 2021-05-24 16:21:03 -07:00
Anton Bikineev dc7ebd2cb0 [C++2b] Support size_t literals
This adds support for C++2b's z/uz suffixes for size_t literals (P0330).
2021-03-31 13:36:23 +00:00
Aaron Ballman e448310059 Add support for digit separators in C2x.
WG14 adopted N2626 at the meetings this week. This commit adds support
for using ' as a digit separator in a numeric literal which is
compatible with the C++ feature.
2021-03-12 07:21:03 -05:00
Richard Smith 564f5b0734 Revert "[c++20] Mark class type NTTPs as done and start defining the feature test macro."
Some of the parts of this work were reverted; stop defining the feature
test macro for now.

This reverts commit b4c63ef6dd.
2021-03-01 12:53:35 -08:00
Richard Smith 72d8f79f0c [c++2b] Add tests for feature test macros. 2020-12-18 13:42:23 -08:00
Richard Smith 939ba0b501 Add tests for the absence of feature test macros for features we don't
support yet.
2020-12-18 13:42:23 -08:00
Richard Smith b4c63ef6dd [c++20] Mark class type NTTPs as done and start defining the feature test macro. 2020-12-18 13:42:23 -08:00
Leonard Chan 64c0792946 [clang][feature] Add cxx_abi_relative_vtable feature
This will be enabled if relative vtables is enabled.

Differential revision: https://reviews.llvm.org/D85924
2020-10-08 10:30:54 -07:00
Chuyang Chen 8fa45e1fd5 Convert diagnostics about multi-character literals from extension to warning
This addresses PR46797.
2020-10-06 08:47:17 -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
Fanbo Meng 2240ca0bd1 [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS
Aligned allocation is not supported on z/OS. This patch sets -faligned-alloc-unavailable as default in z/OS toolchain.

Reviewed By: abhina.sreeskantharajan, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D87611
2020-09-16 14:49:03 -04:00
Abhina Sreeskantharajan dedaf78fa7 [SystemZ][z/OS] enable trigraphs by default on z/OS
This patch enables trigraphs on z/OS.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D85722
2020-08-13 16:02:07 -04:00
Zola Bridges 18a855da43 [clang][slh] Add test for SLH feature checking macro
Summary:
I forgot to include a test in this commit:
https://reviews.llvm.org/rG379e68a763097bed55556c6dc7453e4b732e3d68

Here's the test. It passes after that commit and fails before that commit.

Reviewed By: mattdr

Differential Revision: https://reviews.llvm.org/D79894
2020-05-15 12:23:31 -07:00
Nico Weber 51d938bc94 Fix bugs when an included file name is typo corrected.
D52774 fixed a bug with typo correction of includes, but didn't add
a test.

D65907 then broke recovery of typo correction of includes again,
because it extracted the code that writes to Filename to a separate
function that took the parameter not by reference.

Fix that, and also don't repeat the slash normalization computation
and fix both lookup and regular file name after recovery.

Differential Revision: https://reviews.llvm.org/D79595
2020-05-08 13:33:39 -04:00
Nico Weber d03838343f Make -Wnonportable-include-path ignore drive case on Windows.
See PR45812 for motivation.

No explicit test since I couldn't figure out how to get the
current disk drive in lower case into a form in lit where I could
mkdir it and cd to it. But the change does have test coverage in
that I can remove the case normalization in lit, and tests failed
on several bots (and for me locally if in a pwd with a lower-case
drive) without that normalization prior to this change.

Differential Revision: https://reviews.llvm.org/D79531
2020-05-07 15:54:09 -04:00
Nico Weber 8fc7a907b9 Let normalize() for posix style convert backslash to slash unconditionally.
Currently, normalize() for posix replaces backslashes to slashes, except
that two backslashes in sequence are kept as-is.

clang calls normalize() to convert \ to / is microsoft compat mode. This
generally works well, but a path like "c:\\foo\\bar.h" with two
backslashes doesn't work due to the exception in normalize().

These paths happen naturally on Windows hosts with e.g.
`#include __FILE__`, and them not working on other hosts makes it
more difficult to write tests for this case.

The special case has been around without justification since this code
was added in r203611 (since then moved around in r215241 r215243).  No
integration tests fail if I remove it.

Try removing the special case.

Differential Revision: https://reviews.llvm.org/D79265
2020-05-05 13:54:55 -04:00
Nico Weber b9d50bdff2 Fix pr31836 on Windows too, and correctly handle repeated separators.
The approach in D30000 assumes that the '/' returned by path::begin()
is the first element for absolute paths, but that's not true on
Windows.

Also, on Windows backslashes in include lines often end up escaped
so that there are two of them. Having backslashes in include lines
is undefined behavior in most cases and implementation-defined
behavior in C++20, but since clang treats it as normal repeated
path separators, the diagnostic should too.

Unbreaks -Wnonportable-include-path for absolute paths on Windows,
and unbreaks it on non-Windows in the case of absolute paths with
repeated directory separators.

This affects e.g. the `#include __FILE__` technique if the file
passed to clang has the wrong case for the drive letter. Before:

C:\src\llvm-project>bin\clang-cl.exe c:\src\llvm-project\test.cc
c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file
    '"c\\srccllvm-projectctest.cc.'; specified path differs in case from
    file name on disk [-Wnonportable-include-path]
         ^

Now:

C:\src\llvm-project> out\gn\bin\clang-cl c:\src\llvm-project\test.cc
c:\\src\\llvm-project\\test.cc(4,10): warning: non-portable path to file
    '"C:\\src\\llvm-project\\test.cc"'; specified path differs in case from
    file name on disk [-Wnonportable-include-path]
         ^

Differential Revision: https://reviews.llvm.org/D79223
2020-05-01 14:17:01 -04:00
Richard Smith 20df6038ee Make -fno-char8_t disable the char8_t keyword, even in C++20.
This fixes a regression introduced in r354736, and makes our behavior
compatible with that of Clang 8 and GCC.
2020-04-28 23:49:35 -07:00
Richard Smith 24ad121582 Add -std=c++20 flag, replace C++2a with C++20 throughout the Clang
user interface and documentation, and update __cplusplus for C++20.

WG21 considers the C++20 standard to be finished (even though it still
has some more steps to pass through in the ISO process).

The old flag names are accepted for compatibility, as usual, and we
still have lots of references to C++2a in comments and identifiers;
those can be cleaned up separately.
2020-02-18 16:16:37 -08:00
Diogo Sampaio bce360b704 Detect source location overflow due includes
Summary:
As discussed in http://lists.llvm.org/pipermail/cfe-dev/2019-October/063459.html
the overflow of the souce locations (limited to 2^31 chars) can generate all sorts of
weird things (bogus warnings, hangs, crashes, miscompilation and correct compilation).
In debug mode this assert would fail. So it might be a good start, as in PR42301,
to detect the failure and exit with a proper error message.

Reviewers: rsmith, thakis, miyuki

Reviewed By: miyuki

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70183
2020-01-24 23:56:47 +00:00
Saar Raz 67c608a969 [Concepts] Deprecate -fconcepts-ts, enable Concepts under -std=c++2a
Now with concepts support merged and mostly complete, we do not need -fconcepts-ts
(which was also misleading as we were not implementing the TS) and can enable
concepts features under C++2a. A warning will be generated if users still attempt
to use -fconcepts-ts.
2020-01-24 00:48:59 +02:00
Richard Smith f4a45c2ce4 Fix crash on init-capture packs where the type of the initializer is non-dependent. 2019-12-19 15:20:10 -08:00
Richard Smith df2e2ab07b Implement latest C++ feature test macro recommendations.
We don't yet advertise init capture packs, because I found some bugs
while testing it. We reject-valid and then crash on both of these:

template<int ...a> auto x = [...y = a] {};
template<int ...a> auto x = [y = a...] {};
2019-12-19 12:59:13 -08:00
Richard Smith bc633a42dd Mark the major papers for C++20 consistent comparisons as "done", and
start publishing the corresponding feature-test macro.
2019-12-15 22:20:06 -08:00
Eric Christopher fd39b1bb20 Revert "Revert "As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.""
This reapplies: 8ff85ed905

Original commit message:

As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.

This change doesn't include any change to move from selection dag to fast isel
and that will come with other numbers that should help inform that decision.
There also haven't been any real debuggability studies with this pipeline yet,
this is just the initial start done so that people could see it and we could start
tweaking after.

Test updates: Outside of the newpm tests most of the updates are coming from either
optimization passes not run anymore (and without a compelling argument at the moment)
that were largely used for canonicalization in clang.

Original post:

http://lists.llvm.org/pipermail/llvm-dev/2019-April/131494.html

Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65410

This reverts commit c9ddb02659.
2019-11-26 20:28:52 -08:00
Muhammad Omair Javaid c9ddb02659 Revert "As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there."
This reverts commit 8ff85ed905.

This commit introduced 9 new failures on lldb buildbot host at http://lab.llvm.org:8014/builders/lldb-aarch64-ubuntu

Following tests were failing:
    lldb-api :: functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
    lldb-api :: functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
    lldb-api :: functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
    lldb-api :: functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py
    lldb-api :: functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py
    lldb-api :: functionalities/tail_call_frames/inlining_and_tail_calls/TestInliningAndTailCalls.py
    lldb-api :: functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py
    lldb-api :: functionalities/tail_call_frames/thread_step_out_message/TestArtificialFrameStepOutMessage.py
    lldb-api :: functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py
    lldb-api :: functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py

Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65410
2019-11-26 09:32:13 +05:00
Eric Christopher 8ff85ed905 As a follow-up to my initial mail to llvm-dev here's a first pass at the O1 described there.
This change doesn't include any change to move from selection dag to fast isel
and that will come with other numbers that should help inform that decision.
There also haven't been any real debuggability studies with this pipeline yet,
this is just the initial start done so that people could see it and we could start
tweaking after.

Test updates: Outside of the newpm tests most of the updates are coming from either
optimization passes not run anymore (and without a compelling argument at the moment)
that were largely used for canonicalization in clang.

Original post:

http://lists.llvm.org/pipermail/llvm-dev/2019-April/131494.html

Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65410
2019-11-25 17:16:46 -08:00
Richard Smith 69e9d84b1a Mark P0784R7 as complete and start defining its feature-test macro.
Note that this only covers the language side of this feature. (The
library side has its own feature test macro.)

llvm-svn: 373548
2019-10-03 00:39:37 +00:00
Reid Kleckner adc1830187 Move normalization of `\` in #includes from -fms-compatibility to -fms-extensions
Handling backslashes in include paths in the implementation isn't
non-conforming.

llvm-svn: 372999
2019-09-26 17:19:22 +00:00
Michal Gorny 96f35266a5 [clang] [Basic] Enable __has_feature(leak_sanitizer)
Add a 'leak_sanitizer' feature akin to existing '*_sanitizer' features
to let programmers switch code paths accounting for leak sanitizers
being enabled.

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

llvm-svn: 372527
2019-09-22 20:55:01 +00:00
Richard Smith a6e8b685e1 [c++20] P1143R2: Add support for the C++20 'constinit' keyword.
This is mostly the same as the
[[clang::require_constant_initialization]] attribute, but has a couple
of additional syntactic and semantic restrictions.

In passing, I added a warning for the attribute form being added after
we have already seen the initialization of the variable (but before we
see the definition); that case previously slipped between the cracks and
the attribute was silently ignored.

llvm-svn: 370972
2019-09-04 20:30:37 +00:00
Alexandre Ganea 3c307370c8 Try fixing CRLF issues in Git with [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings
Differential Revision: https://reviews.llvm.org/D66556

llvm-svn: 370219
2019-08-28 15:14:37 +00:00
Hans Wennborg 248abe2b66 Delete minimize_source_to_dependency_directives_invalid_error.c
It was added in r370129 with a .gitattributes file that means the file
always shows up as having a local diff in Git checkouts (at least on
Linux). Deleting it until we can figure out the right way to do this.

llvm-svn: 370175
2019-08-28 09:14:00 +00:00
Alexandre Ganea 57b4e107e4 Re-land [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings
Previously, an #error directive with quoted, multi-line content, along with CR+LF line endings wasn't handled correctly.

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

llvm-svn: 370129
2019-08-28 00:04:06 +00:00
Richard Smith f3f00b2e5e Revert "[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings"
This reverts commit r369986.

This change added a dependency on the 'dos2unix' tool, which is not one
of our accepted test dependencies and may not exist on all machines that
build Clang.

llvm-svn: 370000
2019-08-27 01:06:23 +00:00
Alexandre Ganea e6561e0068 [clang-scan-deps] Skip UTF-8 BOM in source minimizer
Differential Revision: https://reviews.llvm.org/D66511

llvm-svn: 369993
2019-08-27 00:13:52 +00:00
Alexandre Ganea 6137cecf87 [clang-scan-deps] Minimizer: Correctly skip over double slashes in angle bracket #include
Previously, double slashes (//) occurring in angle brackets #include were incorrectly interpreted as comments. eg. #include <dir//file.h>

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

llvm-svn: 369988
2019-08-26 23:28:05 +00:00
Alexandre Ganea 2abca4f06c [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings
Previously, an #error directive with quoted, multi-line content, along with CR+LF line endings wasn't handled correctly.

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

llvm-svn: 369986
2019-08-26 23:19:21 +00:00
Erich Keane 62b072d413 Implement P1668R1
Allow inline assembly statements in unexecuted branches of constexpr
functions.

llvm-svn: 369281
2019-08-19 17:39:59 +00:00
Evgeniy Stepanov c5e7f56249 ARM MTE stack sanitizer.
Add "memtag" sanitizer that detects and mitigates stack memory issues
using armv8.5 Memory Tagging Extension.

It is similar in principle to HWASan, which is a software implementation
of the same idea, but there are enough differencies to warrant a new
sanitizer type IMHO. It is also expected to have very different
performance properties.

The new sanitizer does not have a runtime library (it may grow one
later, along with a "debugging" mode). Similar to SafeStack and
StackProtector, the instrumentation pass (in a follow up change) will be
inserted in all cases, but will only affect functions marked with the
new sanitize_memtag attribute.

Reviewers: pcc, hctim, vitalybuka, ostannard

Subscribers: srhines, mehdi_amini, javed.absar, kristof.beyls, hiraditya, cryptoad, steven_wu, dexonsmith, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 366123
2019-07-15 20:02:23 +00:00
Alex Lorenz 6e2d36b60b Add clang source minimizer that reduces source to directives
that might affect the dependency list for a compilation

This commit introduces a dependency directives source minimizer to clang
that minimizes header and source files to the minimum necessary preprocessor
directives for evaluating includes. It reduces the source down to #define, #include,

The source minimizer works by lexing the input with a custom fast lexer that recognizes
the preprocessor directives it cares about, and emitting those directives in the minimized source.
It ignores source code, comments, and normalizes whitespace. It gives up and fails if seems
any directives that it doesn't recognize as valid (e.g. #define 0).

In addition to the source minimizer this patch adds a
-print-dependency-directives-minimized-source CC1 option that allows you to invoke the minimizer
from clang directly.

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

llvm-svn: 362459
2019-06-03 22:59:17 +00:00
Richard Smith b9b05100c5 Factor out repeated code parsing and concatenating header-names from
tokens.

We now actually form an angled_string_literal token for a header name by
concatenation rather than just working out what its contents would be.
This substantially simplifies downstream processing and is necessary for
C++20 header unit imports.

llvm-svn: 356433
2019-03-19 01:51:19 +00:00
Nico Weber 885b790f89 Remove esan.
It hasn't seen active development in years, and it hasn't reached a
state where it was useful.

Remove the code until someone is interested in working on it again.

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

llvm-svn: 355862
2019-03-11 20:23:40 +00:00
Richard Smith 10ab78e854 Enable coroutines under -std=c++2a.
llvm-svn: 354736
2019-02-23 21:06:26 +00:00
Reid Kleckner c1648f2bfd [MSVC] Recognize `static_assert` keyword in C and C++98
Summary:
The main effect is that clang now accepts the following conforming C11
code with MSVC headers:
  #include <assert.h>
  static_assert(1, "true");

This is a non-conforming extension (the keyword is outside the
implementer's namespace), so it is placed under -fms-compatibility
instead of -fms-extensions like most MSVC-specific keyword extensions.

Normally, in C11, the compiler is supposed to provide the _Static_assert
keyword, and assert.h should define static_assert to _Static_assert.
However, that is not what MSVC does, and MSVC doesn't even provide
_Static_assert.

This also has the less important side effect of enabling static_assert
in C++98 mode with -fms-compatibility. It's exceptionally difficult to
use modern MSVC headers without C++14 even, so this is relatively
unimportant.

Fixes PR26672

Patch by Andrey Bokhanko!

Reviewers: rsmith, thakis

Subscribers: cfe-commits, STL_MSFT

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

llvm-svn: 354162
2019-02-15 19:59:45 +00:00