Skip to content

Commit 2400dc6

Browse files
committed
Merge remote-tracking branch 'llvm/release/8.x' into rustc/8.0-2019-01-16
2 parents dba9e78 + b821974 commit 2400dc6

File tree

69 files changed

+1513
-1066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1513
-1066
lines changed

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
===================================================
2-
Extra Clang Tools 8.0.0 (In-Progress) Release Notes
3-
===================================================
1+
=====================================
2+
Extra Clang Tools 8.0.0 Release Notes
3+
=====================================
44

55
.. contents::
66
:local:
77
:depth: 3
88

99
Written by the `LLVM Team <https://llvm.org/>`_
1010

11-
.. warning::
12-
13-
These are in-progress notes for the upcoming Extra Clang Tools 8 release.
14-
Release notes for previous releases can be found on
15-
`the Download Page <https://releases.llvm.org/download.html>`_.
16-
1711
Introduction
1812
============
1913

@@ -27,11 +21,6 @@ For more information about Clang or LLVM, including information about
2721
the latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or
2822
the `LLVM Web Site <https://llvm.org>`_.
2923

30-
Note that if you are reading this file from a Subversion checkout or the
31-
main Clang web page, this document applies to the *next* release, not
32-
the current one. To see the release notes for a specific release, please
33-
see the `releases page <https://llvm.org/releases/>`_.
34-
3524
What's New in Extra Clang Tools 8.0.0?
3625
======================================
3726

clang-tools-extra/docs/index.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,6 @@ Contents
2929
clang-doc
3030

3131

32-
Doxygen Documentation
33-
=====================
34-
The Doxygen documentation describes the **internal** software that makes up the
35-
tools of clang-tools-extra, not the **external** use of these tools. The Doxygen
36-
documentation contains no instructions about how to use the tools, only the APIs
37-
that make up the software. For usage instructions, please see the user's guide
38-
or reference manual for each tool.
39-
40-
* `Doxygen documentation`_
41-
42-
.. _`Doxygen documentation`: doxygen/annotated.html
43-
44-
.. note::
45-
This documentation is generated directly from the source code with doxygen.
46-
Since the tools of clang-tools-extra are constantly under active
47-
development, what you're about to read is out of date!
48-
49-
5032
Indices and tables
5133
==================
5234

clang/docs/ReleaseNotes.rst

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
=======================================
2-
Clang 8.0.0 (In-Progress) Release Notes
3-
=======================================
1+
=========================
2+
Clang 8.0.0 Release Notes
3+
=========================
44

55
.. contents::
66
:local:
77
:depth: 2
88

99
Written by the `LLVM Team <https://llvm.org/>`_
1010

11-
.. warning::
12-
13-
These are in-progress notes for the upcoming Clang 8 release.
14-
Release notes for previous releases can be found on
15-
`the Download Page <https://releases.llvm.org/download.html>`_.
16-
1711
Introduction
1812
============
1913

@@ -30,11 +24,6 @@ For more information about Clang or LLVM, including information about the
3024
latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
3125
`LLVM Web Site <https://llvm.org>`_.
3226

33-
Note that if you are reading this file from a Subversion checkout or the
34-
main Clang web page, this document applies to the *next* release, not
35-
the current one. To see the release notes for a specific release, please
36-
see the `releases page <https://llvm.org/releases/>`_.
37-
3827
What's New in Clang 8.0.0?
3928
==========================
4029

