r329346 - [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
Eugene Zelenko via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 5 14:09:03 PDT 2018
Author: eugenezelenko
Date: Thu Apr 5 14:09:03 2018
New Revision: 329346
URL: http://llvm.org/viewvc/llvm-project?rev=329346&view=rev
Log:
[Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
Modified:
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/SemaFixItUtils.h
cfe/trunk/include/clang/Sema/SemaInternal.h
cfe/trunk/include/clang/Sema/Weak.h
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/IdentifierResolver.cpp
cfe/trunk/lib/Sema/SemaFixItUtils.cpp
Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Thu Apr 5 14:09:03 2018
@@ -1,4 +1,4 @@
-//===--- DeclSpec.h - Parsed declaration specifiers -------------*- C++ -*-===//
+//===- DeclSpec.h - Parsed declaration specifiers ---------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,7 +6,7 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-///
+//
/// \file
/// \brief This file defines the classes used to store parsed information about
/// declaration-specifiers and declarators.
@@ -17,7 +17,7 @@
/// declaration-specifiers \ | /
/// declarators
/// \endverbatim
-///
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_SEMA_DECLSPEC_H
@@ -25,28 +25,39 @@
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/Basic/ExceptionSpecificationType.h"
+#include "clang/Basic/LLVM.h"
#include "clang/Basic/Lambda.h"
#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Lex/Token.h"
#include "clang/Sema/AttributeList.h"
#include "clang/Sema/Ownership.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <memory>
+#include <utility>
namespace clang {
- class ASTContext;
- class CXXRecordDecl;
- class TypeLoc;
- class LangOptions;
- class IdentifierInfo;
- class NamespaceAliasDecl;
- class NamespaceDecl;
- class ObjCDeclSpec;
- class Sema;
- class Declarator;
- struct TemplateIdAnnotation;
+
+class ASTContext;
+class CXXRecordDecl;
+class Decl;
+class Declarator;
+class Expr;
+class IdentifierInfo;
+class LangOptions;
+class NamedDecl;
+class NamespaceAliasDecl;
+class NamespaceDecl;
+class ObjCDeclSpec;
+class Sema;
+struct TemplateIdAnnotation;
+class TypeLoc;
/// \brief Represents a C++ nested-name-specifier or a global scope specifier.
///
@@ -187,11 +198,13 @@ public:
/// No scope specifier.
bool isEmpty() const { return !Range.isValid(); }
+
/// A scope specifier is present, but may be valid or invalid.
bool isNotEmpty() const { return !isEmpty(); }
/// An error occurred during parsing of the scope specifier.
bool isInvalid() const { return isNotEmpty() && getScopeRep() == nullptr; }
+
/// A scope specifier is present, and it refers to a real scope.
bool isValid() const { return isNotEmpty() && getScopeRep() != nullptr; }
@@ -242,14 +255,14 @@ public:
// Import thread storage class specifier enumeration and constants.
// These can be combined with SCS_extern and SCS_static.
- typedef ThreadStorageClassSpecifier TSCS;
+ using TSCS = ThreadStorageClassSpecifier;
static const TSCS TSCS_unspecified = clang::TSCS_unspecified;
static const TSCS TSCS___thread = clang::TSCS___thread;
static const TSCS TSCS_thread_local = clang::TSCS_thread_local;
static const TSCS TSCS__Thread_local = clang::TSCS__Thread_local;
// Import type specifier width enumeration and constants.
- typedef TypeSpecifierWidth TSW;
+ using TSW = TypeSpecifierWidth;
static const TSW TSW_unspecified = clang::TSW_unspecified;
static const TSW TSW_short = clang::TSW_short;
static const TSW TSW_long = clang::TSW_long;
@@ -262,13 +275,13 @@ public:
};
// Import type specifier sign enumeration and constants.
- typedef TypeSpecifierSign TSS;
+ using TSS = TypeSpecifierSign;
static const TSS TSS_unspecified = clang::TSS_unspecified;
static const TSS TSS_signed = clang::TSS_signed;
static const TSS TSS_unsigned = clang::TSS_unsigned;
// Import type specifier type enumeration and constants.
- typedef TypeSpecifierType TST;
+ using TST = TypeSpecifierType;
static const TST TST_unspecified = clang::TST_unspecified;
static const TST TST_void = clang::TST_void;
static const TST TST_char = clang::TST_char;
@@ -381,11 +394,13 @@ private:
SourceLocation StorageClassSpecLoc, ThreadStorageClassSpecLoc;
SourceRange TSWRange;
SourceLocation TSCLoc, TSSLoc, TSTLoc, AltiVecLoc;
+
/// TSTNameLoc - If TypeSpecType is any of class, enum, struct, union,
/// typename, then this is the location of the named type (if present);
/// otherwise, it is the same as TSTLoc. Hence, the pair TSTLoc and
/// TSTNameLoc provides source range info for tag types.
SourceLocation TSTNameLoc;
+
SourceRange TypeofParensRange;
SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc,
TQ_unalignedLoc;
@@ -395,64 +410,57 @@ private:
SourceLocation TQ_pipeLoc;
WrittenBuiltinSpecs writtenBS;
+
void SaveWrittenBuiltinSpecs();
- ObjCDeclSpec *ObjCQualifiers;
+ ObjCDeclSpec *ObjCQualifiers = nullptr;
static bool isTypeRep(TST T) {
return (T == TST_typename || T == TST_typeofType ||
T == TST_underlyingType || T == TST_atomic);
}
+
static bool isExprRep(TST T) {
return (T == TST_typeofExpr || T == TST_decltype);
}
- DeclSpec(const DeclSpec &) = delete;
- void operator=(const DeclSpec &) = delete;
public:
+ DeclSpec(AttributeFactory &attrFactory)
+ : StorageClassSpec(SCS_unspecified),
+ ThreadStorageClassSpec(TSCS_unspecified),
+ SCS_extern_in_linkage_spec(false), TypeSpecWidth(TSW_unspecified),
+ TypeSpecComplex(TSC_unspecified), TypeSpecSign(TSS_unspecified),
+ TypeSpecType(TST_unspecified), TypeAltiVecVector(false),
+ TypeAltiVecPixel(false), TypeAltiVecBool(false), TypeSpecOwned(false),
+ TypeSpecPipe(false), TypeQualifiers(TQ_unspecified),
+ FS_inline_specified(false), FS_forceinline_specified(false),
+ FS_virtual_specified(false), FS_explicit_specified(false),
+ FS_noreturn_specified(false), Friend_specified(false),
+ Constexpr_specified(false), Attrs(attrFactory) {}
+ DeclSpec(const DeclSpec &) = delete;
+ DeclSpec &operator=(const DeclSpec &) = delete;
+
static bool isDeclRep(TST T) {
return (T == TST_enum || T == TST_struct ||
T == TST_interface || T == TST_union ||
T == TST_class);
}
- DeclSpec(AttributeFactory &attrFactory)
- : StorageClassSpec(SCS_unspecified),
- ThreadStorageClassSpec(TSCS_unspecified),
- SCS_extern_in_linkage_spec(false),
- TypeSpecWidth(TSW_unspecified),
- TypeSpecComplex(TSC_unspecified),
- TypeSpecSign(TSS_unspecified),
- TypeSpecType(TST_unspecified),
- TypeAltiVecVector(false),
- TypeAltiVecPixel(false),
- TypeAltiVecBool(false),
- TypeSpecOwned(false),
- TypeSpecPipe(false),
- TypeQualifiers(TQ_unspecified),
- FS_inline_specified(false),
- FS_forceinline_specified(false),
- FS_virtual_specified(false),
- FS_explicit_specified(false),
- FS_noreturn_specified(false),
- Friend_specified(false),
- Constexpr_specified(false),
- Attrs(attrFactory),
- writtenBS(),
- ObjCQualifiers(nullptr) {
- }
-
// storage-class-specifier
SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; }
+
TSCS getThreadStorageClassSpec() const {
return (TSCS)ThreadStorageClassSpec;
}
+
bool isExternInLinkageSpec() const { return SCS_extern_in_linkage_spec; }
+
void setExternInLinkageSpec(bool Value) {
SCS_extern_in_linkage_spec = Value;
}
SourceLocation getStorageClassSpecLoc() const { return StorageClassSpecLoc; }
+
SourceLocation getThreadStorageClassSpecLoc() const {
return ThreadStorageClassSpecLoc;
}
@@ -487,14 +495,17 @@ public:
assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
return TypeRep;
}
+
Decl *getRepAsDecl() const {
assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
return DeclRep;
}
+
Expr *getRepAsExpr() const {
assert(isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr");
return ExprRep;
}
+
CXXScopeSpec &getTypeSpecScope() { return TypeScope; }
const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
@@ -557,9 +568,11 @@ public:
}
// function-specifier
+
bool isInlineSpecified() const {
return FS_inline_specified | FS_forceinline_specified;
}
+
SourceLocation getInlineSpecLoc() const {
return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc;
}
@@ -647,7 +660,7 @@ public:
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID, Expr *Rep,
- const PrintingPolicy &policy);
+ const PrintingPolicy &Policy);
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
const char *&PrevSpec, unsigned &DiagID,
const PrintingPolicy &Policy);
@@ -661,14 +674,17 @@ public:
const char *&PrevSpec, unsigned &DiagID,
const PrintingPolicy &Policy);
bool SetTypeSpecError();
+
void UpdateDeclRep(Decl *Rep) {
assert(isDeclRep((TST) TypeSpecType));
DeclRep = Rep;
}
+
void UpdateTypeRep(ParsedType Rep) {
assert(isTypeRep((TST) TypeSpecType));
TypeRep = Rep;
}
+
void UpdateExprRep(Expr *Rep) {
assert(isExprRep((TST) TypeSpecType));
ExprRep = Rep;
@@ -729,7 +745,6 @@ public:
/// short __attribute__((unused)) __attribute__((deprecated))
/// int __attribute__((may_alias)) __attribute__((aligned(16))) var;
/// \endcode
- ///
void addAttributes(AttributeList *AL) {
Attrs.addAll(AL);
}
@@ -804,15 +819,17 @@ public:
};
ObjCDeclSpec()
- : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
- Nullability(0), GetterName(nullptr), SetterName(nullptr) { }
+ : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
+ Nullability(0) {}
ObjCDeclQualifier getObjCDeclQualifier() const {
return (ObjCDeclQualifier)objcDeclQualifier;
}
+
void setObjCDeclQualifier(ObjCDeclQualifier DQVal) {
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal);
}
+
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal) {
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
}
@@ -820,6 +837,7 @@ public:
ObjCPropertyAttributeKind getPropertyAttributes() const {
return ObjCPropertyAttributeKind(PropertyAttributes);
}
+
void setPropertyAttributes(ObjCPropertyAttributeKind PRVal) {
PropertyAttributes =
(ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
@@ -850,6 +868,7 @@ public:
const IdentifierInfo *getGetterName() const { return GetterName; }
IdentifierInfo *getGetterName() { return GetterName; }
SourceLocation getGetterNameLoc() const { return GetterNameLoc; }
+
void setGetterName(IdentifierInfo *name, SourceLocation loc) {
GetterName = name;
GetterNameLoc = loc;
@@ -858,6 +877,7 @@ public:
const IdentifierInfo *getSetterName() const { return SetterName; }
IdentifierInfo *getSetterName() { return SetterName; }
SourceLocation getSetterNameLoc() const { return SetterNameLoc; }
+
void setSetterName(IdentifierInfo *name, SourceLocation loc) {
SetterName = name;
SetterNameLoc = loc;
@@ -876,33 +896,48 @@ private:
SourceLocation NullabilityLoc;
- IdentifierInfo *GetterName; // getter name or NULL if no getter
- IdentifierInfo *SetterName; // setter name or NULL if no setter
- SourceLocation GetterNameLoc; // location of the getter attribute's value
- SourceLocation SetterNameLoc; // location of the setter attribute's value
+ // Getter name or nullptr if no getter.
+ IdentifierInfo *GetterName = nullptr;
+ // Setter name or nullptr if no setter.
+ IdentifierInfo *SetterName = nullptr;
+
+ // Location of the getter attribute's value.
+ SourceLocation GetterNameLoc;
+
+ // Location of the setter attribute's value.
+ SourceLocation SetterNameLoc;
};
/// \brief Describes the kind of unqualified-id parsed.
enum class UnqualifiedIdKind {
/// \brief An identifier.
IK_Identifier,
+
/// \brief An overloaded operator name, e.g., operator+.
IK_OperatorFunctionId,
+
/// \brief A conversion function name, e.g., operator int.
IK_ConversionFunctionId,
+
/// \brief A user-defined literal name, e.g., operator "" _i.
IK_LiteralOperatorId,
+
/// \brief A constructor name.
IK_ConstructorName,
+
/// \brief A constructor named via a template-id.
IK_ConstructorTemplateId,
+
/// \brief A destructor name.
IK_DestructorName,
+
/// \brief A template-id, e.g., f<int>.
IK_TemplateId,
+
/// \brief An implicit 'self' parameter
IK_ImplicitSelfParam,
+
/// \brief A deduction-guide name (a template-name)
IK_DeductionGuideName
};
@@ -910,12 +945,9 @@ enum class UnqualifiedIdKind {
/// \brief Represents a C++ unqualified-id that has been parsed.
class UnqualifiedId {
private:
- UnqualifiedId(const UnqualifiedId &Other) = delete;
- const UnqualifiedId &operator=(const UnqualifiedId &) = delete;
-
public:
/// \brief Describes the kind of unqualified-id parsed.
- UnqualifiedIdKind Kind;
+ UnqualifiedIdKind Kind = UnqualifiedIdKind::IK_Identifier;
struct OFI {
/// \brief The kind of overloaded operator.
@@ -971,8 +1003,9 @@ public:
/// \brief The location of the last token that describes this unqualified-id.
SourceLocation EndLocation;
- UnqualifiedId()
- : Kind(UnqualifiedIdKind::IK_Identifier), Identifier(nullptr) {}
+ UnqualifiedId() : Identifier(nullptr) {}
+ UnqualifiedId(const UnqualifiedId &Other) = delete;
+ UnqualifiedId &operator=(const UnqualifiedId &) = delete;
/// \brief Clear out this unqualified-id, setting it to default (invalid)
/// state.
@@ -1111,12 +1144,13 @@ public:
SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(StartLocation, EndLocation);
}
+
SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; }
SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; }
};
/// \brief A set of tokens that has been cached for later parsing.
-typedef SmallVector<Token, 4> CachedTokens;
+using CachedTokens = SmallVector<Token, 4>;
/// \brief One instance of this struct is used for each type in a
/// declarator that is parsed.
@@ -1129,6 +1163,7 @@ struct DeclaratorChunk {
/// Loc - The place where this type was defined.
SourceLocation Loc;
+
/// EndLoc - If valid, the place where this chunck ends.
SourceLocation EndLoc;
@@ -1161,17 +1196,17 @@ struct DeclaratorChunk {
/// The location of the __unaligned-qualifier, if any.
unsigned UnalignedQualLoc;
- void destroy() {
- }
+ void destroy() {}
};
struct ReferenceTypeInfo : TypeInfoCommon {
/// The type qualifier: restrict. [GNU] C++ extension
bool HasRestrict : 1;
+
/// True if this is an lvalue reference, false if it's an rvalue reference.
bool LValueRef : 1;
- void destroy() {
- }
+
+ void destroy() {}
};
struct ArrayTypeInfo : TypeInfoCommon {
@@ -1216,8 +1251,8 @@ struct DeclaratorChunk {
ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
Decl *param,
std::unique_ptr<CachedTokens> DefArgTokens = nullptr)
- : Ident(ident), IdentLoc(iloc), Param(param),
- DefaultArgTokens(std::move(DefArgTokens)) {}
+ : Ident(ident), IdentLoc(iloc), Param(param),
+ DefaultArgTokens(std::move(DefArgTokens)) {}
};
struct TypeAndRange {
@@ -1459,32 +1494,33 @@ struct DeclaratorChunk {
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
unsigned TypeQuals : 5;
- void destroy() {
- }
+ void destroy() {}
};
struct MemberPointerTypeInfo : TypeInfoCommon {
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
unsigned TypeQuals : 5;
+
// CXXScopeSpec has a constructor, so it can't be a direct member.
// So we need some pointer-aligned storage and a bit of trickery.
alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
+
CXXScopeSpec &Scope() {
return *reinterpret_cast<CXXScopeSpec *>(ScopeMem);
}
+
const CXXScopeSpec &Scope() const {
return *reinterpret_cast<const CXXScopeSpec *>(ScopeMem);
}
- void destroy() {
- Scope().~CXXScopeSpec();
- }
+
+ void destroy() { Scope().~CXXScopeSpec(); }
};
struct PipeTypeInfo : TypeInfoCommon {
- /// The access writes.
- unsigned AccessWrites : 3;
+ /// The access writes.
+ unsigned AccessWrites : 3;
- void destroy() {}
+ void destroy() {}
};
union {
@@ -1659,21 +1695,21 @@ public:
};
private:
+ friend class Declarator;
+
/// The locations of the '[' and ']' tokens.
SourceLocation LSquareLoc, RSquareLoc;
/// The bindings.
- Binding *Bindings;
+ Binding *Bindings = nullptr;
unsigned NumBindings : 31;
unsigned DeleteBindings : 1;
- friend class Declarator;
-
public:
- DecompositionDeclarator()
- : Bindings(nullptr), NumBindings(0), DeleteBindings(false) {}
+ DecompositionDeclarator() : NumBindings(0), DeleteBindings(false) {}
DecompositionDeclarator(const DecompositionDeclarator &G) = delete;
DecompositionDeclarator &operator=(const DecompositionDeclarator &G) = delete;
+
~DecompositionDeclarator() {
if (DeleteBindings)
delete[] Bindings;
@@ -1696,6 +1732,7 @@ public:
SourceLocation getLSquareLoc() const { return LSquareLoc; }
SourceLocation getRSquareLoc() const { return RSquareLoc; }
+
SourceRange getSourceRange() const {
return SourceRange(LSquareLoc, RSquareLoc);
}
@@ -1711,34 +1748,84 @@ enum FunctionDefinitionKind {
};
enum class DeclaratorContext {
- FileContext, // File scope declaration.
- PrototypeContext, // Within a function prototype.
- ObjCResultContext, // An ObjC method result type.
- ObjCParameterContext,// An ObjC method parameter type.
- KNRTypeListContext, // K&R type definition list for formals.
- TypeNameContext, // Abstract declarator for types.
- FunctionalCastContext, // Type in a C++ functional cast expression.
- MemberContext, // Struct/Union field.
- BlockContext, // Declaration within a block in a function.
- ForContext, // Declaration within first part of a for loop.
- InitStmtContext, // Declaration within optional init stmt of if/switch.
- ConditionContext, // Condition declaration in a C++ if/switch/while/for.
- TemplateParamContext,// Within a template parameter list.
- CXXNewContext, // C++ new-expression.
- CXXCatchContext, // C++ catch exception-declaration
- ObjCCatchContext, // Objective-C catch exception-declaration
- BlockLiteralContext, // Block literal declarator.
- LambdaExprContext, // Lambda-expression declarator.
- LambdaExprParameterContext, // Lambda-expression parameter declarator.
- ConversionIdContext, // C++ conversion-type-id.
- TrailingReturnContext, // C++11 trailing-type-specifier.
- TrailingReturnVarContext, // C++11 trailing-type-specifier for variable.
- TemplateArgContext, // Any template argument (in template argument list).
- TemplateTypeArgContext, // Template type argument (in default argument).
- AliasDeclContext, // C++11 alias-declaration.
- AliasTemplateContext // C++11 alias-declaration template.
-};
+ // File scope declaration.
+ FileContext,
+
+ // Within a function prototype.
+ PrototypeContext,
+
+ // An ObjC method result type.
+ ObjCResultContext,
+
+ // An ObjC method parameter type.
+ ObjCParameterContext,
+
+ // K&R type definition list for formals.
+ KNRTypeListContext,
+
+ // Abstract declarator for types.
+ TypeNameContext,
+
+ // Type in a C++ functional cast expression.
+ FunctionalCastContext,
+
+ // Struct/Union field.
+ MemberContext,
+
+ // Declaration within a block in a function.
+ BlockContext,
+
+ // Declaration within first part of a for loop.
+ ForContext,
+ // Declaration within optional init stmt of if/switch.
+ InitStmtContext,
+
+ // Condition declaration in a C++ if/switch/while/for.
+ ConditionContext,
+
+ // Within a template parameter list.
+ TemplateParamContext,
+
+ // C++ new-expression.
+ CXXNewContext,
+
+ // C++ catch exception-declaration.
+ CXXCatchContext,
+
+ // Objective-C catch exception-declaration.
+ ObjCCatchContext,
+
+ // Block literal declarator.
+ BlockLiteralContext,
+
+ // Lambda-expression declarator.
+ LambdaExprContext,
+
+ // Lambda-expression parameter declarator.
+ LambdaExprParameterContext,
+
+ // C++ conversion-type-id.
+ ConversionIdContext,
+
+ // C++11 trailing-type-specifier.
+ TrailingReturnContext,
+
+ // C++11 trailing-type-specifier for variable.
+ TrailingReturnVarContext,
+
+ // Any template argument (in template argument list).
+ TemplateArgContext,
+
+ // Template type argument (in default argument).
+ TemplateTypeArgContext,
+
+ // C++11 alias-declaration.
+ AliasDeclContext,
+
+ // C++11 alias-declaration template.
+ AliasTemplateContext
+};
/// \brief Information about one declarator, including the parsed type
/// information and the identifier.
@@ -1753,8 +1840,9 @@ enum class DeclaratorContext {
/// Instances of this class should be a transient object that lives on the
/// stack, not objects that are allocated in large quantities on the heap.
class Declarator {
-
private:
+ friend struct DeclaratorChunk;
+
const DeclSpec &DS;
CXXScopeSpec SS;
UnqualifiedId Name;
@@ -1803,7 +1891,7 @@ private:
ParsedAttributes Attrs;
/// \brief The asm label, if specified.
- Expr *AsmLabel;
+ Expr *AsmLabel = nullptr;
#ifndef _MSC_VER
union {
@@ -1825,8 +1913,6 @@ private:
/// this declarator as a parameter pack.
SourceLocation EllipsisLoc;
- friend struct DeclaratorChunk;
-
public:
Declarator(const DeclSpec &ds, DeclaratorContext C)
: DS(ds), Range(ds.getSourceRange()), Context(C),
@@ -1834,11 +1920,12 @@ public:
GroupingParens(false), FunctionDefinition(FDK_Declaration),
Redeclaration(false), Extension(false), ObjCIvar(false),
ObjCWeakProperty(false), InlineStorageUsed(false),
- Attrs(ds.getAttributePool().getFactory()), AsmLabel(nullptr) {}
+ Attrs(ds.getAttributePool().getFactory()) {}
~Declarator() {
clear();
}
+
/// getDeclSpec - Return the declaration-specifier that this declarator was
/// declared with.
const DeclSpec &getDeclSpec() const { return DS; }
@@ -1881,17 +1968,20 @@ public:
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
void SetSourceRange(SourceRange R) { Range = R; }
+
/// SetRangeBegin - Set the start of the source range to Loc, unless it's
/// invalid.
void SetRangeBegin(SourceLocation Loc) {
if (!Loc.isInvalid())
Range.setBegin(Loc);
}
+
/// SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
void SetRangeEnd(SourceLocation Loc) {
if (!Loc.isInvalid())
Range.setEnd(Loc);
}
+
/// ExtendWithDeclSpec - Extend the declarator source range to include the
/// given declspec, unless its location is invalid. Adopts the range start if
/// the current range start is invalid.
@@ -1910,8 +2000,8 @@ public:
Range = DS.getSourceRange();
BindingGroup.clear();
- for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
- DeclTypeInfo[i].destroy();
+ for (auto &i : DeclTypeInfo)
+ i.destroy();
DeclTypeInfo.clear();
Attrs.clear();
AsmLabel = nullptr;
@@ -2135,8 +2225,7 @@ public:
/// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
/// EndLoc, which should be the last token of the chunk.
- void AddTypeInfo(const DeclaratorChunk &TI,
- ParsedAttributes &attrs,
+ void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs,
SourceLocation EndLoc) {
DeclTypeInfo.push_back(TI);
DeclTypeInfo.back().getAttrListRef() = attrs.getList();
@@ -2165,8 +2254,8 @@ public:
return DeclTypeInfo[i];
}
- typedef SmallVectorImpl<DeclaratorChunk>::const_iterator type_object_iterator;
- typedef llvm::iterator_range<type_object_iterator> type_object_range;
+ using type_object_iterator = SmallVectorImpl<DeclaratorChunk>::const_iterator;
+ using type_object_range = llvm::iterator_range<type_object_iterator>;
/// Returns the range of type objects, from the identifier outwards.
type_object_range type_objects() const {
@@ -2183,9 +2272,9 @@ public:
/// declarator that is not a parens chunk, or null if there are no
/// non-parens chunks.
const DeclaratorChunk *getInnermostNonParenChunk() const {
- for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
- if (!DeclTypeInfo[i].isParen())
- return &DeclTypeInfo[i];
+ for (const auto &i : DeclTypeInfo) {
+ if (!i.isParen())
+ return &i;
}
return nullptr;
}
@@ -2424,6 +2513,7 @@ public:
bool isObjCWeakProperty() const { return ObjCWeakProperty; }
void setInvalidType(bool Val = true) { InvalidType = Val; }
+
bool isInvalidType() const {
return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
}
@@ -2473,10 +2563,10 @@ public:
/// structure field declarators, which is basically just a bitfield size.
struct FieldDeclarator {
Declarator D;
- Expr *BitfieldSize;
+ Expr *BitfieldSize = nullptr;
+
explicit FieldDeclarator(const DeclSpec &DS)
- : D(DS, DeclaratorContext::MemberContext),
- BitfieldSize(nullptr) {}
+ : D(DS, DeclaratorContext::MemberContext) {}
};
/// \brief Represents a C++11 virt-specifier-seq.
@@ -2491,7 +2581,7 @@ public:
VS_GNU_Final = 8
};
- VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { }
+ VirtSpecifiers() = default;
bool SetSpecifier(Specifier VS, SourceLocation Loc,
const char *&PrevSpec);
@@ -2514,8 +2604,8 @@ public:
Specifier getLastSpecifier() const { return LastSpecifier; }
private:
- unsigned Specifiers;
- Specifier LastSpecifier;
+ unsigned Specifiers = 0;
+ Specifier LastSpecifier = VS_None;
SourceLocation VS_overrideLoc, VS_finalLoc;
SourceLocation FirstLocation;
@@ -2540,6 +2630,7 @@ struct LambdaIntroducer {
LambdaCaptureInitKind InitKind;
ExprResult Init;
ParsedType InitCaptureType;
+
LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc,
IdentifierInfo *Id, SourceLocation EllipsisLoc,
LambdaCaptureInitKind InitKind, ExprResult Init,
@@ -2550,11 +2641,10 @@ struct LambdaIntroducer {
SourceRange Range;
SourceLocation DefaultLoc;
- LambdaCaptureDefault Default;
+ LambdaCaptureDefault Default = LCD_None;
SmallVector<LambdaCapture, 4> Captures;
- LambdaIntroducer()
- : Default(LCD_None) {}
+ LambdaIntroducer() = default;
/// \brief Append a capture in a lambda introducer.
void addCapture(LambdaCaptureKind Kind,
@@ -2569,6 +2659,6 @@ struct LambdaIntroducer {
}
};
-} // end namespace clang
+} // namespace clang
#endif // LLVM_CLANG_SEMA_DECLSPEC_H
Modified: cfe/trunk/include/clang/Sema/SemaFixItUtils.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaFixItUtils.h?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/SemaFixItUtils.h (original)
+++ cfe/trunk/include/clang/Sema/SemaFixItUtils.h Thu Apr 5 14:09:03 2018
@@ -1,4 +1,4 @@
-//===--- SemaFixItUtils.h - Sema FixIts -----------------------------------===//
+//===- SemaFixItUtils.h - Sema FixIts ---------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,13 +10,22 @@
// This file defines helper classes for generation of Sema FixItHints.
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_CLANG_SEMA_SEMAFIXITUTILS_H
#define LLVM_CLANG_SEMA_SEMAFIXITUTILS_H
-#include "clang/AST/Expr.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
+#include <vector>
namespace clang {
+class Expr;
+class Sema;
+
enum OverloadFixItKind {
OFIK_Undefined = 0,
OFIK_Dereference,
@@ -25,8 +34,6 @@ enum OverloadFixItKind {
OFIK_RemoveTakeAddress
};
-class Sema;
-
/// The class facilities generation and storage of conversion FixIts. Hints for
/// new conversions are added using TryToFixConversion method. The default type
/// conversion checker can be reset.
@@ -43,29 +50,25 @@ struct ConversionFixItGenerator {
/// The number of Conversions fixed. This can be different from the size
/// of the Hints vector since we allow multiple FixIts per conversion.
- unsigned NumConversionsFixed;
+ unsigned NumConversionsFixed = 0;
/// The type of fix applied. If multiple conversions are fixed, corresponds
/// to the kid of the very first conversion.
- OverloadFixItKind Kind;
+ OverloadFixItKind Kind = OFIK_Undefined;
+
+ using TypeComparisonFuncTy = bool (*) (const CanQualType FromTy,
+ const CanQualType ToTy,
+ Sema &S,
+ SourceLocation Loc,
+ ExprValueKind FromVK);
- typedef bool (*TypeComparisonFuncTy) (const CanQualType FromTy,
- const CanQualType ToTy,
- Sema &S,
- SourceLocation Loc,
- ExprValueKind FromVK);
/// The type comparison function used to decide if expression FromExpr of
/// type FromTy can be converted to ToTy. For example, one could check if
/// an implicit conversion exists. Returns true if comparison exists.
- TypeComparisonFuncTy CompareTypes;
+ TypeComparisonFuncTy CompareTypes = compareTypesSimple;
- ConversionFixItGenerator(TypeComparisonFuncTy Foo): NumConversionsFixed(0),
- Kind(OFIK_Undefined),
- CompareTypes(Foo) {}
-
- ConversionFixItGenerator(): NumConversionsFixed(0),
- Kind(OFIK_Undefined),
- CompareTypes(compareTypesSimple) {}
+ ConversionFixItGenerator() = default;
+ ConversionFixItGenerator(TypeComparisonFuncTy Foo) : CompareTypes(Foo) {}
/// Resets the default conversion checker method.
void setConversionChecker(TypeComparisonFuncTy Foo) {
@@ -87,5 +90,6 @@ struct ConversionFixItGenerator {
}
};
-} // endof namespace clang
-#endif
+} // namespace clang
+
+#endif // LLVM_CLANG_SEMA_SEMAFIXITUTILS_H
Modified: cfe/trunk/include/clang/Sema/SemaInternal.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaInternal.h?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/SemaInternal.h (original)
+++ cfe/trunk/include/clang/Sema/SemaInternal.h Thu Apr 5 14:09:03 2018
@@ -1,4 +1,4 @@
-//===--- SemaInternal.h - Internal Sema Interfaces --------------*- C++ -*-===//
+//===- SemaInternal.h - Internal Sema Interfaces ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,12 +16,41 @@
#define LLVM_CLANG_SEMA_SEMAINTERNAL_H
#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaDiagnostic.h"
+#include "clang/Sema/TypoCorrection.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <cstddef>
+#include <iterator>
+#include <limits>
+#include <map>
+#include <memory>
+#include <string>
+#include <utility>
namespace clang {
+class IdentifierInfo;
+class NestedNameSpecifier;
+class Scope;
+
inline PartialDiagnostic Sema::PDiag(unsigned DiagID) {
return PartialDiagnostic(DiagID, Context.getDiagAllocator());
}
@@ -102,9 +131,9 @@ inline InheritableAttr *getDLLAttr(Decl
}
class TypoCorrectionConsumer : public VisibleDeclConsumer {
- typedef SmallVector<TypoCorrection, 1> TypoResultList;
- typedef llvm::StringMap<TypoResultList> TypoResultsMap;
- typedef std::map<unsigned, TypoResultsMap> TypoEditDistanceMap;
+ using TypoResultList = SmallVector<TypoCorrection, 1>;
+ using TypoResultsMap = llvm::StringMap<TypoResultList>;
+ using TypoEditDistanceMap = std::map<unsigned, TypoResultsMap>;
public:
TypoCorrectionConsumer(Sema &SemaRef,
@@ -114,13 +143,12 @@ public:
std::unique_ptr<CorrectionCandidateCallback> CCC,
DeclContext *MemberContext,
bool EnteringContext)
- : Typo(TypoName.getName().getAsIdentifierInfo()), CurrentTCIndex(0),
- SavedTCIndex(0), SemaRef(SemaRef), S(S),
+ : Typo(TypoName.getName().getAsIdentifierInfo()), SemaRef(SemaRef), S(S),
SS(SS ? llvm::make_unique<CXXScopeSpec>(*SS) : nullptr),
CorrectionValidator(std::move(CCC)), MemberContext(MemberContext),
Result(SemaRef, TypoName, LookupKind),
Namespaces(SemaRef.Context, SemaRef.CurContext, SS),
- EnteringContext(EnteringContext), SearchNamespaces(false) {
+ EnteringContext(EnteringContext) {
Result.suppressDiagnostics();
// Arrange for ValidatedCorrections[0] to always be an empty correction.
ValidatedCorrections.push_back(TypoCorrection());
@@ -129,6 +157,7 @@ public:
bool includeHiddenDecls() const override { return true; }
// Methods for adding potential corrections to the consumer.
+
void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
bool InBaseClass) override;
void FoundName(StringRef Name);
@@ -149,7 +178,7 @@ public:
/// closest/best edit distance from the original typop.
unsigned getBestEditDistance(bool Normalized) {
if (CorrectionResults.empty())
- return (std::numeric_limits<unsigned>::max)();
+ return std::numeric_limits<unsigned>::max();
unsigned BestED = CorrectionResults.begin()->first;
return Normalized ? TypoCorrection::NormalizeEditDistance(BestED) : BestED;
@@ -218,6 +247,7 @@ public:
bool isAddressOfOperand() const { return CorrectionValidator->IsAddressOfOperand; }
const CXXScopeSpec *getSS() const { return SS.get(); }
Scope *getScope() const { return S; }
+
CorrectionCandidateCallback *getCorrectionValidator() const {
return CorrectionValidator.get();
}
@@ -226,18 +256,18 @@ private:
class NamespaceSpecifierSet {
struct SpecifierInfo {
DeclContext* DeclCtx;
- NestedNameSpecifier* NameSpecifier;
+ NestedNameSpecifier *NameSpecifier;
unsigned EditDistance;
};
- typedef SmallVector<DeclContext*, 4> DeclContextList;
- typedef SmallVector<SpecifierInfo, 16> SpecifierInfoList;
+ using DeclContextList = SmallVector<DeclContext *, 4>;
+ using SpecifierInfoList = SmallVector<SpecifierInfo, 16>;
ASTContext &Context;
DeclContextList CurContextChain;
std::string CurNameSpecifier;
- SmallVector<const IdentifierInfo*, 4> CurContextIdentifiers;
- SmallVector<const IdentifierInfo*, 4> CurNameSpecifierIdentifiers;
+ SmallVector<const IdentifierInfo *, 4> CurContextIdentifiers;
+ SmallVector<const IdentifierInfo *, 4> CurNameSpecifierIdentifiers;
std::map<unsigned, SpecifierInfoList> DistanceMap;
@@ -248,7 +278,7 @@ private:
unsigned buildNestedNameSpecifier(DeclContextList &DeclChain,
NestedNameSpecifier *&NNS);
- public:
+ public:
NamespaceSpecifierSet(ASTContext &Context, DeclContext *CurContext,
CXXScopeSpec *CurScopeSpec);
@@ -262,8 +292,10 @@ private:
SpecifierInfo> {
/// Always points to the last element in the distance map.
const std::map<unsigned, SpecifierInfoList>::iterator OuterBack;
+
/// Iterator on the distance map.
std::map<unsigned, SpecifierInfoList>::iterator Outer;
+
/// Iterator on an element in the distance map.
SpecifierInfoList::iterator Inner;
@@ -317,8 +349,8 @@ private:
TypoEditDistanceMap CorrectionResults;
SmallVector<TypoCorrection, 4> ValidatedCorrections;
- size_t CurrentTCIndex;
- size_t SavedTCIndex;
+ size_t CurrentTCIndex = 0;
+ size_t SavedTCIndex = 0;
Sema &SemaRef;
Scope *S;
@@ -329,10 +361,10 @@ private:
NamespaceSpecifierSet Namespaces;
SmallVector<TypoCorrection, 2> QualifiedResults;
bool EnteringContext;
- bool SearchNamespaces;
+ bool SearchNamespaces = false;
};
-inline Sema::TypoExprState::TypoExprState() {}
+inline Sema::TypoExprState::TypoExprState() = default;
inline Sema::TypoExprState::TypoExprState(TypoExprState &&other) noexcept {
*this = std::move(other);
@@ -346,6 +378,6 @@ operator=(Sema::TypoExprState &&other) n
return *this;
}
-} // end namespace clang
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_SEMA_SEMAINTERNAL_H
Modified: cfe/trunk/include/clang/Sema/Weak.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Weak.h?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Weak.h (original)
+++ cfe/trunk/include/clang/Sema/Weak.h Thu Apr 5 14:09:03 2018
@@ -1,4 +1,4 @@
-//===-- UnresolvedSet.h - Unresolved sets of declarations ------*- C++ -*-===//
+//===- UnresolvedSet.h - Unresolved sets of declarations --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -23,24 +23,32 @@ class IdentifierInfo;
/// \brief Captures information about a \#pragma weak directive.
class WeakInfo {
- IdentifierInfo *alias; // alias (optional)
- SourceLocation loc; // for diagnostics
- bool used; // identifier later declared?
+ // alias (optional)
+ IdentifierInfo *alias = nullptr;
+
+ // for diagnostics
+ SourceLocation loc;
+
+ // identifier later declared?
+ bool used = false;
+
public:
- WeakInfo()
- : alias(nullptr), loc(SourceLocation()), used(false) {}
+ WeakInfo() = default;
WeakInfo(IdentifierInfo *Alias, SourceLocation Loc)
- : alias(Alias), loc(Loc), used(false) {}
- inline IdentifierInfo * getAlias() const { return alias; }
- inline SourceLocation getLocation() const { return loc; }
+ : alias(Alias), loc(Loc) {}
+
+ IdentifierInfo *getAlias() const { return alias; }
+ SourceLocation getLocation() const { return loc; }
void setUsed(bool Used=true) { used = Used; }
- inline bool getUsed() { return used; }
+ bool getUsed() { return used; }
+
bool operator==(WeakInfo RHS) const {
return alias == RHS.getAlias() && loc == RHS.getLocation();
}
+
bool operator!=(WeakInfo RHS) const { return !(*this == RHS); }
};
-} // end namespace clang
+} // namespace clang
#endif // LLVM_CLANG_SEMA_WEAK_H
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Thu Apr 5 14:09:03 2018
@@ -285,11 +285,11 @@ CodeCompletionString::CodeCompletionStri
assert(NumChunks <= 0xffff);
assert(NumAnnotations <= 0xffff);
- Chunk *StoredChunks = reinterpret_cast<Chunk *>(this + 1);
+ auto *StoredChunks = reinterpret_cast<Chunk *>(this + 1);
for (unsigned I = 0; I != NumChunks; ++I)
StoredChunks[I] = Chunks[I];
- const char **StoredAnnotations = reinterpret_cast<const char **>(StoredChunks + NumChunks);
+ const auto **StoredAnnotations = reinterpret_cast<const char **>(StoredChunks + NumChunks);
for (unsigned I = 0; I != NumAnnotations; ++I)
StoredAnnotations[I] = Annotations[I];
}
@@ -340,14 +340,14 @@ const char *CodeCompletionAllocator::Cop
// FIXME: It would be more efficient to teach Twine to tell us its size and
// then add a routine there to fill in an allocated char* with the contents
// of the string.
- char *Mem = (char *)Allocate(Ref.size() + 1, 1);
+ auto *Mem = (char *)Allocate(Ref.size() + 1, 1);
std::copy(Ref.begin(), Ref.end(), Mem);
Mem[Ref.size()] = 0;
return Mem;
}
StringRef CodeCompletionTUInfo::getParentName(const DeclContext *DC) {
- const NamedDecl *ND = dyn_cast<NamedDecl>(DC);
+ const auto *ND = dyn_cast<NamedDecl>(DC);
if (!ND)
return {};
@@ -364,7 +364,7 @@ StringRef CodeCompletionTUInfo::getParen
// Find the interesting names.
SmallVector<const DeclContext *, 2> Contexts;
while (DC && !DC->isFunctionOrMethod()) {
- if (const NamedDecl *ND = dyn_cast<NamedDecl>(DC)) {
+ if (const auto *ND = dyn_cast<NamedDecl>(DC)) {
if (ND->getIdentifier())
Contexts.push_back(DC);
}
@@ -384,10 +384,10 @@ StringRef CodeCompletionTUInfo::getParen
}
const DeclContext *CurDC = Contexts[I-1];
- if (const ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC))
+ if (const auto *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC))
CurDC = CatImpl->getCategoryDecl();
- if (const ObjCCategoryDecl *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) {
+ if (const auto *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) {
const ObjCInterfaceDecl *Interface = Cat->getClassInterface();
if (!Interface) {
// Assign an empty StringRef but with non-null data to distinguish
@@ -413,7 +413,7 @@ CodeCompletionString *CodeCompletionBuil
sizeof(CodeCompletionString) + sizeof(Chunk) * Chunks.size() +
sizeof(const char *) * Annotations.size(),
alignof(CodeCompletionString));
- CodeCompletionString *Result
+ auto *Result
= new (Mem) CodeCompletionString(Chunks.data(), Chunks.size(),
Priority, Availability,
Annotations.data(), Annotations.size(),
@@ -463,7 +463,7 @@ void CodeCompletionBuilder::addParentCon
if (DC->isFunctionOrMethod())
return;
- const NamedDecl *ND = dyn_cast<NamedDecl>(DC);
+ const auto *ND = dyn_cast<NamedDecl>(DC);
if (!ND)
return;
@@ -655,7 +655,7 @@ void CodeCompletionResult::computeCursor
break;
}
- if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(Declaration))
+ if (const auto *Function = dyn_cast<FunctionDecl>(Declaration))
if (Function->isDeleted())
Availability = CXAvailability_NotAvailable;
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Thu Apr 5 14:09:03 2018
@@ -1,4 +1,4 @@
-//===--- DeclSpec.cpp - Declaration Specifier Semantic Analysis -----------===//
+//===- DeclSpec.cpp - Declaration Specifier Semantic Analysis -------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,20 +13,35 @@
#include "clang/Sema/DeclSpec.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/LocInfoType.h"
+#include "clang/AST/PrettyPrinter.h"
+#include "clang/AST/Type.h"
#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/ExceptionSpecificationType.h"
+#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/OpenCLOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
+#include "clang/Sema/AttributeList.h"
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
#include <cstring>
-using namespace clang;
+#include <utility>
+using namespace clang;
void UnqualifiedId::setTemplateId(TemplateIdAnnotation *TemplateId) {
assert(TemplateId && "NULL template-id annotation?");
@@ -135,14 +150,14 @@ void CXXScopeSpec::Adopt(NestedNameSpeci
SourceLocation CXXScopeSpec::getLastQualifierNameLoc() const {
if (!Builder.getRepresentation())
- return SourceLocation();
+ return {};
return Builder.getTemporary().getLocalBeginLoc();
}
NestedNameSpecifierLoc
CXXScopeSpec::getWithLocInContext(ASTContext &Context) const {
if (!Builder.getRepresentation())
- return NestedNameSpecifierLoc();
+ return {};
return Builder.getWithLocInContext(Context);
}
@@ -289,7 +304,7 @@ void Declarator::setDecompositionBinding
Name.EndLocation = RSquareLoc;
// Allocate storage for bindings and stash them away.
- if (Bindings.size()) {
+ if (!Bindings.empty()) {
if (!InlineStorageUsed &&
Bindings.size() <= llvm::array_lengthof(InlineBindings)) {
BindingGroup.Bindings = InlineBindings;
@@ -306,8 +321,8 @@ void Declarator::setDecompositionBinding
}
bool Declarator::isDeclarationOfFunction() const {
- for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
- switch (DeclTypeInfo[i].Kind) {
+ for (const auto &i : DeclTypeInfo) {
+ switch (i.Kind) {
case DeclaratorChunk::Function:
return true;
case DeclaratorChunk::Paren:
@@ -373,7 +388,7 @@ bool Declarator::isDeclarationOfFunction
if (QT.isNull())
return false;
- if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT))
+ if (const auto *LIT = dyn_cast<LocInfoType>(QT))
QT = LIT->getType();
if (QT.isNull())
@@ -407,7 +422,6 @@ bool DeclSpec::hasTagDefinition() const
/// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
/// declaration specifier includes.
-///
unsigned DeclSpec::getParsedSpecifiers() const {
unsigned Res = 0;
if (StorageClassSpec != SCS_unspecified ||
@@ -482,7 +496,6 @@ const char *DeclSpec::getSpecifierName(T
llvm_unreachable("Unknown typespec!");
}
-
const char *DeclSpec::getSpecifierName(TSS S) {
switch (S) {
case TSS_unspecified: return "unspecified";
@@ -777,16 +790,14 @@ bool DeclSpec::SetTypeAltiVecVector(bool
bool DeclSpec::SetTypePipe(bool isPipe, SourceLocation Loc,
const char *&PrevSpec, unsigned &DiagID,
const PrintingPolicy &Policy) {
-
if (TypeSpecType != TST_unspecified) {
PrevSpec = DeclSpec::getSpecifierName((TST)TypeSpecType, Policy);
DiagID = diag::err_invalid_decl_spec_combination;
return true;
}
- if (isPipe) {
+ if (isPipe)
TypeSpecPipe = TSP_pipe;
- }
return false;
}
@@ -975,7 +986,7 @@ void DeclSpec::SaveWrittenBuiltinSpecs()
writtenBS.Type = getTypeSpecType();
// Search the list of attributes for the presence of a mode attribute.
writtenBS.ModeAttr = false;
- AttributeList* attrs = getAttributes().getList();
+ AttributeList *attrs = getAttributes().getList();
while (attrs) {
if (attrs->getKind() == AttributeList::AT_Mode) {
writtenBS.ModeAttr = true;
Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Thu Apr 5 14:09:03 2018
@@ -147,7 +147,7 @@ void IdentifierResolver::AddDecl(NamedDe
if (IdentifierInfo *II = Name.getAsIdentifierInfo())
updatingIdentifier(*II);
- void *Ptr = Name.getFETokenInfo<void>();
+ auto *Ptr = Name.getFETokenInfo<void>();
if (!Ptr) {
Name.setFETokenInfo(D);
@@ -159,7 +159,7 @@ void IdentifierResolver::AddDecl(NamedDe
if (isDeclPtr(Ptr)) {
Name.setFETokenInfo(nullptr);
IDI = &(*IdDeclInfos)[Name];
- NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr);
+ auto *PrevD = static_cast<NamedDecl *>(Ptr);
IDI->AddDecl(PrevD);
} else
IDI = toIdDeclInfo(Ptr);
@@ -172,7 +172,7 @@ void IdentifierResolver::InsertDeclAfter
if (IdentifierInfo *II = Name.getAsIdentifierInfo())
updatingIdentifier(*II);
- void *Ptr = Name.getFETokenInfo<void>();
+ auto *Ptr = Name.getFETokenInfo<void>();
if (!Ptr) {
AddDecl(D);
@@ -184,7 +184,7 @@ void IdentifierResolver::InsertDeclAfter
// as appropriate.
if (Pos == iterator()) {
// Add the new declaration before the existing declaration.
- NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr);
+ auto *PrevD = static_cast<NamedDecl *>(Ptr);
RemoveDecl(PrevD);
AddDecl(D);
AddDecl(PrevD);
@@ -213,7 +213,7 @@ void IdentifierResolver::RemoveDecl(Name
if (IdentifierInfo *II = Name.getAsIdentifierInfo())
updatingIdentifier(*II);
- void *Ptr = Name.getFETokenInfo<void>();
+ auto *Ptr = Name.getFETokenInfo<void>();
assert(Ptr && "Didn't find this decl on its identifier's chain!");
@@ -232,11 +232,11 @@ IdentifierResolver::begin(DeclarationNam
if (IdentifierInfo *II = Name.getAsIdentifierInfo())
readingIdentifier(*II);
- void *Ptr = Name.getFETokenInfo<void>();
+ auto *Ptr = Name.getFETokenInfo<void>();
if (!Ptr) return end();
if (isDeclPtr(Ptr))
- return iterator(static_cast<NamedDecl*>(Ptr));
+ return iterator(static_cast<NamedDecl *>(Ptr));
IdDeclInfo *IDI = toIdDeclInfo(Ptr);
@@ -304,7 +304,7 @@ bool IdentifierResolver::tryAddTopLevelD
if (IdentifierInfo *II = Name.getAsIdentifierInfo())
readingIdentifier(*II);
- void *Ptr = Name.getFETokenInfo<void>();
+ auto *Ptr = Name.getFETokenInfo<void>();
if (!Ptr) {
Name.setFETokenInfo(D);
@@ -314,7 +314,7 @@ bool IdentifierResolver::tryAddTopLevelD
IdDeclInfo *IDI;
if (isDeclPtr(Ptr)) {
- NamedDecl *PrevD = static_cast<NamedDecl*>(Ptr);
+ auto *PrevD = static_cast<NamedDecl *>(Ptr);
switch (compareDeclarations(PrevD, D)) {
case DMK_Different:
@@ -397,7 +397,7 @@ void IdentifierResolver::updatingIdentif
/// It creates a new IdDeclInfo if one was not created before for this id.
IdentifierResolver::IdDeclInfo &
IdentifierResolver::IdDeclInfoMap::operator[](DeclarationName Name) {
- void *Ptr = Name.getFETokenInfo<void>();
+ auto *Ptr = Name.getFETokenInfo<void>();
if (Ptr) return *toIdDeclInfo(Ptr);
@@ -415,7 +415,7 @@ IdentifierResolver::IdDeclInfoMap::opera
void IdentifierResolver::iterator::incrementSlowCase() {
NamedDecl *D = **this;
- void *InfoPtr = D->getDeclName().getFETokenInfo<void>();
+ auto *InfoPtr = D->getDeclName().getFETokenInfo<void>();
assert(!isDeclPtr(InfoPtr) && "Decl with wrong id ?");
IdDeclInfo *Info = toIdDeclInfo(InfoPtr);
Modified: cfe/trunk/lib/Sema/SemaFixItUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaFixItUtils.cpp?rev=329346&r1=329345&r2=329346&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaFixItUtils.cpp (original)
+++ cfe/trunk/lib/Sema/SemaFixItUtils.cpp Thu Apr 5 14:09:03 2018
@@ -1,4 +1,4 @@
-//===--- SemaFixItUtils.cpp - Sema FixIts ---------------------------------===//
+//===- SemaFixItUtils.cpp - Sema FixIts -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,12 +11,24 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Sema/SemaFixItUtils.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Sema.h"
-#include "clang/Sema/SemaFixItUtils.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <string>
using namespace clang;
@@ -91,7 +103,7 @@ bool ConversionFixItGenerator::tryToFixC
// Check if the argument needs to be dereferenced:
// (type * -> type) or (type * -> type &).
- if (const PointerType *FromPtrTy = dyn_cast<PointerType>(FromQTy)) {
+ if (const auto *FromPtrTy = dyn_cast<PointerType>(FromQTy)) {
OverloadFixItKind FixKind = OFIK_Dereference;
bool CanConvert = CompareTypes(
@@ -103,7 +115,7 @@ bool ConversionFixItGenerator::tryToFixC
isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull))
return false;
- if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(Expr)) {
+ if (const auto *UO = dyn_cast<UnaryOperator>(Expr)) {
if (UO->getOpcode() == UO_AddrOf) {
FixKind = OFIK_RemoveTakeAddress;
Hints.push_back(FixItHint::CreateRemoval(
@@ -136,8 +148,7 @@ bool ConversionFixItGenerator::tryToFixC
CanConvert = CompareTypes(S.Context.getPointerType(FromQTy), ToQTy,
S, Begin, VK_RValue);
if (CanConvert) {
-
- if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(Expr)) {
+ if (const auto *UO = dyn_cast<UnaryOperator>(Expr)) {
if (UO->getOpcode() == UO_Deref) {
FixKind = OFIK_RemoveDereference;
Hints.push_back(FixItHint::CreateRemoval(
@@ -171,7 +182,7 @@ static std::string getScalarZeroExpressi
// Suggest "0" for non-enumeration scalar types, unless we can find a
// better initializer.
if (T.isEnumeralType())
- return std::string();
+ return {};
if ((T.isObjCObjectPointerType() || T.isBlockPointerType()) &&
isMacroDefined(S, Loc, "nil"))
return "nil";
@@ -208,12 +219,12 @@ Sema::getFixItZeroInitializerForType(Qua
const CXXRecordDecl *RD = T->getAsCXXRecordDecl();
if (!RD || !RD->hasDefinition())
- return std::string();
+ return {};
if (LangOpts.CPlusPlus11 && !RD->hasUserProvidedDefaultConstructor())
return "{}";
if (RD->isAggregate())
return " = {}";
- return std::string();
+ return {};
}
std::string
More information about the cfe-commits
mailing list