Commit Graph

369 Commits

Author SHA1 Message Date
Volodymyr Sapsai 579f0b307c [Lex] Fix handling numerical literals ending with ' and signed exponent.
For input `0'e+1` lexer tokenized as numeric constant only `0'e`. Later
NumericLiteralParser skipped 0 and ' as digits and parsed `e+1` as valid
exponent going past the end of the token. Because it didn't mark numeric
literal as having an error, it continued parsing and tried to expandUCNs
with StringRef of length -2.

The fix is not to parse exponent when we reached the end of token.

Discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4588

rdar://problem/36076719

Reviewers: rsmith, t.p.northover

Reviewed By: rsmith

Subscribers: cfe-commits, jkorous-apple

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

llvm-svn: 324419
2018-02-06 22:39:25 +00:00
Volodymyr Sapsai abb8dfc114 [Lex] Avoid out-of-bounds dereference in LexAngledStringLiteral.
Fix makes the loop in LexAngledStringLiteral more like the loops in
LexStringLiteral, LexCharConstant. When we skip a character after
backslash, we need to check if we reached the end of the file instead of
reading the next character unconditionally.

Discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3832

rdar://problem/35572754

Reviewers: arphaman, kcc, rsmith, dexonsmith

Reviewed By: rsmith, dexonsmith

Subscribers: cfe-commits, rsmith, dexonsmith

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

llvm-svn: 322390
2018-01-12 18:54:35 +00:00
Richard Smith 77091b167f Warn if we find a Unicode homoglyph for a symbol in an identifier.
Specifically, warn if:
 * we find a character that the language standard says we must treat as an
   identifier, and
 * that character is not reasonably an identifier character (it's a punctuation
   character or similar), and 
 * it renders identically to a valid non-identifier character in common
   fixed-width fonts.

Some tools "helpfully" substitute the surprising characters for the expected
characters, and replacing semicolons with Greek question marks is a common
"prank".

llvm-svn: 320697
2017-12-14 13:15:08 +00:00
Tim Northover 36bb6d5d46 Switch to gnu++14 as the default dialect.
This is C++14 with conforming GNU extensions.

llvm-svn: 320250
2017-12-09 12:09:54 +00:00
Evgeniy Stepanov 12817e59de Hardware-assisted AddressSanitizer (clang part).
Summary:
Driver, frontend and LLVM codegen for HWASan.
A clone of ASan, basically.

Reviewers: kcc, pcc, alekseyshl

Subscribers: srhines, javed.absar, cfe-commits

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

llvm-svn: 320232
2017-12-09 01:32:07 +00:00
Richard Smith d30b23d6a5 [c++2a] P0515R3: Support for overloaded operator<=>.
No CodeGen support for MSABI yet, we don't know how to mangle this there.

llvm-svn: 319513
2017-12-01 02:13:10 +00:00
Richard Smith edbf5972a4 [c++2a] P0515R3: lexer support for new <=> token.
llvm-svn: 319509
2017-12-01 01:07:10 +00:00
Saleem Abdulrasool 729379a1e1 Driver: hoist the `wchar_t` handling to the driver
Move the logic for determining the `wchar_t` type information into the
driver.  Rather than passing the single bit of information of
`-fshort-wchar` indicate to the frontend the desired type of `wchar_t`
through a new `-cc1` option of `-fwchar-type` and indicate the
signedness through `-f{,no-}signed-wchar`.  This replicates the current
logic which was spread throughout Basic into the
`RenderCharacterOptions`.

Most of the changes to the tests are to ensure that the frontend uses
the correct type.  Add a new test set under `test/Driver/wchar_t.c` to
ensure that we calculate the proper types for the various cases.

llvm-svn: 315126
2017-10-06 23:09:55 +00:00
Sjoerd Meijer cc623ad071 Recommit "Add _Float16 as a C/C++ source language type"
This is a recommit of r312781; in some build configurations
variable names are omitted, so changed the new regression
test accordingly.

llvm-svn: 312794
2017-09-08 15:15:00 +00:00
Sjoerd Meijer 9aeedde7ff Revert "Add _Float16 as a C/C++ source language type"
The clang-with-lto-ubuntu bot didn't like the new regression
test, revert while I investigate the issue.

