forked from OSchip/llvm-project
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 319487
This commit is contained in:
parent
279e5fa715
commit
f71964a184
|
@ -1,4 +1,4 @@
|
|||
//===------ CXXInheritance.h - C++ Inheritance ------------------*- C++ -*-===//
|
||||
//===- CXXInheritance.h - C++ Inheritance -----------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -16,19 +16,23 @@
|
|||
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeOrdering.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include <cassert>
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class CXXBaseSpecifier;
|
||||
class CXXMethodDecl;
|
||||
class CXXRecordDecl;
|
||||
|
||||
class ASTContext;
|
||||
class NamedDecl;
|
||||
|
||||
/// \brief Represents an element in a path from a derived class to a
|
||||
|
@ -66,12 +70,12 @@ struct CXXBasePathElement {
|
|||
/// subobject is being used.
|
||||
class CXXBasePath : public SmallVector<CXXBasePathElement, 4> {
|
||||
public:
|
||||
CXXBasePath() : Access(AS_public) {}
|
||||
|
||||
/// \brief The access along this inheritance path. This is only
|
||||
/// calculated when recording paths. AS_none is a special value
|
||||
/// used to indicate a path which permits no legal access.
|
||||
AccessSpecifier Access;
|
||||
AccessSpecifier Access = AS_public;
|
||||
|
||||
CXXBasePath() = default;
|
||||
|
||||
/// \brief The set of declarations found inside this base class
|
||||
/// subobject.
|
||||
|
@ -113,8 +117,10 @@ public:
|
|||
/// refer to the same base class subobject of type A (the virtual
|
||||
/// one), there is no ambiguity.
|
||||
class CXXBasePaths {
|
||||
friend class CXXRecordDecl;
|
||||
|
||||
/// \brief The type from which this search originated.
|
||||
CXXRecordDecl *Origin;
|
||||
CXXRecordDecl *Origin = nullptr;
|
||||
|
||||
/// Paths - The actual set of paths that can be taken from the
|
||||
/// derived class to the same base class.
|
||||
|
@ -152,15 +158,13 @@ class CXXBasePaths {
|
|||
CXXBasePath ScratchPath;
|
||||
|
||||
/// DetectedVirtual - The base class that is virtual.
|
||||
const RecordType *DetectedVirtual;
|
||||
const RecordType *DetectedVirtual = nullptr;
|
||||
|
||||
/// \brief Array of the declarations that have been found. This
|
||||
/// array is constructed only if needed, e.g., to iterate over the
|
||||
/// results within LookupResult.
|
||||
std::unique_ptr<NamedDecl *[]> DeclsFound;
|
||||
unsigned NumDeclsFound;
|
||||
|
||||
friend class CXXRecordDecl;
|
||||
unsigned NumDeclsFound = 0;
|
||||
|
||||
void ComputeDeclsFound();
|
||||
|
||||
|
@ -169,17 +173,16 @@ class CXXBasePaths {
|
|||
bool LookupInDependent = false);
|
||||
|
||||
public:
|
||||
typedef std::list<CXXBasePath>::iterator paths_iterator;
|
||||
typedef std::list<CXXBasePath>::const_iterator const_paths_iterator;
|
||||
typedef NamedDecl **decl_iterator;
|
||||
using paths_iterator = std::list<CXXBasePath>::iterator;
|
||||
using const_paths_iterator = std::list<CXXBasePath>::const_iterator;
|
||||
using decl_iterator = NamedDecl **;
|
||||
|
||||
/// BasePaths - Construct a new BasePaths structure to record the
|
||||
/// paths for a derived-to-base search.
|
||||
explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true,
|
||||
bool DetectVirtual = true)
|
||||
: Origin(), FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
|
||||
DetectVirtual(DetectVirtual), DetectedVirtual(nullptr),
|
||||
NumDeclsFound(0) {}
|
||||
: FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
|
||||
DetectVirtual(DetectVirtual) {}
|
||||
|
||||
paths_iterator begin() { return Paths.begin(); }
|
||||
paths_iterator end() { return Paths.end(); }
|
||||
|
@ -189,7 +192,8 @@ public:
|
|||
CXXBasePath& front() { return Paths.front(); }
|
||||
const CXXBasePath& front() const { return Paths.front(); }
|
||||
|
||||
typedef llvm::iterator_range<decl_iterator> decl_range;
|
||||
using decl_range = llvm::iterator_range<decl_iterator>;
|
||||
|
||||
decl_range found_decls();
|
||||
|
||||
/// \brief Determine whether the path from the most-derived type to the
|
||||
|
@ -231,25 +235,24 @@ public:
|
|||
/// \brief Uniquely identifies a virtual method within a class
|
||||
/// hierarchy by the method itself and a class subobject number.
|
||||
struct UniqueVirtualMethod {
|
||||
UniqueVirtualMethod()
|
||||
: Method(nullptr), Subobject(0), InVirtualSubobject(nullptr) { }
|
||||
|
||||
UniqueVirtualMethod(CXXMethodDecl *Method, unsigned Subobject,
|
||||
const CXXRecordDecl *InVirtualSubobject)
|
||||
: Method(Method), Subobject(Subobject),
|
||||
InVirtualSubobject(InVirtualSubobject) { }
|
||||
|
||||
/// \brief The overriding virtual method.
|
||||
CXXMethodDecl *Method;
|
||||
CXXMethodDecl *Method = nullptr;
|
||||
|
||||
/// \brief The subobject in which the overriding virtual method
|
||||
/// resides.
|
||||
unsigned Subobject;
|
||||
unsigned Subobject = 0;
|
||||
|
||||
/// \brief The virtual base class subobject of which this overridden
|
||||
/// virtual method is a part. Note that this records the closest
|
||||
/// derived virtual base class subobject.
|
||||
const CXXRecordDecl *InVirtualSubobject;
|
||||
const CXXRecordDecl *InVirtualSubobject = nullptr;
|
||||
|
||||
UniqueVirtualMethod() = default;
|
||||
|
||||
UniqueVirtualMethod(CXXMethodDecl *Method, unsigned Subobject,
|
||||
const CXXRecordDecl *InVirtualSubobject)
|
||||
: Method(Method), Subobject(Subobject),
|
||||
InVirtualSubobject(InVirtualSubobject) {}
|
||||
|
||||
friend bool operator==(const UniqueVirtualMethod &X,
|
||||
const UniqueVirtualMethod &Y) {
|
||||
|
@ -271,14 +274,16 @@ struct UniqueVirtualMethod {
|
|||
/// pair is the virtual method that overrides it (including the
|
||||
/// subobject in which that virtual function occurs).
|
||||
class OverridingMethods {
|
||||
typedef SmallVector<UniqueVirtualMethod, 4> ValuesT;
|
||||
typedef llvm::MapVector<unsigned, ValuesT> MapType;
|
||||
using ValuesT = SmallVector<UniqueVirtualMethod, 4>;
|
||||
using MapType = llvm::MapVector<unsigned, ValuesT>;
|
||||
|
||||
MapType Overrides;
|
||||
|
||||
public:
|
||||
// Iterate over the set of subobjects that have overriding methods.
|
||||
typedef MapType::iterator iterator;
|
||||
typedef MapType::const_iterator const_iterator;
|
||||
using iterator = MapType::iterator;
|
||||
using const_iterator = MapType::const_iterator;
|
||||
|
||||
iterator begin() { return Overrides.begin(); }
|
||||
const_iterator begin() const { return Overrides.begin(); }
|
||||
iterator end() { return Overrides.end(); }
|
||||
|
@ -287,10 +292,10 @@ public:
|
|||
|
||||
// Iterate over the set of overriding virtual methods in a given
|
||||
// subobject.
|
||||
typedef SmallVectorImpl<UniqueVirtualMethod>::iterator
|
||||
overriding_iterator;
|
||||
typedef SmallVectorImpl<UniqueVirtualMethod>::const_iterator
|
||||
overriding_const_iterator;
|
||||
using overriding_iterator =
|
||||
SmallVectorImpl<UniqueVirtualMethod>::iterator;
|
||||
using overriding_const_iterator =
|
||||
SmallVectorImpl<UniqueVirtualMethod>::const_iterator;
|
||||
|
||||
// Add a new overriding method for a particular subobject.
|
||||
void add(unsigned OverriddenSubobject, UniqueVirtualMethod Overriding);
|
||||
|
@ -357,12 +362,12 @@ public:
|
|||
/// subobject numbers greater than 0 refer to non-virtual base class
|
||||
/// subobjects of that type.
|
||||
class CXXFinalOverriderMap
|
||||
: public llvm::MapVector<const CXXMethodDecl *, OverridingMethods> { };
|
||||
: public llvm::MapVector<const CXXMethodDecl *, OverridingMethods> {};
|
||||
|
||||
/// \brief A set of all the primary bases for a class.
|
||||
class CXXIndirectPrimaryBaseSet
|
||||
: public llvm::SmallSet<const CXXRecordDecl*, 32> { };
|
||||
: public llvm::SmallSet<const CXXRecordDecl*, 32> {};
|
||||
|
||||
} // end namespace clang
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_CXXINHERITANCE_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===-- DeclLookups.h - Low-level interface to all names in a DC-*- C++ -*-===//
|
||||
//===- DeclLookups.h - Low-level interface to all names in a DC -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -18,6 +18,9 @@
|
|||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclContextInternals.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/AST/ExternalASTSource.h"
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace clang {
|
||||
|
||||
|
@ -25,14 +28,15 @@ namespace clang {
|
|||
/// of looking up every possible name.
|
||||
class DeclContext::all_lookups_iterator {
|
||||
StoredDeclsMap::iterator It, End;
|
||||
public:
|
||||
typedef lookup_result value_type;
|
||||
typedef lookup_result reference;
|
||||
typedef lookup_result pointer;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
all_lookups_iterator() {}
|
||||
public:
|
||||
using value_type = lookup_result;
|
||||
using reference = lookup_result;
|
||||
using pointer = lookup_result;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
all_lookups_iterator() = default;
|
||||
all_lookups_iterator(StoredDeclsMap::iterator It,
|
||||
StoredDeclsMap::iterator End)
|
||||
: It(It), End(End) {}
|
||||
|
@ -63,6 +67,7 @@ public:
|
|||
friend bool operator==(all_lookups_iterator x, all_lookups_iterator y) {
|
||||
return x.It == y.It;
|
||||
}
|
||||
|
||||
friend bool operator!=(all_lookups_iterator x, all_lookups_iterator y) {
|
||||
return x.It != y.It;
|
||||
}
|
||||
|
@ -110,6 +115,6 @@ DeclContext::all_lookups_iterator DeclContext::noload_lookups_end() const {
|
|||
return noload_lookups().end();
|
||||
}
|
||||
|
||||
} // end namespace clang
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_DECLLOOKUPS_H
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
//===------ CXXInheritance.cpp - C++ Inheritance ----------------*- C++ -*-===//
|
||||
//===- CXXInheritance.cpp - C++ Inheritance -------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -10,13 +10,27 @@
|
|||
// This file provides routines that help analyzing C++ inheritance hierarchies.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/CXXInheritance.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/RecordLayout.h"
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
|
@ -26,7 +40,7 @@ void CXXBasePaths::ComputeDeclsFound() {
|
|||
assert(NumDeclsFound == 0 && !DeclsFound &&
|
||||
"Already computed the set of declarations");
|
||||
|
||||
llvm::SetVector<NamedDecl *, SmallVector<NamedDecl *, 8> > Decls;
|
||||
llvm::SetVector<NamedDecl *, SmallVector<NamedDecl *, 8>> Decls;
|
||||
for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path)
|
||||
Decls.insert(Path->Decls.front());
|
||||
|
||||
|
@ -419,8 +433,8 @@ bool CXXRecordDecl::FindTagMember(const CXXBaseSpecifier *Specifier,
|
|||
|
||||
static bool findOrdinaryMember(RecordDecl *BaseRecord, CXXBasePath &Path,
|
||||
DeclarationName Name) {
|
||||
const unsigned IDNS = clang::Decl::IDNS_Ordinary | clang::Decl::IDNS_Tag |
|
||||
clang::Decl::IDNS_Member;
|
||||
const unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Tag |
|
||||
Decl::IDNS_Member;
|
||||
for (Path.Decls = BaseRecord->lookup(Name);
|
||||
!Path.Decls.empty();
|
||||
Path.Decls = Path.Decls.slice(1)) {
|
||||
|
@ -550,26 +564,27 @@ void OverridingMethods::replaceAll(UniqueVirtualMethod Overriding) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
class FinalOverriderCollector {
|
||||
/// \brief The number of subobjects of a given class type that
|
||||
/// occur within the class hierarchy.
|
||||
llvm::DenseMap<const CXXRecordDecl *, unsigned> SubobjectCount;
|
||||
|
||||
/// \brief Overriders for each virtual base subobject.
|
||||
llvm::DenseMap<const CXXRecordDecl *, CXXFinalOverriderMap *> VirtualOverriders;
|
||||
class FinalOverriderCollector {
|
||||
/// \brief The number of subobjects of a given class type that
|
||||
/// occur within the class hierarchy.
|
||||
llvm::DenseMap<const CXXRecordDecl *, unsigned> SubobjectCount;
|
||||
|
||||
CXXFinalOverriderMap FinalOverriders;
|
||||
/// \brief Overriders for each virtual base subobject.
|
||||
llvm::DenseMap<const CXXRecordDecl *, CXXFinalOverriderMap *> VirtualOverriders;
|
||||
|
||||
public:
|
||||
~FinalOverriderCollector();
|
||||
CXXFinalOverriderMap FinalOverriders;
|
||||
|
||||
void Collect(const CXXRecordDecl *RD, bool VirtualBase,
|
||||
const CXXRecordDecl *InVirtualSubobject,
|
||||
CXXFinalOverriderMap &Overriders);
|
||||
};
|
||||
}
|
||||
public:
|
||||
~FinalOverriderCollector();
|
||||
|
||||
void Collect(const CXXRecordDecl *RD, bool VirtualBase,
|
||||
const CXXRecordDecl *InVirtualSubobject,
|
||||
CXXFinalOverriderMap &Overriders);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void FinalOverriderCollector::Collect(const CXXRecordDecl *RD,
|
||||
bool VirtualBase,
|
||||
|
@ -656,8 +671,8 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD,
|
|||
// overrider. To do so, we dig down to the original virtual
|
||||
// functions using data recursion and update all of the methods it
|
||||
// overrides.
|
||||
typedef llvm::iterator_range<CXXMethodDecl::method_iterator>
|
||||
OverriddenMethods;
|
||||
using OverriddenMethods =
|
||||
llvm::iterator_range<CXXMethodDecl::method_iterator>;
|
||||
SmallVector<OverriddenMethods, 4> Stack;
|
||||
Stack.push_back(llvm::make_range(CanonM->begin_overridden_methods(),
|
||||
CanonM->end_overridden_methods()));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- ExprObjC.cpp - (ObjC) Expression AST Node Implementation ---------===//
|
||||
//===- ExprObjC.cpp - (ObjC) Expression AST Node Implementation -----------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -12,8 +12,15 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/ExprObjC.h"
|
||||
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/SelectorLocationsKind.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
|
@ -45,7 +52,6 @@ ObjCArrayLiteral *ObjCArrayLiteral::Create(const ASTContext &C,
|
|||
|
||||
ObjCArrayLiteral *ObjCArrayLiteral::CreateEmpty(const ASTContext &C,
|
||||
unsigned NumElements) {
|
||||
|
||||
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumElements));
|
||||
return new (Mem) ObjCArrayLiteral(EmptyShell(), NumElements);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue