forked from OSchip/llvm-project
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318882
This commit is contained in:
parent
16e798873e
commit
2f8e66bbd8
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
//===--- DeclObjC.cpp - ObjC Declaration AST Node Implementation ----------===//
|
||||
//===- DeclObjC.cpp - ObjC Declaration AST Node Implementation ------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -15,9 +15,27 @@
|
|||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/ASTMutationListener.h"
|
||||
#include "clang/AST/Attr.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/Stmt.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/None.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -28,7 +46,6 @@ void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
|
|||
List = nullptr;
|
||||
if (Elts == 0) return; // Setting to an empty list is a noop.
|
||||
|
||||
|
||||
List = new (Ctx) void*[Elts];
|
||||
NumElts = Elts;
|
||||
memcpy(List, InList, sizeof(void*)*Elts);
|
||||
|
@ -82,7 +99,6 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance,
|
|||
// - (int) class_method;
|
||||
// + (float) class_method;
|
||||
// @end
|
||||
//
|
||||
lookup_result R = lookup(Sel);
|
||||
for (lookup_iterator Meth = R.begin(), MethEnd = R.end();
|
||||
Meth != MethEnd; ++Meth) {
|
||||
|
@ -341,7 +357,6 @@ SourceLocation ObjCInterfaceDecl::getSuperClassLoc() const {
|
|||
/// FindPropertyVisibleInPrimaryClass - Finds declaration of the property
|
||||
/// with name 'PropertyId' in the primary class; including those in protocols
|
||||
/// (direct or indirect) used by the primary class.
|
||||
///
|
||||
ObjCPropertyDecl *
|
||||
ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass(
|
||||
IdentifierInfo *PropertyId,
|
||||
|
@ -409,8 +424,7 @@ const ObjCInterfaceDecl *ObjCInterfaceDecl::isObjCRequiresPropertyDefs() const {
|
|||
|
||||
void ObjCInterfaceDecl::mergeClassExtensionProtocolList(
|
||||
ObjCProtocolDecl *const* ExtList, unsigned ExtNum,
|
||||
ASTContext &C)
|
||||
{
|
||||
ASTContext &C) {
|
||||
if (data().ExternallyCompleted)
|
||||
LoadExternalDefinition();
|
||||
|
||||
|
@ -488,7 +502,7 @@ bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const {
|
|||
return true;
|
||||
case DefinitionData::IDI_NotInherited:
|
||||
return false;
|
||||
case DefinitionData::IDI_Unknown: {
|
||||
case DefinitionData::IDI_Unknown:
|
||||
// If the class introduced initializers we conservatively assume that we
|
||||
// don't know if any of them is a designated initializer to avoid possible
|
||||
// misleading warnings.
|
||||
|
@ -510,7 +524,6 @@ bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const {
|
|||
return data().InheritedDesignatedInitializers ==
|
||||
DefinitionData::IDI_Inherited;
|
||||
}
|
||||
}
|
||||
|
||||
llvm_unreachable("unexpected InheritedDesignatedInitializers value");
|
||||
}
|
||||
|
@ -902,7 +915,6 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
|
|||
if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(),
|
||||
isInstanceMethod()))
|
||||
return MD;
|
||||
|
||||
} else if (ObjCCategoryImplDecl *CImplD =
|
||||
dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
|
||||
if (ObjCCategoryDecl *CatD = CImplD->getCategoryDecl())
|
||||
|
@ -1312,7 +1324,8 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const {
|
|||
if (!CheckOverrides)
|
||||
return nullptr;
|
||||
|
||||
typedef SmallVector<const ObjCMethodDecl *, 8> OverridesTy;
|
||||
using OverridesTy = SmallVector<const ObjCMethodDecl *, 8>;
|
||||
|
||||
OverridesTy Overrides;
|
||||
getOverriddenMethods(Overrides);
|
||||
for (OverridesTy::const_iterator I = Overrides.begin(), E = Overrides.end();
|
||||
|
@ -1373,14 +1386,12 @@ SourceRange ObjCTypeParamDecl::getSourceRange() const {
|
|||
ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
|
||||
ArrayRef<ObjCTypeParamDecl *> typeParams,
|
||||
SourceLocation rAngleLoc)
|
||||
: NumParams(typeParams.size())
|
||||
{
|
||||
: NumParams(typeParams.size()) {
|
||||
Brackets.Begin = lAngleLoc.getRawEncoding();
|
||||
Brackets.End = rAngleLoc.getRawEncoding();
|
||||
std::copy(typeParams.begin(), typeParams.end(), begin());
|
||||
}
|
||||
|
||||
|
||||
ObjCTypeParamList *ObjCTypeParamList::create(
|
||||
ASTContext &ctx,
|
||||
SourceLocation lAngleLoc,
|
||||
|
@ -1438,8 +1449,7 @@ ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC,
|
|||
ObjCInterfaceDecl *PrevDecl,
|
||||
bool IsInternal)
|
||||
: ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, AtLoc),
|
||||
redeclarable_base(C), TypeForDecl(nullptr), TypeParamList(nullptr),
|
||||
Data() {
|
||||
redeclarable_base(C) {
|
||||
setPreviousDecl(PrevDecl);
|
||||
|
||||
// Copy the 'data' pointer over.
|
||||
|
@ -1518,9 +1528,11 @@ void ObjCInterfaceDecl::setImplementation(ObjCImplementationDecl *ImplD) {
|
|||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct SynthesizeIvarChunk {
|
||||
uint64_t Size;
|
||||
ObjCIvarDecl *Ivar;
|
||||
|
||||
SynthesizeIvarChunk(uint64_t size, ObjCIvarDecl *ivar)
|
||||
: Size(size), Ivar(ivar) {}
|
||||
};
|
||||
|
@ -1529,7 +1541,8 @@ namespace {
|
|||
const SynthesizeIvarChunk &RHS) {
|
||||
return LHS.Size < RHS.Size;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/// all_declared_ivar_begin - return first ivar declared in this class,
|
||||
/// its extensions and its implementation. Lazily build the list on first
|
||||
|
@ -1798,7 +1811,7 @@ ObjCProtocolDecl::ObjCProtocolDecl(ASTContext &C, DeclContext *DC,
|
|||
SourceLocation atStartLoc,
|
||||
ObjCProtocolDecl *PrevDecl)
|
||||
: ObjCContainerDecl(ObjCProtocol, DC, Id, nameLoc, atStartLoc),
|
||||
redeclarable_base(C), Data() {
|
||||
redeclarable_base(C) {
|
||||
setPreviousDecl(PrevDecl);
|
||||
if (PrevDecl)
|
||||
Data = PrevDecl->Data;
|
||||
|
@ -1874,7 +1887,6 @@ void ObjCProtocolDecl::startDefinition() {
|
|||
|
||||
void ObjCProtocolDecl::collectPropertiesToImplement(PropertyMap &PM,
|
||||
PropertyDeclOrder &PO) const {
|
||||
|
||||
if (const ObjCProtocolDecl *PDecl = getDefinition()) {
|
||||
for (auto *Prop : PDecl->properties()) {
|
||||
// Insert into PM if not there already.
|
||||
|
@ -1931,10 +1943,8 @@ ObjCCategoryDecl::ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
|
|||
SourceLocation IvarLBraceLoc,
|
||||
SourceLocation IvarRBraceLoc)
|
||||
: ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc),
|
||||
ClassInterface(IDecl), TypeParamList(nullptr),
|
||||
NextClassCategory(nullptr), CategoryNameLoc(CategoryNameLoc),
|
||||
IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc)
|
||||
{
|
||||
ClassInterface(IDecl), CategoryNameLoc(CategoryNameLoc),
|
||||
IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc) {
|
||||
setTypeParamList(typeParamList);
|
||||
}
|
||||
|
||||
|
@ -2023,7 +2033,6 @@ ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void ObjCImplDecl::anchor() {}
|
||||
|
||||
void ObjCImplDecl::addPropertyImplementation(ObjCPropertyImplDecl *property) {
|
||||
|
@ -2052,7 +2061,6 @@ void ObjCImplDecl::setClassInterface(ObjCInterfaceDecl *IFace) {
|
|||
/// FindPropertyImplIvarDecl - This method lookup the ivar in the list of
|
||||
/// properties implemented in this \@implementation block and returns
|
||||
/// the implemented property that uses it.
|
||||
///
|
||||
ObjCPropertyImplDecl *ObjCImplDecl::
|
||||
FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
|
||||
for (auto *PID : property_impls())
|
||||
|
@ -2065,7 +2073,6 @@ FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const {
|
|||
/// FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl
|
||||
/// added to the list of those properties \@synthesized/\@dynamic in this
|
||||
/// category \@implementation block.
|
||||
///
|
||||
ObjCPropertyImplDecl *ObjCImplDecl::
|
||||
FindPropertyImplDecl(IdentifierInfo *Id,
|
||||
ObjCPropertyQueryKind QueryKind) const {
|
||||
|
|
Loading…
Reference in New Issue