llvm-svn: 312784
2017-09-08 10:20:52 +00:00
Sjoerd Meijer ab36f33db8 Add _Float16 as a C/C++ source language type
This adds _Float16 as a source language type, which is a 16-bit floating point
type defined in C11 extension ISO/IEC TS 18661-3.

In follow up patches documentation and more tests will be added.

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

llvm-svn: 312781
2017-09-08 09:42:32 +00:00
Richard Smith 55eb844259 Add missing test for warning added in r310803.
llvm-svn: 310978
2017-08-16 00:06:07 +00:00
Kuba Mracek 5b57633a45 [clang] Get rid of "%T" expansions
The %T lit expansion expands to a common directory shared between all the tests in the same directory, which is unexpected and unintuitive, and more importantly, it's been a source of subtle race conditions and flaky tests. In https://reviews.llvm.org/D35396, it was agreed that it would be best to simply ban %T and only keep %t, which is unique to each test. When a test needs a temporary directory, it can just create one using mkdir %t.

This patch removes %T in clang.

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

llvm-svn: 310950
2017-08-15 19:47:06 +00:00
Richard Smith cbaaa295f0 Replace remaining user-visible mentions of C++1z with C++17.
llvm-svn: 310804
2017-08-13 22:26:53 +00:00
Richard Smith 6c74e32139 [c++2a] Treat 'concept' and 'requires' as keywords, add compat warning for C++17 and before.
llvm-svn: 310803
2017-08-13 21:32:33 +00:00
Richard Smith 9d07ae77e7 Implement latest feature test macro recommendations, P0096R4.
llvm-svn: 310694
2017-08-11 03:39:40 +00:00
Tim Northover d1fafc8b05 Revert "Lexer: always allow imaginary constants in GNU mode."
This reverts r310423. It was committed by mistake, I intended to commit the
improved diagnostics for implicit conversions instead.

llvm-svn: 310426
2017-08-08 23:17:51 +00:00
Tim Northover 8fbb4c40b3 Lexer: always allow imaginary constants in GNU mode.
llvm-svn: 310423
2017-08-08 22:03:54 +00:00
Richard Smith adae25d35d Reorder tests to match latest SD-6 draft.
llvm-svn: 309054
2017-07-25 23:31:42 +00:00
Erik Verbruggen b34c79ff27 Allow for unfinished #if blocks in preambles
Previously, a preamble only included #if blocks (and friends like
ifdef) if there was a corresponding #endif before any declaration or
definition. The problem is that any header file that uses include guards
will not have a preamble generated, which can make code-completion very
slow.

To prevent errors about unbalanced preprocessor conditionals in the
preamble, and unbalanced preprocessor conditionals after a preamble
containing unfinished conditionals, the conditional stack is stored
in the pch file.

This fixes PR26045.

Differential Revision: http://reviews.llvm.org/D15994

llvm-svn: 304207
2017-05-30 11:54:55 +00:00
Eric Fiselier 4bf928282f [coroutines] Bump __cpp_coroutines version
Summary: This patch is needed so that Libc++ can actually tess if Clang supports coroutines, instead of just paying lip service with a partial implementation. Otherwise the libc++ test suite will fail against older versions of Clang

Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 303867
2017-05-25 14:58:46 +00:00
Richard Smith 4c132e576b Do not warn about whitespace between ??/ trigraph and newline in line comments if trigraphs are disabled in the current language.
llvm-svn: 300609
2017-04-18 21:45:04 +00:00
Richard Smith 1d2ae94b5d Fix mishandling of escaped newlines followed by newlines or nuls.
Previously, if an escaped newline was followed by a newline or a nul, we'd lex
the escaped newline as a bogus space character. This led to a bunch of
different broken corner cases:

For the pattern "\\\n\0#", we would then have a (horizontal) space whose
spelling ends in a newline, and would decide that the '#' is at the start of a
line, and incorrectly start preprocessing a directive in the middle of a
logical source line. If we were already in the middle of a directive, this
would result in our attempting to process multiple directives at the same time!
This resulted in crashes, asserts, and hangs on invalid input, as discovered by
fuzz-testing.

For the pattern "\\\n" at EOF (with an implicit following nul byte), we would
produce a bogus trailing space character with spelling "\\\n". This was mostly
harmless, but would lead to clang-format getting confused and misformatting in
rare cases. We now produce a trailing EOF token with spelling "\\\n",
consistent with our handling for other similar cases -- an escaped newline is
always part of the token containing the next character, if any.