@@ -50,7 +39,38 @@ Major New Features
5039
profile data captured for one version of a program to be applied
5140
when building another version where symbols have changed (for
5241
example, due to renaming a class or namespace).
53-
See the :doc:`UsersManual` for details.
42+
See the :ref:`UsersManual <profile_remapping>` for details.
43+
44+
- Clang has new options to initialize automatic variables with either a pattern or with zeroes. The default is still that automatic variables are uninitialized. This isn't meant to change the semantics of C and C++. Rather, it's meant to be a last resort when programmers inadvertently have some undefined behavior in their code. These options aim to make undefined behavior hurt less, which security-minded people will be very happy about. Notably, this means that there's no inadvertent information leak when:
45+
46+
* The compiler re-uses stack slots, and a value is used uninitialized.
47+
48+
* The compiler re-uses a register, and a value is used uninitialized.
49+
50+
* Stack structs / arrays / unions with padding are copied.
51+
52+
These options only address stack and register information leaks.
53+
54+
Caveats:
55+
56+
* Variables declared in unreachable code and used later aren't initialized. This affects goto statements, Duff's device, and other objectionable uses of switch statements. This should instead be a hard-error in any serious codebase.
57+
58+
* These options don't affect volatile stack variables.
59+
60+
* Padding isn't fully handled yet.
61+
62+
How to use it on the command line:
63+
64+
* ``-ftrivial-auto-var-init=uninitialized`` (the default)
65+
66+
* ``-ftrivial-auto-var-init=pattern``
67+
68+
* ``-ftrivial-auto-var-init=zero`` ``-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang``
69+
70+
There is also a new attribute to request a variable to not be initialized, mainly to disable initialization of large stack arrays when deemed too expensive:
71+
72+
* ``int dont_initialize_me __attribute((uninitialized));``
73+
5474

5575
Improvements to Clang's diagnostics
5676
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -131,14 +151,24 @@ Non-comprehensive list of changes in this release
131151

132152
- Improved support for MIPS N32 ABI and MIPS R6 target triples.
133153

154+
- Clang now includes builtin functions for bitwise rotation of common value
155+
sizes, such as: `__builtin_rotateleft32
156+
<LanguageExtensions.html#builtin-rotateleft>`_
157+
158+
- Improved optimization for the corresponding MSVC compatibility builtins such
159+
as ``_rotl()``.
160+
134161
New Compiler Flags
135162
------------------
136163

164+
- ``-mspeculative-load-hardening`` Clang now has an option to enable
165+
Speculative Load Hardening.
166+
137167
- ``-fprofile-filter-files=[regexes]`` and ``-fprofile-exclude-files=[regexes]``.
138168

139169
Clang has now options to filter or exclude some files when
140170
instrumenting for gcov-based profiling.
141-
See the :doc:`UsersManual` for details.
171+
See the `UsersManual <UsersManual.html#cmdoption-fprofile-filter-files>`_ for details.
142172

143173
- When using a custom stack alignment, the ``stackrealign`` attribute is now
144174
implicitly set on the main function.
@@ -175,7 +205,9 @@ New Pragmas in Clang
175205
Attribute Changes in Clang
176206
--------------------------
177207

178-
- ...
208+
* Clang now supports enabling/disabling speculative load hardening on a
209+
per-function basis using the function attribute
210+
``speculative_load_hardening``/``no_speculative_load_hardening``.
179211

180212
Windows Support
181213
---------------

