summaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* [backported/clang-8][CodeComplete] Generate completion fix-its for C code as ↵release_60-basedIvan Donchevskii2018-09-211-0/+19
| | | | | | | | | | | | | | | well -------------------------------------------------------------------------- * https://reviews.llvm.org/D52261 -------------------------------------------------------------------------- Current completion fix-its approach does not provide OtherOpBase for C code. But we can easily proceed in this case taking the original Base type. Task-number: QTCREATORBUG-21104 Change-Id: I11d8bc417480a50291a07267ece9ff3a071961f0 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* [backported/clang-8][libclang] Return the proper pointee type for 'auto' ↵Ivan Donchevskii2018-09-071-0/+3
| | | | | | | | | | | | | deduced to pointer -------------------------------------------------------------------------- * https://reviews.llvm.org/D51281 -------------------------------------------------------------------------- Currently the resulting type is always invalid in such case. Change-Id: Ic0c9be8c44905d286af38980e4dd65c51f64f0d9 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-8][libclang] Fix cursors for arguments of Subscript and ↵Ivan Donchevskii2018-08-281-0/+84
| | | | | | | | | | | | | | | | | | | | | Call operators -------------------------------------------------------------------------- * https://reviews.llvm.org/D40481 -------------------------------------------------------------------------- The DeclRefExpr of CXXOperatorCallExpr refering to the custom operator is visited before the arguments to the operator call. For the Call and Subscript operator the range of this DeclRefExpr includes the whole call expression, so that all tokens in that range were mapped to the operator function, even the tokens of the arguments. Fix this by ensuring that this particular DeclRefExpr is visited last. Fixes PR25775. Change-Id: If5badf4041849fd05d95d590aef0005fc3cd8451 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* [libclang] Allow skipping warnings from all included filesNikolai Kosjar2018-06-212-0/+8
| | | | | | | | | | | | | | | ------------------------------------------------------------------ * https://reviews.llvm.org/D48116 ------------------------------------------------------------------ Depending on the included files and the used warning flags, e.g. - Weverything, a huge number of warnings can be reported for included files. As processing that many diagnostics comes with a performance impact and not all clients are interested in those diagnostics, add a flag to skip them. Change-Id: Ia738a9382b43d210046bff68b3be8cb9dd89206f Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-7][libclang] Optionally add code completion results for ↵Ivan Donchevskii2018-06-141-0/+54
| | | | | | | | | | | | | | arrow instead of dot -------------------------------------------------------------------------- * https://reviews.llvm.org/D46862 -------------------------------------------------------------------------- Follow up for https://reviews.llvm.org/D41537 - libclang part is extracted into this review Change-Id: Ib166eb7b8675be605c81330df0c5f342942815ce Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-7][Sema] Don't skip function bodies with 'auto' without ↵Ilya Biryukov2018-05-312-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | trailing return type -------------------------------------------------------------------------- * https://reviews.llvm.org/D44480 -------------------------------------------------------------------------- Summary: Skipping them was clearly not intentional. It's impossible to guarantee correctness if the bodies are skipped. Also adds a test case for r327504, now that it does not produce invalid errors that made the test fail. Reviewers: aaron.ballman, sammccall, rsmith Reviewed By: rsmith Subscribers: rayglover-ibm, rwols, cfe-commits Differential Revision: https://reviews.llvm.org/D44480 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333538 91177308-0d34-0410-b5e6-96231b3b80d8 Task-number: QTCREATORBUG-20515 Change-Id: I5d60a094a967dc0e1e401256a1d70093084909f5 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-7] Optionally add code completion results for arrow ↵Ivan Donchevskii2018-05-291-0/+44
| | | | | | | | | | | | | | | | | instead of dot -------------------------------------------------------------------------- * https://reviews.llvm.org/D41537 -------------------------------------------------------------------------- Currently getting such completions requires source correction, reparsing and calling completion again. And if it shows no results and rollback is required then it costs one more reparse. With this change it's possible to get all results which can be later filtered to split changes which require correction. Change-Id: Id2fc3f0518fd53f2a6d0097da3ee723ddeb372ab Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* [backported/clang-7][libclang] Allow skipping function bodies in preamble onlyNikolai Kosjar2018-05-172-1/+15
| | | | | | | | | | | | | | | | | | | | -------------------------------------------------------------------------- * https://reviews.llvm.org/D45815 * Speed ups parse/reparse significantly but on the other hand does not issue any more diagnostics from template functions from headers. -------------------------------------------------------------------------- As an addition to CXTranslationUnit_SkipFunctionBodies, provide the new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, which constraints the skipping of functions bodies to the preamble only. Function bodies in the main file are not affected if this option is set. Skipping function bodies only in the preamble is what clangd already does and the introduced flag implements it for libclang clients. Change-Id: I092a2d78d1e59a9e546d317ee2f18c98cdc7dcdb Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-7][Frontend] Avoid running plugins during code completion ↵Nikolai Kosjar2018-05-171-0/+7
| | | | | | | | | | | | | | | | | | | | parse -------------------------------------------------------------------------- * https://reviews.llvm.org/D46050 * Fixes slow completion if tidy/clazy checks are activated. -------------------------------------------------------------------------- The parsing that is done for code completion is a special case that will discard any generated diagnostics, so avoid running plugins for this case in the first place to avoid performance penalties due to the plugins. A scenario for this is for example libclang with extra plugins like tidy. Change-Id: Ibd325f234823e4650553d2a9a3c20d993d57c87d Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Fix completion involving overloaded static functions for templatesNikolai Kosjar2018-04-201-0/+49
| | | | | | | | | | | -------------------------------------------------------------------------- * https://reviews.llvm.org/D43453 -------------------------------------------------------------------------- Apply almost the same fix as D36390 but for templates. Change-Id: I80b44d69898237f2f2b4310bc330120b7dfc49a8 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-7][libclang] Only mark CXCursors for explicit attributes ↵Nikolai Kosjar2018-04-201-0/+20
| | | | | | | | | | | | | | | | | | | | | | | with a type ------------------------------------------------------------------------- * https://reviews.llvm.org/D38615 * Fixes highlighting of classes e.g. in Qt Creator's texteditor.cpp. ------------------------------------------------------------------------- All attributes have a source range associated with it. However, implicit attributes are added by the compiler, and not added because the user wrote something in the input. So no token type should be set to CXCursor_*Attr. The problem was visible when a class gets marked by e.g. MSInheritanceAttr, which has the full CXXRecordDecl's range as its own range. The effect of marking that range as CXCursor_UnexposedAttr was that all cursors for the record decl, including all child decls, would become CXCursor_UnexposedAttr. Change-Id: If447dd6f21611adff8eaa2752eba2109e2f7ef35 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-7][libclang] Add PrintingPolicy for pretty printing ↵Nikolai Kosjar2018-04-191-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | declarations ------------------------------------------------------------------------- * Improves pretty printing for Qt Creator's tooltips. ------------------------------------------------------------------------- Summary: Introduce clang_getCursorPrettyPrinted() for pretty printing declarations. Expose also PrintingPolicy, so the user gets more fine-grained control of the entities being printed. The already existing clang_getCursorDisplayName() is pretty limited - for example, it does not handle return types, parameter names or default arguments for function declarations. Addressing these issues in clang_getCursorDisplayName() would mean to duplicate existing code (e.g. clang::DeclPrinter), so rather expose new API to access the existing functionality. Reviewed By: jbcoe Subscribers: cfe-commits Tags: #clang Patch by nik (Nikolai Kosjar) Differential Revision: https://reviews.llvm.org/D39903 Change-Id: I509a01bb5a1e4e1d899c2725f50ed78e482c075f Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* [backported/clang-7][libclang] Support querying whether a declaration is invalidNikolai Kosjar2018-04-192-17/+17
| | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ * Enables fix for https://bugreports.qt.io/browse/QTCREATORBUG-18686 ------------------------------------------------------------------------ This is useful for e.g. highlighting purposes in an IDE. Note: First version of this patch was reverted due to failing tests in opencl-types.cl with -target ppc64le-unknown-linux. These tests are adapted now. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40072 Change-Id: Iac9d51f729bda7493c56d4d14f9bc1ff2891b465 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* Merging r325651:Simon Dardis2018-04-112-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r325651 | sdardis | 2018-02-21 00:05:05 +0000 (Wed, 21 Feb 2018) | 34 lines [mips] Spectre variant two mitigation for MIPSR2 This patch provides mitigation for CVE-2017-5715, Spectre variant two, which affects the P5600 and P6600. It provides the option -mindirect-jump=hazard, which instructs the LLVM backend to replace indirect branches with their hazard barrier variants. This option is accepted when targeting MIPS revision two or later. The migitation strategy suggested by MIPS for these processors is to use two hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard barrier variants of the 'jalr' and 'jr' instructions respectively. These instructions impede the execution of instruction stream until architecturally defined hazards (changes to the instruction stream, privileged registers which may affect execution) are cleared. These instructions in MIPS' designs are not speculated past. These instructions are used with the option -mindirect-jump=hazard when branching indirectly and for indirect function calls. These instructions are defined by the MIPS32R2 ISA, so this mitigation method is not compatible with processors which implement an earlier revision of the MIPS ISA. Implementation note: I've opted to provide this as an -mindirect-jump={hazard,...} style option in case alternative mitigation methods are required for other implementations of the MIPS ISA in future, e.g. retpoline style solutions. Reviewers: atanasyan Differential Revision: https://reviews.llvm.org/D43487 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@329799 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r328829:Tom Stellard2018-04-101-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r328829 | manojgupta | 2018-03-29 14:11:15 -0700 (Thu, 29 Mar 2018) | 23 lines [AArch64]: Add support for parsing rN registers. Summary: Allow rN registers to be simply parsed as correspoing xN registers. The "register ... asm("rN")" is an command to the compiler's register allocator, not an operand to any individual assembly instruction. GCC documents this syntax as "...the name of the register that should be used." This is needed to support the changes in Linux kernel (see https://lkml.org/lkml/2018/3/1/268 ) Note: This will add support only for the limited use case of register ... asm("rN"). Any other uses that make rN leak into assembly are not supported. Reviewers: kristof.beyls, rengolin, peter.smith, t.p.northover Reviewed By: peter.smith Subscribers: javed.absar, eraman, cfe-commits, srhines Differential Revision: https://reviews.llvm.org/D44815 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@329669 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r327099:Tom Stellard2018-04-071-0/+4
| | | | | | | | | | | | ------------------------------------------------------------------------ r327099 | rsmith | 2018-03-08 18:00:01 -0800 (Thu, 08 Mar 2018) | 3 lines PR36645: Go looking for an appropriate array bound when constant-evaluating a name of an array object. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@329478 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324308:Hans Wennborg2018-02-221-0/+15
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r324308 | rtrieu | 2018-02-06 03:58:21 +0100 (Tue, 06 Feb 2018) | 4 lines Fix crash on invalid. Don't call a method when the pointer is null. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325766 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r325655:Hans Wennborg2018-02-211-2/+2
| | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r325655 | ctopper | 2018-02-21 01:16:50 +0100 (Wed, 21 Feb 2018) | 8 lines [X86] Disable CLWB in Cannon Lake Cannon Lake does not support CLWB, therefore it does not include all features listed under SKX. Patch by Gabor Buella Differential Revision: https://reviews.llvm.org/D43459 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325672 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r325576:Hans Wennborg2018-02-201-36/+4
| | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r325576 | hans | 2018-02-20 13:43:02 +0100 (Tue, 20 Feb 2018) | 13 lines Revert r325375 "[MS] Make constexpr static data members implicitly inline" This broke Clang bootstrap on Windows, PR36453. > This handles them exactly the same way that we handle const integral > static data members with inline definitions, which is what MSVC does. > > As a follow-up, now that we have a way to mark variables inline in the > AST, we should consider marking them implicitly inline there instead of > only treating them as inline in CodeGen. Unfortunately, this breaks a > lot of dllimport test cases, so that is future work for now. > > Fixes PR36125. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325577 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r325375:Hans Wennborg2018-02-191-4/+36
| | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r325375 | rnk | 2018-02-16 20:44:47 +0100 (Fri, 16 Feb 2018) | 11 lines [MS] Make constexpr static data members implicitly inline This handles them exactly the same way that we handle const integral static data members with inline definitions, which is what MSVC does. As a follow-up, now that we have a way to mark variables inline in the AST, we should consider marking them implicitly inline there instead of only treating them as inline in CodeGen. Unfortunately, this breaks a lot of dllimport test cases, so that is future work for now. Fixes PR36125. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325500 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r319777 for PR36357Hans Wennborg2018-02-142-26/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325114 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r323998:Hans Wennborg2018-02-142-0/+13
| | | | | | | | | | | | | | | ------------------------------------------------------------------------ r323998 | rsmith | 2018-02-01 21:01:49 +0100 (Thu, 01 Feb 2018) | 5 lines PR36157: When injecting an implicit function declaration in C89, find the right DeclContext rather than injecting it wherever we happen to be. This avoids creating functions whose DeclContext is a struct or similar. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@325104 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324537:Hans Wennborg2018-02-092-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r324537 | rsmith | 2018-02-07 23:25:16 +0100 (Wed, 07 Feb 2018) | 14 lines PR36055: fix computation of *-dependence in nested initializer lists. When we synthesize an implicit inner initializer list when analyzing an outer initializer list, we add it to the outer list immediately, and then fill in the inner list. This gives the outer list no chance to update its *-dependence bits with those of the completed inner list. To fix this, re-add the inner list to the outer list once it's completed. Note that we do not recompute the *-dependence bits from scratch when we complete an outer list; this would give the wrong result for the case where a designated initializer overwrites a dependent initializer with a non-dependent one. The resulting list in that case should still be dependent, even though all traces of the dependence were removed from the semantic form. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324719 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324594:Hans Wennborg2018-02-091-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r324594 | aivchenk | 2018-02-08 12:15:21 +0100 (Thu, 08 Feb 2018) | 17 lines Fix for #31362 - ms_abi is implemented incorrectly for values >=16 bytes. Summary: This patch is a fix for following issue: https://bugs.llvm.org/show_bug.cgi?id=31362 The problem was caused by front end lowering C calling conventions without taking into account calling conventions enforced by attribute. In this case win64cc was no correctly lowered on targets other than Windows. Reviewed By: rnk (Reid Kleckner) Differential Revision: https://reviews.llvm.org/D43016 Author: belickim <mateusz.belicki@intel.com> ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324718 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324514:Hans Wennborg2018-02-081-0/+13
| | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r324514 | arphaman | 2018-02-07 21:45:39 +0100 (Wed, 07 Feb 2018) | 10 lines [PR36008] Avoid -Wsign-compare warning for enum constants in typeof expressions This commit looks through typeof type at the original expression when diagnosing -Wsign-compare to avoid an unfriendly diagnostic. rdar://36588828 Differential Revision: https://reviews.llvm.org/D42561 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324602 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324419:Hans Wennborg2018-02-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r324419 | vsapsai | 2018-02-06 23:39:25 +0100 (Tue, 06 Feb 2018) | 23 lines [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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324579 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324439:Hans Wennborg2018-02-071-0/+28
| | | | | | | | | | | | | | | ------------------------------------------------------------------------ r324439 | compnerd | 2018-02-07 02:55:08 +0100 (Wed, 07 Feb 2018) | 5 lines AST: support SwiftCC on MS ABI Microsoft has reserved the identifier 'S' as the swift calling convention. Decorate the symbols appropriately. This enables swift on Windows. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324460 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324059:Hans Wennborg2018-02-052-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r324059 | mstorsjo | 2018-02-02 07:22:35 +0100 (Fri, 02 Feb 2018) | 21 lines [MinGW] Emit typeinfo locally for dllimported classes without key functions This fixes building Qt as shared libraries with clang in MinGW mode; previously subclasses of the QObjectData class (in other DLLs than the base DLL) failed to find the typeinfo symbols (that neither were emitted in the base DLL nor in the DLL containing the subclass). If the virtual destructor in the newly added testcase wouldn't be pure (or if there'd be another non-pure virtual method), it'd be a key function and things would work out even before this change. Make sure to locally emit the typeinfo for these classes as well. This matches what GCC does in this specific testcase. This fixes the root issue that spawned PR35146. (The difference to GCC that is initially described in that bug still is present though.) Differential Revision: https://reviews.llvm.org/D42641 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324219 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r323935:Hans Wennborg2018-02-051-0/+11
| | | | | | | | | | | | | | | ------------------------------------------------------------------------ r323935 | rsmith | 2018-02-01 01:28:36 +0100 (Thu, 01 Feb 2018) | 5 lines PR36181: Teach CodeGen to properly ignore requests to emit dependent entities. Previously, friend function definitions within class templates slipped through the gaps and caused the MS mangler to assert. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324215 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r324134:Hans Wennborg2018-02-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r324134 | ericwf | 2018-02-02 21:30:39 +0100 (Fri, 02 Feb 2018) | 14 lines Make __has_unique_object_representations reject empty union types. Summary: Clang incorrectly reports empty unions as having a unique object representation. However, this is not correct since `sizeof(EmptyUnion) == 1` AKA it has 8 bits of padding. Therefore it should be treated the same as an empty struct and report `false`. @erichkeane also suggested this fix should be merged into the 6.0 release branch, so the initial release of `__has_unique_object_representations` is as bug-free as possible. Reviewers: erichkeane, rsmith, aaron.ballman, majnemer Reviewed By: erichkeane Subscribers: cfe-commits, erichkeane Differential Revision: https://reviews.llvm.org/D42863 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324213 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r323155:Hans Wennborg2018-02-021-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r323155 | chandlerc | 2018-01-22 23:05:25 +0100 (Mon, 22 Jan 2018) | 133 lines Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target Injection", and is one of the two halves to Spectre.. Summary: First, we need to explain the core of the vulnerability. Note that this is a very incomplete description, please see the Project Zero blog post for details: https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html The basis for branch target injection is to direct speculative execution of the processor to some "gadget" of executable code by poisoning the prediction of indirect branches with the address of that gadget. The gadget in turn contains an operation that provides a side channel for reading data. Most commonly, this will look like a load of secret data followed by a branch on the loaded value and then a load of some predictable cache line. The attacker then uses timing of the processors cache to determine which direction the branch took *in the speculative execution*, and in turn what one bit of the loaded value was. Due to the nature of these timing side channels and the branch predictor on Intel processors, this allows an attacker to leak data only accessible to a privileged domain (like the kernel) back into an unprivileged domain. The goal is simple: avoid generating code which contains an indirect branch that could have its prediction poisoned by an attacker. In many cases, the compiler can simply use directed conditional branches and a small search tree. LLVM already has support for lowering switches in this way and the first step of this patch is to disable jump-table lowering of switches and introduce a pass to rewrite explicit indirectbr sequences into a switch over integers. However, there is no fully general alternative to indirect calls. We introduce a new construct we call a "retpoline" to implement indirect calls in a non-speculatable way. It can be thought of loosely as a trampoline for indirect calls which uses the RET instruction on x86. Further, we arrange for a specific call->ret sequence which ensures the processor predicts the return to go to a controlled, known location. The retpoline then "smashes" the return address pushed onto the stack by the call with the desired target of the original indirect call. The result is a predicted return to the next instruction after a call (which can be used to trap speculative execution within an infinite loop) and an actual indirect branch to an arbitrary address. On 64-bit x86 ABIs, this is especially easily done in the compiler by using a guaranteed scratch register to pass the target into this device. For 32-bit ABIs there isn't a guaranteed scratch register and so several different retpoline variants are introduced to use a scratch register if one is available in the calling convention and to otherwise use direct stack push/pop sequences to pass the target address. This "retpoline" mitigation is fully described in the following blog post: https://support.google.com/faqs/answer/7625886 We also support a target feature that disables emission of the retpoline thunk by the compiler to allow for custom thunks if users want them. These are particularly useful in environments like kernels that routinely do hot-patching on boot and want to hot-patch their thunk to different code sequences. They can write this custom thunk and use `-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this case, on x86-64 thu thunk names must be: ``` __llvm_external_retpoline_r11 ``` or on 32-bit: ``` __llvm_external_retpoline_eax __llvm_external_retpoline_ecx __llvm_external_retpoline_edx __llvm_external_retpoline_push ``` And the target of the retpoline is passed in the named register, or in the case of the `push` suffix on the top of the stack via a `pushl` instruction. There is one other important source of indirect branches in x86 ELF binaries: the PLT. These patches also include support for LLD to generate PLT entries that perform a retpoline-style indirection. The only other indirect branches remaining that we are aware of are from precompiled runtimes (such as crt0.o and similar). The ones we have found are not really attackable, and so we have not focused on them here, but eventually these runtimes should also be replicated for retpoline-ed configurations for completeness. For kernels or other freestanding or fully static executables, the compiler switch `-mretpoline` is sufficient to fully mitigate this particular attack. For dynamic executables, you must compile *all* libraries with `-mretpoline` and additionally link the dynamic executable and all shared libraries with LLD and pass `-z retpolineplt` (or use similar functionality from some other linker). We strongly recommend also using `-z now` as non-lazy binding allows the retpoline-mitigated PLT to be substantially smaller. When manually apply similar transformations to `-mretpoline` to the Linux kernel we observed very small performance hits to applications running typical workloads, and relatively minor hits (approximately 2%) even for extremely syscall-heavy applications. This is largely due to the small number of indirect branches that occur in performance sensitive paths of the kernel. When using these patches on statically linked applications, especially C++ applications, you should expect to see a much more dramatic performance hit. For microbenchmarks that are switch, indirect-, or virtual-call heavy we have seen overheads ranging from 10% to 50%. However, real-world workloads exhibit substantially lower performance impact. Notably, techniques such as PGO and ThinLTO dramatically reduce the impact of hot indirect calls (by speculatively promoting them to direct calls) and allow optimized search trees to be used to lower switches. If you need to deploy these techniques in C++ applications, we *strongly* recommend that you ensure all hot call targets are statically linked (avoiding PLT indirection) and use both PGO and ThinLTO. Well tuned servers using all of these techniques saw 5% - 10% overhead from the use of retpoline. We will add detailed documentation covering these components in subsequent patches, but wanted to make the core functionality available as soon as possible. Happy for more code review, but we'd really like to get these patches landed and backported ASAP for obvious reasons. We're planning to backport this to both 6.0 and 5.0 release streams and get a 5.0 release with just this cherry picked ASAP for distros and vendors. This patch is the work of a number of people over the past month: Eric, Reid, Rui, and myself. I'm mailing it out as a single commit due to the time sensitive nature of landing this and the need to backport it. Huge thanks to everyone who helped out here, and everyone at Intel who helped out in discussions about how to craft this. Also, credit goes to Paul Turner (at Google, but not an LLVM contributor) for much of the underlying retpoline design. Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D41723 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324068 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r323360:Hans Wennborg2018-01-301-2/+7
| | | | | | | | | | | | ------------------------------------------------------------------------ r323360 | kparzysz | 2018-01-24 19:42:19 +0100 (Wed, 24 Jan 2018) | 2 lines [Hexagon] Accept lowercase b in -hvx-length=64b and -hvx-length=128b ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@323769 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r323485:Hans Wennborg2018-01-301-0/+24
| | | | | | | | | | | | | ------------------------------------------------------------------------ r323485 | aemerson | 2018-01-26 01:27:22 +0100 (Fri, 26 Jan 2018) | 3 lines [Driver] Add an -fexperimental-isel driver option to enable/disable GlobalISel. Differential Revision: https://reviews.llvm.org/D42276 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@323745 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r323008:Hans Wennborg2018-01-242-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r323008 | vsapsai | 2018-01-20 00:41:47 +0100 (Sat, 20 Jan 2018) | 32 lines [Lex] Fix crash on code completion in comment in included file. This fixes PR32732 by updating CurLexerKind to reflect available lexers. We were hitting null pointer in Preprocessor::Lex because CurLexerKind was CLK_Lexer but CurLexer was null. And we set it to null in Preprocessor::HandleEndOfFile when exiting a file with code completion point. To reproduce the crash it is important for a comment to be inside a class specifier. In this case in Parser::ParseClassSpecifier we improve error recovery by pushing a semicolon token back into the preprocessor and later on try to lex a token because we haven't reached the end of file. Also clang crashes only on code completion in included file, i.e. when IncludeMacroStack is not empty. Though we reset CurLexer even if include stack is empty. The difference is that during pushing back a semicolon token, preprocessor calls EnterCachingLexMode which decides it is already in caching mode because various lexers are null and IncludeMacroStack is not empty. As the result, CurLexerKind remains CLK_Lexer instead of updating to CLK_CachingLexer. rdar://problem/34787685 Reviewers: akyrtzi, doug.gregor, arphaman Reviewed By: arphaman Subscribers: cfe-commits, kfunk, arphaman, nemanjai, kbarton Differential Revision: https://reviews.llvm.org/D41688 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@323333 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r322984:Hans Wennborg2018-01-221-0/+119
| | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r322984 | rtrieu | 2018-01-19 21:46:19 +0100 (Fri, 19 Jan 2018) | 7 lines Allow BlockDecl in CXXRecord scope to have no access specifier. Using a BlockDecl in a default member initializer causes it to be attached to CXXMethodDecl without its access specifier being set. This prevents a crash where getAccess is called on this BlockDecl, since that method expects any Decl in CXXRecord scope to have an access specifier. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@323108 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r322901:Hans Wennborg2018-01-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r322901 | nico | 2018-01-18 13:40:27 -0800 (Thu, 18 Jan 2018) | 19 lines Remove TautologicalInRangeCompare from Extra and TautologicalCompare. This removes the following (already default-off) warnings from -Wextra: -Wtautological-type-limit-compare, -Wtautological-unsigned-zero-compare -Wtautological-unsigned-enum-zero-compare On the thread "[cfe-dev] -Wtautological-constant-compare issues", clang code owners Richard Smith, John McCall, and Reid Kleckner as well as libc++ code owner Marshall Clow stated that these new warnings are not yet ready for prime time and shouldn't be part of -Wextra. Furthermore, Vedant Kumar (Apple), Peter Hosek (Fuchsia), and me (Chromium) expressed the same concerns (Vedant on that thread, Peter on https://reviews.llvm.org/D39462, me on https://reviews.llvm.org/D41512). So remove them from -Wextra, and remove TautologicalInRangeCompare from TautologicalCompare too until they're usable with real-world code. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322931 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r321779:Hans Wennborg2018-01-171-0/+11
| | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r321779 | rsmith | 2018-01-03 17:24:17 -0800 (Wed, 03 Jan 2018) | 7 lines PR35045: Convert injected-class-name to its corresponding simple-template-id during template argument deduction. We already did this when the injected-class-name was in P, but missed the case where it was in A. This (probably) can't happen except in implicit deduction guides. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322677 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r321777:Hans Wennborg2018-01-171-0/+11
| | | | | | | | | | | | ------------------------------------------------------------------------ r321777 | rsmith | 2018-01-03 17:02:18 -0800 (Wed, 03 Jan 2018) | 2 lines PR35028: Retain duplicate alignas attributes in template instantiation. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322676 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r322390:Hans Wennborg2018-01-171-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r322390 | vsapsai | 2018-01-12 10:54:35 -0800 (Fri, 12 Jan 2018) | 20 lines [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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322649 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r322236:Hans Wennborg2018-01-172-0/+19
| | | | | | | | | | | | | ------------------------------------------------------------------------ r322236 | rsmith | 2018-01-10 15:08:26 -0800 (Wed, 10 Jan 2018) | 3 lines In C++17, when instantiating an out-of-line definition of an inline static data member, don't forget to instantiate the initializer too. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322641 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r322350, r322405, r322420, r322593:Hans Wennborg2018-01-176-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r322350 | rtrieu | 2018-01-11 20:42:27 -0800 (Thu, 11 Jan 2018) | 6 lines [ODRHash] Don't hash friend functions. In certain combinations of templated classes and friend functions, the body of friend functions does not get propagated along with function signature. Exclude friend functions for hashing to avoid this case. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r322405 | rtrieu | 2018-01-12 13:49:20 -0800 (Fri, 12 Jan 2018) | 2 lines Disable test for Windows to fix Windows buildbots. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r322420 | rtrieu | 2018-01-12 15:13:33 -0800 (Fri, 12 Jan 2018) | 2 lines Try to suppress Windows testing again. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r322593 | rtrieu | 2018-01-16 11:53:06 -0800 (Tue, 16 Jan 2018) | 6 lines Add context to why test was disabled on Windows test/Modules/odr_hash-Friend.cpp triggers an assertion in MicrosoftMangle.cpp This has been reported in PR35939 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322632 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r321754:Hans Wennborg2018-01-163-3/+19
| | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r321754 | adrian | 2018-01-03 11:10:21 -0800 (Wed, 03 Jan 2018) | 9 lines -gmodules: Emit debug info for implicit module imports via #include. When a type is only used as a template parameter and that type is the only type imported from another #include'd module, no skeleton CU for that module is generated, so a consumer doesn't know where to find the type definition. By emitting an import declaration, we can force a skeleton CU to be generated for each imported module. rdar://problem/36266156 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322557 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r321771:Hans Wennborg2018-01-161-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r321771 | vedantk | 2018-01-03 15:11:32 -0800 (Wed, 03 Jan 2018) | 21 lines [CGBuiltin] Handle unsigned mul overflow properly (PR35750) r320902 fixed the IRGen for some types of checked multiplications. It did not handle unsigned overflow correctly in the case where the signed operand is negative (PR35750). Eli pointed out that on overflow, the result must be equal to the unique value that is equivalent to the mathematically-correct result modulo two raised to the k power, where k is the number of bits in the result type. This patch fixes the specialized IRGen from r320902 accordingly. Testing: Apart from check-clang, I modified the test harness from r320902 to validate the results of all multiplications -- not just the ones which don't overflow: https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081 llvm.org/PR35750, rdar://34963321 Differential Revision: https://reviews.llvm.org/D41717 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322555 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r321933:Hans Wennborg2018-01-161-7/+0
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r321933 | xazax | 2018-01-06 02:51:00 -0800 (Sat, 06 Jan 2018) | 4 lines [analyzer] Fix some check's output plist not containing the check name Differential Revision: https://reviews.llvm.org/D41538 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322550 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r322518:Hans Wennborg2018-01-162-32/+10
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r322518 | erichkeane | 2018-01-15 13:16:25 -0800 (Mon, 15 Jan 2018) | 4 lines Revert 319303: Add _Float128 as alias to __float128 to enable compilations on Fedora27/glibc2 Differential Revision: https://reviews.llvm.org/D40673 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@322539 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Fix cursors for functions with trailing return typeIvan Donchevskii2018-01-031-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This one was rolled back as follow-up to the failing commit. Second try. For the function declaration auto foo5(Foo) -> Foo; the parameter tokens were mapped to cursors representing the FunctionDecl: Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 Punctuation: ";" [1:19 - 1:20] Fix this by ensuring that the trailing return type is not visited as first. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40561 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321709 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r321697 "[libclang] Support querying whether a declaration is ↵Hans Wennborg2018-01-032-13/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | invalid" and follow-ups. This broke test/Index/opencl-types.cl on several buildbots: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/3294 http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/6498 http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/5239 > [libclang] Support querying whether a declaration is invalid > > This is useful for e.g. highlighting purposes in an IDE. > > Patch by Nikolai Kosjar. > > Differential Revision: https://reviews.llvm.org/D40072 Also reverting follow-ups that otherwise caused conflicts for the revert: r321700 "Fix line endings." r321701 "Fix more line endings." r321698 "[libclang] Fix cursors for functions with trailing return type" > For the function declaration > > auto foo5(Foo) -> Foo; > the parameter tokens were mapped to cursors representing the > FunctionDecl: > > Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 > Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 > Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 > Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef > Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 > Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 > Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 > Punctuation: ";" [1:19 - 1:20] > > Fix this by ensuring that the trailing return type is not visited as > first. > > Patch by Nikolai Kosjar. > > Differential Revision: https://reviews.llvm.org/D40561 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321708 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix line endings.Ivan Donchevskii2018-01-032-31/+31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321700 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Fix cursors for functions with trailing return typeIvan Donchevskii2018-01-031-13/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | For the function declaration auto foo5(Foo) -> Foo; the parameter tokens were mapped to cursors representing the FunctionDecl: Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 Punctuation: ";" [1:19 - 1:20] Fix this by ensuring that the trailing return type is not visited as first. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40561 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321698 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Support querying whether a declaration is invalidIvan Donchevskii2018-01-031-8/+8
| | | | | | | | | | This is useful for e.g. highlighting purposes in an IDE. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40072 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321697 91177308-0d34-0410-b5e6-96231b3b80d8