For the pattern "\\\n\n", this was somewhat more benign, but would produce an
extraneous whitespace token to clients who care about preserving whitespace.
However, it turns out that our lexing for line comments was relying on this bug
due to an off-by-one error in its computation of the end of the comment, on the
slow path where the comment might contain escaped newlines.

llvm-svn: 300515
2017-04-17 23:44:51 +00:00
Sanne Wouda db1bdf472a Skip Unicode character expansion in assembly files
Summary: When using the C preprocessor with assembly files, either with a
capital `S` file extension, or with `-xassembler-with-cpp`, the Unicode escape
sequence `\u` is ignored. The `\u` pattern can be used for expanding a macro
argument that starts with `u`.

Author: Salman Arif <salman.arif@arm.com>

Reviewers: rengolin, olista01

Reviewed By: olista01

Subscribers: cfe-commits

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

llvm-svn: 299754
2017-04-07 10:13:00 +00:00
Richard Smith b80bbca254 [c++1z] Mark constexpr lambdas as done on status page and start advertising
them via feature test macro __cpp_constexpr.

Thanks to Faisal for implementing this feature!

llvm-svn: 295791
2017-02-21 23:58:29 +00:00
Taewook Oh cc89bacabe Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters
Summary: This is a patch for PR31836. As the bug replaces the path separators in the included file name with the characters following them, the test script makes sure that there's no "Ccase-insensitive-include-pr31836.h" in the warning message.

Reviewers: rsmith, eric_niebler

Reviewed By: eric_niebler

Subscribers: karies, cfe-commits

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

llvm-svn: 295779
2017-02-21 22:30:55 +00:00
Richard Smith cbe079321e [c++1z] Add some more tests for class template argument deduction, add
feature-test macro, and mark feature as done on status page.

llvm-svn: 295011
2017-02-14 00:55:25 +00:00
Richard Smith 5e29dd3fe0 P0426: Make the library implementation of constexpr char_traits a little easier
by providing a memchr builtin that returns char* instead of void*.

Also add a __has_feature flag to indicate the presence of constexpr forms of
the relevant <string> functions.

llvm-svn: 292555
2017-01-20 00:45:35 +00:00
Richard Smith dbe74e0ccd Add __cpp_structured_bindings feature test macro for structured bindings, per
latest (provisional) draft of SD-6.

llvm-svn: 290082
2016-12-19 04:21:36 +00:00
Richard Smith cb0ccb08ee [c++1z] cxx_status: mark p0195r2 as done.
llvm-svn: 290081
2016-12-19 04:16:03 +00:00
Richard Smith 6cc02c2fcd p0012r1: define corresponding feature test macro
llvm-svn: 288452
2016-12-02 02:02:23 +00:00
Richard Smith f5d8a75efa Mark aligned allocation as done.
llvm-svn: 283724
2016-10-10 06:55:42 +00:00
Gor Nishanov 4ffb434ca8 [coroutines] Rename driver flag -fcoroutines to -fcoroutines-ts
Summary:
Also makes -fcoroutines_ts to be both a Driver and CC1 flag.

Patch mostly by EricWF.

Reviewers: rnk, cfe-commits, rsmith, EricWF

Subscribers: mehdi_amini

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

llvm-svn: 283064
2016-10-02 03:31:58 +00:00
Richard Smith 27143d82f0 Mark P0127R3 as done, and replace its __has_feature check with the corresponding SD-6 macro.
llvm-svn: 282652
2016-09-29 00:08:05 +00:00
Richard Smith 6e4bedc0d7 Add a couple more tentative names for upcoming SD-6 feature checks. These might
not reflect the final chosen names, but supporting them now seems to have
little downside.

llvm-svn: 282629
2016-09-28 20:42:56 +00:00
Richard Smith 38d91d49ce P0095R3: Implement the latest published revision of SD-6 (C++ feature test macros).
llvm-svn: 282627
2016-09-28 20:26:06 +00:00
Richard Smith b02043cd0f P0096R2: Implement more recent revision of SD-6 (C++ feature test macros).
llvm-svn: 282622
2016-09-28 19:44:50 +00:00
Richard Smith c7bf3805a1 Add -fmodules-ts flag to cc1 for the provisional C++ modules TS, and mark
'module' and 'import' as keywords when the flag is specified.