clang/docs/UsersManual.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,8 @@ In these cases, you can use the flag ``-fno-profile-instr-generate`` (or
17991799
Note that these flags should appear after the corresponding profile
18001800
flags to have an effect.
18011801

1802+
.. _profile_remapping:
1803+
18021804
Profile remapping
18031805
^^^^^^^^^^^^^^^^^
18041806

clang/include/clang/AST/Expr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,11 @@ class CallExpr : public Expr {
25772577
NumArgs = NewNumArgs;
25782578
}
25792579

2580+
/// Bluntly set a new number of arguments without doing any checks whatsoever.
2581+
/// Only used during construction of a CallExpr in a few places in Sema.
2582+
/// FIXME: Find a way to remove it.
2583+
void setNumArgsUnsafe(unsigned NewNumArgs) { NumArgs = NewNumArgs; }
2584+
25802585
typedef ExprIterator arg_iterator;
25812586
typedef ConstExprIterator const_arg_iterator;
25822587
typedef llvm::iterator_range<arg_iterator> arg_range;

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,6 @@ def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
103103
[{S->isInstanceMethod()}],
104104
"Objective-C instance methods">;
105105

106-
def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
107-
[{S->getMethodFamily() == OMF_init &&
108-
(isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
109-
(isa<ObjCCategoryDecl>(S->getDeclContext()) &&
110-
cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}],
111-
"init methods of interface or class extension declarations">;
112-
113106
def Struct : SubsetSubject<Record,
114107
[{!S->isUnion()}], "structs">;
115108

@@ -1762,7 +1755,7 @@ def ObjCExplicitProtocolImpl : InheritableAttr {
17621755

17631756
def ObjCDesignatedInitializer : Attr {
17641757
let Spellings = [Clang<"objc_designated_initializer">];
1765-
let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag>;
1758+
let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
17661759
let Documentation = [Undocumented];
17671760
}
17681761

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3460,6 +3460,9 @@ def warn_objc_secondary_init_missing_init_call : Warning<
34603460
def warn_objc_implementation_missing_designated_init_override : Warning<
34613461
"method override for the designated initializer of the superclass %objcinstance0 not found">,
34623462
InGroup<ObjCDesignatedInit>;
3463+
def err_designated_init_attr_non_init : Error<
3464+
"'objc_designated_initializer' attribute only applies to init methods "
3465+
"of interface or class extension declarations">;
34633466

34643467
// objc_bridge attribute diagnostics.
34653468
def err_objc_attr_not_id : Error<

clang/include/clang/Parse/Parser.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,6 @@ class Parser : public CodeCompletionHandler {
360360
/// just a regular sub-expression.
361361
SourceLocation ExprStatementTokLoc;
362362

363-
/// Tests whether an expression value is discarded based on token lookahead.
364-
/// It will return true if the lexer is currently processing the })
365-
/// terminating a GNU statement expression and false otherwise.
366-
bool isExprValueDiscarded();
367-
368363
public:
369364
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
370365
~Parser() override;

clang/include/clang/Sema/Sema.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,6 @@ class Sema {
13691369
void PopCompoundScope();
13701370

13711371
sema::CompoundScopeInfo &getCurCompoundScope() const;
1372-
bool isCurCompoundStmtAStmtExpr() const;
13731372

13741373
bool hasAnyUnrecoverableErrorsInThisFunction() const;
13751374

@@ -3690,17 +3689,16 @@ class Sema {
36903689
return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
36913690
}
36923691
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) {
3693-
return FullExprArg(
3694-
ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
3692+
return FullExprArg(ActOnFinishFullExpr(Arg, CC).get());
36953693
}
36963694
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg) {
36973695
ExprResult FE =
3698-
ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
3699-
/*DiscardedValue*/ true);
3696+
ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
3697+
/*DiscardedValue*/ true);
37003698
return FullExprArg(FE.get());
37013699
}
37023700

3703-
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
3701+
StmtResult ActOnExprStmt(ExprResult Arg);
37043702
StmtResult ActOnExprStmtError();
37053703

37063704
StmtResult ActOnNullStmt(SourceLocation SemiLoc,
@@ -5346,12 +5344,13 @@ class Sema {
53465344
CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary,
53475345
bool BoundToLvalueReference);
53485346

5349-
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
5350-
return ActOnFinishFullExpr(
5351-
Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
5347+
ExprResult ActOnFinishFullExpr(Expr *Expr) {
5348+
return ActOnFinishFullExpr(Expr, Expr ? Expr->getExprLoc()
5349+
: SourceLocation());
53525350
}
53535351
ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC,
5354-
bool DiscardedValue, bool IsConstexpr = false);
5352+
bool DiscardedValue = false,
5353+
bool IsConstexpr = false);
53555354
StmtResult ActOnFinishFullStmt(Stmt *Stmt);
53565355

53575356
// Marks SS invalid if it represents an incomplete type.

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,8 +1620,9 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
16201620
bool capturedByInit =
16211621
Init && emission.IsEscapingByRef && isCapturedBy(D, Init);
16221622

1623-
Address Loc =
1624-
capturedByInit ? emission.Addr : emission.getObjectAddress(*this);
1623+
bool locIsByrefHeader = !capturedByInit;
1624+
const Address Loc =
1625+
locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
16251626

16261627
// Note: constexpr already initializes everything correctly.
16271628
LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
@@ -1637,7 +1638,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
16371638
return;
16381639

16391640
// Only initialize a __block's storage: we always initialize the header.
1640-
if (emission.IsEscapingByRef)
1641+
if (emission.IsEscapingByRef && !locIsByrefHeader)
16411642
Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
16421643

16431644
CharUnits Size = getContext().getTypeSizeInChars(type);
@@ -1745,10 +1746,9 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
17451746
}
17461747

17471748
llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace());
1748-
if (Loc.getType() != BP)
1749-
Loc = Builder.CreateBitCast(Loc, BP);
1750-
1751-
emitStoresForConstant(CGM, D, Loc, isVolatile, Builder, constant);
1749+
emitStoresForConstant(
1750+
CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP),
1751+
isVolatile, Builder, constant);
17521752
}
17531753

