<div dir="ltr"><div><div><div><div>Hello Eugene,<br><br></div>This commit broke the following tests:</div><div><br></div><div> Clang :: CodeCompletion/member-access.cpp<br> Clang :: Index/complete-call.cpp<br><br>Please see, for example<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/6231/steps/test-check-all/logs/stdio">http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/6231/steps/test-check-all/logs/stdio</a><br><br></div>Could you take care of this, please?<br></div><div><br></div><div>Feel free to let me know if you need intermediate files from that bot.<br></div><div><br></div>Thanks<br><br></div>Galina<br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 15, 2017 at 2:00 PM, Eugene Zelenko via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: eugenezelenko<br>
Date: Wed Nov 15 14:00:04 2017<br>
New Revision: 318341<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=318341&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=318341&view=rev</a><br>
Log:<br>
[AST, Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).<br>
<br>
Modified:<br>
cfe/trunk/include/clang/AST/<wbr>Expr.h<br>
cfe/trunk/lib/AST/Expr.cpp<br>
cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/<wbr>Expr.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=318341&r1=318340&r2=318341&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/AST/Expr.h?rev=318341&<wbr>r1=318340&r2=318341&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/AST/<wbr>Expr.h (original)<br>
+++ cfe/trunk/include/clang/AST/<wbr>Expr.h Wed Nov 15 14:00:04 2017<br>
@@ -1,4 +1,4 @@<br>
-//===--- Expr.h - Classes for representing expressions ----------*- C++ -*-===//<br>
+//===- Expr.h - Classes for representing expressions ------------*- C++ -*-===//<br>
//<br>
// The LLVM Compiler Infrastructure<br>
//<br>
@@ -18,42 +18,56 @@<br>
#include "clang/AST/ASTVector.h"<br>
#include "clang/AST/Decl.h"<br>
#include "clang/AST/DeclAccessPair.h"<br>
+#include "clang/AST/DeclarationName.h"<br>
+#include "clang/AST/<wbr>NestedNameSpecifier.h"<br>
#include "clang/AST/OperationKinds.h"<br>
#include "clang/AST/Stmt.h"<br>
#include "clang/AST/TemplateBase.h"<br>
#include "clang/AST/Type.h"<br>
#include "clang/Basic/CharInfo.h"<br>
+#include "clang/Basic/LLVM.h"<br>
#include "clang/Basic/LangOptions.h"<br>
+#include "clang/Basic/OperatorKinds.h"<br>
+#include "clang/Basic/SourceLocation.h"<br>
+#include "clang/Basic/Specifiers.h"<br>
#include "clang/Basic/SyncScope.h"<br>
#include "clang/Basic/TypeTraits.h"<br>
#include "llvm/ADT/APFloat.h"<br>
+#include "llvm/ADT/APInt.h"<br>
#include "llvm/ADT/APSInt.h"<br>
+#include "llvm/ADT/ArrayRef.h"<br>
+#include "llvm/ADT/None.h"<br>
+#include "llvm/ADT/PointerIntPair.h"<br>
+#include "llvm/ADT/PointerUnion.h"<br>
#include "llvm/ADT/SmallVector.h"<br>
#include "llvm/ADT/StringRef.h"<br>
-#include "llvm/Support/AtomicOrdering.<wbr>h"<br>
+#include "llvm/ADT/iterator_range.h"<br>
+#include "llvm/Support/Casting.h"<br>
#include "llvm/Support/Compiler.h"<br>
+#include "llvm/Support/ErrorHandling.h"<br>
+#include "llvm/Support/TrailingObjects.<wbr>h"<br>
+#include <cassert><br>
+#include <cstddef><br>
+#include <cstdint><br>
+#include <memory><br>
+#include <string><br>
<br>
namespace clang {<br>
- class APValue;<br>
- class ASTContext;<br>
- class BlockDecl;<br>
- class CXXBaseSpecifier;<br>
- class CXXMemberCallExpr;<br>
- class CXXOperatorCallExpr;<br>
- class CastExpr;<br>
- class Decl;<br>
- class IdentifierInfo;<br>
- class MaterializeTemporaryExpr;<br>
- class NamedDecl;<br>
- class ObjCPropertyRefExpr;<br>
- class OpaqueValueExpr;<br>
- class ParmVarDecl;<br>
- class StringLiteral;<br>
- class TargetInfo;<br>
- class ValueDecl;<br>
+<br>
+class ASTContext;<br>
+class CastExpr;<br>
+class CXXBaseSpecifier;<br>
+class CXXRecordDecl;<br>
+class Decl;<br>
+class Expr;<br>
+class IdentifierInfo;<br>
+class ObjCPropertyRefExpr;<br>
+class SourceManager;<br>
+class StringLiteral;<br>
+class TargetInfo;<br>
<br>
/// \brief A simple array of base specifiers.<br>
-typedef SmallVector<CXXBaseSpecifier*, 4> CXXCastPath;<br>
+using CXXCastPath = SmallVector<CXXBaseSpecifier *, 4>;<br>
<br>
/// \brief An adjustment to be made to the temporary created when emitting a<br>
/// reference binding, which accesses a particular subobject of that temporary.<br>
@@ -82,18 +96,17 @@ struct SubobjectAdjustment {<br>
<br>
SubobjectAdjustment(const CastExpr *BasePath,<br>
const CXXRecordDecl *DerivedClass)<br>
- : Kind(DerivedToBaseAdjustment) {<br>
+ : Kind(DerivedToBaseAdjustment) {<br>
DerivedToBase.BasePath = BasePath;<br>
DerivedToBase.DerivedClass = DerivedClass;<br>
}<br>
<br>
- SubobjectAdjustment(FieldDecl *Field)<br>
- : Kind(FieldAdjustment) {<br>
+ SubobjectAdjustment(FieldDecl *Field) : Kind(FieldAdjustment) {<br>
this->Field = Field;<br>
}<br>
<br>
SubobjectAdjustment(const MemberPointerType *MPT, Expr *RHS)<br>
- : Kind(MemberPointerAdjustment) {<br>
+ : Kind(MemberPointerAdjustment) {<br>
this->Ptr.MPT = MPT;<br>
this->Ptr.RHS = RHS;<br>
}<br>
@@ -109,8 +122,7 @@ class Expr : public Stmt {<br>
protected:<br>
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,<br>
bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPac<wbr>k)<br>
- : Stmt(SC)<br>
- {<br>
+ : Stmt(SC) {<br>
ExprBits.TypeDependent = TD;<br>
ExprBits.ValueDependent = VD;<br>
ExprBits.<wbr>InstantiationDependent = ID;<br>
@@ -122,10 +134,11 @@ protected:<br>
}<br>
<br>
/// \brief Construct an empty expression.<br>
- explicit Expr(StmtClass SC, EmptyShell) : Stmt(SC) { }<br>
+ explicit Expr(StmtClass SC, EmptyShell) : Stmt(SC) {}<br>
<br>
public:<br>
QualType getType() const { return TR; }<br>
+<br>
void setType(QualType t) {<br>
// In C++, the type of an expression is always adjusted so that it<br>
// will not have reference type (C++ [expr]p6). Use<br>
@@ -187,7 +200,6 @@ public:<br>
/// sizeof(sizeof(T() + T());<br>
/// }<br>
/// \endcode<br>
- ///<br>
bool isInstantiationDependent() const {<br>
return ExprBits.<wbr>InstantiationDependent;<br>
}<br>
@@ -263,6 +275,7 @@ public:<br>
LV_ClassTemporary,<br>
LV_ArrayTemporary<br>
};<br>
+<br>
/// Reasons why an expression might not be an l-value.<br>
LValueClassification ClassifyLValue(ASTContext &Ctx) const;<br>
<br>
@@ -285,6 +298,7 @@ public:<br>
MLV_ClassTemporary,<br>
MLV_ArrayTemporary<br>
};<br>
+<br>
/// isModifiableLvalue - C99 <a href="http://6.3.2.1" rel="noreferrer" target="_blank">6.3.2.1</a>: an lvalue that does not have array type,<br>
/// does not have an incomplete type, does not have a const-qualified type,<br>
/// and if it is a structure or union, does not have any member (including,<br>
@@ -316,6 +330,7 @@ public:<br>
CL_ObjCMessageRValue, // ObjC message is an rvalue<br>
CL_PRValue // A prvalue for any other reason, of any other type<br>
};<br>
+<br>
/// \brief The results of modification testing.<br>
enum ModifiableType {<br>
CM_Untested, // testModifiable was false.<br>
@@ -338,17 +353,18 @@ public:<br>
unsigned short Modifiable;<br>
<br>
explicit Classification(Kinds k, ModifiableType m)<br>
- : Kind(k), Modifiable(m)<br>
- {}<br>
+ : Kind(k), Modifiable(m) {}<br>
<br>
public:<br>
- Classification() {}<br>
+ Classification() = default;<br>
<br>
Kinds getKind() const { return static_cast<Kinds>(Kind); }<br>
+<br>
ModifiableType getModifiable() const {<br>
assert(Modifiable != CM_Untested && "Did not test for modifiability.");<br>
return static_cast<ModifiableType>(<wbr>Modifiable);<br>
}<br>
+<br>
bool isLValue() const { return Kind == CL_LValue; }<br>
bool isXValue() const { return Kind == CL_XValue; }<br>
bool isGLValue() const { return Kind <= CL_XValue; }<br>
@@ -362,6 +378,7 @@ public:<br>
}<br>
<br>
};<br>
+<br>
/// \brief Classify - Classify this expression according to the C++11<br>
/// expression taxonomy.<br>
///<br>
@@ -428,7 +445,6 @@ private:<br>
Classification ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const;<br>
<br>
public:<br>
-<br>
/// \brief Returns true if this expression is a gl-value that<br>
/// potentially refers to a bit-field.<br>
///<br>
@@ -541,12 +557,12 @@ public:<br>
struct EvalStatus {<br>
/// \brief Whether the evaluated expression has side effects.<br>
/// For example, (f() && 0) can be folded, but it still has side effects.<br>
- bool HasSideEffects;<br>
+ bool HasSideEffects = false;<br>
<br>
/// \brief Whether the evaluation hit undefined behavior.<br>
/// For example, 1.0 / 0.0 can be folded to Inf, but has undefined behavior.<br>
/// Likewise, INT_MAX + 1 can be folded to INT_MIN, but has UB.<br>
- bool HasUndefinedBehavior;<br>
+ bool HasUndefinedBehavior = false;<br>
<br>
/// Diag - If this is non-null, it will be filled in with a stack of notes<br>
/// indicating why evaluation failed (or why it failed to produce a constant<br>
@@ -555,10 +571,9 @@ public:<br>
/// foldable. If the expression is foldable, but not a constant expression,<br>
/// the notes will describes why it isn't a constant expression. If the<br>
/// expression *is* a constant expression, no notes will be produced.<br>
- SmallVectorImpl<<wbr>PartialDiagnosticAt> *Diag;<br>
+ SmallVectorImpl<<wbr>PartialDiagnosticAt> *Diag = nullptr;<br>
<br>
- EvalStatus()<br>
- : HasSideEffects(false), HasUndefinedBehavior(false), Diag(nullptr) {}<br>
+ EvalStatus() = default;<br>
<br>
// hasSideEffects - Return true if the evaluated expression has<br>
// side effects.<br>
@@ -592,10 +607,15 @@ public:<br>
bool EvaluateAsBooleanCondition(<wbr>bool &Result, const ASTContext &Ctx) const;<br>
<br>
enum SideEffectsKind {<br>
- SE_NoSideEffects, ///< Strictly evaluate the expression.<br>
- SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value, but not<br>
- ///< arbitrary unmodeled side effects.<br>
- SE_AllowSideEffects ///< Allow any unmodeled side effect.<br>
+ /// Strictly evaluate the expression.<br>
+ SE_NoSideEffects,<br>
+<br>
+ /// Allow UB that we can give a value, but not arbitrary unmodeled side<br>
+ /// effects.<br>
+ SE_AllowUndefinedBehavior,<br>
+<br>
+ /// Allow any unmodeled side effect.<br>
+ SE_AllowSideEffects<br>
};<br>
<br>
/// EvaluateAsInt - Return true if this is a constant which we can fold and<br>
@@ -807,12 +827,15 @@ public:<br>
const Expr *IgnoreImpCasts() const LLVM_READONLY {<br>
return const_cast<Expr*>(this)-><wbr>IgnoreImpCasts();<br>
}<br>
+<br>
const Expr *IgnoreParens() const LLVM_READONLY {<br>
return const_cast<Expr*>(this)-><wbr>IgnoreParens();<br>
}<br>
+<br>
const Expr *IgnoreParenCasts() const LLVM_READONLY {<br>
return const_cast<Expr*>(this)-><wbr>IgnoreParenCasts();<br>
}<br>
+<br>
/// Strip off casts, but keep parentheses.<br>
const Expr *IgnoreCasts() const LLVM_READONLY {<br>
return const_cast<Expr*>(this)-><wbr>IgnoreCasts();<br>
@@ -867,6 +890,7 @@ public:<br>
/// context.<br>
class OpaqueValueExpr : public Expr {<br>
friend class ASTStmtReader;<br>
+<br>
Expr *SourceExpr;<br>
SourceLocation Loc;<br>
<br>
@@ -891,7 +915,7 @@ public:<br>
static const OpaqueValueExpr *findInCopyConstruct(const Expr *expr);<br>
<br>
explicit OpaqueValueExpr(EmptyShell Empty)<br>
- : Expr(OpaqueValueExprClass, Empty) { }<br>
+ : Expr(OpaqueValueExprClass, Empty) {}<br>
<br>
/// \brief Retrieve the location of this expression.<br>
SourceLocation getLocation() const { return Loc; }<br>
@@ -899,9 +923,11 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return SourceExpr ? SourceExpr->getLocStart() : Loc;<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return SourceExpr ? SourceExpr->getLocEnd() : Loc;<br>
}<br>
+<br>
SourceLocation getExprLoc() const LLVM_READONLY {<br>
if (SourceExpr) return SourceExpr->getExprLoc();<br>
return Loc;<br>
@@ -968,6 +994,18 @@ class DeclRefExpr final<br>
/// embedded in D.<br>
DeclarationNameLoc DNLoc;<br>
<br>
+ DeclRefExpr(const ASTContext &Ctx,<br>
+ NestedNameSpecifierLoc QualifierLoc,<br>
+ SourceLocation TemplateKWLoc,<br>
+ ValueDecl *D, bool RefersToEnlosingVariableOrCapt<wbr>ure,<br>
+ const DeclarationNameInfo &NameInfo,<br>
+ NamedDecl *FoundD,<br>
+ const TemplateArgumentListInfo *TemplateArgs,<br>
+ QualType T, ExprValueKind VK);<br>
+<br>
+ /// \brief Construct an empty declaration reference expression.<br>
+ explicit DeclRefExpr(EmptyShell Empty) : Expr(DeclRefExprClass, Empty) {}<br>
+<br>
size_t numTrailingObjects(<wbr>OverloadToken<<wbr>NestedNameSpecifierLoc>) const {<br>
return hasQualifier() ? 1 : 0;<br>
}<br>
@@ -984,24 +1022,15 @@ class DeclRefExpr final<br>
/// this DRE.<br>
bool hasFoundDecl() const { return DeclRefExprBits.HasFoundDecl; }<br>
<br>
- DeclRefExpr(const ASTContext &Ctx,<br>
- NestedNameSpecifierLoc QualifierLoc,<br>
- SourceLocation TemplateKWLoc,<br>
- ValueDecl *D, bool RefersToEnlosingVariableOrCapt<wbr>ure,<br>
- const DeclarationNameInfo &NameInfo,<br>
- NamedDecl *FoundD,<br>
- const TemplateArgumentListInfo *TemplateArgs,<br>
- QualType T, ExprValueKind VK);<br>
-<br>
- /// \brief Construct an empty declaration reference expression.<br>
- explicit DeclRefExpr(EmptyShell Empty)<br>
- : Expr(DeclRefExprClass, Empty) { }<br>
-<br>
/// \brief Computes the type- and value-dependence flags for this<br>
/// declaration reference expression.<br>
void computeDependence(const ASTContext &C);<br>
<br>
public:<br>
+ friend class ASTStmtReader;<br>
+ friend class ASTStmtWriter;<br>
+ friend TrailingObjects;<br>
+<br>
DeclRefExpr(ValueDecl *D, bool RefersToEnclosingVariableOrCap<wbr>ture, QualType T,<br>
ExprValueKind VK, SourceLocation L,<br>
const DeclarationNameLoc &LocInfo = DeclarationNameLoc())<br>
@@ -1074,7 +1103,6 @@ public:<br>
/// This Decl may be different from the ValueDecl actually referred to in the<br>
/// presence of using declarations, etc. It always returns non-NULL, and may<br>
/// simple return the ValueDecl when appropriate.<br>
-<br>
NamedDecl *getFoundDecl() {<br>
return hasFoundDecl() ? *getTrailingObjects<NamedDecl *>() : D;<br>
}<br>
@@ -1153,6 +1181,7 @@ public:<br>
bool hadMultipleCandidates() const {<br>
return DeclRefExprBits.<wbr>HadMultipleCandidates;<br>
}<br>
+<br>
/// \brief Sets the flag telling whether this expression refers to<br>
/// a function that was resolved from an overloaded set having size<br>
/// greater than 1.<br>
@@ -1178,10 +1207,6 @@ public:<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
-<br>
- friend TrailingObjects;<br>
- friend class ASTStmtReader;<br>
- friend class ASTStmtWriter;<br>
};<br>
<br>
/// \brief [C99 6.4.2.2] - A predefined identifier such as __func__.<br>
@@ -1190,10 +1215,13 @@ public:<br>
enum IdentType {<br>
Func,<br>
Function,<br>
- LFunction, // Same as Function, but as wide string.<br>
+<br>
+ // Same as Function, but as wide string.<br>
+ LFunction,<br>
FuncDName,<br>
FuncSig,<br>
PrettyFunction,<br>
+<br>
/// \brief The same as PrettyFunction, except that the<br>
/// 'virtual' keyword is omitted for virtual member functions.<br>
PrettyFunctionNoVirtual<br>
@@ -1202,15 +1230,17 @@ public:<br>
private:<br>
SourceLocation Loc;<br>
IdentType Type;<br>
- Stmt *FnName;<br>
+ Stmt *FnName = nullptr;<br>
<br>
public:<br>
+ friend class ASTStmtReader;<br>
+<br>
PredefinedExpr(SourceLocation L, QualType FNTy, IdentType IT,<br>
StringLiteral *SL);<br>
<br>
/// \brief Construct an empty predefined expression.<br>
explicit PredefinedExpr(EmptyShell Empty)<br>
- : Expr(PredefinedExprClass, Empty), Loc(), Type(Func), FnName(nullptr) {}<br>
+ : Expr(PredefinedExprClass, Empty), Type(Func) {}<br>
<br>
IdentType getIdentType() const { return Type; }<br>
<br>
@@ -1234,11 +1264,10 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&FnName, &FnName + 1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&FnName, &FnName + 1);<br>
}<br>
-<br>
- friend class ASTStmtReader;<br>
};<br>
<br>
/// \brief Used by IntegerLiteral/FloatingLiteral to store the numeric without<br>
@@ -1254,15 +1283,12 @@ class APNumericStorage {<br>
uint64_t VAL; ///< Used to store the <= 64 bits integer value.<br>
uint64_t *pVal; ///< Used to store the >64 bits integer value.<br>
};<br>
- unsigned BitWidth;<br>
+ unsigned BitWidth = 0;<br>
<br>
bool hasAllocation() const { return llvm::APInt::getNumWords(<wbr>BitWidth) > 1; }<br>
<br>
- APNumericStorage(const APNumericStorage &) = delete;<br>
- void operator=(const APNumericStorage &) = delete;<br>
-<br>
protected:<br>
- APNumericStorage() : VAL(0), BitWidth(0) { }<br>
+ APNumericStorage() : VAL(0) {}<br>
<br>
llvm::APInt getIntValue() const {<br>
unsigned NumWords = llvm::APInt::getNumWords(<wbr>BitWidth);<br>
@@ -1271,12 +1297,18 @@ protected:<br>
else<br>
return llvm::APInt(BitWidth, VAL);<br>
}<br>
+<br>
void setIntValue(const ASTContext &C, const llvm::APInt &Val);<br>
+<br>
+public:<br>
+ APNumericStorage(const APNumericStorage &) = delete;<br>
+ APNumericStorage &operator=(const APNumericStorage &) = delete;<br>
};<br>
<br>
class APIntStorage : private APNumericStorage {<br>
public:<br>
llvm::APInt getValue() const { return getIntValue(); }<br>
+<br>
void setValue(const ASTContext &C, const llvm::APInt &Val) {<br>
setIntValue(C, Val);<br>
}<br>
@@ -1287,6 +1319,7 @@ public:<br>
llvm::APFloat getValue(const llvm::fltSemantics &Semantics) const {<br>
return llvm::APFloat(Semantics, getIntValue());<br>
}<br>
+<br>
void setValue(const ASTContext &C, const llvm::APFloat &Val) {<br>
setIntValue(C, Val.bitcastToAPInt());<br>
}<br>
@@ -1297,7 +1330,7 @@ class IntegerLiteral : public Expr, publ<br>
<br>
/// \brief Construct an empty integer literal.<br>
explicit IntegerLiteral(EmptyShell Empty)<br>
- : Expr(IntegerLiteralClass, Empty) { }<br>
+ : Expr(IntegerLiteralClass, Empty) {}<br>
<br>
public:<br>
// type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,<br>
@@ -1311,6 +1344,7 @@ public:<br>
/// \param V - the value that the returned integer literal contains.<br>
static IntegerLiteral *Create(const ASTContext &C, const llvm::APInt &V,<br>
QualType type, SourceLocation l);<br>
+<br>
/// \brief Returns a new empty integer literal.<br>
static IntegerLiteral *Create(const ASTContext &C, EmptyShell Empty);<br>
<br>
@@ -1330,6 +1364,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -1348,6 +1383,7 @@ public:<br>
private:<br>
unsigned Value;<br>
SourceLocation Loc;<br>
+<br>
public:<br>
// type should be IntTy<br>
CharacterLiteral(unsigned value, CharacterKind kind, QualType type,<br>
@@ -1359,9 +1395,10 @@ public:<br>
}<br>
<br>
/// \brief Construct an empty character literal.<br>
- CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) { }<br>
+ CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) {}<br>
<br>
SourceLocation getLocation() const { return Loc; }<br>
+<br>
CharacterKind getKind() const {<br>
return static_cast<CharacterKind>(<wbr>CharacterLiteralBits.Kind);<br>
}<br>
@@ -1383,6 +1420,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -1405,6 +1443,7 @@ public:<br>
llvm::APFloat getValue() const {<br>
return APFloatStorage::getValue(<wbr>getSemantics());<br>
}<br>
+<br>
void setValue(const ASTContext &C, const llvm::APFloat &Val) {<br>
assert(&getSemantics() == &Val.getSemantics() && "Inconsistent semantics");<br>
APFloatStorage::setValue(C, Val);<br>
@@ -1450,6 +1489,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -1459,9 +1499,9 @@ public:<br>
/// like "1.0i". We represent these as a wrapper around FloatingLiteral and<br>
/// IntegerLiteral classes. Instances of this class always have a Complex type<br>
/// whose element type matches the subexpression.<br>
-///<br>
class ImaginaryLiteral : public Expr {<br>
Stmt *Val;<br>
+<br>
public:<br>
ImaginaryLiteral(Expr *val, QualType Ty)<br>
: Expr(ImaginaryLiteralClass, Ty, VK_RValue, OK_Ordinary, false, false,<br>
@@ -1470,7 +1510,7 @@ public:<br>
<br>
/// \brief Build an empty imaginary literal.<br>
explicit ImaginaryLiteral(EmptyShell Empty)<br>
- : Expr(ImaginaryLiteralClass, Empty) { }<br>
+ : Expr(ImaginaryLiteralClass, Empty) {}<br>
<br>
const Expr *getSubExpr() const { return cast<Expr>(Val); }<br>
Expr *getSubExpr() { return cast<Expr>(Val); }<br>
@@ -1485,6 +1525,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&Val, &Val+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Val, &Val + 1);<br>
}<br>
@@ -1531,11 +1572,11 @@ private:<br>
unsigned NumConcatenated;<br>
SourceLocation TokLocs[1];<br>
<br>
- StringLiteral(QualType Ty) :<br>
- Expr(StringLiteralClass, Ty, VK_LValue, OK_Ordinary, false, false, false,<br>
- false) {}<br>
+ StringLiteral(QualType Ty)<br>
+ : Expr(StringLiteralClass, Ty, VK_LValue, OK_Ordinary, false, false,<br>
+ false, false) {}<br>
<br>
- static int mapCharByteWidth(TargetInfo const &target,StringKind k);<br>
+ static int mapCharByteWidth(TargetInfo const &target, StringKind k);<br>
<br>
public:<br>
/// This is the "fully general" constructor that allows representation of<br>
@@ -1596,7 +1637,6 @@ public:<br>
<br>
StringKind getKind() const { return static_cast<StringKind>(Kind); }<br>
<br>
-<br>
bool isAscii() const { return Kind == Ascii; }<br>
bool isWide() const { return Kind == Wide; }<br>
bool isUTF8() const { return Kind == UTF8; }<br>
@@ -1638,11 +1678,13 @@ public:<br>
unsigned *StartToken = nullptr,<br>
unsigned *StartTokenByteOffset = nullptr) const;<br>
<br>
- typedef const SourceLocation *tokloc_iterator;<br>
+ using tokloc_iterator = const SourceLocation *;<br>
+<br>
tokloc_iterator tokloc_begin() const { return TokLocs; }<br>
tokloc_iterator tokloc_end() const { return TokLocs + NumConcatenated; }<br>
<br>
SourceLocation getLocStart() const LLVM_READONLY { return TokLocs[0]; }<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return TokLocs[NumConcatenated - 1];<br>
}<br>
@@ -1655,6 +1697,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -1665,6 +1708,7 @@ public:<br>
class ParenExpr : public Expr {<br>
SourceLocation L, R;<br>
Stmt *Val;<br>
+<br>
public:<br>
ParenExpr(SourceLocation l, SourceLocation r, Expr *val)<br>
: Expr(ParenExprClass, val->getType(),<br>
@@ -1675,8 +1719,7 @@ public:<br>
L(l), R(r), Val(val) {}<br>
<br>
/// \brief Construct an empty parenthesized expression.<br>
- explicit ParenExpr(EmptyShell Empty)<br>
- : Expr(ParenExprClass, Empty) { }<br>
+ explicit ParenExpr(EmptyShell Empty) : Expr(ParenExprClass, Empty) {}<br>
<br>
const Expr *getSubExpr() const { return cast<Expr>(Val); }<br>
Expr *getSubExpr() { return cast<Expr>(Val); }<br>
@@ -1699,6 +1742,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&Val, &Val+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Val, &Val + 1);<br>
}<br>
@@ -1713,17 +1757,16 @@ public:<br>
/// Real/Imag - These return the real/imag part of a complex operand. If<br>
/// applied to a non-complex value, the former returns its operand and the<br>
/// later returns zero in the type of the operand.<br>
-///<br>
class UnaryOperator : public Expr {<br>
public:<br>
- typedef UnaryOperatorKind Opcode;<br>
+ using Opcode = UnaryOperatorKind;<br>
<br>
private:<br>
unsigned Opc : 5;<br>
SourceLocation Loc;<br>
Stmt *Val;<br>
-public:<br>
<br>
+public:<br>
UnaryOperator(Expr *input, Opcode opc, QualType type,<br>
ExprValueKind VK, ExprObjectKind OK, SourceLocation l)<br>
: Expr(UnaryOperatorClass, type, VK, OK,<br>
@@ -1736,7 +1779,7 @@ public:<br>
<br>
/// \brief Build an empty unary operator.<br>
explicit UnaryOperator(EmptyShell Empty)<br>
- : Expr(UnaryOperatorClass, Empty), Opc(UO_AddrOf) { }<br>
+ : Expr(UnaryOperatorClass, Empty), Opc(UO_AddrOf) {}<br>
<br>
Opcode getOpcode() const { return static_cast<Opcode>(Opc); }<br>
void setOpcode(Opcode O) { Opc = O; }<br>
@@ -1800,9 +1843,11 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return isPostfix() ? Val->getLocStart() : Loc;<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return isPostfix() ? Loc : Val->getLocEnd();<br>
}<br>
+<br>
SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }<br>
<br>
static bool classof(const Stmt *T) {<br>
@@ -1811,6 +1856,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&Val, &Val+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Val, &Val + 1);<br>
}<br>
@@ -1825,10 +1871,13 @@ public:<br>
enum Kind {<br>
/// \brief An index into an array.<br>
Array = 0x00,<br>
+<br>
/// \brief A field.<br>
Field = 0x01,<br>
+<br>
/// \brief A field in a dependent type, known only by its name.<br>
Identifier = 0x02,<br>
+<br>
/// \brief An implicit indirection through a C++ base class, when the<br>
/// field found is in a base class.<br>
Base = 0x03<br>
@@ -1870,7 +1919,7 @@ public:<br>
<br>
/// \brief Create an offsetof node that refers into a C++ base class.<br>
explicit OffsetOfNode(const CXXBaseSpecifier *Base)<br>
- : Range(), Data(reinterpret_cast<uintptr_<wbr>t>(Base) | OffsetOfNode::Base) {}<br>
+ : Data(reinterpret_cast<uintptr_<wbr>t>(Base) | OffsetOfNode::Base) {}<br>
<br>
/// \brief Determine what kind of offsetof node this is.<br>
Kind getKind() const { return static_cast<Kind>(Data & Mask); }<br>
@@ -1922,15 +1971,17 @@ public:<br>
/// };<br>
/// @endcode<br>
/// we can represent and evaluate the expression @c offsetof(struct T, s[2].d).<br>
-<br>
class OffsetOfExpr final<br>
: public Expr,<br>
private llvm::TrailingObjects<<wbr>OffsetOfExpr, OffsetOfNode, Expr *> {<br>
SourceLocation OperatorLoc, RParenLoc;<br>
+<br>
// Base type;<br>
- TypeSourceInfo *TSInfo;<br>
+ TypeSourceInfo *TSInfo = nullptr;<br>
+<br>
// Number of sub-components (i.e. instances of OffsetOfNode).<br>
unsigned NumComps;<br>
+<br>
// Number of sub-expressions (i.e. array subscript expressions).<br>
unsigned NumExprs;<br>
<br>
@@ -1944,10 +1995,11 @@ class OffsetOfExpr final<br>
SourceLocation RParenLoc);<br>
<br>
explicit OffsetOfExpr(unsigned numComps, unsigned numExprs)<br>
- : Expr(OffsetOfExprClass, EmptyShell()),<br>
- TSInfo(nullptr), NumComps(numComps), NumExprs(numExprs) {}<br>
+ : Expr(OffsetOfExprClass, EmptyShell()), NumComps(numComps),<br>
+ NumExprs(numExprs) {}<br>
<br>
public:<br>
+ friend TrailingObjects;<br>
<br>
static OffsetOfExpr *Create(const ASTContext &C, QualType type,<br>
SourceLocation OperatorLoc, TypeSourceInfo *tsi,<br>
@@ -1968,6 +2020,7 @@ public:<br>
TypeSourceInfo *getTypeSourceInfo() const {<br>
return TSInfo;<br>
}<br>
+<br>
void setTypeSourceInfo(<wbr>TypeSourceInfo *tsi) {<br>
TSInfo = tsi;<br>
}<br>
@@ -2017,12 +2070,12 @@ public:<br>
Stmt **begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>());<br>
return child_range(begin, begin + NumExprs);<br>
}<br>
+<br>
const_child_range children() const {<br>
Stmt *const *begin =<br>
reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>());<br>
return const_child_range(begin, begin + NumExprs);<br>
}<br>
- friend TrailingObjects;<br>
};<br>
<br>
/// UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated)<br>
@@ -2057,21 +2110,25 @@ public:<br>
<br>
/// \brief Construct an empty sizeof/alignof expression.<br>
explicit UnaryExprOrTypeTraitExpr(<wbr>EmptyShell Empty)<br>
- : Expr(<wbr>UnaryExprOrTypeTraitExprClass, Empty) { }<br>
+ : Expr(<wbr>UnaryExprOrTypeTraitExprClass, Empty) {}<br>
<br>
UnaryExprOrTypeTrait getKind() const {<br>
return static_cast<<wbr>UnaryExprOrTypeTrait>(<wbr>UnaryExprOrTypeTraitExprBits.<wbr>Kind);<br>
}<br>
+<br>
void setKind(UnaryExprOrTypeTrait K) { UnaryExprOrTypeTraitExprBits.<wbr>Kind = K;}<br>
<br>
bool isArgumentType() const { return UnaryExprOrTypeTraitExprBits.<wbr>IsType; }<br>
+<br>
QualType getArgumentType() const {<br>
return getArgumentTypeInfo()-><wbr>getType();<br>
}<br>
+<br>
TypeSourceInfo *getArgumentTypeInfo() const {<br>
assert(isArgumentType() && "calling getArgumentType() when arg is expr");<br>
return Argument.Ty;<br>
}<br>
+<br>
Expr *getArgumentExpr() {<br>
assert(!isArgumentType() && "calling getArgumentExpr() when arg is type");<br>
return static_cast<Expr*>(Argument.<wbr>Ex);<br>
@@ -2120,8 +2177,10 @@ public:<br>
/// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.<br>
class ArraySubscriptExpr : public Expr {<br>
enum { LHS, RHS, END_EXPR=2 };<br>
+<br>
Stmt* SubExprs[END_EXPR];<br>
SourceLocation RBracketLoc;<br>
+<br>
public:<br>
ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t,<br>
ExprValueKind VK, ExprObjectKind OK,<br>
@@ -2140,7 +2199,7 @@ public:<br>
<br>
/// \brief Create an empty array subscript expression.<br>
explicit ArraySubscriptExpr(EmptyShell Shell)<br>
- : Expr(ArraySubscriptExprClass, Shell) { }<br>
+ : Expr(ArraySubscriptExprClass, Shell) {}<br>
<br>
/// An array access can be written A[4] or 4[A] (both are equivalent).<br>
/// - getBase() and getIdx() always present the normalized view: A[4].<br>
@@ -2178,6 +2237,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getLHS()->getLocStart();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY { return RBracketLoc; }<br>
<br>
SourceLocation getRBracketLoc() const { return RBracketLoc; }<br>
@@ -2195,6 +2255,7 @@ public:<br>
child_range children() {<br>
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SubExprs[0]<wbr>, &SubExprs[0] + END_EXPR);<br>
}<br>
@@ -2208,8 +2269,9 @@ public:<br>
/// "str1 + str2" to resolve to a function call.<br>
class CallExpr : public Expr {<br>
enum { FN=0, PREARGS_START=1 };<br>
- Stmt **SubExprs;<br>
- unsigned NumArgs;<br>
+<br>
+ Stmt **SubExprs = nullptr;<br>
+ unsigned NumArgs = 0;<br>
SourceLocation RParenLoc;<br>
<br>
void updateDependenciesFromArg(Expr *Arg);<br>
@@ -2262,7 +2324,6 @@ public:<br>
}<br>
<br>
/// getNumArgs - Return the number of actual arguments to this call.<br>
- ///<br>
unsigned getNumArgs() const { return NumArgs; }<br>
<br>
/// \brief Retrieve the call arguments.<br>
@@ -2295,10 +2356,10 @@ public:<br>
/// to null.<br>
void setNumArgs(const ASTContext& C, unsigned NumArgs);<br>
<br>
- typedef ExprIterator arg_iterator;<br>
- typedef ConstExprIterator const_arg_iterator;<br>
- typedef llvm::iterator_range<arg_<wbr>iterator> arg_range;<br>
- typedef llvm::iterator_range<const_<wbr>arg_iterator> arg_const_range;<br>
+ using arg_iterator = ExprIterator;<br>
+ using const_arg_iterator = ConstExprIterator;<br>
+ using arg_range = llvm::iterator_range<arg_<wbr>iterator>;<br>
+ using arg_const_range = llvm::iterator_range<const_<wbr>arg_iterator>;<br>
<br>
arg_range arguments() { return arg_range(arg_begin(), arg_end()); }<br>
arg_const_range arguments() const {<br>
@@ -2306,12 +2367,15 @@ public:<br>
}<br>
<br>
arg_iterator arg_begin() { return SubExprs+PREARGS_START+<wbr>getNumPreArgs(); }<br>
+<br>
arg_iterator arg_end() {<br>
return SubExprs+PREARGS_START+<wbr>getNumPreArgs()+getNumArgs();<br>
}<br>
+<br>
const_arg_iterator arg_begin() const {<br>
return SubExprs+PREARGS_START+<wbr>getNumPreArgs();<br>
}<br>
+<br>
const_arg_iterator arg_end() const {<br>
return SubExprs+PREARGS_START+<wbr>getNumPreArgs()+getNumArgs();<br>
}<br>
@@ -2436,6 +2500,10 @@ class MemberExpr final<br>
}<br>
<br>
public:<br>
+ friend class ASTReader;<br>
+ friend class ASTStmtWriter;<br>
+ friend TrailingObjects;<br>
+<br>
MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,<br>
ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo,<br>
QualType ty, ExprValueKind VK, ExprObjectKind OK)<br>
@@ -2459,7 +2527,7 @@ public:<br>
: Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),<br>
base->isValueDependent(), base-><wbr>isInstantiationDependent(),<br>
base-><wbr>containsUnexpandedParameterPac<wbr>k()),<br>
- Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l),<br>
+ Base(base), MemberDecl(memberdecl), MemberLoc(l),<br>
OperatorLoc(operatorloc), IsArrow(isarrow),<br>
HasQualifierOrFoundDecl(false)<wbr>, HasTemplateKWAndArgsInfo(<wbr>false),<br>
HadMultipleCandidates(false) {}<br>
@@ -2602,6 +2670,7 @@ public:<br>
bool hadMultipleCandidates() const {<br>
return HadMultipleCandidates;<br>
}<br>
+<br>
/// \brief Sets the flag telling whether this expression refers to<br>
/// a method that was resolved from an overloaded set having size<br>
/// greater than 1.<br>
@@ -2623,17 +2692,13 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&Base, &Base+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Base, &Base + 1);<br>
}<br>
-<br>
- friend TrailingObjects;<br>
- friend class ASTReader;<br>
- friend class ASTStmtWriter;<br>
};<br>
<br>
/// CompoundLiteralExpr - [C99 6.5.2.5]<br>
-///<br>
class CompoundLiteralExpr : public Expr {<br>
/// LParenLoc - If non-null, this is the location of the left paren in a<br>
/// compound literal like "(int){4}". This can be null if this is a<br>
@@ -2645,6 +2710,7 @@ class CompoundLiteralExpr : public Expr<br>
/// The int part of the pair stores whether this expr is file scope.<br>
llvm::PointerIntPair<<wbr>TypeSourceInfo *, 1, bool> TInfoAndScope;<br>
Stmt *Init;<br>
+<br>
public:<br>
CompoundLiteralExpr(<wbr>SourceLocation lparenloc, TypeSourceInfo *tinfo,<br>
QualType T, ExprValueKind VK, Expr *init, bool fileScope)<br>
@@ -2658,7 +2724,7 @@ public:<br>
<br>
/// \brief Construct an empty compound literal.<br>
explicit CompoundLiteralExpr(EmptyShell Empty)<br>
- : Expr(CompoundLiteralExprClass, Empty) { }<br>
+ : Expr(CompoundLiteralExprClass, Empty) {}<br>
<br>
const Expr *getInitializer() const { return cast<Expr>(Init); }<br>
Expr *getInitializer() { return cast<Expr>(Init); }<br>
@@ -2673,6 +2739,7 @@ public:<br>
TypeSourceInfo *getTypeSourceInfo() const {<br>
return TInfoAndScope.getPointer();<br>
}<br>
+<br>
void setTypeSourceInfo(<wbr>TypeSourceInfo *tinfo) {<br>
TInfoAndScope.setPointer(<wbr>tinfo);<br>
}<br>
@@ -2685,6 +2752,7 @@ public:<br>
return Init->getLocStart();<br>
return LParenLoc;<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
// FIXME: Init should never be null.<br>
if (!Init)<br>
@@ -2698,6 +2766,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&Init, &Init+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Init, &Init + 1);<br>
}<br>
@@ -2716,6 +2785,7 @@ private:<br>
const CXXBaseSpecifier * const *path_buffer() const {<br>
return const_cast<CastExpr*>(this)-><wbr>path_buffer();<br>
}<br>
+<br>
CXXBaseSpecifier **path_buffer();<br>
<br>
void setBasePathSize(unsigned basePathSize) {<br>
@@ -2750,7 +2820,7 @@ protected:<br>
<br>
/// \brief Construct an empty cast.<br>
CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize)<br>
- : Expr(SC, Empty) {<br>
+ : Expr(SC, Empty) {<br>
setBasePathSize(BasePathSize);<br>
}<br>
<br>
@@ -2771,8 +2841,9 @@ public:<br>
return const_cast<CastExpr *>(this)->getSubExprAsWritten(<wbr>);<br>
}<br>
<br>
- typedef CXXBaseSpecifier **path_iterator;<br>
- typedef const CXXBaseSpecifier * const *path_const_iterator;<br>
+ using path_iterator = CXXBaseSpecifier **;<br>
+ using path_const_iterator = const CXXBaseSpecifier * const *;<br>
+<br>
bool path_empty() const { return CastExprBits.BasePathSize == 0; }<br>
unsigned path_size() const { return CastExprBits.BasePathSize; }<br>
path_iterator path_begin() { return path_buffer(); }<br>
@@ -2826,19 +2897,21 @@ class ImplicitCastExpr final<br>
private:<br>
ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,<br>
unsigned BasePathLength, ExprValueKind VK)<br>
- : CastExpr(<wbr>ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) {<br>
- }<br>
+ : CastExpr(<wbr>ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) {}<br>
<br>
/// \brief Construct an empty implicit cast.<br>
explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize)<br>
- : CastExpr(<wbr>ImplicitCastExprClass, Shell, PathSize) { }<br>
+ : CastExpr(<wbr>ImplicitCastExprClass, Shell, PathSize) {}<br>
<br>
public:<br>
+ friend class CastExpr;<br>
+ friend TrailingObjects;<br>
+<br>
enum OnStack_t { OnStack };<br>
+<br>
ImplicitCastExpr(OnStack_t _, QualType ty, CastKind kind, Expr *op,<br>
ExprValueKind VK)<br>
- : CastExpr(<wbr>ImplicitCastExprClass, ty, VK, kind, op, 0) {<br>
- }<br>
+ : CastExpr(<wbr>ImplicitCastExprClass, ty, VK, kind, op, 0) {}<br>
<br>
static ImplicitCastExpr *Create(const ASTContext &Context, QualType T,<br>
CastKind Kind, Expr *Operand,<br>
@@ -2851,6 +2924,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getSubExpr()->getLocStart();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return getSubExpr()->getLocEnd();<br>
}<br>
@@ -2858,9 +2932,6 @@ public:<br>
static bool classof(const Stmt *T) {<br>
return T->getStmtClass() == ImplicitCastExprClass;<br>
}<br>
-<br>
- friend TrailingObjects;<br>
- friend class CastExpr;<br>
};<br>
<br>
inline Expr *Expr::IgnoreImpCasts() {<br>
@@ -2895,11 +2966,11 @@ protected:<br>
ExplicitCastExpr(StmtClass SC, QualType exprTy, ExprValueKind VK,<br>
CastKind kind, Expr *op, unsigned PathSize,<br>
TypeSourceInfo *writtenTy)<br>
- : CastExpr(SC, exprTy, VK, kind, op, PathSize), TInfo(writtenTy) {}<br>
+ : CastExpr(SC, exprTy, VK, kind, op, PathSize), TInfo(writtenTy) {}<br>
<br>
/// \brief Construct an empty explicit cast.<br>
ExplicitCastExpr(StmtClass SC, EmptyShell Shell, unsigned PathSize)<br>
- : CastExpr(SC, Shell, PathSize) { }<br>
+ : CastExpr(SC, Shell, PathSize) {}<br>
<br>
public:<br>
/// getTypeInfoAsWritten - Returns the type source info for the type<br>
@@ -2923,8 +2994,11 @@ public:<br>
class CStyleCastExpr final<br>
: public ExplicitCastExpr,<br>
private llvm::TrailingObjects<<wbr>CStyleCastExpr, CXXBaseSpecifier *> {<br>
- SourceLocation LPLoc; // the location of the left paren<br>
- SourceLocation RPLoc; // the location of the right paren<br>
+ // the location of the left paren<br>
+ SourceLocation LPLoc;<br>
+<br>
+ // the location of the right paren<br>
+ SourceLocation RPLoc;<br>
<br>
CStyleCastExpr(QualType exprTy, ExprValueKind vk, CastKind kind, Expr *op,<br>
unsigned PathSize, TypeSourceInfo *writtenTy,<br>
@@ -2934,9 +3008,12 @@ class CStyleCastExpr final<br>
<br>
/// \brief Construct an empty C-style explicit cast.<br>
explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize)<br>
- : ExplicitCastExpr(<wbr>CStyleCastExprClass, Shell, PathSize) { }<br>
+ : ExplicitCastExpr(<wbr>CStyleCastExprClass, Shell, PathSize) {}<br>
<br>
public:<br>
+ friend class CastExpr;<br>
+ friend TrailingObjects;<br>
+<br>
static CStyleCastExpr *Create(const ASTContext &Context, QualType T,<br>
ExprValueKind VK, CastKind K,<br>
Expr *Op, const CXXCastPath *BasePath,<br>
@@ -2953,6 +3030,7 @@ public:<br>
void setRParenLoc(SourceLocation L) { RPLoc = L; }<br>
<br>
SourceLocation getLocStart() const LLVM_READONLY { return LPLoc; }<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return getSubExpr()->getLocEnd();<br>
}<br>
@@ -2960,9 +3038,6 @@ public:<br>
static bool classof(const Stmt *T) {<br>
return T->getStmtClass() == CStyleCastExprClass;<br>
}<br>
-<br>
- friend TrailingObjects;<br>
- friend class CastExpr;<br>
};<br>
<br>
/// \brief A builtin binary operation expression such as "x + y" or "x <= y".<br>
@@ -2985,7 +3060,7 @@ public:<br>
/// be used to express the computation.<br>
class BinaryOperator : public Expr {<br>
public:<br>
- typedef BinaryOperatorKind Opcode;<br>
+ using Opcode = BinaryOperatorKind;<br>
<br>
private:<br>
unsigned Opc : 6;<br>
@@ -2993,12 +3068,13 @@ private:<br>
// This is only meaningful for operations on floating point types and 0<br>
// otherwise.<br>
unsigned FPFeatures : 2;<br>
+<br>
SourceLocation OpLoc;<br>
<br>
enum { LHS, RHS, END_EXPR };<br>
Stmt* SubExprs[END_EXPR];<br>
-public:<br>
<br>
+public:<br>
BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,<br>
ExprValueKind VK, ExprObjectKind OK,<br>
SourceLocation opLoc, FPOptions FPFeatures)<br>
@@ -3018,7 +3094,7 @@ public:<br>
<br>
/// \brief Construct an empty binary operator.<br>
explicit BinaryOperator(EmptyShell Empty)<br>
- : Expr(BinaryOperatorClass, Empty), Opc(BO_Comma) { }<br>
+ : Expr(BinaryOperatorClass, Empty), Opc(BO_Comma) {}<br>
<br>
SourceLocation getExprLoc() const LLVM_READONLY { return OpLoc; }<br>
SourceLocation getOperatorLoc() const { return OpLoc; }<br>
@@ -3035,6 +3111,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getLHS()->getLocStart();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return getRHS()->getLocEnd();<br>
}<br>
@@ -3117,6 +3194,7 @@ public:<br>
bool isCompoundAssignmentOp() const {<br>
return isCompoundAssignmentOp(<wbr>getOpcode());<br>
}<br>
+<br>
static Opcode getOpForCompoundAssignment(<wbr>Opcode Opc) {<br>
assert(isCompoundAssignmentOp(<wbr>Opc));<br>
if (Opc >= BO_AndAssign)<br>
@@ -3147,6 +3225,7 @@ public:<br>
child_range children() {<br>
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SubExprs[0]<wbr>, &SubExprs[0] + END_EXPR);<br>
}<br>
@@ -3180,7 +3259,7 @@ protected:<br>
}<br>
<br>
BinaryOperator(StmtClass SC, EmptyShell Empty)<br>
- : Expr(SC, Empty), Opc(BO_MulAssign) { }<br>
+ : Expr(SC, Empty), Opc(BO_MulAssign) {}<br>
};<br>
<br>
/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep<br>
@@ -3192,6 +3271,7 @@ protected:<br>
class CompoundAssignOperator : public BinaryOperator {<br>
QualType ComputationLHSType;<br>
QualType ComputationResultType;<br>
+<br>
public:<br>
CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResType,<br>
ExprValueKind VK, ExprObjectKind OK,<br>
@@ -3207,7 +3287,7 @@ public:<br>
<br>
/// \brief Build an empty compound assignment operator expression.<br>
explicit CompoundAssignOperator(<wbr>EmptyShell Empty)<br>
- : BinaryOperator(<wbr>CompoundAssignOperatorClass, Empty) { }<br>
+ : BinaryOperator(<wbr>CompoundAssignOperatorClass, Empty) {}<br>
<br>
// The two computation types are the type the LHS is converted<br>
// to for the computation and the type of the result; the two are<br>
@@ -3226,9 +3306,10 @@ public:<br>
/// AbstractConditionalOperator - An abstract base class for<br>
/// ConditionalOperator and BinaryConditionalOperator.<br>
class AbstractConditionalOperator : public Expr {<br>
- SourceLocation QuestionLoc, ColonLoc;<br>
friend class ASTStmtReader;<br>
<br>
+ SourceLocation QuestionLoc, ColonLoc;<br>
+<br>
protected:<br>
AbstractConditionalOperator(<wbr>StmtClass SC, QualType T,<br>
ExprValueKind VK, ExprObjectKind OK,<br>
@@ -3240,7 +3321,7 @@ protected:<br>
QuestionLoc(qloc), ColonLoc(cloc) {}<br>
<br>
AbstractConditionalOperator(<wbr>StmtClass SC, EmptyShell Empty)<br>
- : Expr(SC, Empty) { }<br>
+ : Expr(SC, Empty) {}<br>
<br>
public:<br>
// getCond - Return the expression representing the condition for<br>
@@ -3268,10 +3349,13 @@ public:<br>
/// ConditionalOperator - The ?: ternary operator. The GNU "missing<br>
/// middle" extension is a BinaryConditionalOperator.<br>
class ConditionalOperator : public AbstractConditionalOperator {<br>
+ friend class ASTStmtReader;<br>
+<br>
enum { COND, LHS, RHS, END_EXPR };<br>
- Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.<br>
<br>
- friend class ASTStmtReader;<br>
+ // Left/Middle/Right hand sides.<br>
+ Stmt* SubExprs[END_EXPR];<br>
+<br>
public:<br>
ConditionalOperator(Expr *cond, SourceLocation QLoc, Expr *lhs,<br>
SourceLocation CLoc, Expr *rhs,<br>
@@ -3297,7 +3381,7 @@ public:<br>
<br>
/// \brief Build an empty conditional operator.<br>
explicit ConditionalOperator(EmptyShell Empty)<br>
- : AbstractConditionalOperator(<wbr>ConditionalOperatorClass, Empty) { }<br>
+ : AbstractConditionalOperator(<wbr>ConditionalOperatorClass, Empty) {}<br>
<br>
// getCond - Return the expression representing the condition for<br>
// the ?: operator.<br>
@@ -3318,6 +3402,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getCond()->getLocStart();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return getRHS()->getLocEnd();<br>
}<br>
@@ -3330,6 +3415,7 @@ public:<br>
child_range children() {<br>
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SubExprs[0]<wbr>, &SubExprs[0] + END_EXPR);<br>
}<br>
@@ -3341,6 +3427,8 @@ public:<br>
/// This is a different expression kind on the assumption that almost<br>
/// every client ends up needing to know that these are different.<br>
class BinaryConditionalOperator : public AbstractConditionalOperator {<br>
+ friend class ASTStmtReader;<br>
+<br>
enum { COMMON, COND, LHS, RHS, NUM_SUBEXPRS };<br>
<br>
/// - the common condition/left-hand-side expression, which will be<br>
@@ -3351,7 +3439,6 @@ class BinaryConditionalOperator : public<br>
Stmt *SubExprs[NUM_SUBEXPRS];<br>
OpaqueValueExpr *OpaqueValue;<br>
<br>
- friend class ASTStmtReader;<br>
public:<br>
BinaryConditionalOperator(Expr *common, OpaqueValueExpr *opaqueValue,<br>
Expr *cond, Expr *lhs, Expr *rhs,<br>
@@ -3375,7 +3462,7 @@ public:<br>
<br>
/// \brief Build an empty conditional operator.<br>
explicit BinaryConditionalOperator(<wbr>EmptyShell Empty)<br>
- : AbstractConditionalOperator(<wbr>BinaryConditionalOperatorClass<wbr>, Empty) { }<br>
+ : AbstractConditionalOperator(<wbr>BinaryConditionalOperatorClass<wbr>, Empty) {}<br>
<br>
/// \brief getCommon - Return the common expression, written to the<br>
/// left of the condition. The opaque value will be bound to the<br>
@@ -3406,6 +3493,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getCommon()->getLocStart();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return getFalseExpr()->getLocEnd();<br>
}<br>
@@ -3418,6 +3506,7 @@ public:<br>
child_range children() {<br>
return child_range(SubExprs, SubExprs + NUM_SUBEXPRS);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(SubExprs, SubExprs + NUM_SUBEXPRS);<br>
}<br>
@@ -3445,6 +3534,7 @@ inline Expr *AbstractConditionalOperator<br>
class AddrLabelExpr : public Expr {<br>
SourceLocation AmpAmpLoc, LabelLoc;<br>
LabelDecl *Label;<br>
+<br>
public:<br>
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L,<br>
QualType t)<br>
@@ -3453,8 +3543,7 @@ public:<br>
AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}<br>
<br>
/// \brief Build an empty address of a label expression.<br>
- explicit AddrLabelExpr(EmptyShell Empty)<br>
- : Expr(AddrLabelExprClass, Empty) { }<br>
+ explicit AddrLabelExpr(EmptyShell Empty) : Expr(AddrLabelExprClass, Empty) {}<br>
<br>
SourceLocation getAmpAmpLoc() const { return AmpAmpLoc; }<br>
void setAmpAmpLoc(SourceLocation L) { AmpAmpLoc = L; }<br>
@@ -3475,6 +3564,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -3489,18 +3579,19 @@ public:<br>
class StmtExpr : public Expr {<br>
Stmt *SubStmt;<br>
SourceLocation LParenLoc, RParenLoc;<br>
+<br>
public:<br>
// FIXME: Does type-dependence need to be computed differently?<br>
// FIXME: Do we need to compute instantiation instantiation-dependence for<br>
// statements? (ugh!)<br>
StmtExpr(CompoundStmt *substmt, QualType T,<br>
- SourceLocation lp, SourceLocation rp) :<br>
- Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,<br>
- T->isDependentType(), false, false, false),<br>
- SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }<br>
+ SourceLocation lp, SourceLocation rp)<br>
+ : Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,<br>
+ T->isDependentType(), false, false, false),<br>
+ SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) {}<br>
<br>
/// \brief Build an empty statement expression.<br>
- explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }<br>
+ explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) {}<br>
<br>
CompoundStmt *getSubStmt() { return cast<CompoundStmt>(SubStmt); }<br>
const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); }<br>
@@ -3520,6 +3611,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&SubStmt, &SubStmt+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SubStmt, &SubStmt + 1);<br>
}<br>
@@ -3538,7 +3630,7 @@ class ShuffleVectorExpr : public Expr {<br>
// function. The first two are vectors, and the rest are constant<br>
// indices. The number of values in this list is always<br>
// 2+the number of indices in the vector type.<br>
- Stmt **SubExprs;<br>
+ Stmt **SubExprs = nullptr;<br>
unsigned NumExprs;<br>
<br>
public:<br>
@@ -3547,7 +3639,7 @@ public:<br>
<br>
/// \brief Build an empty vector-shuffle expression.<br>
explicit ShuffleVectorExpr(EmptyShell Empty)<br>
- : Expr(ShuffleVectorExprClass, Empty), SubExprs(nullptr) { }<br>
+ : Expr(ShuffleVectorExprClass, Empty) {}<br>
<br>
SourceLocation getBuiltinLoc() const { return BuiltinLoc; }<br>
void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }<br>
@@ -3591,6 +3683,7 @@ public:<br>
child_range children() {<br>
return child_range(&SubExprs[0], &SubExprs[0]+NumExprs);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SubExprs[0]<wbr>, &SubExprs[0] + NumExprs);<br>
}<br>
@@ -3601,12 +3694,13 @@ public:<br>
/// vector type of the same arity.<br>
class ConvertVectorExpr : public Expr {<br>
private:<br>
+ friend class ASTReader;<br>
+ friend class ASTStmtReader;<br>
+<br>
Stmt *SrcExpr;<br>
TypeSourceInfo *TInfo;<br>
SourceLocation BuiltinLoc, RParenLoc;<br>
<br>
- friend class ASTReader;<br>
- friend class ASTStmtReader;<br>
explicit ConvertVectorExpr(EmptyShell Empty) : Expr(ConvertVectorExprClass, Empty) {}<br>
<br>
public:<br>
@@ -3648,6 +3742,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SrcExpr, &SrcExpr + 1);<br>
}<br>
@@ -3664,9 +3759,11 @@ public:<br>
/// sub-expression.<br>
class ChooseExpr : public Expr {<br>
enum { COND, LHS, RHS, END_EXPR };<br>
+<br>
Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.<br>
SourceLocation BuiltinLoc, RParenLoc;<br>
bool CondIsTrue;<br>
+<br>
public:<br>
ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs,<br>
QualType t, ExprValueKind VK, ExprObjectKind OK,<br>
@@ -3686,7 +3783,7 @@ public:<br>
}<br>
<br>
/// \brief Build an empty __builtin_choose_expr.<br>
- explicit ChooseExpr(EmptyShell Empty) : Expr(ChooseExprClass, Empty) { }<br>
+ explicit ChooseExpr(EmptyShell Empty) : Expr(ChooseExprClass, Empty) {}<br>
<br>
/// isConditionTrue - Return whether the condition is true (i.e. not<br>
/// equal to zero).<br>
@@ -3731,6 +3828,7 @@ public:<br>
child_range children() {<br>
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SubExprs[0]<wbr>, &SubExprs[0] + END_EXPR);<br>
}<br>
@@ -3748,12 +3846,12 @@ class GNUNullExpr : public Expr {<br>
<br>
public:<br>
GNUNullExpr(QualType Ty, SourceLocation Loc)<br>
- : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary, false, false, false,<br>
- false),<br>
- TokenLoc(Loc) { }<br>
+ : Expr(GNUNullExprClass, Ty, VK_RValue, OK_Ordinary, false, false, false,<br>
+ false),<br>
+ TokenLoc(Loc) {}<br>
<br>
/// \brief Build an empty GNU __null expression.<br>
- explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { }<br>
+ explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) {}<br>
<br>
/// getTokenLocation - The location of the __null token.<br>
SourceLocation getTokenLocation() const { return TokenLoc; }<br>
@@ -3770,6 +3868,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -3777,9 +3876,10 @@ public:<br>
<br>
/// Represents a call to the builtin function \c __builtin_va_arg.<br>
class VAArgExpr : public Expr {<br>
- Stmt *Val;<br>
+ Stmt *Val = nullptr;<br>
llvm::PointerIntPair<<wbr>TypeSourceInfo *, 1, bool> TInfo;<br>
SourceLocation BuiltinLoc, RParenLoc;<br>
+<br>
public:<br>
VAArgExpr(SourceLocation BLoc, Expr *e, TypeSourceInfo *TInfo,<br>
SourceLocation RPLoc, QualType t, bool IsMS)<br>
@@ -3792,7 +3892,7 @@ public:<br>
<br>
/// Create an empty __builtin_va_arg expression.<br>
explicit VAArgExpr(EmptyShell Empty)<br>
- : Expr(VAArgExprClass, Empty), Val(nullptr), TInfo(nullptr, false) {}<br>
+ : Expr(VAArgExprClass, Empty), TInfo(nullptr, false) {}<br>
<br>
const Expr *getSubExpr() const { return cast<Expr>(Val); }<br>
Expr *getSubExpr() { return cast<Expr>(Val); }<br>
@@ -3820,6 +3920,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&Val, &Val+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Val, &Val + 1);<br>
}<br>
@@ -3872,7 +3973,8 @@ public:<br>
/// semantic initializer list also serves as its syntactic form.<br>
class InitListExpr : public Expr {<br>
// FIXME: Eliminate this vector in favor of ASTContext allocation<br>
- typedef ASTVector<Stmt *> InitExprsTy;<br>
+ using InitExprsTy = ASTVector<Stmt *>;<br>
+<br>
InitExprsTy InitExprs;<br>
SourceLocation LBraceLoc, RBraceLoc;<br>
<br>
@@ -3893,12 +3995,15 @@ class InitListExpr : public Expr {<br>
llvm::PointerUnion<Expr *, FieldDecl *> ArrayFillerOrUnionFieldInit;<br>
<br>
public:<br>
+ friend class ASTStmtReader;<br>
+ friend class ASTStmtWriter;<br>
+<br>
InitListExpr(const ASTContext &C, SourceLocation lbraceloc,<br>
ArrayRef<Expr*> initExprs, SourceLocation rbraceloc);<br>
<br>
/// \brief Build an empty initializer list.<br>
explicit InitListExpr(EmptyShell Empty)<br>
- : Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }<br>
+ : Expr(InitListExprClass, Empty), AltForm(nullptr, true) {}<br>
<br>
unsigned getNumInits() const { return InitExprs.size(); }<br>
<br>
@@ -4021,12 +4126,15 @@ public:<br>
void setRBraceLoc(SourceLocation Loc) { RBraceLoc = Loc; }<br>
<br>
bool isSemanticForm() const { return AltForm.getInt(); }<br>
+<br>
InitListExpr *getSemanticForm() const {<br>
return isSemanticForm() ? nullptr : AltForm.getPointer();<br>
}<br>
+<br>
bool isSyntacticForm() const {<br>
return !AltForm.getInt() || !AltForm.getPointer();<br>
}<br>
+<br>
InitListExpr *getSyntacticForm() const {<br>
return isSemanticForm() ? AltForm.getPointer() : nullptr;<br>
}<br>
@@ -4041,6 +4149,7 @@ public:<br>
bool hadArrayRangeDesignator() const {<br>
return InitListExprBits.<wbr>HadArrayRangeDesignator != 0;<br>
}<br>
+<br>
void sawArrayRangeDesignator(bool ARD = true) {<br>
InitListExprBits.<wbr>HadArrayRangeDesignator = ARD;<br>
}<br>
@@ -4066,10 +4175,10 @@ public:<br>
return const_child_range(&InitExprs[<wbr>0], &InitExprs[0] + InitExprs.size());<br>
}<br>
<br>
- typedef InitExprsTy::iterator iterator;<br>
- typedef InitExprsTy::const_iterator const_iterator;<br>
- typedef InitExprsTy::reverse_iterator reverse_iterator;<br>
- typedef InitExprsTy::const_reverse_<wbr>iterator const_reverse_iterator;<br>
+ using iterator = InitExprsTy::iterator;<br>
+ using const_iterator = InitExprsTy::const_iterator;<br>
+ using reverse_iterator = InitExprsTy::reverse_iterator;<br>
+ using const_reverse_iterator = InitExprsTy::const_reverse_<wbr>iterator;<br>
<br>
iterator begin() { return InitExprs.begin(); }<br>
const_iterator begin() const { return InitExprs.begin(); }<br>
@@ -4079,9 +4188,6 @@ public:<br>
const_reverse_iterator rbegin() const { return InitExprs.rbegin(); }<br>
reverse_iterator rend() { return InitExprs.rend(); }<br>
const_reverse_iterator rend() const { return InitExprs.rend(); }<br>
-<br>
- friend class ASTStmtReader;<br>
- friend class ASTStmtWriter;<br>
};<br>
<br>
/// @brief Represents a C99 designated initializer expression.<br>
@@ -4130,7 +4236,7 @@ private:<br>
<br>
/// \brief The designators in this designated initialization<br>
/// expression.<br>
- Designator *Designators;<br>
+ Designator *Designators = nullptr;<br>
<br>
DesignatedInitExpr(const ASTContext &C, QualType Ty,<br>
llvm::ArrayRef<Designator> Designators,<br>
@@ -4138,10 +4244,12 @@ private:<br>
ArrayRef<Expr *> IndexExprs, Expr *Init);<br>
<br>
explicit DesignatedInitExpr(unsigned NumSubExprs)<br>
- : Expr(DesignatedInitExprClass, EmptyShell()),<br>
- NumDesignators(0), NumSubExprs(NumSubExprs), Designators(nullptr) { }<br>
+ : Expr(DesignatedInitExprClass, EmptyShell()),<br>
+ NumDesignators(0), NumSubExprs(NumSubExprs) {}<br>
<br>
public:<br>
+ friend TrailingObjects;<br>
+<br>
/// A field designator, e.g., ".x".<br>
struct FieldDesignator {<br>
/// Refers to the field that is being initialized. The low bit<br>
@@ -4164,11 +4272,14 @@ public:<br>
/// Location of the first index expression within the designated<br>
/// initializer expression's list of subexpressions.<br>
unsigned Index;<br>
+<br>
/// The location of the '[' starting the array range designator.<br>
unsigned LBracketLoc;<br>
+<br>
/// The location of the ellipsis separating the start and end<br>
/// indices. Only valid for GNU array-range designators.<br>
unsigned EllipsisLoc;<br>
+<br>
/// The location of the ']' terminating the array range designator.<br>
unsigned RBracketLoc;<br>
};<br>
@@ -4180,6 +4291,8 @@ public:<br>
/// keep us from reusing it. Try harder, later, to rectify these<br>
/// differences.<br>
class Designator {<br>
+ friend class DesignatedInitExpr;<br>
+<br>
/// @brief The kind of designator this describes.<br>
enum {<br>
FieldDesignator,<br>
@@ -4190,13 +4303,13 @@ public:<br>
union {<br>
/// A field designator, e.g., ".x".<br>
struct FieldDesignator Field;<br>
+<br>
/// An array or GNU array-range designator, e.g., "[9]" or "[10..15]".<br>
struct ArrayOrRangeDesignator ArrayOrRange;<br>
};<br>
- friend class DesignatedInitExpr;<br>
<br>
public:<br>
- Designator() {}<br>
+ Designator() = default;<br>
<br>
/// @brief Initializes a field designator.<br>
Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc,<br>
@@ -4286,9 +4399,11 @@ public:<br>
else<br>
return getLBracketLoc();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc();<br>
}<br>
+<br>
SourceRange getSourceRange() const LLVM_READONLY {<br>
return SourceRange(getLocStart(), getLocEnd());<br>
}<br>
@@ -4381,12 +4496,11 @@ public:<br>
Stmt **begin = getTrailingObjects<Stmt *>();<br>
return child_range(begin, begin + NumSubExprs);<br>
}<br>
+<br>
const_child_range children() const {<br>
Stmt * const *begin = getTrailingObjects<Stmt *>();<br>
return const_child_range(begin, begin + NumSubExprs);<br>
}<br>
-<br>
- friend TrailingObjects;<br>
};<br>
<br>
/// \brief Represents a place-holder for an object not to be initialized by<br>
@@ -4401,11 +4515,10 @@ public:<br>
class NoInitExpr : public Expr {<br>
public:<br>
explicit NoInitExpr(QualType ty)<br>
- : Expr(NoInitExprClass, ty, VK_RValue, OK_Ordinary,<br>
- false, false, ty-><wbr>isInstantiationDependentType()<wbr>, false) { }<br>
+ : Expr(NoInitExprClass, ty, VK_RValue, OK_Ordinary,<br>
+ false, false, ty-><wbr>isInstantiationDependentType()<wbr>, false) {}<br>
<br>
- explicit NoInitExpr(EmptyShell Empty)<br>
- : Expr(NoInitExprClass, Empty) { }<br>
+ explicit NoInitExpr(EmptyShell Empty) : Expr(NoInitExprClass, Empty) {}<br>
<br>
static bool classof(const Stmt *T) {<br>
return T->getStmtClass() == NoInitExprClass;<br>
@@ -4418,6 +4531,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -4444,7 +4558,7 @@ public:<br>
Expr *baseExprs, SourceLocation rBraceLoc);<br>
<br>
explicit DesignatedInitUpdateExpr(<wbr>EmptyShell Empty)<br>
- : Expr(<wbr>DesignatedInitUpdateExprClass, Empty) { }<br>
+ : Expr(<wbr>DesignatedInitUpdateExprClass, Empty) {}<br>
<br>
SourceLocation getLocStart() const LLVM_READONLY;<br>
SourceLocation getLocEnd() const LLVM_READONLY;<br>
@@ -4459,6 +4573,7 @@ public:<br>
InitListExpr *getUpdater() const {<br>
return cast<InitListExpr>(<wbr>BaseAndUpdaterExprs[1]);<br>
}<br>
+<br>
void setUpdater(Expr *Updater) { BaseAndUpdaterExprs[1] = Updater; }<br>
<br>
// Iterators<br>
@@ -4466,6 +4581,7 @@ public:<br>
child_range children() {<br>
return child_range(&<wbr>BaseAndUpdaterExprs[0], &BaseAndUpdaterExprs[0] + 2);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&<wbr>BaseAndUpdaterExprs[0],<br>
&BaseAndUpdaterExprs[0] + 2);<br>
@@ -4495,6 +4611,10 @@ class ArrayInitLoopExpr : public Expr {<br>
: Expr(ArrayInitLoopExprClass, Empty), SubExprs{} {}<br>
<br>
public:<br>
+ friend class ASTReader;<br>
+ friend class ASTStmtReader;<br>
+ friend class ASTStmtWriter;<br>
+<br>
explicit ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit)<br>
: Expr(ArrayInitLoopExprClass, T, VK_RValue, OK_Ordinary, false,<br>
CommonInit->isValueDependent() || ElementInit->isValueDependent(<wbr>),<br>
@@ -4524,6 +4644,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getCommonExpr()->getLocStart()<wbr>;<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return getCommonExpr()->getLocEnd();<br>
}<br>
@@ -4531,13 +4652,10 @@ public:<br>
child_range children() {<br>
return child_range(SubExprs, SubExprs + 2);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(SubExprs, SubExprs + 2);<br>
}<br>
-<br>
- friend class ASTReader;<br>
- friend class ASTStmtReader;<br>
- friend class ASTStmtWriter;<br>
};<br>
<br>
/// \brief Represents the index of the current element of an array being<br>
@@ -4548,6 +4666,9 @@ class ArrayInitIndexExpr : public Expr {<br>
: Expr(ArrayInitIndexExprClass, Empty) {}<br>
<br>
public:<br>
+ friend class ASTReader;<br>
+ friend class ASTStmtReader;<br>
+<br>
explicit ArrayInitIndexExpr(QualType T)<br>
: Expr(ArrayInitIndexExprClass, T, VK_RValue, OK_Ordinary,<br>
false, false, false, false) {}<br>
@@ -4562,12 +4683,10 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
-<br>
- friend class ASTReader;<br>
- friend class ASTStmtReader;<br>
};<br>
<br>
/// \brief Represents an implicitly-generated value initialization of<br>
@@ -4581,12 +4700,12 @@ public:<br>
class ImplicitValueInitExpr : public Expr {<br>
public:<br>
explicit ImplicitValueInitExpr(QualType ty)<br>
- : Expr(<wbr>ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary,<br>
- false, false, ty-><wbr>isInstantiationDependentType()<wbr>, false) { }<br>
+ : Expr(<wbr>ImplicitValueInitExprClass, ty, VK_RValue, OK_Ordinary,<br>
+ false, false, ty-><wbr>isInstantiationDependentType()<wbr>, false) {}<br>
<br>
/// \brief Construct an empty implicit value initialization.<br>
explicit ImplicitValueInitExpr(<wbr>EmptyShell Empty)<br>
- : Expr(<wbr>ImplicitValueInitExprClass, Empty) { }<br>
+ : Expr(<wbr>ImplicitValueInitExprClass, Empty) {}<br>
<br>
static bool classof(const Stmt *T) {<br>
return T->getStmtClass() == ImplicitValueInitExprClass;<br>
@@ -4599,6 +4718,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -4610,11 +4730,14 @@ class ParenListExpr : public Expr {<br>
SourceLocation LParenLoc, RParenLoc;<br>
<br>
public:<br>
+ friend class ASTStmtReader;<br>
+ friend class ASTStmtWriter;<br>
+<br>
ParenListExpr(const ASTContext& C, SourceLocation lparenloc,<br>
ArrayRef<Expr*> exprs, SourceLocation rparenloc);<br>
<br>
/// \brief Build an empty paren list.<br>
- explicit ParenListExpr(EmptyShell Empty) : Expr(ParenListExprClass, Empty) { }<br>
+ explicit ParenListExpr(EmptyShell Empty) : Expr(ParenListExprClass, Empty) {}<br>
<br>
unsigned getNumExprs() const { return NumExprs; }<br>
<br>
@@ -4648,12 +4771,10 @@ public:<br>
child_range children() {<br>
return child_range(&Exprs[0], &Exprs[0]+NumExprs);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Exprs[0], &Exprs[0] + NumExprs);<br>
}<br>
-<br>
- friend class ASTStmtReader;<br>
- friend class ASTStmtWriter;<br>
};<br>
<br>
/// \brief Represents a C11 generic selection.<br>
@@ -4684,12 +4805,15 @@ public:<br>
/// Result-dependent generic associations are both type- and value-dependent.<br>
class GenericSelectionExpr : public Expr {<br>
enum { CONTROLLING, END_EXPR };<br>
+<br>
TypeSourceInfo **AssocTypes;<br>
Stmt **SubExprs;<br>
unsigned NumAssocs, ResultIndex;<br>
SourceLocation GenericLoc, DefaultLoc, RParenLoc;<br>
<br>
public:<br>
+ friend class ASTStmtReader;<br>
+<br>
GenericSelectionExpr(const ASTContext &Context,<br>
SourceLocation GenericLoc, Expr *ControllingExpr,<br>
ArrayRef<TypeSourceInfo*> AssocTypes,<br>
@@ -4707,7 +4831,7 @@ public:<br>
bool ContainsUnexpandedParameterPac<wbr>k);<br>
<br>
explicit GenericSelectionExpr(<wbr>EmptyShell Empty)<br>
- : Expr(<wbr>GenericSelectionExprClass, Empty) { }<br>
+ : Expr(<wbr>GenericSelectionExprClass, Empty) {}<br>
<br>
unsigned getNumAssocs() const { return NumAssocs; }<br>
<br>
@@ -4718,17 +4842,22 @@ public:<br>
const Expr *getAssocExpr(unsigned i) const {<br>
return cast<Expr>(SubExprs[END_EXPR+<wbr>i]);<br>
}<br>
+<br>
Expr *getAssocExpr(unsigned i) { return cast<Expr>(SubExprs[END_EXPR+<wbr>i]); }<br>
+<br>
ArrayRef<Expr *> getAssocExprs() const {<br>
return NumAssocs<br>
? llvm::makeArrayRef(<br>
&reinterpret_cast<Expr **>(SubExprs)[END_EXPR], NumAssocs)<br>
: None;<br>
}<br>
+<br>
const TypeSourceInfo *getAssocTypeSourceInfo(<wbr>unsigned i) const {<br>
return AssocTypes[i];<br>
}<br>
+<br>
TypeSourceInfo *getAssocTypeSourceInfo(<wbr>unsigned i) { return AssocTypes[i]; }<br>
+<br>
ArrayRef<TypeSourceInfo *> getAssocTypeSourceInfos() const {<br>
return NumAssocs ? llvm::makeArrayRef(&<wbr>AssocTypes[0], NumAssocs) : None;<br>
}<br>
@@ -4743,6 +4872,7 @@ public:<br>
const Expr *getControllingExpr() const {<br>
return cast<Expr>(SubExprs[<wbr>CONTROLLING]);<br>
}<br>
+<br>
Expr *getControllingExpr() { return cast<Expr>(SubExprs[<wbr>CONTROLLING]); }<br>
<br>
/// Whether this generic selection is result-dependent.<br>
@@ -4771,10 +4901,10 @@ public:<br>
child_range children() {<br>
return child_range(SubExprs, SubExprs+END_EXPR+NumAssocs);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(SubExprs, SubExprs + END_EXPR + NumAssocs);<br>
}<br>
- friend class ASTStmtReader;<br>
};<br>
<br>
//===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
@@ -4787,11 +4917,11 @@ public:<br>
///<br>
/// Note that the base may have either vector or pointer to vector type, just<br>
/// like a struct field reference.<br>
-///<br>
class ExtVectorElementExpr : public Expr {<br>
Stmt *Base;<br>
IdentifierInfo *Accessor;<br>
SourceLocation AccessorLoc;<br>
+<br>
public:<br>
ExtVectorElementExpr(QualType ty, ExprValueKind VK, Expr *base,<br>
IdentifierInfo &accessor, SourceLocation loc)<br>
@@ -4804,7 +4934,7 @@ public:<br>
<br>
/// \brief Build an empty vector element expression.<br>
explicit ExtVectorElementExpr(<wbr>EmptyShell Empty)<br>
- : Expr(<wbr>ExtVectorElementExprClass, Empty) { }<br>
+ : Expr(<wbr>ExtVectorElementExprClass, Empty) {}<br>
<br>
const Expr *getBase() const { return cast<Expr>(Base); }<br>
Expr *getBase() { return cast<Expr>(Base); }<br>
@@ -4830,6 +4960,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getBase()->getLocStart();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY { return AccessorLoc; }<br>
<br>
/// isArrow - Return true if the base expression is a pointer to vector,<br>
@@ -4842,6 +4973,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&Base, &Base+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&Base, &Base + 1);<br>
}<br>
@@ -4852,6 +4984,7 @@ public:<br>
class BlockExpr : public Expr {<br>
protected:<br>
BlockDecl *TheBlock;<br>
+<br>
public:<br>
BlockExpr(BlockDecl *BD, QualType ty)<br>
: Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary,<br>
@@ -4861,7 +4994,7 @@ public:<br>
TheBlock(BD) {}<br>
<br>
/// \brief Build an empty block expression.<br>
- explicit BlockExpr(EmptyShell Empty) : Expr(BlockExprClass, Empty) { }<br>
+ explicit BlockExpr(EmptyShell Empty) : Expr(BlockExprClass, Empty) {}<br>
<br>
const BlockDecl *getBlockDecl() const { return TheBlock; }<br>
BlockDecl *getBlockDecl() { return TheBlock; }<br>
@@ -4886,6 +5019,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -4896,11 +5030,12 @@ public:<br>
/// type of the same size.<br>
class AsTypeExpr : public Expr {<br>
private:<br>
+ friend class ASTReader;<br>
+ friend class ASTStmtReader;<br>
+<br>
Stmt *SrcExpr;<br>
SourceLocation BuiltinLoc, RParenLoc;<br>
<br>
- friend class ASTReader;<br>
- friend class ASTStmtReader;<br>
explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {}<br>
<br>
public:<br>
@@ -4934,6 +5069,7 @@ public:<br>
<br>
// Iterators<br>
child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }<br>
+<br>
const_child_range children() const {<br>
return const_child_range(&SrcExpr, &SrcExpr + 1);<br>
}<br>
@@ -4981,22 +5117,26 @@ class PseudoObjectExpr final<br>
// in to Create, which is an index within the semantic forms.<br>
// Note also that ASTStmtWriter assumes this encoding.<br>
<br>
- Expr **getSubExprsBuffer() { return getTrailingObjects<Expr *>(); }<br>
- const Expr * const *getSubExprsBuffer() const {<br>
- return getTrailingObjects<Expr *>();<br>
- }<br>
-<br>
PseudoObjectExpr(QualType type, ExprValueKind VK,<br>
Expr *syntactic, ArrayRef<Expr*> semantic,<br>
unsigned resultIndex);<br>
<br>
PseudoObjectExpr(EmptyShell shell, unsigned numSemanticExprs);<br>
<br>
+ Expr **getSubExprsBuffer() { return getTrailingObjects<Expr *>(); }<br>
+<br>
+ const Expr * const *getSubExprsBuffer() const {<br>
+ return getTrailingObjects<Expr *>();<br>
+ }<br>
+<br>
unsigned getNumSubExprs() const {<br>
return PseudoObjectExprBits.<wbr>NumSubExprs;<br>
}<br>
<br>
public:<br>
+ friend class ASTStmtReader;<br>
+ friend TrailingObjects;<br>
+<br>
/// NoResult - A value for the result index indicating that there is<br>
/// no semantic result.<br>
enum : unsigned { NoResult = ~0U };<br>
@@ -5033,17 +5173,21 @@ public:<br>
<br>
unsigned getNumSemanticExprs() const { return getNumSubExprs() - 1; }<br>
<br>
- typedef Expr * const *semantics_iterator;<br>
- typedef const Expr * const *const_semantics_iterator;<br>
+ using semantics_iterator = Expr * const *;<br>
+ using const_semantics_iterator = const Expr * const *;<br>
+<br>
semantics_iterator semantics_begin() {<br>
return getSubExprsBuffer() + 1;<br>
}<br>
+<br>
const_semantics_iterator semantics_begin() const {<br>
return getSubExprsBuffer() + 1;<br>
}<br>
+<br>
semantics_iterator semantics_end() {<br>
return getSubExprsBuffer() + getNumSubExprs();<br>
}<br>
+<br>
const_semantics_iterator semantics_end() const {<br>
return getSubExprsBuffer() + getNumSubExprs();<br>
}<br>
@@ -5051,6 +5195,7 @@ public:<br>
llvm::iterator_range<<wbr>semantics_iterator> semantics() {<br>
return llvm::make_range(semantics_<wbr>begin(), semantics_end());<br>
}<br>
+<br>
llvm::iterator_range<const_<wbr>semantics_iterator> semantics() const {<br>
return llvm::make_range(semantics_<wbr>begin(), semantics_end());<br>
}<br>
@@ -5059,6 +5204,7 @@ public:<br>
assert(index + 1 < getNumSubExprs());<br>
return getSubExprsBuffer()[index + 1];<br>
}<br>
+<br>
const Expr *getSemanticExpr(unsigned index) const {<br>
return const_cast<PseudoObjectExpr*>(<wbr>this)->getSemanticExpr(index);<br>
}<br>
@@ -5070,6 +5216,7 @@ public:<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return getSyntacticForm()-><wbr>getLocStart();<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY {<br>
return getSyntacticForm()->getLocEnd(<wbr>);<br>
}<br>
@@ -5080,6 +5227,7 @@ public:<br>
return child_range(cast_away_const(<wbr>CCR.begin()),<br>
cast_away_const(CCR.end()));<br>
}<br>
+<br>
const_child_range children() const {<br>
Stmt *const *cs = const_cast<Stmt *const *>(<br>
reinterpret_cast<const Stmt *const *>(getSubExprsBuffer()));<br>
@@ -5089,9 +5237,6 @@ public:<br>
static bool classof(const Stmt *T) {<br>
return T->getStmtClass() == PseudoObjectExprClass;<br>
}<br>
-<br>
- friend TrailingObjects;<br>
- friend class ASTStmtReader;<br>
};<br>
<br>
/// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,<br>
@@ -5112,16 +5257,18 @@ public:<br>
};<br>
<br>
private:<br>
+ friend class ASTStmtReader;<br>
+<br>
/// \brief Location of sub-expressions.<br>
/// The location of Scope sub-expression is NumSubExprs - 1, which is<br>
/// not fixed, therefore is not defined in enum.<br>
enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };<br>
+<br>
Stmt *SubExprs[END_EXPR + 1];<br>
unsigned NumSubExprs;<br>
SourceLocation BuiltinLoc, RParenLoc;<br>
AtomicOp Op;<br>
<br>
- friend class ASTStmtReader;<br>
public:<br>
AtomicExpr(SourceLocation BLoc, ArrayRef<Expr*> args, QualType t,<br>
AtomicOp op, SourceLocation RP);<br>
@@ -5131,44 +5278,52 @@ public:<br>
static unsigned getNumSubExprs(AtomicOp Op);<br>
<br>
/// \brief Build an empty AtomicExpr.<br>
- explicit AtomicExpr(EmptyShell Empty) : Expr(AtomicExprClass, Empty) { }<br>
+ explicit AtomicExpr(EmptyShell Empty) : Expr(AtomicExprClass, Empty) {}<br>
<br>
Expr *getPtr() const {<br>
return cast<Expr>(SubExprs[PTR]);<br>
}<br>
+<br>
Expr *getOrder() const {<br>
return cast<Expr>(SubExprs[ORDER]);<br>
}<br>
+<br>
Expr *getScope() const {<br>
assert(getScopeModel() && "No scope");<br>
return cast<Expr>(SubExprs[<wbr>NumSubExprs - 1]);<br>
}<br>
+<br>
Expr *getVal1() const {<br>
if (Op == AO__c11_atomic_init || Op == AO__opencl_atomic_init)<br>
return cast<Expr>(SubExprs[ORDER]);<br>
assert(NumSubExprs > VAL1);<br>
return cast<Expr>(SubExprs[VAL1]);<br>
}<br>
+<br>
Expr *getOrderFail() const {<br>
assert(NumSubExprs > ORDER_FAIL);<br>
return cast<Expr>(SubExprs[ORDER_<wbr>FAIL]);<br>
}<br>
+<br>
Expr *getVal2() const {<br>
if (Op == AO__atomic_exchange)<br>
return cast<Expr>(SubExprs[ORDER_<wbr>FAIL]);<br>
assert(NumSubExprs > VAL2);<br>
return cast<Expr>(SubExprs[VAL2]);<br>
}<br>
+<br>
Expr *getWeak() const {<br>
assert(NumSubExprs > WEAK);<br>
return cast<Expr>(SubExprs[WEAK]);<br>
}<br>
+<br>
QualType getValueType() const;<br>
<br>
AtomicOp getOp() const { return Op; }<br>
unsigned getNumSubExprs() const { return NumSubExprs; }<br>
<br>
Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }<br>
+<br>
const Expr * const *getSubExprs() const {<br>
return reinterpret_cast<Expr * const *>(SubExprs);<br>
}<br>
@@ -5205,6 +5360,7 @@ public:<br>
child_range children() {<br>
return child_range(SubExprs, SubExprs+NumSubExprs);<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(SubExprs, SubExprs + NumSubExprs);<br>
}<br>
@@ -5244,6 +5400,7 @@ public:<br>
child_range children() {<br>
return child_range(child_iterator(), child_iterator());<br>
}<br>
+<br>
const_child_range children() const {<br>
return const_child_range(const_child_<wbr>iterator(), const_child_iterator());<br>
}<br>
@@ -5254,8 +5411,8 @@ public:<br>
static bool classof(const Stmt *T) {<br>
return T->getStmtClass() == TypoExprClass;<br>
}<br>
-<br>
};<br>
-} // end namespace clang<br>
+<br>
+} // namespace clang<br>
<br>
#endif // LLVM_CLANG_AST_EXPR_H<br>
<br>
Modified: cfe/trunk/lib/AST/Expr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=318341&r1=318340&r2=318341&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/AST/<wbr>Expr.cpp?rev=318341&r1=318340&<wbr>r2=318341&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/Expr.cpp (original)<br>
+++ cfe/trunk/lib/AST/Expr.cpp Wed Nov 15 14:00:04 2017<br>
@@ -1,4 +1,4 @@<br>
-//===--- Expr.cpp - Expression AST Node Implementation --------------------===//<br>
+//===- Expr.cpp - Expression AST Node Implementation ----------------------===//<br>
//<br>
// The LLVM Compiler Infrastructure<br>
//<br>
@@ -11,28 +11,62 @@<br>
//<br>
//===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
+#include "clang/AST/Expr.h"<br>
#include "clang/AST/ASTContext.h"<br>
#include "clang/AST/Attr.h"<br>
+#include "clang/AST/Decl.h"<br>
+#include "clang/AST/DeclBase.h"<br>
#include "clang/AST/DeclCXX.h"<br>
#include "clang/AST/DeclObjC.h"<br>
#include "clang/AST/DeclTemplate.h"<br>
+#include "clang/AST/DeclarationName.h"<br>
#include "clang/AST/<wbr>EvaluatedExprVisitor.h"<br>
-#include "clang/AST/Expr.h"<br>
#include "clang/AST/ExprCXX.h"<br>
+#include "clang/AST/ExprObjC.h"<br>
+#include "clang/AST/ExprOpenMP.h"<br>
#include "clang/AST/Mangle.h"<br>
-#include "clang/AST/RecordLayout.h"<br>
-#include "clang/AST/StmtVisitor.h"<br>
+#include "clang/AST/<wbr>NestedNameSpecifier.h"<br>
+#include "clang/AST/OperationKinds.h"<br>
+#include "clang/AST/PrettyPrinter.h"<br>
+#include "clang/AST/Stmt.h"<br>
+#include "clang/AST/TemplateBase.h"<br>
+#include "clang/AST/Type.h"<br>
+#include "clang/Basic/AddressSpaces.h"<br>
#include "clang/Basic/Builtins.h"<br>
#include "clang/Basic/CharInfo.h"<br>
+#include "clang/Basic/LLVM.h"<br>
+#include "clang/Basic/Lambda.h"<br>
+#include "clang/Basic/LangOptions.h"<br>
+#include "clang/Basic/OperatorKinds.h"<br>
+#include "clang/Basic/SourceLocation.h"<br>
#include "clang/Basic/SourceManager.h"<br>
+#include "clang/Basic/Specifiers.h"<br>
#include "clang/Basic/TargetInfo.h"<br>
+#include "clang/Basic/TypeTraits.h"<br>
#include "clang/Lex/Lexer.h"<br>
#include "clang/Lex/LiteralSupport.h"<br>
-#include "clang/Sema/SemaDiagnostic.h"<br>
+#include "clang/Lex/Token.h"<br>
+#include "llvm/ADT/APFloat.h"<br>
+#include "llvm/ADT/APInt.h"<br>
+#include "llvm/ADT/APSInt.h"<br>
+#include "llvm/ADT/ArrayRef.h"<br>
+#include "llvm/ADT/None.h"<br>
+#include "llvm/ADT/SmallString.h"<br>
+#include "llvm/ADT/SmallVector.h"<br>
+#include "llvm/ADT/StringRef.h"<br>
+#include "llvm/Support/Casting.h"<br>
+#include "llvm/Support/Compiler.h"<br>
#include "llvm/Support/ErrorHandling.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
#include <algorithm><br>
+#include <cassert><br>
+#include <cstddef><br>
+#include <cstdint><br>
#include <cstring><br>
+#include <memory><br>
+#include <string><br>
+#include <utility><br>
+<br>
using namespace clang;<br>
<br>
const Expr *Expr::<wbr>getBestDynamicClassTypeExpr() const {<br>
@@ -193,24 +227,23 @@ bool Expr::<wbr>isKnownToHaveBooleanValue() c<br>
// a more specific implementation of getExprLoc().<br>
//<br>
// See also Stmt.cpp:{getLocStart(),<wbr>getLocEnd()}.<br>
-namespace {<br>
- /// This implementation is used when a class provides a custom<br>
- /// implementation of getExprLoc.<br>
- template <class E, class T><br>
- SourceLocation getExprLocImpl(const Expr *expr,<br>
- SourceLocation (T::*v)() const) {<br>
- return static_cast<const E*>(expr)->getExprLoc();<br>
- }<br>
-<br>
- /// This implementation is used when a class doesn't provide<br>
- /// a custom implementation of getExprLoc. Overload resolution<br>
- /// should pick it over the implementation above because it's<br>
- /// more specialized according to function template partial ordering.<br>
- template <class E><br>
- SourceLocation getExprLocImpl(const Expr *expr,<br>
- SourceLocation (Expr::*v)() const) {<br>
- return static_cast<const E*>(expr)->getLocStart();<br>
- }<br>
+<br>
+/// This implementation is used when a class provides a custom<br>
+/// implementation of getExprLoc.<br>
+template <class E, class T><br>
+static SourceLocation getExprLocImpl(const Expr *expr,<br>
+ SourceLocation (T::*v)() const) {<br>
+ return static_cast<const E*>(expr)->getExprLoc();<br>
+}<br>
+<br>
+/// This implementation is used when a class doesn't provide<br>
+/// a custom implementation of getExprLoc. Overload resolution<br>
+/// should pick it over the implementation above because it's<br>
+/// more specialized according to function template partial ordering.<br>
+template <class E><br>
+static SourceLocation getExprLocImpl(const Expr *expr,<br>
+ SourceLocation (Expr::*v)() const) {<br>
+ return static_cast<const E*>(expr)->getLocStart();<br>
}<br>
<br>
SourceLocation Expr::getExprLoc() const {<br>
@@ -452,6 +485,7 @@ SourceLocation DeclRefExpr::getLocStart(<br>
return getQualifierLoc().getBeginLoc(<wbr>);<br>
return getNameInfo().getLocStart();<br>
}<br>
+<br>
SourceLocation DeclRefExpr::getLocEnd() const {<br>
if (hasExplicitTemplateArgs())<br>
return getRAngleLoc();<br>
@@ -606,8 +640,9 @@ std::string PredefinedExpr::ComputeName(<br>
POut << " &&";<br>
}<br>
<br>
- typedef SmallVector<const ClassTemplateSpecializationDec<wbr>l *, 8> SpecsTy;<br>
+ using SpecsTy = SmallVector<const ClassTemplateSpecializationDec<wbr>l *, 8>;<br>
SpecsTy Specs;<br>
+<br>
const DeclContext *Ctx = FD->getDeclContext();<br>
while (Ctx && isa<NamedDecl>(Ctx)) {<br>
const ClassTemplateSpecializationDec<wbr>l *Spec<br>
@@ -765,7 +800,7 @@ FloatingLiteral::<wbr>FloatingLiteral(const A<br>
}<br>
<br>
FloatingLiteral::<wbr>FloatingLiteral(const ASTContext &C, EmptyShell Empty)<br>
- : Expr(FloatingLiteralClass, Empty) {<br>
+ : Expr(FloatingLiteralClass, Empty) {<br>
setRawSemantics(IEEEhalf);<br>
FloatingLiteralBits.IsExact = false;<br>
}<br>
@@ -1035,7 +1070,6 @@ void StringLiteral::setString(const ASTC<br>
/// Using these two parameters can reduce the time complexity from O(n^2) to<br>
/// O(n) if one wants to get the location of byte for all the tokens in a<br>
/// string.<br>
-///<br>
SourceLocation<br>
StringLiteral::<wbr>getLocationOfByte(unsigned ByteNo, const SourceManager &SM,<br>
const LangOptions &Features,<br>
@@ -1054,7 +1088,7 @@ StringLiteral::<wbr>getLocationOfByte(unsigne<br>
StringOffset = *StartTokenByteOffset;<br>
ByteNo -= StringOffset;<br>
}<br>
- while (1) {<br>
+ while (true) {<br>
assert(TokNo < getNumConcatenated() && "Invalid byte number!");<br>
SourceLocation StrTokLoc = getStrTokenLoc(TokNo);<br>
<br>
@@ -1109,8 +1143,6 @@ StringLiteral::<wbr>getLocationOfByte(unsigne<br>
}<br>
}<br>
<br>
-<br>
-<br>
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it<br>
/// corresponds to, e.g. "sizeof" or "[pre]++".<br>
StringRef UnaryOperator::getOpcodeStr(<wbr>Opcode Op) {<br>
@@ -1152,7 +1184,6 @@ OverloadedOperatorKind UnaryOperator::ge<br>
}<br>
}<br>
<br>
-<br>
//===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
// Postfix Operators.<br>
//===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
@@ -1164,7 +1195,6 @@ CallExpr::CallExpr(const ASTContext &C,<br>
fn->isValueDependent(), fn->isInstantiationDependent()<wbr>,<br>
fn-><wbr>containsUnexpandedParameterPac<wbr>k()),<br>
NumArgs(args.size()) {<br>
-<br>
unsigned NumPreArgs = preargs.size();<br>
SubExprs = new (C) Stmt *[args.size()+PREARGS_START+<wbr>NumPreArgs];<br>
SubExprs[FN] = fn;<br>
@@ -1188,15 +1218,15 @@ CallExpr::CallExpr(const ASTContext &C,<br>
<br>
CallExpr::CallExpr(const ASTContext &C, Expr *fn, ArrayRef<Expr *> args,<br>
QualType t, ExprValueKind VK, SourceLocation rparenloc)<br>
- : CallExpr(C, CallExprClass, fn, ArrayRef<Expr *>(), args, t, VK, rparenloc) {<br>
-}<br>
+ : CallExpr(C, CallExprClass, fn, ArrayRef<Expr *>(), args, t, VK,<br>
+ rparenloc) {}<br>
<br>
CallExpr::CallExpr(const ASTContext &C, StmtClass SC, EmptyShell Empty)<br>
: CallExpr(C, SC, /*NumPreArgs=*/0, Empty) {}<br>
<br>
CallExpr::CallExpr(const ASTContext &C, StmtClass SC, unsigned NumPreArgs,<br>
EmptyShell Empty)<br>
- : Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) {<br>
+ : Expr(SC, Empty) {<br>
// FIXME: Why do we allocate this?<br>
SubExprs = new (C) Stmt*[PREARGS_START+<wbr>NumPreArgs]();<br>
CallExprBits.NumPreArgs = NumPreArgs;<br>
@@ -1332,6 +1362,7 @@ SourceLocation CallExpr::getLocStart() c<br>
begin = getArg(0)->getLocStart();<br>
return begin;<br>
}<br>
+<br>
SourceLocation CallExpr::getLocEnd() const {<br>
if (isa<CXXOperatorCallExpr>(<wbr>this))<br>
return cast<CXXOperatorCallExpr>(<wbr>this)->getLocEnd();<br>
@@ -1393,7 +1424,7 @@ IdentifierInfo *OffsetOfNode::getFieldNa<br>
if (getKind() == Field)<br>
return getField()->getIdentifier();<br>
<br>
- return reinterpret_cast<<wbr>IdentifierInfo *> (Data & ~(uintptr_t)Mask);<br>
+ return reinterpret_cast<<wbr>IdentifierInfo *>(Data & ~(uintptr_t)Mask);<br>
}<br>
<br>
UnaryExprOrTypeTraitExpr::<wbr>UnaryExprOrTypeTraitExpr(<br>
@@ -1440,7 +1471,6 @@ MemberExpr *MemberExpr::Create(<br>
ValueDecl *memberdecl, DeclAccessPair founddecl,<br>
DeclarationNameInfo nameinfo, const TemplateArgumentListInfo *targs,<br>
QualType ty, ExprValueKind vk, ExprObjectKind ok) {<br>
-<br>
bool hasQualOrFound = (QualifierLoc ||<br>
founddecl.getDecl() != memberdecl ||<br>
founddecl.getAccess() != memberdecl->getAccess());<br>
@@ -1508,6 +1538,7 @@ SourceLocation MemberExpr::getLocStart()<br>
return BaseStartLoc;<br>
return MemberLoc;<br>
}<br>
+<br>
SourceLocation MemberExpr::getLocEnd() const {<br>
SourceLocation EndLoc = getMemberNameInfo().getEndLoc(<wbr>);<br>
if (hasExplicitTemplateArgs())<br>
@@ -1641,19 +1672,17 @@ const char *CastExpr::getCastKindName()<br>
llvm_unreachable("Unhandled cast kind!");<br>
}<br>
<br>
-namespace {<br>
- Expr *skipImplicitTemporary(Expr *expr) {<br>
- // Skip through reference binding to temporary.<br>
- if (MaterializeTemporaryExpr *Materialize<br>
- = dyn_cast<<wbr>MaterializeTemporaryExpr>(<wbr>expr))<br>
- expr = Materialize->GetTemporaryExpr(<wbr>);<br>
+static Expr *skipImplicitTemporary(Expr *expr) {<br>
+ // Skip through reference binding to temporary.<br>
+ if (MaterializeTemporaryExpr *Materialize<br>
+ = dyn_cast<<wbr>MaterializeTemporaryExpr>(<wbr>expr))<br>
+ expr = Materialize->GetTemporaryExpr(<wbr>);<br>
+<br>
+ // Skip any temporary bindings; they're implicit.<br>
+ if (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr><wbr>(expr))<br>
+ expr = Binder->getSubExpr();<br>
<br>
- // Skip any temporary bindings; they're implicit.<br>
- if (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr><wbr>(expr))<br>
- expr = Binder->getSubExpr();<br>
-<br>
- return expr;<br>
- }<br>
+ return expr;<br>
}<br>
<br>
Expr *CastExpr::<wbr>getSubExprAsWritten() {<br>
@@ -1861,13 +1890,13 @@ bool BinaryOperator::<wbr>isNullPointerArithm<br>
<br>
return true;<br>
}<br>
+<br>
InitListExpr::InitListExpr(<wbr>const ASTContext &C, SourceLocation lbraceloc,<br>
ArrayRef<Expr*> initExprs, SourceLocation rbraceloc)<br>
- : Expr(InitListExprClass, QualType(), VK_RValue, OK_Ordinary, false, false,<br>
- false, false),<br>
- InitExprs(C, initExprs.size()),<br>
- LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr, true)<br>
-{<br>
+ : Expr(InitListExprClass, QualType(), VK_RValue, OK_Ordinary, false, false,<br>
+ false, false),<br>
+ InitExprs(C, initExprs.size()),<br>
+ LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr, true) {<br>
sawArrayRangeDesignator(false)<wbr>;<br>
for (unsigned I = 0; I != initExprs.size(); ++I) {<br>
if (initExprs[I]-><wbr>isTypeDependent())<br>
@@ -1999,7 +2028,6 @@ SourceLocation InitListExpr::getLocEnd()<br>
}<br>
<br>
/// getFunctionType - Return the underlying function type for this block.<br>
-///<br>
const FunctionProtoType *BlockExpr::getFunctionType() const {<br>
// The block pointer is never sugared, but the function type might be.<br>
return cast<BlockPointerType>(<wbr>getType())<br>
@@ -2009,14 +2037,15 @@ const FunctionProtoType *BlockExpr::getF<br>
SourceLocation BlockExpr::getCaretLocation() const {<br>
return TheBlock->getCaretLocation();<br>
}<br>
+<br>
const Stmt *BlockExpr::getBody() const {<br>
return TheBlock->getBody();<br>
}<br>
+<br>
Stmt *BlockExpr::getBody() {<br>
return TheBlock->getBody();<br>
}<br>
<br>
-<br>
//===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
// Generic Expression Routines<br>
//===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
@@ -2211,7 +2240,7 @@ bool Expr::isUnusedResultAWarning(<wbr>const<br>
return false;<br>
<br>
case CXXTemporaryObjectExprClass:<br>
- case CXXConstructExprClass: {<br>
+ case CXXConstructExprClass:<br>
if (const CXXRecordDecl *Type = getType()->getAsCXXRecordDecl(<wbr>)) {<br>
if (Type->hasAttr<WarnUnusedAttr><wbr>()) {<br>
WarnE = this;<br>
@@ -2221,7 +2250,6 @@ bool Expr::isUnusedResultAWarning(<wbr>const<br>
}<br>
}<br>
return false;<br>
- }<br>
<br>
case ObjCMessageExprClass: {<br>
const ObjCMessageExpr *ME = cast<ObjCMessageExpr>(this);<br>
@@ -2894,7 +2922,6 @@ bool Expr::isConstantInitializer(<wbr>ASTCont<br>
case MaterializeTemporaryExprClass:<br>
return cast<MaterializeTemporaryExpr><wbr>(this)->GetTemporaryExpr()<br>
->isConstantInitializer(Ctx, false, Culprit);<br>
-<br>
case SubstNonTypeTemplateParmExprCl<wbr>ass:<br>
return cast<<wbr>SubstNonTypeTemplateParmExpr>(<wbr>this)->getReplacement()<br>
->isConstantInitializer(Ctx, false, Culprit);<br>
@@ -2916,16 +2943,17 @@ bool Expr::isConstantInitializer(<wbr>ASTCont<br>
}<br>
<br>
namespace {<br>
+<br>
/// \brief Look for any side effects within a Stmt.<br>
class SideEffectFinder : public ConstEvaluatedExprVisitor<<wbr>SideEffectFinder> {<br>
- typedef ConstEvaluatedExprVisitor<<wbr>SideEffectFinder> Inherited;<br>
+ using Inherited = ConstEvaluatedExprVisitor<<wbr>SideEffectFinder>;<br>
+<br>
const bool IncludePossibleEffects;<br>
- bool HasSideEffects;<br>
+ bool HasSideEffects = false;<br>
<br>
public:<br>
explicit SideEffectFinder(const ASTContext &Context, bool IncludePossible)<br>
- : Inherited(Context),<br>
- IncludePossibleEffects(<wbr>IncludePossible), HasSideEffects(false) { }<br>
+ : Inherited(Context), IncludePossibleEffects(<wbr>IncludePossible) {}<br>
<br>
bool hasSideEffects() const { return HasSideEffects; }<br>
<br>
@@ -2935,7 +2963,8 @@ namespace {<br>
HasSideEffects = true;<br>
}<br>
};<br>
-}<br>
+<br>
+} // namespace<br>
<br>
bool Expr::HasSideEffects(const ASTContext &Ctx,<br>
bool IncludePossibleEffects) const {<br>
@@ -3211,16 +3240,17 @@ bool Expr::HasSideEffects(const ASTConte<br>
}<br>
<br>
namespace {<br>
+<br>
/// \brief Look for a call to a non-trivial function within an expression.<br>
- class NonTrivialCallFinder : public ConstEvaluatedExprVisitor<<wbr>NonTrivialCallFinder><br>
- {<br>
- typedef ConstEvaluatedExprVisitor<<wbr>NonTrivialCallFinder> Inherited;<br>
+ class NonTrivialCallFinder<br>
+ : public ConstEvaluatedExprVisitor<<wbr>NonTrivialCallFinder> {<br>
+ using Inherited = ConstEvaluatedExprVisitor<<wbr>NonTrivialCallFinder>;<br>
<br>
- bool NonTrivial;<br>
+ bool NonTrivial = false;<br>
<br>
public:<br>
explicit NonTrivialCallFinder(const ASTContext &Context)<br>
- : Inherited(Context), NonTrivial(false) { }<br>
+ : Inherited(Context) {}<br>
<br>
bool hasNonTrivialCall() const { return NonTrivial; }<br>
<br>
@@ -3256,7 +3286,8 @@ namespace {<br>
NonTrivial = true;<br>
}<br>
};<br>
-}<br>
+<br>
+} // namespace<br>
<br>
bool Expr::hasNonTrivialCall(const ASTContext &Ctx) const {<br>
NonTrivialCallFinder Finder(Ctx);<br>
@@ -3282,7 +3313,6 @@ Expr::isNullPointerConstant(<wbr>ASTContext &<br>
return NPCK_ZeroExpression;<br>
else<br>
return NPCK_NotNull;<br>
-<br>
case NPC_ValueDependentIsNotNull:<br>
return NPCK_NotNull;<br>
}<br>
@@ -3580,12 +3610,11 @@ void ExtVectorElementExpr::<wbr>getEncodedEle<br>
ShuffleVectorExpr::<wbr>ShuffleVectorExpr(const ASTContext &C, ArrayRef<Expr*> args,<br>
QualType Type, SourceLocation BLoc,<br>
SourceLocation RP)<br>
- : Expr(ShuffleVectorExprClass, Type, VK_RValue, OK_Ordinary,<br>
- Type->isDependentType(), Type->isDependentType(),<br>
- Type-><wbr>isInstantiationDependentType()<wbr>,<br>
- Type-><wbr>containsUnexpandedParameterPac<wbr>k()),<br>
- BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())<br>
-{<br>
+ : Expr(ShuffleVectorExprClass, Type, VK_RValue, OK_Ordinary,<br>
+ Type->isDependentType(), Type->isDependentType(),<br>
+ Type-><wbr>isInstantiationDependentType()<wbr>,<br>
+ Type-><wbr>containsUnexpandedParameterPac<wbr>k()),<br>
+ BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size()) {<br>
SubExprs = new (C) Stmt*[args.size()];<br>
for (unsigned i = 0; i != args.size(); i++) {<br>
if (args[i]->isTypeDependent())<br>
@@ -3906,7 +3935,7 @@ PseudoObjectExpr *PseudoObjectExpr::Crea<br>
ArrayRef<Expr*> semantics,<br>
unsigned resultIndex) {<br>
assert(syntax && "no syntactic expression!");<br>
- assert(semantics.size() && "no semantic expressions!");<br>
+ assert(!semantics.empty() && "no semantic expressions!");<br>
<br>
QualType type;<br>
ExprValueKind VK;<br>
@@ -3980,10 +4009,9 @@ Stmt::const_child_range UnaryExprOrTypeT<br>
<br>
AtomicExpr::AtomicExpr(<wbr>SourceLocation BLoc, ArrayRef<Expr*> args,<br>
QualType t, AtomicOp op, SourceLocation RP)<br>
- : Expr(AtomicExprClass, t, VK_RValue, OK_Ordinary,<br>
- false, false, false, false),<br>
- NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)<br>
-{<br>
+ : Expr(AtomicExprClass, t, VK_RValue, OK_Ordinary,<br>
+ false, false, false, false),<br>
+ NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) {<br>
assert(args.size() == getNumSubExprs(op) && "wrong number of subexpressions");<br>
for (unsigned i = 0; i != args.size(); i++) {<br>
if (args[i]->isTypeDependent())<br>
@@ -4086,7 +4114,7 @@ QualType OMPArraySectionExpr::<wbr>getBaseOri<br>
if (OriginalTy->isAnyPointerType(<wbr>))<br>
OriginalTy = OriginalTy->getPointeeType();<br>
else {<br>
- assert (OriginalTy->isArrayType());<br>
+ assert(OriginalTy-><wbr>isArrayType());<br>
OriginalTy = OriginalTy-><wbr>castAsArrayTypeUnsafe()-><wbr>getElementType();<br>
}<br>
}<br>
<br>
Modified: cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=318341&r1=318340&r2=318341&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp?rev=318341&<wbr>r1=318340&r2=318341&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp (original)<br>
+++ cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp Wed Nov 15 14:00:04 2017<br>
@@ -1,4 +1,4 @@<br>
-//===--- SemaChecking.cpp - Extra Semantic Checking -----------------------===//<br>
+//===- SemaChecking.cpp - Extra Semantic Checking -------------------------===//<br>
//<br>
// The LLVM Compiler Infrastructure<br>
//<br>
@@ -12,35 +12,88 @@<br>
//<br>
//===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
+#include "clang/AST/APValue.h"<br>
#include "clang/AST/ASTContext.h"<br>
+#include "clang/AST/Attr.h"<br>
+#include "clang/AST/AttrIterator.h"<br>
#include "clang/AST/CharUnits.h"<br>
+#include "clang/AST/Decl.h"<br>
+#include "clang/AST/DeclBase.h"<br>
#include "clang/AST/DeclCXX.h"<br>
#include "clang/AST/DeclObjC.h"<br>
+#include "clang/AST/DeclarationName.h"<br>
#include "clang/AST/<wbr>EvaluatedExprVisitor.h"<br>
#include "clang/AST/Expr.h"<br>
#include "clang/AST/ExprCXX.h"<br>
#include "clang/AST/ExprObjC.h"<br>
#include "clang/AST/ExprOpenMP.h"<br>
-#include "clang/AST/StmtCXX.h"<br>
-#include "clang/AST/StmtObjC.h"<br>
+#include "clang/AST/NSAPI.h"<br>
+#include "clang/AST/OperationKinds.h"<br>
+#include "clang/AST/Stmt.h"<br>
+#include "clang/AST/TemplateBase.h"<br>
+#include "clang/AST/Type.h"<br>
+#include "clang/AST/TypeLoc.h"<br>
+#include "clang/AST/UnresolvedSet.h"<br>
#include "clang/Analysis/Analyses/<wbr>FormatString.h"<br>
+#include "clang/Basic/AddressSpaces.h"<br>
#include "clang/Basic/CharInfo.h"<br>
+#include "clang/Basic/Diagnostic.h"<br>
+#include "clang/Basic/IdentifierTable.<wbr>h"<br>
+#include "clang/Basic/LLVM.h"<br>
+#include "clang/Basic/LangOptions.h"<br>
+#include "clang/Basic/OpenCLOptions.h"<br>
+#include "clang/Basic/OperatorKinds.h"<br>
+#include "clang/Basic/<wbr>PartialDiagnostic.h"<br>
+#include "clang/Basic/SourceLocation.h"<br>
+#include "clang/Basic/SourceManager.h"<br>
+#include "clang/Basic/Specifiers.h"<br>
#include "clang/Basic/SyncScope.h"<br>
#include "clang/Basic/TargetBuiltins.h"<br>
+#include "clang/Basic/TargetCXXABI.h"<br>
#include "clang/Basic/TargetInfo.h"<br>
+#include "clang/Basic/TypeTraits.h"<br>
#include "clang/Lex/Lexer.h" // TODO: Extract static functions to fix layering.<br>
#include "clang/Sema/Initialization.h"<br>
#include "clang/Sema/Lookup.h"<br>
+#include "clang/Sema/Ownership.h"<br>
+#include "clang/Sema/Scope.h"<br>
#include "clang/Sema/ScopeInfo.h"<br>
#include "clang/Sema/Sema.h"<br>
#include "clang/Sema/SemaInternal.h"<br>
+#include "llvm/ADT/APFloat.h"<br>
+#include "llvm/ADT/APInt.h"<br>
+#include "llvm/ADT/APSInt.h"<br>
+#include "llvm/ADT/ArrayRef.h"<br>
+#include "llvm/ADT/DenseMap.h"<br>
+#include "llvm/ADT/FoldingSet.h"<br>
+#include "llvm/ADT/None.h"<br>
+#include "llvm/ADT/Optional.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
#include "llvm/ADT/SmallBitVector.h"<br>
+#include "llvm/ADT/SmallPtrSet.h"<br>
#include "llvm/ADT/SmallString.h"<br>
+#include "llvm/ADT/SmallVector.h"<br>
+#include "llvm/ADT/StringRef.h"<br>
+#include "llvm/ADT/StringSwitch.h"<br>
+#include "llvm/ADT/Triple.h"<br>
+#include "llvm/Support/AtomicOrdering.<wbr>h"<br>
+#include "llvm/Support/Casting.h"<br>
+#include "llvm/Support/Compiler.h"<br>
#include "llvm/Support/ConvertUTF.h"<br>
+#include "llvm/Support/ErrorHandling.h"<br>
#include "llvm/Support/Format.h"<br>
#include "llvm/Support/Locale.h"<br>
+#include "llvm/Support/MathExtras.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
+#include <algorithm><br>
+#include <cassert><br>
+#include <cstddef><br>
+#include <cstdint><br>
+#include <functional><br>
+#include <limits><br>
+#include <string><br>
+#include <tuple><br>
+#include <utility><br>
<br>
using namespace clang;<br>
using namespace sema;<br>
@@ -638,7 +691,7 @@ static bool SemaBuiltinRWPipe(Sema &S, C<br>
// OpenCL v2.0 s6.13.16.2 - The built-in read/write<br>
// functions have two forms.<br>
switch (Call->getNumArgs()) {<br>
- case 2: {<br>
+ case 2:<br>
if (checkOpenCLPipeArg(S, Call))<br>
return true;<br>
// The call with 2 arguments should be<br>
@@ -646,7 +699,7 @@ static bool SemaBuiltinRWPipe(Sema &S, C<br>
// Check packet type T.<br>
if (checkOpenCLPipePacketType(S, Call, 1))<br>
return true;<br>
- } break;<br>
+ break;<br>
<br>
case 4: {<br>
if (checkOpenCLPipeArg(S, Call))<br>
@@ -753,6 +806,7 @@ static bool SemaBuiltinPipePackets(Sema<br>
<br>
return false;<br>
}<br>
+<br>
// \brief OpenCL v2.0 s6.13.9 - Address space qualifier functions.<br>
// \brief Performs semantic analysis for the to_global/local/private call.<br>
// \param S Reference to the semantic analyzer.<br>
@@ -905,7 +959,6 @@ Sema::<wbr>CheckBuiltinFunctionCall(<wbr>FunctionD<br>
if (checkArgCount(*this, TheCall, 1))<br>
return true;<br>
break;<br>
-<br>
case Builtin::BI__builtin_classify_<wbr>type:<br>
if (checkArgCount(*this, TheCall, 1)) return true;<br>
TheCall->setType(Context.<wbr>IntTy);<br>
@@ -1170,9 +1223,8 @@ Sema::<wbr>CheckBuiltinFunctionCall(<wbr>FunctionD<br>
break;<br>
case Builtin::BI__builtin_os_log_<wbr>format:<br>
case Builtin::BI__builtin_os_log_<wbr>format_buffer_size:<br>
- if (SemaBuiltinOSLogFormat(<wbr>TheCall)) {<br>
+ if (SemaBuiltinOSLogFormat(<wbr>TheCall))<br>
return ExprError();<br>
- }<br>
break;<br>
}<br>
<br>
@@ -2508,6 +2560,7 @@ bool Sema::GetFormatNSStringIdx(<wbr>const Fo<br>
}<br>
return false;<br>
}<br>
+<br>
/// \brief Diagnose use of %s directive in an NSString which is being passed<br>
/// as formatting string to formatting method.<br>
static void<br>
@@ -2874,23 +2927,32 @@ ExprResult Sema::SemaAtomicOpsOverloaded<br>
enum {<br>
// C __c11_atomic_init(A *, C)<br>
Init,<br>
+<br>
// C __c11_atomic_load(A *, int)<br>
Load,<br>
+<br>
// void __atomic_load(A *, CP, int)<br>
LoadCopy,<br>
+<br>
// void __atomic_store(A *, CP, int)<br>
Copy,<br>
+<br>
// C __c11_atomic_add(A *, M, int)<br>
Arithmetic,<br>
+<br>
// C __atomic_exchange_n(A *, CP, int)<br>
Xchg,<br>
+<br>
// void __atomic_exchange(A *, C *, CP, int)<br>
GNUXchg,<br>
+<br>
// bool __c11_atomic_compare_exchange_<wbr>strong(A *, C *, CP, int, int)<br>
C11CmpXchg,<br>
+<br>
// bool __atomic_compare_exchange(A *, C *, CP, bool, int, int)<br>
GNUCmpXchg<br>
} Form = Init;<br>
+<br>
const unsigned NumForm = GNUCmpXchg + 1;<br>
const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 };<br>
const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 };<br>
@@ -3783,7 +3845,7 @@ static bool checkVAStartABI(Sema &S, uns<br>
bool IsWindows = TT.isOSWindows();<br>
bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_<wbr>start;<br>
if (IsX64 || IsAArch64) {<br>
- clang::CallingConv CC = CC_C;<br>
+ CallingConv CC = CC_C;<br>
if (const FunctionDecl *FD = S.getCurFunctionDecl())<br>
CC = FD->getType()->getAs<<wbr>FunctionType>()->getCallConv()<wbr>;<br>
if (IsMSVAStart) {<br>
@@ -4305,9 +4367,9 @@ bool Sema::<wbr>SemaBuiltinAllocaWithAlign(Ca<br>
<< (unsigned)Context.<wbr>getCharWidth()<br>
<< Arg->getSourceRange();<br>
<br>
- if (Result > INT32_MAX)<br>
+ if (Result > std::numeric_limits<int32_t>::<wbr>max())<br>
return Diag(TheCall->getLocStart(), diag::err_alignment_too_big)<br>
- << INT32_MAX<br>
+ << std::numeric_limits<int32_t>::<wbr>max()<br>
<< Arg->getSourceRange();<br>
}<br>
<br>
@@ -4572,7 +4634,6 @@ bool Sema::<wbr>SemaBuiltinARMSpecialReg(unsi<br>
if (!ValidString)<br>
return Diag(TheCall->getLocStart(), diag::err_arm_invalid_<wbr>specialreg)<br>
<< Arg->getSourceRange();<br>
-<br>
} else if (IsAArch64Builtin && Fields.size() == 1) {<br>
// If the register name is one of those that appear in the condition below<br>
// and the special register builtin being used is one of the write builtins,<br>
@@ -4626,13 +4687,15 @@ bool Sema::SemaBuiltinSetjmp(<wbr>CallExpr *T<br>
}<br>
<br>
namespace {<br>
+<br>
class UncoveredArgHandler {<br>
enum { Unknown = -1, AllCovered = -2 };<br>
- signed FirstUncoveredArg;<br>
+<br>
+ signed FirstUncoveredArg = Unknown;<br>
SmallVector<const Expr *, 4> DiagnosticExprs;<br>
<br>
public:<br>
- UncoveredArgHandler() : FirstUncoveredArg(Unknown) { }<br>
+ UncoveredArgHandler() = default;<br>
<br>
bool hasUncoveredArg() const {<br>
return (FirstUncoveredArg >= 0);<br>
@@ -4676,7 +4739,8 @@ enum StringLiteralCheckType {<br>
SLCT_UncheckedLiteral,<br>
SLCT_CheckedLiteral<br>
};<br>
-} // end anonymous namespace<br>
+<br>
+} // namespace<br>
<br>
static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,<br>
BinaryOperatorKind BinOpKind,<br>
@@ -4709,7 +4773,8 @@ static void sumOffsets(llvm::APSInt &Off<br>
// We add an offset to a pointer here so we should support an offset as big as<br>
// possible.<br>
if (Ov) {<br>
- assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");<br>
+ assert(BitWidth <= std::numeric_limits<unsigned>:<wbr>:max() / 2 &&<br>
+ "index (intermediate) result too big");<br>
Offset = Offset.sext(2 * BitWidth);<br>
sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);<br>
return;<br>
@@ -4719,6 +4784,7 @@ static void sumOffsets(llvm::APSInt &Off<br>
}<br>
<br>
namespace {<br>
+<br>
// This is a wrapper class around StringLiteral to support offsetted string<br>
// literals as format strings. It takes the offset into account when returning<br>
// the string and its length or the source locations to display notes correctly.<br>
@@ -4737,6 +4803,7 @@ class FormatStringLiteral {<br>
unsigned getByteLength() const {<br>
return FExpr->getByteLength() - getCharByteWidth() * Offset;<br>
}<br>
+<br>
unsigned getLength() const { return FExpr->getLength() - Offset; }<br>
unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }<br>
<br>
@@ -4762,9 +4829,11 @@ class FormatStringLiteral {<br>
SourceLocation getLocStart() const LLVM_READONLY {<br>
return FExpr->getLocStart().<wbr>getLocWithOffset(Offset);<br>
}<br>
+<br>
SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }<br>
};<br>
-} // end anonymous namespace<br>
+<br>
+} // namespace<br>
<br>
static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr,<br>
const Expr *OrigFormatExpr,<br>
@@ -4851,10 +4920,9 @@ checkFormatStringExpr(Sema &S, const Exp<br>
return (CheckLeft && Left < Right) ? Left : Right;<br>
}<br>
<br>
- case Stmt::ImplicitCastExprClass: {<br>
+ case Stmt::ImplicitCastExprClass:<br>
E = cast<ImplicitCastExpr>(E)-><wbr>getSubExpr();<br>
goto tryAgain;<br>
- }<br>
<br>
case Stmt::OpaqueValueExprClass:<br>
if (const Expr *src = cast<OpaqueValueExpr>(E)-><wbr>getSourceExpr()) {<br>
@@ -5043,7 +5111,7 @@ checkFormatStringExpr(Sema &S, const Exp<br>
case Stmt::UnaryOperatorClass: {<br>
const UnaryOperator *UnaOp = cast<UnaryOperator>(E);<br>
auto ASE = dyn_cast<ArraySubscriptExpr>(<wbr>UnaOp->getSubExpr());<br>
- if (UnaOp->getOpcode() == clang::UO_AddrOf && ASE) {<br>
+ if (UnaOp->getOpcode() == UO_AddrOf && ASE) {<br>
llvm::APSInt IndexResult;<br>
if (ASE->getRHS()->EvaluateAsInt(<wbr>IndexResult, S.Context)) {<br>
sumOffsets(Offset, IndexResult, BO_Add, /*RHS is int*/ true);<br>
@@ -5176,6 +5244,7 @@ bool Sema::CheckFormatArguments(<wbr>ArrayRef<br>
}<br>
<br>
namespace {<br>
+<br>
class CheckFormatHandler : public analyze_format_string::<wbr>FormatStringHandler {<br>
protected:<br>
Sema &S;<br>
@@ -5189,8 +5258,8 @@ protected:<br>
ArrayRef<const Expr *> Args;<br>
unsigned FormatIdx;<br>
llvm::SmallBitVector CoveredArgs;<br>
- bool usesPositionalArgs;<br>
- bool atFirstArg;<br>
+ bool usesPositionalArgs = false;<br>
+ bool atFirstArg = true;<br>
bool inFunctionCall;<br>
Sema::VariadicCallType CallType;<br>
llvm::SmallBitVector &CheckedVarArgs;<br>
@@ -5208,7 +5277,6 @@ public:<br>
: S(s), FExpr(fexpr), OrigFormatExpr(origFormatExpr)<wbr>, FSType(type),<br>
FirstDataArg(firstDataArg), NumDataArgs(numDataArgs), Beg(beg),<br>
HasVAListArg(hasVAListArg), Args(Args), FormatIdx(formatIdx),<br>
- usesPositionalArgs(false), atFirstArg(true),<br>
inFunctionCall(inFunctionCall)<wbr>, CallType(callType),<br>
CheckedVarArgs(CheckedVarArgs)<wbr>, UncoveredArg(UncoveredArg) {<br>
CoveredArgs.resize(<wbr>numDataArgs);<br>
@@ -5278,7 +5346,8 @@ protected:<br>
bool IsStringLocation, Range StringRange,<br>
ArrayRef<FixItHint> Fixit = None);<br>
};<br>
-} // end anonymous namespace<br>
+<br>
+} // namespace<br>
<br>
SourceRange CheckFormatHandler::<wbr>getFormatStringRange() {<br>
return OrigFormatExpr-><wbr>getSourceRange();<br>
@@ -5632,6 +5701,7 @@ void CheckFormatHandler::<wbr>EmitFormatDiagn<br>
//===--- CHECK: Printf format string checking ------------------------------<wbr>===//<br>
<br>
namespace {<br>
+<br>
class CheckPrintfHandler : public CheckFormatHandler {<br>
public:<br>
CheckPrintfHandler(Sema &s, const FormatStringLiteral *fexpr,<br>
@@ -5696,7 +5766,8 @@ public:<br>
const char *conversionPosition)<br>
override;<br>
};<br>
-} // end anonymous namespace<br>
+<br>
+} // namespace<br>
<br>
bool CheckPrintfHandler::<wbr>HandleInvalidPrintfConversionS<wbr>pecifier(<br>
const analyze_printf::<wbr>PrintfSpecifier &FS,<br>
@@ -5814,10 +5885,6 @@ void CheckPrintfHandler::<wbr>HandleIgnoredFl<br>
getSpecifierRange(ignoredFlag.<wbr>getPosition(), 1)));<br>
}<br>
<br>
-// void EmitFormatDiagnostic(<wbr>PartialDiagnostic PDiag, SourceLocation StringLoc,<br>
-// bool IsStringLocation, Range StringRange,<br>
-// ArrayRef<FixItHint> Fixit = None);<br>
-<br>
void CheckPrintfHandler::<wbr>HandleEmptyObjCModifierFlag(<wbr>const char *startFlag,<br>
unsigned flagLen) {<br>
// Warn about an empty flag.<br>
@@ -5884,7 +5951,8 @@ CXXRecordMembersNamed(<wbr>StringRef Name, Se<br>
/// FIXME: This returns the wrong results in some cases (if cv-qualifiers don't<br>
/// allow the call, or if it would be ambiguous).<br>
bool Sema::hasCStrMethod(const Expr *E) {<br>
- typedef llvm::SmallPtrSet<<wbr>CXXMethodDecl*, 1> MethodSet;<br>
+ using MethodSet = llvm::SmallPtrSet<<wbr>CXXMethodDecl *, 1>;<br>
+<br>
MethodSet Results =<br>
CXXRecordMembersNamed<<wbr>CXXMethodDecl>("c_str", *this, E->getType());<br>
for (MethodSet::iterator MI = Results.begin(), ME = Results.end();<br>
@@ -5899,7 +5967,7 @@ bool Sema::hasCStrMethod(const Expr *E)<br>
// Returns true when a c_str() conversion method is found.<br>
bool CheckPrintfHandler::<wbr>checkForCStrMembers(<br>
const analyze_printf::ArgType &AT, const Expr *E) {<br>
- typedef llvm::SmallPtrSet<<wbr>CXXMethodDecl*, 1> MethodSet;<br>
+ using MethodSet = llvm::SmallPtrSet<<wbr>CXXMethodDecl *, 1>;<br>
<br>
MethodSet Results =<br>
CXXRecordMembersNamed<<wbr>CXXMethodDecl>("c_str", S, E->getType());<br>
@@ -5927,7 +5995,8 @@ CheckPrintfHandler::<wbr>HandlePrintfSpecifie<br>
const char *startSpecifier,<br>
unsigned specifierLen) {<br>
using namespace analyze_format_string;<br>
- using namespace analyze_printf;<br>
+ using namespace analyze_printf;<br>
+<br>
const PrintfConversionSpecifier &CS = FS.getConversionSpecifier();<br>
<br>
if (FS.consumesDataArgument()) {<br>
@@ -6225,6 +6294,7 @@ CheckPrintfHandler::<wbr>checkFormatExpr(cons<br>
const Expr *E) {<br>
using namespace analyze_format_string;<br>
using namespace analyze_printf;<br>
+<br>
// Now type check the data expression that matches the<br>
// format specifier.<br>
const analyze_printf::ArgType &AT = FS.getArgType(S.Context, isObjCContext());<br>
@@ -6477,6 +6547,7 @@ CheckPrintfHandler::<wbr>checkFormatExpr(cons<br>
//===--- CHECK: Scanf format string checking ------------------------------<wbr>===//<br>
<br>
namespace {<br>
+<br>
class CheckScanfHandler : public CheckFormatHandler {<br>
public:<br>
CheckScanfHandler(Sema &s, const FormatStringLiteral *fexpr,<br>
@@ -6503,7 +6574,8 @@ public:<br>
<br>
void HandleIncompleteScanList(const char *start, const char *end) override;<br>
};<br>
-} // end anonymous namespace<br>
+<br>
+} // namespace<br>
<br>
void CheckScanfHandler::<wbr>HandleIncompleteScanList(const char *start,<br>
const char *end) {<br>
@@ -6516,7 +6588,6 @@ bool CheckScanfHandler::<wbr>HandleInvalidSca<br>
const analyze_scanf::ScanfSpecifier &FS,<br>
const char *startSpecifier,<br>
unsigned specifierLen) {<br>
-<br>
const analyze_scanf::<wbr>ScanfConversionSpecifier &CS =<br>
FS.getConversionSpecifier();<br>
<br>
@@ -7258,7 +7329,7 @@ static const CXXRecordDecl *getContained<br>
static const Expr *getSizeOfExprArg(const Expr *E) {<br>
if (const UnaryExprOrTypeTraitExpr *SizeOf =<br>
dyn_cast<<wbr>UnaryExprOrTypeTraitExpr>(E))<br>
- if (SizeOf->getKind() == clang::UETT_SizeOf && !SizeOf->isArgumentType())<br>
+ if (SizeOf->getKind() == UETT_SizeOf && !SizeOf->isArgumentType())<br>
return SizeOf->getArgumentExpr()-><wbr>IgnoreParenImpCasts();<br>
<br>
return nullptr;<br>
@@ -7268,7 +7339,7 @@ static const Expr *getSizeOfExprArg(cons<br>
static QualType getSizeOfArgType(const Expr *E) {<br>
if (const UnaryExprOrTypeTraitExpr *SizeOf =<br>
dyn_cast<<wbr>UnaryExprOrTypeTraitExpr>(E))<br>
- if (SizeOf->getKind() == clang::UETT_SizeOf)<br>
+ if (SizeOf->getKind() == UETT_SizeOf)<br>
return SizeOf->getTypeOfArgument();<br>
<br>
return QualType();<br>
@@ -7456,7 +7527,7 @@ void Sema::CheckMemaccessArguments(<wbr>const<br>
static const Expr *ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx) {<br>
Ex = Ex->IgnoreParenCasts();<br>
<br>
- for (;;) {<br>
+ while (true) {<br>
const BinaryOperator * BO = dyn_cast<BinaryOperator>(Ex);<br>
if (!BO || !BO->isAdditiveOp())<br>
break;<br>
@@ -7674,7 +7745,6 @@ static const Expr *EvalAddr(const Expr *<br>
static void<br>
CheckReturnStackAddr(Sema &S, Expr *RetValExp, QualType lhsType,<br>
SourceLocation ReturnLoc) {<br>
-<br>
const Expr *stackE = nullptr;<br>
SmallVector<const DeclRefExpr *, 8> refVars;<br>
<br>
@@ -8159,8 +8229,7 @@ struct IntRange {<br>
bool NonNegative;<br>
<br>
IntRange(unsigned Width, bool NonNegative)<br>
- : Width(Width), NonNegative(NonNegative)<br>
- {}<br>
+ : Width(Width), NonNegative(NonNegative) {}<br>
<br>
/// Returns the range of the bool type.<br>
static IntRange forBoolType() {<br>
@@ -8249,7 +8318,10 @@ struct IntRange {<br>
}<br>
};<br>
<br>
-IntRange GetValueRange(ASTContext &C, llvm::APSInt &value, unsigned MaxWidth) {<br>
+} // namespace<br>
+<br>
+static IntRange GetValueRange(ASTContext &C, llvm::APSInt &value,<br>
+ unsigned MaxWidth) {<br>
if (value.isSigned() && value.isNegative())<br>
return IntRange(value.<wbr>getMinSignedBits(), false);<br>
<br>
@@ -8261,8 +8333,8 @@ IntRange GetValueRange(ASTContext &C, ll<br>
return IntRange(value.getActiveBits()<wbr>, true);<br>
}<br>
<br>
-IntRange GetValueRange(ASTContext &C, APValue &result, QualType Ty,<br>
- unsigned MaxWidth) {<br>
+static IntRange GetValueRange(ASTContext &C, APValue &result, QualType Ty,<br>
+ unsigned MaxWidth) {<br>
if (result.isInt())<br>
return GetValueRange(C, result.getInt(), MaxWidth);<br>
<br>
@@ -8290,7 +8362,7 @@ IntRange GetValueRange(ASTContext &C, AP<br>
return IntRange(MaxWidth, Ty-><wbr>isUnsignedIntegerOrEnumeration<wbr>Type());<br>
}<br>
<br>
-QualType GetExprType(const Expr *E) {<br>
+static QualType GetExprType(const Expr *E) {<br>
QualType Ty = E->getType();<br>
if (const AtomicType *AtomicRHS = Ty->getAs<AtomicType>())<br>
Ty = AtomicRHS->getValueType();<br>
@@ -8301,7 +8373,7 @@ QualType GetExprType(const Expr *E) {<br>
/// range of values it might take.<br>
///<br>
/// \param MaxWidth - the width to which the value will be truncated<br>
-IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth) {<br>
+static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth) {<br>
E = E->IgnoreParens();<br>
<br>
// Try a full evaluation first.<br>
@@ -8519,16 +8591,16 @@ IntRange GetExprRange(ASTContext &C, con<br>
return IntRange::forValueOfType(C, GetExprType(E));<br>
}<br>
<br>
-IntRange GetExprRange(ASTContext &C, const Expr *E) {<br>
+static IntRange GetExprRange(ASTContext &C, const Expr *E) {<br>
return GetExprRange(C, E, C.getIntWidth(GetExprType(E)))<wbr>;<br>
}<br>
<br>
/// Checks whether the given value, which currently has the given<br>
/// source semantics, has the same value when coerced through the<br>
/// target semantics.<br>
-bool IsSameFloatAfterCast(const llvm::APFloat &value,<br>
- const llvm::fltSemantics &Src,<br>
- const llvm::fltSemantics &Tgt) {<br>
+static bool IsSameFloatAfterCast(const llvm::APFloat &value,<br>
+ const llvm::fltSemantics &Src,<br>
+ const llvm::fltSemantics &Tgt) {<br>
llvm::APFloat truncated = value;<br>
<br>
bool ignored;<br>
@@ -8543,9 +8615,9 @@ bool IsSameFloatAfterCast(const llvm::AP<br>
/// target semantics.<br>
///<br>
/// The value might be a vector of floats (or a complex number).<br>
-bool IsSameFloatAfterCast(const APValue &value,<br>
- const llvm::fltSemantics &Src,<br>
- const llvm::fltSemantics &Tgt) {<br>
+static bool IsSameFloatAfterCast(const APValue &value,<br>
+ const llvm::fltSemantics &Src,<br>
+ const llvm::fltSemantics &Tgt) {<br>
if (value.isFloat())<br>
return IsSameFloatAfterCast(value.<wbr>getFloat(), Src, Tgt);<br>
<br>
@@ -8561,9 +8633,9 @@ bool IsSameFloatAfterCast(const APValue<br>
IsSameFloatAfterCast(value.<wbr>getComplexFloatImag(), Src, Tgt));<br>
}<br>
<br>
-void AnalyzeImplicitConversions(<wbr>Sema &S, Expr *E, SourceLocation CC);<br>
+static void AnalyzeImplicitConversions(<wbr>Sema &S, Expr *E, SourceLocation CC);<br>
<br>
-bool IsEnumConstOrFromMacro(Sema &S, Expr *E) {<br>
+static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) {<br>
// Suppress cases where we are comparing against an enum constant.<br>
if (const DeclRefExpr *DR =<br>
dyn_cast<DeclRefExpr>(E-><wbr>IgnoreParenImpCasts()))<br>
@@ -8577,11 +8649,11 @@ bool IsEnumConstOrFromMacro(Sema &S, Exp<br>
return false;<br>
}<br>
<br>
-bool isNonBooleanIntegerValue(Expr *E) {<br>
+static bool isNonBooleanIntegerValue(Expr *E) {<br>
return !E->isKnownToHaveBooleanValue(<wbr>) && E->getType()->isIntegerType();<br>
}<br>
<br>
-bool isNonBooleanUnsignedValue(Expr *E) {<br>
+static bool isNonBooleanUnsignedValue(Expr *E) {<br>
// We are checking that the expression is not known to have boolean value,<br>
// is an integer type; and is either unsigned after implicit casts,<br>
// or was unsigned before implicit casts.<br>
@@ -8590,6 +8662,8 @@ bool isNonBooleanUnsignedValue(Expr *E)<br>
!E->IgnoreParenImpCasts()-><wbr>getType()-><wbr>isSignedIntegerType());<br>
}<br>
<br>
+namespace {<br>
+<br>
enum class LimitType {<br>
Max = 1U << 0U, // e.g. 32767 for short<br>
Min = 1U << 1U, // e.g. -32768 for short<br>
@@ -8597,12 +8671,15 @@ enum class LimitType {<br>
// same time; e.g. in C++, A::a in enum A { a = 0 };<br>
};<br>
<br>
+} // namespace<br>
+<br>
/// Checks whether Expr 'Constant' may be the<br>
/// std::numeric_limits<>::max() or std::numeric_limits<>::min()<br>
/// of the Expr 'Other'. If true, then returns the limit type (min or max).<br>
/// The Value is the evaluation of Constant<br>
-llvm::Optional<LimitType> IsTypeLimit(Sema &S, Expr *Constant, Expr *Other,<br>
- const llvm::APSInt &Value) {<br>
+static llvm::Optional<LimitType> IsTypeLimit(Sema &S, Expr *Constant,<br>
+ Expr *Other,<br>
+ const llvm::APSInt &Value) {<br>
if (IsEnumConstOrFromMacro(S, Constant))<br>
return llvm::Optional<LimitType>();<br>
<br>
@@ -8636,7 +8713,7 @@ llvm::Optional<LimitType> IsTypeLimit(Se<br>
return llvm::None;<br>
}<br>
<br>
-bool HasEnumType(Expr *E) {<br>
+static bool HasEnumType(Expr *E) {<br>
// Strip off implicit integral promotions.<br>
while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {<br>
if (ICE->getCastKind() != CK_IntegralCast &&<br>
@@ -8648,9 +8725,10 @@ bool HasEnumType(Expr *E) {<br>
return E->getType()->isEnumeralType()<wbr>;<br>
}<br>
<br>
-bool CheckTautologicalComparison(<wbr>Sema &S, BinaryOperator *E, Expr *Constant,<br>
- Expr *Other, const llvm::APSInt &Value,<br>
- bool RhsConstant) {<br>
+static bool CheckTautologicalComparison(<wbr>Sema &S, BinaryOperator *E,<br>
+ Expr *Constant, Expr *Other,<br>
+ const llvm::APSInt &Value,<br>
+ bool RhsConstant) {<br>
// Disable warning in template instantiations<br>
// and only analyze <, >, <= and >= operations.<br>
if (S.inTemplateInstantiation() || !E->isRelationalOp())<br>
@@ -8696,9 +8774,10 @@ bool CheckTautologicalComparison(<wbr>Sema &S<br>
return true;<br>
}<br>
<br>
-bool DiagnoseOutOfRangeComparison(<wbr>Sema &S, BinaryOperator *E, Expr *Constant,<br>
- Expr *Other, const llvm::APSInt &Value,<br>
- bool RhsConstant) {<br>
+static bool DiagnoseOutOfRangeComparison(<wbr>Sema &S, BinaryOperator *E,<br>
+ Expr *Constant, Expr *Other,<br>
+ const llvm::APSInt &Value,<br>
+ bool RhsConstant) {<br>
// Disable warning in template instantiations.<br>
if (S.inTemplateInstantiation())<br>
return false;<br>
@@ -8907,7 +8986,7 @@ bool DiagnoseOutOfRangeComparison(<wbr>Sema &<br>
<br>
/// Analyze the operands of the given comparison. Implements the<br>
/// fallback case from AnalyzeComparison.<br>
-void AnalyzeImpConvsInComparison(<wbr>Sema &S, BinaryOperator *E) {<br>
+static void AnalyzeImpConvsInComparison(<wbr>Sema &S, BinaryOperator *E) {<br>
AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());<br>
AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());<br>
}<br>
@@ -8915,7 +8994,7 @@ void AnalyzeImpConvsInComparison(<wbr>Sema &S<br>
/// \brief Implements -Wsign-compare.<br>
///<br>
/// \param E the binary operator to check for warnings<br>
-void AnalyzeComparison(Sema &S, BinaryOperator *E) {<br>
+static void AnalyzeComparison(Sema &S, BinaryOperator *E) {<br>
// The type the comparison is being performed in.<br>
QualType T = E->getLHS()->getType();<br>
<br>
@@ -9023,8 +9102,8 @@ void AnalyzeComparison(Sema &S, BinaryOp<br>
/// Analyzes an attempt to assign the given value to a bitfield.<br>
///<br>
/// Returns true if there was something fishy about the attempt.<br>
-bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,<br>
- SourceLocation InitLoc) {<br>
+static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,<br>
+ SourceLocation InitLoc) {<br>
assert(Bitfield->isBitField())<wbr>;<br>
if (Bitfield->isInvalidDecl())<br>
return false;<br>
@@ -9154,7 +9233,7 @@ bool AnalyzeBitFieldAssignment(Sema &S,<br>
<br>
/// Analyze the given simple or compound assignment for warning-worthy<br>
/// operations.<br>
-void AnalyzeAssignment(Sema &S, BinaryOperator *E) {<br>
+static void AnalyzeAssignment(Sema &S, BinaryOperator *E) {<br>
// Just recurse on the LHS.<br>
AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());<br>
<br>
@@ -9173,9 +9252,9 @@ void AnalyzeAssignment(Sema &S, BinaryOp<br>
}<br>
<br>
/// Diagnose an implicit cast; purely a helper for CheckImplicitConversion.<br>
-void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,<br>
- SourceLocation CContext, unsigned diag,<br>
- bool pruneControlFlow = false) {<br>
+static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,<br>
+ SourceLocation CContext, unsigned diag,<br>
+ bool pruneControlFlow = false) {<br>
if (pruneControlFlow) {<br>
S.DiagRuntimeBehavior(E-><wbr>getExprLoc(), E,<br>
S.PDiag(diag)<br>
@@ -9188,16 +9267,16 @@ void DiagnoseImpCast(Sema &S, Expr *E, Q<br>
}<br>
<br>
/// Diagnose an implicit cast; purely a helper for CheckImplicitConversion.<br>
-void DiagnoseImpCast(Sema &S, Expr *E, QualType T, SourceLocation CContext,<br>
- unsigned diag, bool pruneControlFlow = false) {<br>
+static void DiagnoseImpCast(Sema &S, Expr *E, QualType T,<br>
+ SourceLocation CContext,<br>
+ unsigned diag, bool pruneControlFlow = false) {<br>
DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);<br>
}<br>
<br>
<br>
/// Diagnose an implicit cast from a floating point value to an integer value.<br>
-void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,<br>
-<br>
- SourceLocation CContext) {<br>
+static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,<br>
+ SourceLocation CContext) {<br>
const bool IsBool = T->isSpecificBuiltinType(<wbr>BuiltinType::Bool);<br>
const bool PruneWarnings = S.inTemplateInstantiation();<br>
<br>
@@ -9287,7 +9366,8 @@ void DiagnoseFloatingImpCast(Sema &S, Ex<br>
}<br>
}<br>
<br>
-std::string PrettyPrintInRange(const llvm::APSInt &Value, IntRange Range) {<br>
+static std::string PrettyPrintInRange(const llvm::APSInt &Value,<br>
+ IntRange Range) {<br>
if (!Range.Width) return "0";<br>
<br>
llvm::APSInt ValueInRange = Value;<br>
@@ -9296,7 +9376,7 @@ std::string PrettyPrintInRange(const llv<br>
return ValueInRange.toString(10);<br>
}<br>
<br>
-bool IsImplicitBoolFloatConversion(<wbr>Sema &S, Expr *Ex, bool ToBool) {<br>
+static bool IsImplicitBoolFloatConversion(<wbr>Sema &S, Expr *Ex, bool ToBool) {<br>
if (!isa<ImplicitCastExpr>(Ex))<br>
return false;<br>
<br>
@@ -9315,8 +9395,8 @@ bool IsImplicitBoolFloatConversion(<wbr>Sema<br>
FloatCandidateBT && (FloatCandidateBT-><wbr>isFloatingPoint()));<br>
}<br>
<br>
-void CheckImplicitArgumentConversio<wbr>ns(Sema &S, CallExpr *TheCall,<br>
- SourceLocation CC) {<br>
+static void CheckImplicitArgumentConversio<wbr>ns(Sema &S, CallExpr *TheCall,<br>
+ SourceLocation CC) {<br>
unsigned NumArgs = TheCall->getNumArgs();<br>
for (unsigned i = 0; i < NumArgs; ++i) {<br>
Expr *CurrA = TheCall->getArg(i);<br>
@@ -9336,7 +9416,8 @@ void CheckImplicitArgumentConversio<wbr>ns(Se<br>
}<br>
}<br>
<br>
-void DiagnoseNullConversion(Sema &S, Expr *E, QualType T, SourceLocation CC) {<br>
+static void DiagnoseNullConversion(Sema &S, Expr *E, QualType T,<br>
+ SourceLocation CC) {<br>
if (S.Diags.isIgnored(diag::warn_<wbr>impcast_null_pointer_to_<wbr>integer,<br>
E->getExprLoc()))<br>
return;<br>
@@ -9380,20 +9461,24 @@ void DiagnoseNullConversion(Sema &S, Exp<br>
return;<br>
<br>
S.Diag(Loc, diag::warn_impcast_null_<wbr>pointer_to_integer)<br>
- << (NullKind == Expr::NPCK_CXX11_nullptr) << T << clang::SourceRange(CC)<br>
+ << (NullKind == Expr::NPCK_CXX11_nullptr) << T << SourceRange(CC)<br>
<< FixItHint::CreateReplacement(<wbr>Loc,<br>
S.getFixItZeroLiteralForType(<wbr>T, Loc));<br>
}<br>
<br>
-void checkObjCArrayLiteral(Sema &S, QualType TargetType,<br>
- ObjCArrayLiteral *ArrayLiteral);<br>
-void checkObjCDictionaryLiteral(<wbr>Sema &S, QualType TargetType,<br>
- ObjCDictionaryLiteral *DictionaryLiteral);<br>
+static void checkObjCArrayLiteral(Sema &S, QualType TargetType,<br>
+ ObjCArrayLiteral *ArrayLiteral);<br>
+<br>
+static void<br>
+checkObjCDictionaryLiteral(<wbr>Sema &S, QualType TargetType,<br>
+ ObjCDictionaryLiteral *DictionaryLiteral);<br>
<br>
/// Check a single element within a collection literal against the<br>
/// target element type.<br>
-void checkObjCCollectionLiteralElem<wbr>ent(Sema &S, QualType TargetElementType,<br>
- Expr *Element, unsigned ElementKind) {<br>
+static void checkObjCCollectionLiteralElem<wbr>ent(Sema &S,<br>
+ QualType TargetElementType,<br>
+ Expr *Element,<br>
+ unsigned ElementKind) {<br>
// Skip a bitcast to 'id' or qualified 'id'.<br>
if (auto ICE = dyn_cast<ImplicitCastExpr>(<wbr>Element)) {<br>
if (ICE->getCastKind() == CK_BitCast &&<br>
@@ -9422,8 +9507,8 @@ void checkObjCCollectionLiteralElem<wbr>ent(S<br>
<br>
/// Check an Objective-C array literal being converted to the given<br>
/// target type.<br>
-void checkObjCArrayLiteral(Sema &S, QualType TargetType,<br>
- ObjCArrayLiteral *ArrayLiteral) {<br>
+static void checkObjCArrayLiteral(Sema &S, QualType TargetType,<br>
+ ObjCArrayLiteral *ArrayLiteral) {<br>
if (!S.NSArrayDecl)<br>
return;<br>
<br>
@@ -9450,8 +9535,9 @@ void checkObjCArrayLiteral(Sema &S, Qual<br>
<br>
/// Check an Objective-C dictionary literal being converted to the given<br>
/// target type.<br>
-void checkObjCDictionaryLiteral(<wbr>Sema &S, QualType TargetType,<br>
- ObjCDictionaryLiteral *DictionaryLiteral) {<br>
+static void<br>
+checkObjCDictionaryLiteral(<wbr>Sema &S, QualType TargetType,<br>
+ ObjCDictionaryLiteral *DictionaryLiteral) {<br>
if (!S.NSDictionaryDecl)<br>
return;<br>
<br>
@@ -9479,8 +9565,8 @@ void checkObjCDictionaryLiteral(<wbr>Sema &S,<br>
<br>
// Helper function to filter out cases for constant width constant conversion.<br>
// Don't warn on char array initialization or for non-decimal values.<br>
-bool isSameWidthConstantConversion(<wbr>Sema &S, Expr *E, QualType T,<br>
- SourceLocation CC) {<br>
+static bool isSameWidthConstantConversion(<wbr>Sema &S, Expr *E, QualType T,<br>
+ SourceLocation CC) {<br>
// If initializing from a constant, and the constant starts with '0',<br>
// then it is a binary, octal, or hexadecimal. Allow these constants<br>
// to fill all the bits, even if there is a sign change.<br>
@@ -9503,8 +9589,9 @@ bool isSameWidthConstantConversion(<wbr>Sema<br>
return true;<br>
}<br>
<br>
-void CheckImplicitConversion(Sema &S, Expr *E, QualType T,<br>
- SourceLocation CC, bool *ICContext = nullptr) {<br>
+static void<br>
+CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC,<br>
+ bool *ICContext = nullptr) {<br>
if (E->isTypeDependent() || E->isValueDependent()) return;<br>
<br>
const Type *Source = S.Context.getCanonicalType(E-><wbr>getType()).getTypePtr();<br>
@@ -9772,11 +9859,11 @@ void CheckImplicitConversion(Sema &S, Ex<br>
}<br>
}<br>
<br>
-void CheckConditionalOperator(Sema &S, ConditionalOperator *E,<br>
- SourceLocation CC, QualType T);<br>
+static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,<br>
+ SourceLocation CC, QualType T);<br>
<br>
-void CheckConditionalOperand(Sema &S, Expr *E, QualType T,<br>
- SourceLocation CC, bool &ICContext) {<br>
+static void CheckConditionalOperand(Sema &S, Expr *E, QualType T,<br>
+ SourceLocation CC, bool &ICContext) {<br>
E = E->IgnoreParenImpCasts();<br>
<br>
if (isa<ConditionalOperator>(E))<br>
@@ -9787,8 +9874,8 @@ void CheckConditionalOperand(Sema &S, Ex<br>
return CheckImplicitConversion(S, E, T, CC, &ICContext);<br>
}<br>
<br>
-void CheckConditionalOperator(Sema &S, ConditionalOperator *E,<br>
- SourceLocation CC, QualType T) {<br>
+static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,<br>
+ SourceLocation CC, QualType T) {<br>
AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());<br>
<br>
bool Suspicious = false;<br>
@@ -9817,7 +9904,7 @@ void CheckConditionalOperator(Sema &S, C<br>
<br>
/// CheckBoolLikeConversion - Check conversion of given expression to boolean.<br>
/// Input argument E is a logical expression.<br>
-void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC) {<br>
+static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC) {<br>
if (S.getLangOpts().Bool)<br>
return;<br>
CheckImplicitConversion(S, E->IgnoreParenImpCasts(), S.Context.BoolTy, CC);<br>
@@ -9826,7 +9913,8 @@ void CheckBoolLikeConversion(Sema &S, Ex<br>
/// AnalyzeImplicitConversions - Find and report any interesting<br>
/// implicit conversions in the given expression. There are a couple<br>
/// of competing diagnostics here, -Wconversion and -Wsign-compare.<br>
-void AnalyzeImplicitConversions(<wbr>Sema &S, Expr *OrigE, SourceLocation CC) {<br>
+static void AnalyzeImplicitConversions(<wbr>Sema &S, Expr *OrigE,<br>
+ SourceLocation CC) {<br>
QualType T = OrigE->getType();<br>
Expr *E = OrigE->IgnoreParenImpCasts();<br>
<br>
@@ -9919,8 +10007,6 @@ void AnalyzeImplicitConversions(<wbr>Sema &S,<br>
::CheckBoolLikeConversion(S, U->getSubExpr(), CC);<br>
}<br>
<br>
-} // end anonymous namespace<br>
-<br>
/// Diagnose integer type and any valid implicit convertion to it.<br>
static bool checkOpenCLEnqueueIntType(Sema &S, Expr *E, const QualType &IntT) {<br>
// Taking into account implicit conversions,<br>
@@ -10226,10 +10312,11 @@ void Sema::CheckForIntOverflow (Expr *E)<br>
}<br>
<br>
namespace {<br>
+<br>
/// \brief Visitor for expressions which looks for unsequenced operations on the<br>
/// same object.<br>
class SequenceChecker : public EvaluatedExprVisitor<<wbr>SequenceChecker> {<br>
- typedef EvaluatedExprVisitor<<wbr>SequenceChecker> Base;<br>
+ using Base = EvaluatedExprVisitor<<wbr>SequenceChecker>;<br>
<br>
/// \brief A tree of sequenced regions within an expression. Two regions are<br>
/// unsequenced if one is an ancestor or a descendent of the other. When we<br>
@@ -10248,11 +10335,14 @@ class SequenceChecker : public Evaluated<br>
/// \brief A region within an expression which may be sequenced with respect<br>
/// to some other region.<br>
class Seq {<br>
- explicit Seq(unsigned N) : Index(N) {}<br>
- unsigned Index;<br>
friend class SequenceTree;<br>
+<br>
+ unsigned Index = 0;<br>
+<br>
+ explicit Seq(unsigned N) : Index(N) {}<br>
+<br>
public:<br>
- Seq() : Index(0) {}<br>
+ Seq() = default;<br>
};<br>
<br>
SequenceTree() { Values.push_back(Value(0)); }<br>
@@ -10296,16 +10386,18 @@ class SequenceChecker : public Evaluated<br>
};<br>
<br>
/// An object for which we can track unsequenced uses.<br>
- typedef NamedDecl *Object;<br>
+ using Object = NamedDecl *;<br>
<br>
/// Different flavors of object usage which we track. We only track the<br>
/// least-sequenced usage of each kind.<br>
enum UsageKind {<br>
/// A read of an object. Multiple unsequenced reads are OK.<br>
UK_Use,<br>
+<br>
/// A modification of an object which is sequenced before the value<br>
/// computation of the expression, such as ++n in C++.<br>
UK_ModAsValue,<br>
+<br>
/// A modification of an object which is not sequenced before the value<br>
/// computation of the expression, such as n++.<br>
UK_ModAsSideEffect,<br>
@@ -10314,29 +10406,37 @@ class SequenceChecker : public Evaluated<br>
};<br>
<br>
struct Usage {<br>
- Usage() : Use(nullptr), Seq() {}<br>
- Expr *Use;<br>
+ Expr *Use = nullptr;<br>
SequenceTree::Seq Seq;<br>
+<br>
+ Usage() = default;<br>
};<br>
<br>
struct UsageInfo {<br>
- UsageInfo() : Diagnosed(false) {}<br>
Usage Uses[UK_Count];<br>
+<br>
/// Have we issued a diagnostic for this variable already?<br>
- bool Diagnosed;<br>
+ bool Diagnosed = false;<br>
+<br>
+ UsageInfo() = default;<br>
};<br>
- typedef llvm::SmallDenseMap<Object, UsageInfo, 16> UsageInfoMap;<br>
+ using UsageInfoMap = llvm::SmallDenseMap<Object, UsageInfo, 16>;<br>
<br>
Sema &SemaRef;<br>
+<br>
/// Sequenced regions within the expression.<br>
SequenceTree Tree;<br>
+<br>
/// Declaration modifications and references which we have seen.<br>
UsageInfoMap UsageMap;<br>
+<br>
/// The region we are currently within.<br>
SequenceTree::Seq Region;<br>
+<br>
/// Filled in with declarations which were modified as a side-effect<br>
/// (that is, post-increment operations).<br>
- SmallVectorImpl<std::pair<<wbr>Object, Usage> > *ModAsSideEffect;<br>
+ SmallVectorImpl<std::pair<<wbr>Object, Usage>> *ModAsSideEffect = nullptr;<br>
+<br>
/// Expressions to check later. We defer checking these to reduce<br>
/// stack usage.<br>
SmallVectorImpl<Expr *> &WorkList;<br>
@@ -10351,6 +10451,7 @@ class SequenceChecker : public Evaluated<br>
: Self(Self), OldModAsSideEffect(Self.<wbr>ModAsSideEffect) {<br>
Self.ModAsSideEffect = &ModAsSideEffect;<br>
}<br>
+<br>
~SequencedSubexpression() {<br>
for (auto &M : llvm::reverse(ModAsSideEffect)<wbr>) {<br>
UsageInfo &U = Self.UsageMap[M.first];<br>
@@ -10363,7 +10464,7 @@ class SequenceChecker : public Evaluated<br>
<br>
SequenceChecker &Self;<br>
SmallVector<std::pair<Object, Usage>, 4> ModAsSideEffect;<br>
- SmallVectorImpl<std::pair<<wbr>Object, Usage> > *OldModAsSideEffect;<br>
+ SmallVectorImpl<std::pair<<wbr>Object, Usage>> *OldModAsSideEffect;<br>
};<br>
<br>
/// RAII object wrapping the visitation of a subexpression which we might<br>
@@ -10373,9 +10474,10 @@ class SequenceChecker : public Evaluated<br>
class EvaluationTracker {<br>
public:<br>
EvaluationTracker(<wbr>SequenceChecker &Self)<br>
- : Self(Self), Prev(Self.EvalTracker), EvalOK(true) {<br>
+ : Self(Self), Prev(Self.EvalTracker) {<br>
Self.EvalTracker = this;<br>
}<br>
+<br>
~EvaluationTracker() {<br>
Self.EvalTracker = Prev;<br>
if (Prev)<br>
@@ -10392,8 +10494,8 @@ class SequenceChecker : public Evaluated<br>
private:<br>
SequenceChecker &Self;<br>
EvaluationTracker *Prev;<br>
- bool EvalOK;<br>
- } *EvalTracker;<br>
+ bool EvalOK = true;<br>
+ } *EvalTracker = nullptr;<br>
<br>
/// \brief Find the object which is produced by the specified expression,<br>
/// if any.<br>
@@ -10427,6 +10529,7 @@ class SequenceChecker : public Evaluated<br>
U.Seq = Region;<br>
}<br>
}<br>
+<br>
/// \brief Check whether a modification or use conflicts with a prior usage.<br>
void checkUsage(Object O, UsageInfo &UI, Expr *Ref, UsageKind OtherKind,<br>
bool IsModMod) {<br>
@@ -10454,6 +10557,7 @@ class SequenceChecker : public Evaluated<br>
// Uses conflict with other modifications.<br>
checkUsage(O, U, Use, UK_ModAsValue, false);<br>
}<br>
+<br>
void notePostUse(Object O, Expr *Use) {<br>
UsageInfo &U = UsageMap[O];<br>
checkUsage(O, U, Use, UK_ModAsSideEffect, false);<br>
@@ -10466,6 +10570,7 @@ class SequenceChecker : public Evaluated<br>
checkUsage(O, U, Mod, UK_ModAsValue, true);<br>
checkUsage(O, U, Mod, UK_Use, false);<br>
}<br>
+<br>
void notePostMod(Object O, Expr *Use, UsageKind UK) {<br>
UsageInfo &U = UsageMap[O];<br>
checkUsage(O, U, Use, UK_ModAsSideEffect, true);<br>
@@ -10474,8 +10579,7 @@ class SequenceChecker : public Evaluated<br>
<br>
public:<br>
SequenceChecker(Sema &S, Expr *E, SmallVectorImpl<Expr *> &WorkList)<br>
- : Base(S.Context), SemaRef(S), Region(Tree.root()),<br>
- ModAsSideEffect(nullptr), WorkList(WorkList), EvalTracker(nullptr) {<br>
+ : Base(S.Context), SemaRef(S), Region(Tree.root()), WorkList(WorkList) {<br>
Visit(E);<br>
}<br>
<br>
@@ -10709,7 +10813,8 @@ public:<br>
Tree.merge(Elts[I]);<br>
}<br>
};<br>
-} // end anonymous namespace<br>
+<br>
+} // namespace<br>
<br>
void Sema::<wbr>CheckUnsequencedOperations(<wbr>Expr *E) {<br>
SmallVector<Expr *, 8> WorkList;<br>
@@ -11126,19 +11231,22 @@ void Sema::CheckArrayAccess(const Expr *<br>
//===--- CHECK: Objective-C retain cycles ------------------------------<wbr>----//<br>
<br>
namespace {<br>
- struct RetainCycleOwner {<br>
- RetainCycleOwner() : Variable(nullptr), Indirect(false) {}<br>
- VarDecl *Variable;<br>
- SourceRange Range;<br>
- SourceLocation Loc;<br>
- bool Indirect;<br>
-<br>
- void setLocsFrom(Expr *e) {<br>
- Loc = e->getExprLoc();<br>
- Range = e->getSourceRange();<br>
- }<br>
- };<br>
-} // end anonymous namespace<br>
+<br>
+struct RetainCycleOwner {<br>
+ VarDecl *Variable = nullptr;<br>
+ SourceRange Range;<br>
+ SourceLocation Loc;<br>
+ bool Indirect = false;<br>
+<br>
+ RetainCycleOwner() = default;<br>
+<br>
+ void setLocsFrom(Expr *e) {<br>
+ Loc = e->getExprLoc();<br>
+ Range = e->getSourceRange();<br>
+ }<br>
+};<br>
+<br>
+} // namespace<br>
<br>
/// Consider whether capturing the given variable can possibly lead to<br>
/// a retain cycle.<br>
@@ -11235,15 +11343,16 @@ static bool findRetainCycleOwner(Sema &S<br>
}<br>
<br>
namespace {<br>
+<br>
struct FindCaptureVisitor : EvaluatedExprVisitor<<wbr>FindCaptureVisitor> {<br>
- FindCaptureVisitor(ASTContext &Context, VarDecl *variable)<br>
- : EvaluatedExprVisitor<<wbr>FindCaptureVisitor>(Context),<br>
- Context(Context), Variable(variable), Capturer(nullptr),<br>
- VarWillBeReased(false) {}<br>
ASTContext &Context;<br>
VarDecl *Variable;<br>
- Expr *Capturer;<br>
- bool VarWillBeReased;<br>
+ Expr *Capturer = nullptr;<br>
+ bool VarWillBeReased = false;<br>
+<br>
+ FindCaptureVisitor(ASTContext &Context, VarDecl *variable)<br>
+ : EvaluatedExprVisitor<<wbr>FindCaptureVisitor>(Context),<br>
+ Context(Context), Variable(variable) {}<br>
<br>
void VisitDeclRefExpr(DeclRefExpr *ref) {<br>
if (ref->getDecl() == Variable && !Capturer)<br>
@@ -11268,6 +11377,7 @@ namespace {<br>
if (OVE->getSourceExpr())<br>
Visit(OVE->getSourceExpr());<br>
}<br>
+<br>
void VisitBinaryOperator(<wbr>BinaryOperator *BinOp) {<br>
if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign)<br>
return;<br>
@@ -11284,7 +11394,8 @@ namespace {<br>
}<br>
}<br>
};<br>
-} // end anonymous namespace<br>
+<br>
+} // namespace<br>
<br>
/// Check whether the given argument is a block which captures a<br>
/// variable.<br>
@@ -11691,16 +11802,14 @@ void Sema::checkUnsafeExprAssigns(<wbr>Source<br>
<br>
//===--- CHECK: Empty statement body (-Wempty-body) ---------------------===//<br>
<br>
-namespace {<br>
-bool ShouldDiagnoseEmptyStmtBody(<wbr>const SourceManager &SourceMgr,<br>
- SourceLocation StmtLoc,<br>
- const NullStmt *Body) {<br>
+static bool ShouldDiagnoseEmptyStmtBody(<wbr>const SourceManager &SourceMgr,<br>
+ SourceLocation StmtLoc,<br>
+ const NullStmt *Body) {<br>
// Do not warn if the body is a macro that expands to nothing, e.g:<br>
//<br>
// #define CALL(x)<br>
// if (condition)<br>
// CALL(0);<br>
- //<br>
if (Body->hasLeadingEmptyMacro())<br>
return false;<br>
<br>
@@ -11723,7 +11832,6 @@ bool ShouldDiagnoseEmptyStmtBody(<wbr>const S<br>
<br>
return true;<br>
}<br>
-} // end anonymous namespace<br>
<br>
void Sema::DiagnoseEmptyStmtBody(<wbr>SourceLocation StmtLoc,<br>
const Stmt *Body,<br>
@@ -11903,12 +12011,10 @@ void Sema::DiagnoseSelfMove(const Expr *<br>
<br>
//===--- Layout compatibility ------------------------------<wbr>----------------//<br>
<br>
-namespace {<br>
-<br>
-bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2);<br>
+static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2);<br>
<br>
/// \brief Check if two enumeration types are layout-compatible.<br>
-bool isLayoutCompatible(ASTContext &C, EnumDecl *ED1, EnumDecl *ED2) {<br>
+static bool isLayoutCompatible(ASTContext &C, EnumDecl *ED1, EnumDecl *ED2) {<br>
// C++11 [dcl.enum] p8:<br>
// Two enumeration types are layout-compatible if they have the same<br>
// underlying type.<br>
@@ -11917,7 +12023,8 @@ bool isLayoutCompatible(ASTContext &C, E<br>
}<br>
<br>
/// \brief Check if two fields are layout-compatible.<br>
-bool isLayoutCompatible(ASTContext &C, FieldDecl *Field1, FieldDecl *Field2) {<br>
+static bool isLayoutCompatible(ASTContext &C, FieldDecl *Field1,<br>
+ FieldDecl *Field2) {<br>
if (!isLayoutCompatible(C, Field1->getType(), Field2->getType()))<br>
return false;<br>
<br>
@@ -11938,9 +12045,8 @@ bool isLayoutCompatible(ASTContext &C, F<br>
<br>
/// \brief Check if two standard-layout structs are layout-compatible.<br>
/// (C++11 [class.mem] p17)<br>
-bool isLayoutCompatibleStruct(<wbr>ASTContext &C,<br>
- RecordDecl *RD1,<br>
- RecordDecl *RD2) {<br>
+static bool isLayoutCompatibleStruct(<wbr>ASTContext &C, RecordDecl *RD1,<br>
+ RecordDecl *RD2) {<br>
// If both records are C++ classes, check that base classes match.<br>
if (const CXXRecordDecl *D1CXX = dyn_cast<CXXRecordDecl>(RD1)) {<br>
// If one of records is a CXXRecordDecl we are in C++ mode,<br>
@@ -11983,9 +12089,8 @@ bool isLayoutCompatibleStruct(<wbr>ASTContext<br>
<br>
/// \brief Check if two standard-layout unions are layout-compatible.<br>
/// (C++11 [class.mem] p18)<br>
-bool isLayoutCompatibleUnion(<wbr>ASTContext &C,<br>
- RecordDecl *RD1,<br>
- RecordDecl *RD2) {<br>
+static bool isLayoutCompatibleUnion(<wbr>ASTContext &C, RecordDecl *RD1,<br>
+ RecordDecl *RD2) {<br>
llvm::SmallPtrSet<FieldDecl *, 8> UnmatchedFields;<br>
for (auto *Field2 : RD2->fields())<br>
UnmatchedFields.insert(Field2)<wbr>;<br>
@@ -12010,7 +12115,8 @@ bool isLayoutCompatibleUnion(<wbr>ASTContext<br>
return UnmatchedFields.empty();<br>
}<br>
<br>
-bool isLayoutCompatible(ASTContext &C, RecordDecl *RD1, RecordDecl *RD2) {<br>
+static bool isLayoutCompatible(ASTContext &C, RecordDecl *RD1,<br>
+ RecordDecl *RD2) {<br>
if (RD1->isUnion() != RD2->isUnion())<br>
return false;<br>
<br>
@@ -12021,7 +12127,7 @@ bool isLayoutCompatible(ASTContext &C, R<br>
}<br>
<br>
/// \brief Check if two types are layout-compatible in C++11 sense.<br>
-bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) {<br>
+static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) {<br>
if (T1.isNull() || T2.isNull())<br>
return false;<br>
<br>
@@ -12055,11 +12161,9 @@ bool isLayoutCompatible(ASTContext &C, Q<br>
<br>
return false;<br>
}<br>
-} // end anonymous namespace<br>
<br>
//===--- CHECK: pointer_with_type_tag attribute: datatypes should match ----//<br>
<br>
-namespace {<br>
/// \brief Given a type tag expression find the type tag itself.<br>
///<br>
/// \param TypeExpr Type tag expression, as it appears in user's code.<br>
@@ -12067,8 +12171,8 @@ namespace {<br>
/// \param VD Declaration of an identifier that appears in a type tag.<br>
///<br>
/// \param MagicValue Type tag magic value.<br>
-bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx,<br>
- const ValueDecl **VD, uint64_t *MagicValue) {<br>
+static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx,<br>
+ const ValueDecl **VD, uint64_t *MagicValue) {<br>
while(true) {<br>
if (!TypeExpr)<br>
return false;<br>
@@ -12143,7 +12247,7 @@ bool FindTypeTagExpr(const Expr *TypeExp<br>
/// \param TypeInfo Information about the corresponding C type.<br>
///<br>
/// \returns true if the corresponding C type was found.<br>
-bool GetMatchingCType(<br>
+static bool GetMatchingCType(<br>
const IdentifierInfo *ArgumentKind,<br>
const Expr *TypeExpr, const ASTContext &Ctx,<br>
const llvm::DenseMap<Sema::<wbr>TypeTagMagicValue,<br>
@@ -12186,7 +12290,6 @@ bool GetMatchingCType(<br>
TypeInfo = I->second;<br>
return true;<br>
}<br>
-} // end anonymous namespace<br>
<br>
void Sema::<wbr>RegisterTypeTagForDatatype(<wbr>const IdentifierInfo *ArgumentKind,<br>
uint64_t MagicValue, QualType Type,<br>
@@ -12201,8 +12304,7 @@ void Sema::<wbr>RegisterTypeTagForDatatype(co<br>
TypeTagData(Type, LayoutCompatible, MustBeNull);<br>
}<br>
<br>
-namespace {<br>
-bool IsSameCharType(QualType T1, QualType T2) {<br>
+static bool IsSameCharType(QualType T1, QualType T2) {<br>
const BuiltinType *BT1 = T1->getAs<BuiltinType>();<br>
if (!BT1)<br>
return false;<br>
@@ -12219,7 +12321,6 @@ bool IsSameCharType(QualType T1, QualTyp<br>
(T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) ||<br>
(T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar);<br>
}<br>
-} // end anonymous namespace<br>
<br>
void Sema::<wbr>CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,<br>
const Expr * const *ExprArgs) {<br>
@@ -12448,8 +12549,8 @@ void Sema::<wbr>RefersToMemberWithReducedAlig<br>
<br>
void Sema::<wbr>CheckAddressOfPackedMember(<wbr>Expr *rhs) {<br>
using namespace std::placeholders;<br>
+<br>
RefersToMemberWithReducedAlign<wbr>ment(<br>
rhs, std::bind(&Sema::<wbr>AddPotentialMisalignedMembers, std::ref(*this), _1,<br>
_2, _3, _4));<br>
}<br>
-<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>