llvm-svn: 276508
2016-07-23 02:32:21 +00:00
Taewook Oh f42103ce8b Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.
Differential Revision: http://reviews.llvm.org/D19843
Corresponding LLVM change: http://reviews.llvm.org/D19842

Re-commit of r272562 after addressing clang-x86-win2008-selfhost failure.

llvm-svn: 272584
2016-06-13 20:40:21 +00:00
Taewook Oh cb07d65173 Revert r272562 for build bot failure (clang-x86-win2008-selfhost)
llvm-svn: 272572
2016-06-13 18:32:30 +00:00
Taewook Oh e8533670bf Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.
Differential Revision: http://reviews.llvm.org/D19843
Corresponding LLVM change: http://reviews.llvm.org/D19842

Re-commit after addressing issues with of generating too many warnings for Windows and asan test failures.

Patch by Eric Niebler

llvm-svn: 272562
2016-06-13 17:03:18 +00:00
Taewook Oh 1c1101bb33 Revert commit r271708
llvm-svn: 271761
2016-06-04 03:14:43 +00:00
Taewook Oh fc5d13d9b1 Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.
Differential Revision: http://reviews.llvm.org/D19843
Corresponding LLVM change: http://reviews.llvm.org/D19842

Patch by Eric Niebler

llvm-svn: 271708
2016-06-03 18:52:51 +00:00
Derek Bruening 293772e72e [esan|wset] Add working set tool driver flags
Summary:
Adds a new -fsanitize=efficiency-working-set flag to enable esan's working
set tool.  Adds appropriate tests for the new flag.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits

Differential Revision: http://reviews.llvm.org/D20484

llvm-svn: 270641
2016-05-25 00:41:24 +00:00
David Majnemer 3e5e05ac68 Revert "[Lex] Support more type-traits in __has_feature"
This reverts commit r270580.  Using __has_feature to test for
type-traits is deprecated.

llvm-svn: 270583
2016-05-24 17:21:42 +00:00
David Majnemer 2ffff19134 [Lex] Support more type-traits in __has_feature
It looks like we forgot to update the __has_feature support when we
added some of the type traits.

llvm-svn: 270580
2016-05-24 16:53:13 +00:00
David Majnemer b3d96882ec Clang support for __is_assignable intrinsic
MSVC now supports the __is_assignable type trait intrinsic,
to enable easier and more efficient implementation of the
Standard Library's is_assignable trait.
As of Visual Studio 2015 Update 3, the VC Standard Library
implementation uses the new intrinsic unconditionally.

The implementation is pretty straightforward due to the previously
existing is_nothrow_assignable and is_trivially_assignable.
We handle __is_assignable via the same code as the other two except
that we skip the extra checks for nothrow or triviality.

Patch by Dave Bartolomeo!

Differential Revision: http://reviews.llvm.org/D20492

llvm-svn: 270458
2016-05-23 17:21:55 +00:00
Yaxun Liu 39cf40f6b4 [OpenCL] Add supported OpenCL extensions to target info.
Add supported OpenCL extensions to target info. It serves as default values to save the users of the burden setting each supported extensions and optional core features in command line.

Re-commit after fixing build error due to missing override attribute.

Differential Revision: http://reviews.llvm.org/D19484

llvm-svn: 269670
2016-05-16 17:06:34 +00:00
Yaxun Liu fa1df45c0d Revert "[OpenCL] Add supported OpenCL extensions to target info."
Revert r269431 due to build failure caused by warning msg:

  llvm/tools/clang/lib/Basic/Targets.cpp:2090:9: error: 'setSupportedOpenCLOpts' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
   void setSupportedOpenCLOpts() {

llvm-svn: 269435
2016-05-13 17:16:26 +00:00
Yaxun Liu 64936ce91d [OpenCL] Add supported OpenCL extensions to target info.
Add supported OpenCL extensions to target info. It serves as default values to save the users of the burden setting each supported extensions and optional core features in command line.

Differential Revision: http://reviews.llvm.org/D19484

llvm-svn: 269431
2016-05-13 15:44:37 +00:00