17541754
/// Emit an expression as an initializer for an object (variable, field, etc.)

clang/lib/Frontend/TextDiagnostic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
838838
if (LangOpts.MSCompatibilityVersion &&
839839
!LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
840840
OS << ' ';
841-
OS << ": ";
841+
OS << ':';
842842
break;
843843
}
844844

clang/lib/Parse/ParseObjc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ StmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) {
27412741

27422742
// Otherwise, eat the semicolon.
27432743
ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
2744-
return Actions.ActOnExprStmt(Res, isExprValueDiscarded());
2744+
return Actions.ActOnExprStmt(Res);
27452745
}
27462746

27472747
ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
314314
Actions.ActOnOpenMPDeclareReductionCombinerStart(getCurScope(), D);
315315
ExprResult CombinerResult =
316316
Actions.ActOnFinishFullExpr(ParseAssignmentExpression().get(),
317-
D->getLocation(), /*DiscardedValue*/ false);
317+
D->getLocation(), /*DiscardedValue=*/true);
318318
Actions.ActOnOpenMPDeclareReductionCombinerEnd(D, CombinerResult.get());
319319

320320
if (CombinerResult.isInvalid() && Tok.isNot(tok::r_paren) &&
@@ -356,15 +356,15 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
356356
if (Actions.getLangOpts().CPlusPlus) {
357357
InitializerResult = Actions.ActOnFinishFullExpr(
358358
ParseAssignmentExpression().get(), D->getLocation(),
359-
/*DiscardedValue*/ false);
359+
/*DiscardedValue=*/true);
360360
} else {
361361
ConsumeToken();
362362
ParseOpenMPReductionInitializerForDecl(OmpPrivParm);
363363
}
364364
} else {
365365
InitializerResult = Actions.ActOnFinishFullExpr(
366366
ParseAssignmentExpression().get(), D->getLocation(),
367-
/*DiscardedValue*/ false);
367+
/*DiscardedValue=*/true);
368368
}
369369
Actions.ActOnOpenMPDeclareReductionInitializerEnd(
370370
D, InitializerResult.get(), OmpPrivParm);
@@ -1455,7 +1455,7 @@ ExprResult Parser::ParseOpenMPParensExpr(StringRef ClauseName,
14551455
ExprResult LHS(ParseCastExpression(
14561456
/*isUnaryExpression=*/false, /*isAddressOfOperand=*/false, NotTypeCast));
14571457
ExprResult Val(ParseRHSOfBinaryExpression(LHS, prec::Conditional));
1458-
Val = Actions.ActOnFinishFullExpr(Val.get(), ELoc, /*DiscardedValue*/ false);
1458+
Val = Actions.ActOnFinishFullExpr(Val.get(), ELoc);
14591459

14601460
// Parse ')'.
14611461
RLoc = Tok.getLocation();
@@ -1711,8 +1711,7 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind,
17111711
SourceLocation ELoc = Tok.getLocation();
17121712
ExprResult LHS(ParseCastExpression(false, false, NotTypeCast));
17131713
Val = ParseRHSOfBinaryExpression(LHS, prec::Conditional);
1714-
Val =
1715-
Actions.ActOnFinishFullExpr(Val.get(), ELoc, /*DiscardedValue*/ false);
1714+
Val = Actions.ActOnFinishFullExpr(Val.get(), ELoc);
17161715
}
17171716

17181717
// Parse ')'.
@@ -1997,8 +1996,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
19971996
Data.ColonLoc = Tok.getLocation();
19981997
SourceLocation ELoc = ConsumeToken();
19991998
ExprResult Tail = ParseAssignmentExpression();
2000-
Tail =
2001-
Actions.ActOnFinishFullExpr(Tail.get(), ELoc, /*DiscardedValue*/ false);
1999+
Tail = Actions.ActOnFinishFullExpr(Tail.get(), ELoc);
20022000
if (Tail.isUsable())
20032001
Data.TailExpr = Tail.get();
20042002
else

0 commit comments

Comments
 (0)