forked from OSchip/llvm-project
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 319589
This commit is contained in:
parent
52df8015c5
commit
3d775719eb
|
@ -1,4 +1,4 @@
|
|||
//===-- DeclContextInternals.h - DeclContext Representation -----*- C++ -*-===//
|
||||
//===- DeclContextInternals.h - DeclContext Representation ------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -11,17 +11,19 @@
|
|||
// of DeclContext.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
|
||||
#define LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
|
||||
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/PointerUnion.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
namespace clang {
|
||||
|
||||
|
@ -30,21 +32,20 @@ class DependentDiagnostic;
|
|||
/// \brief An array of decls optimized for the common case of only containing
|
||||
/// one entry.
|
||||
struct StoredDeclsList {
|
||||
|
||||
/// \brief When in vector form, this is what the Data pointer points to.
|
||||
typedef SmallVector<NamedDecl *, 4> DeclsTy;
|
||||
using DeclsTy = SmallVector<NamedDecl *, 4>;
|
||||
|
||||
/// \brief A collection of declarations, with a flag to indicate if we have
|
||||
/// further external declarations.
|
||||
typedef llvm::PointerIntPair<DeclsTy *, 1, bool> DeclsAndHasExternalTy;
|
||||
using DeclsAndHasExternalTy = llvm::PointerIntPair<DeclsTy *, 1, bool>;
|
||||
|
||||
/// \brief The stored data, which will be either a pointer to a NamedDecl,
|
||||
/// or a pointer to a vector with a flag to indicate if there are further
|
||||
/// external declarations.
|
||||
llvm::PointerUnion<NamedDecl*, DeclsAndHasExternalTy> Data;
|
||||
llvm::PointerUnion<NamedDecl *, DeclsAndHasExternalTy> Data;
|
||||
|
||||
public:
|
||||
StoredDeclsList() {}
|
||||
StoredDeclsList() = default;
|
||||
|
||||
StoredDeclsList(StoredDeclsList &&RHS) : Data(RHS.Data) {
|
||||
RHS.Data = (NamedDecl *)nullptr;
|
||||
|
@ -186,7 +187,6 @@ public:
|
|||
|
||||
/// AddSubsequentDecl - This is called on the second and later decl when it is
|
||||
/// not a redeclaration to merge it into the appropriate place in our list.
|
||||
///
|
||||
void AddSubsequentDecl(NamedDecl *D) {
|
||||
assert(!isNull() && "don't AddSubsequentDecl when we have no decls");
|
||||
|
||||
|
@ -237,28 +237,28 @@ public:
|
|||
};
|
||||
|
||||
class StoredDeclsMap
|
||||
: public llvm::SmallDenseMap<DeclarationName, StoredDeclsList, 4> {
|
||||
|
||||
: public llvm::SmallDenseMap<DeclarationName, StoredDeclsList, 4> {
|
||||
public:
|
||||
static void DestroyAll(StoredDeclsMap *Map, bool Dependent);
|
||||
|
||||
private:
|
||||
friend class ASTContext; // walks the chain deleting these
|
||||
friend class DeclContext;
|
||||
|
||||
llvm::PointerIntPair<StoredDeclsMap*, 1> Previous;
|
||||
};
|
||||
|
||||
class DependentStoredDeclsMap : public StoredDeclsMap {
|
||||
public:
|
||||
DependentStoredDeclsMap() : FirstDiagnostic(nullptr) {}
|
||||
DependentStoredDeclsMap() = default;
|
||||
|
||||
private:
|
||||
friend class DependentDiagnostic;
|
||||
friend class DeclContext; // iterates over diagnostics
|
||||
friend class DependentDiagnostic;
|
||||
|
||||
DependentDiagnostic *FirstDiagnostic;
|
||||
DependentDiagnostic *FirstDiagnostic = nullptr;
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- GlobalDecl.h - Global declaration holder ---------------*- C++ -*-===//
|
||||
//===- GlobalDecl.h - Global declaration holder -----------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -19,6 +19,12 @@
|
|||
#include "clang/AST/DeclObjC.h"
|
||||
#include "clang/AST/DeclOpenMP.h"
|
||||
#include "clang/Basic/ABI.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/DenseMapInfo.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/type_traits.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace clang {
|
||||
|
||||
|
@ -27,7 +33,7 @@ namespace clang {
|
|||
/// a CXXDestructorDecl and the destructor type (Base, Complete) or
|
||||
/// a VarDecl, a FunctionDecl or a BlockDecl.
|
||||
class GlobalDecl {
|
||||
llvm::PointerIntPair<const Decl*, 2> Value;
|
||||
llvm::PointerIntPair<const Decl *, 2> Value;
|
||||
|
||||
void Init(const Decl *D) {
|
||||
assert(!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!");
|
||||
|
@ -37,19 +43,15 @@ class GlobalDecl {
|
|||
}
|
||||
|
||||
public:
|
||||
GlobalDecl() {}
|
||||
|
||||
GlobalDecl() = default;
|
||||
GlobalDecl(const VarDecl *D) { Init(D);}
|
||||
GlobalDecl(const FunctionDecl *D) { Init(D); }
|
||||
GlobalDecl(const BlockDecl *D) { Init(D); }
|
||||
GlobalDecl(const CapturedDecl *D) { Init(D); }
|
||||
GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
|
||||
GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
|
||||
|
||||
GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type)
|
||||
: Value(D, Type) {}
|
||||
GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type)
|
||||
: Value(D, Type) {}
|
||||
GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {}
|
||||
GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
|
||||
|
||||
GlobalDecl getCanonicalDecl() const {
|
||||
GlobalDecl CanonGD;
|
||||
|
@ -90,10 +92,9 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
} // namespace clang
|
||||
|
||||
namespace llvm {
|
||||
template<class> struct DenseMapInfo;
|
||||
|
||||
template<> struct DenseMapInfo<clang::GlobalDecl> {
|
||||
static inline clang::GlobalDecl getEmptyKey() {
|
||||
|
@ -113,7 +114,6 @@ namespace llvm {
|
|||
clang::GlobalDecl RHS) {
|
||||
return LHS == RHS;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// GlobalDecl isn't *technically* a POD type. However, its copy constructor,
|
||||
|
@ -122,6 +122,7 @@ namespace llvm {
|
|||
struct isPodLike<clang::GlobalDecl> {
|
||||
static const bool value = true;
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
} // namespace llvm
|
||||
|
||||
#endif // LLVM_CLANG_AST_GLOBALDECL_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- TypeLoc.h - Type Source Info Wrapper -------------------*- C++ -*-===//
|
||||
//===- TypeLoc.h - Type Source Info Wrapper ---------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -6,26 +6,42 @@
|
|||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
///
|
||||
//
|
||||
/// \file
|
||||
/// \brief Defines the clang::TypeLoc interface and its subclasses.
|
||||
///
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_AST_TYPELOC_H
|
||||
#define LLVM_CLANG_AST_TYPELOC_H
|
||||
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
class ParmVarDecl;
|
||||
class TypeSourceInfo;
|
||||
class UnqualTypeLoc;
|
||||
|
||||
class ASTContext;
|
||||
class CXXRecordDecl;
|
||||
class Expr;
|
||||
class ObjCInterfaceDecl;
|
||||
class ObjCProtocolDecl;
|
||||
class ObjCTypeParamDecl;
|
||||
class TemplateTypeParmDecl;
|
||||
class UnqualTypeLoc;
|
||||
class UnresolvedUsingTypenameDecl;
|
||||
|
||||
// Predeclare all the type nodes.
|
||||
#define ABSTRACT_TYPELOC(Class, Base)
|
||||
|
@ -41,10 +57,16 @@ class TypeLoc {
|
|||
protected:
|
||||
// The correctness of this relies on the property that, for Type *Ty,
|
||||
// QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty
|
||||
const void *Ty;
|
||||
void *Data;
|
||||
const void *Ty = nullptr;
|
||||
void *Data = nullptr;
|
||||
|
||||
public:
|
||||
TypeLoc() = default;
|
||||
TypeLoc(QualType ty, void *opaqueData)
|
||||
: Ty(ty.getAsOpaquePtr()), Data(opaqueData) {}
|
||||
TypeLoc(const Type *ty, void *opaqueData)
|
||||
: Ty(ty), Data(opaqueData) {}
|
||||
|
||||
/// \brief Convert to the specified TypeLoc type, asserting that this TypeLoc
|
||||
/// is of the desired type.
|
||||
///
|
||||
|
@ -88,12 +110,6 @@ public:
|
|||
Qualified
|
||||
};
|
||||
|
||||
TypeLoc() : Ty(nullptr), Data(nullptr) { }
|
||||
TypeLoc(QualType ty, void *opaqueData)
|
||||
: Ty(ty.getAsOpaquePtr()), Data(opaqueData) { }
|
||||
TypeLoc(const Type *ty, void *opaqueData)
|
||||
: Ty(ty), Data(opaqueData) { }
|
||||
|
||||
TypeLocClass getTypeLocClass() const {
|
||||
if (getType().hasLocalQualifiers()) return Qualified;
|
||||
return (TypeLocClass) getType()->getTypeClass();
|
||||
|
@ -134,6 +150,7 @@ public:
|
|||
SourceRange getSourceRange() const LLVM_READONLY {
|
||||
return SourceRange(getBeginLoc(), getEndLoc());
|
||||
}
|
||||
|
||||
SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
|
||||
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
|
||||
|
||||
|
@ -228,7 +245,7 @@ inline TypeLoc TypeSourceInfo::getTypeLoc() const {
|
|||
/// no direct qualifiers.
|
||||
class UnqualTypeLoc : public TypeLoc {
|
||||
public:
|
||||
UnqualTypeLoc() {}
|
||||
UnqualTypeLoc() = default;
|
||||
UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
|
||||
|
||||
const Type *getTypePtr() const {
|
||||
|
@ -241,6 +258,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class TypeLoc;
|
||||
|
||||
static bool isKind(const TypeLoc &TL) {
|
||||
return !TL.getType().hasLocalQualifiers();
|
||||
}
|
||||
|
@ -253,9 +271,7 @@ private:
|
|||
/// type qualifiers.
|
||||
class QualifiedTypeLoc : public TypeLoc {
|
||||
public:
|
||||
SourceRange getLocalSourceRange() const {
|
||||
return SourceRange();
|
||||
}
|
||||
SourceRange getLocalSourceRange() const { return {}; }
|
||||
|
||||
UnqualTypeLoc getUnqualifiedLoc() const {
|
||||
unsigned align =
|
||||
|
@ -296,6 +312,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class TypeLoc;
|
||||
|
||||
static bool isKind(const TypeLoc &TL) {
|
||||
return TL.getType().hasLocalQualifiers();
|
||||
}
|
||||
|
@ -337,12 +354,12 @@ inline UnqualTypeLoc TypeLoc::getUnqualifiedLoc() const {
|
|||
/// InheritingConcreteTypeLoc instead.
|
||||
template <class Base, class Derived, class TypeClass, class LocalData>
|
||||
class ConcreteTypeLoc : public Base {
|
||||
friend class TypeLoc;
|
||||
|
||||
const Derived *asDerived() const {
|
||||
return static_cast<const Derived*>(this);
|
||||
}
|
||||
|
||||
friend class TypeLoc;
|
||||
static bool isKind(const TypeLoc &TL) {
|
||||
return !TL.getType().hasLocalQualifiers() &&
|
||||
Derived::classofType(TL.getTypePtr());
|
||||
|
@ -357,6 +374,7 @@ public:
|
|||
return std::max(unsigned(alignof(LocalData)),
|
||||
asDerived()->getExtraLocalDataAlignment());
|
||||
}
|
||||
|
||||
unsigned getLocalDataSize() const {
|
||||
unsigned size = sizeof(LocalData);
|
||||
unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
|
||||
|
@ -449,9 +467,7 @@ private:
|
|||
return TypeLoc::getLocalAlignmentForType(T);
|
||||
}
|
||||
|
||||
TypeLoc getNextTypeLoc(HasNoInnerType _) const {
|
||||
return TypeLoc();
|
||||
}
|
||||
TypeLoc getNextTypeLoc(HasNoInnerType _) const { return {}; }
|
||||
|
||||
TypeLoc getNextTypeLoc(QualType T) const {
|
||||
return TypeLoc(T, getNonLocalData());
|
||||
|
@ -464,6 +480,7 @@ private:
|
|||
template <class Base, class Derived, class TypeClass>
|
||||
class InheritingConcreteTypeLoc : public Base {
|
||||
friend class TypeLoc;
|
||||
|
||||
static bool classofType(const Type *Ty) {
|
||||
return TypeClass::classof(Ty);
|
||||
}
|
||||
|
@ -482,7 +499,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
struct TypeSpecLocInfo {
|
||||
SourceLocation NameLoc;
|
||||
};
|
||||
|
@ -502,22 +518,25 @@ public:
|
|||
SourceLocation getNameLoc() const {
|
||||
return this->getLocalData()->NameLoc;
|
||||
}
|
||||
|
||||
void setNameLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->NameLoc = Loc;
|
||||
}
|
||||
|
||||
SourceRange getLocalSourceRange() const {
|
||||
return SourceRange(getNameLoc(), getNameLoc());
|
||||
}
|
||||
|
||||
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
|
||||
setNameLoc(Loc);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class TypeLoc;
|
||||
|
||||
static bool isKind(const TypeLoc &TL);
|
||||
};
|
||||
|
||||
|
||||
struct BuiltinLocInfo {
|
||||
SourceRange BuiltinRange;
|
||||
};
|
||||
|
@ -531,9 +550,11 @@ public:
|
|||
SourceLocation getBuiltinLoc() const {
|
||||
return getLocalData()->BuiltinRange.getBegin();
|
||||
}
|
||||
|
||||
void setBuiltinLoc(SourceLocation Loc) {
|
||||
getLocalData()->BuiltinRange = Loc;
|
||||
}
|
||||
|
||||
void expandBuiltinRange(SourceRange Range) {
|
||||
SourceRange &BuiltinRange = getLocalData()->BuiltinRange;
|
||||
if (!BuiltinRange.getBegin().isValid()) {
|
||||
|
@ -579,9 +600,11 @@ public:
|
|||
else
|
||||
return TSS_unspecified;
|
||||
}
|
||||
|
||||
bool hasWrittenSignSpec() const {
|
||||
return getWrittenSignSpec() != TSS_unspecified;
|
||||
}
|
||||
|
||||
void setWrittenSignSpec(TypeSpecifierSign written) {
|
||||
if (needsExtraLocalData())
|
||||
getWrittenBuiltinSpecs().Sign = written;
|
||||
|
@ -593,18 +616,22 @@ public:
|
|||
else
|
||||
return TSW_unspecified;
|
||||
}
|
||||
|
||||
bool hasWrittenWidthSpec() const {
|
||||
return getWrittenWidthSpec() != TSW_unspecified;
|
||||
}
|
||||
|
||||
void setWrittenWidthSpec(TypeSpecifierWidth written) {
|
||||
if (needsExtraLocalData())
|
||||
getWrittenBuiltinSpecs().Width = written;
|
||||
}
|
||||
|
||||
TypeSpecifierType getWrittenTypeSpec() const;
|
||||
|
||||
bool hasWrittenTypeSpec() const {
|
||||
return getWrittenTypeSpec() != TST_unspecified;
|
||||
}
|
||||
|
||||
void setWrittenTypeSpec(TypeSpecifierType written) {
|
||||
if (needsExtraLocalData())
|
||||
getWrittenBuiltinSpecs().Type = written;
|
||||
|
@ -616,6 +643,7 @@ public:
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setModeAttr(bool written) {
|
||||
if (needsExtraLocalData())
|
||||
getWrittenBuiltinSpecs().ModeAttr = written;
|
||||
|
@ -633,7 +661,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Wrapper for source info for typedefs.
|
||||
class TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
|
||||
TypedefTypeLoc,
|
||||
|
@ -742,6 +769,7 @@ public:
|
|||
*((SourceLocation*)this->getExtraLocalData()) :
|
||||
SourceLocation();
|
||||
}
|
||||
|
||||
void setProtocolLAngleLoc(SourceLocation Loc) {
|
||||
*((SourceLocation*)this->getExtraLocalData()) = Loc;
|
||||
}
|
||||
|
@ -751,6 +779,7 @@ public:
|
|||
*((SourceLocation*)this->getExtraLocalData() + 1) :
|
||||
SourceLocation();
|
||||
}
|
||||
|
||||
void setProtocolRAngleLoc(SourceLocation Loc) {
|
||||
*((SourceLocation*)this->getExtraLocalData() + 1) = Loc;
|
||||
}
|
||||
|
@ -763,6 +792,7 @@ public:
|
|||
assert(i < getNumProtocols() && "Index is out of bounds!");
|
||||
return getProtocolLocArray()[i];
|
||||
}
|
||||
|
||||
void setProtocolLoc(unsigned i, SourceLocation Loc) {
|
||||
assert(i < getNumProtocols() && "Index is out of bounds!");
|
||||
getProtocolLocArray()[i] = Loc;
|
||||
|
@ -785,9 +815,11 @@ public:
|
|||
// as well.
|
||||
return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
|
||||
}
|
||||
|
||||
unsigned getExtraLocalDataAlignment() const {
|
||||
return alignof(SourceLocation);
|
||||
}
|
||||
|
||||
SourceRange getLocalSourceRange() const {
|
||||
SourceLocation start = getNameLoc();
|
||||
SourceLocation end = getProtocolRAngleLoc();
|
||||
|
@ -938,7 +970,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
struct ObjCObjectTypeLocInfo {
|
||||
SourceLocation TypeArgsLAngleLoc;
|
||||
SourceLocation TypeArgsRAngleLoc;
|
||||
|
@ -971,6 +1002,7 @@ public:
|
|||
SourceLocation getTypeArgsLAngleLoc() const {
|
||||
return this->getLocalData()->TypeArgsLAngleLoc;
|
||||
}
|
||||
|
||||
void setTypeArgsLAngleLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->TypeArgsLAngleLoc = Loc;
|
||||
}
|
||||
|
@ -978,6 +1010,7 @@ public:
|
|||
SourceLocation getTypeArgsRAngleLoc() const {
|
||||
return this->getLocalData()->TypeArgsRAngleLoc;
|
||||
}
|
||||
|
||||
void setTypeArgsRAngleLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->TypeArgsRAngleLoc = Loc;
|
||||
}
|
||||
|
@ -999,6 +1032,7 @@ public:
|
|||
SourceLocation getProtocolLAngleLoc() const {
|
||||
return this->getLocalData()->ProtocolLAngleLoc;
|
||||
}
|
||||
|
||||
void setProtocolLAngleLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->ProtocolLAngleLoc = Loc;
|
||||
}
|
||||
|
@ -1006,6 +1040,7 @@ public:
|
|||
SourceLocation getProtocolRAngleLoc() const {
|
||||
return this->getLocalData()->ProtocolRAngleLoc;
|
||||
}
|
||||
|
||||
void setProtocolRAngleLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->ProtocolRAngleLoc = Loc;
|
||||
}
|
||||
|
@ -1018,6 +1053,7 @@ public:
|
|||
assert(i < getNumProtocols() && "Index is out of bounds!");
|
||||
return getProtocolLocArray()[i];
|
||||
}
|
||||
|
||||
void setProtocolLoc(unsigned i, SourceLocation Loc) {
|
||||
assert(i < getNumProtocols() && "Index is out of bounds!");
|
||||
getProtocolLocArray()[i] = Loc;
|
||||
|
@ -1073,7 +1109,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
struct ObjCInterfaceLocInfo {
|
||||
SourceLocation NameLoc;
|
||||
SourceLocation NameEndLoc;
|
||||
|
@ -1127,12 +1162,15 @@ public:
|
|||
SourceLocation getLParenLoc() const {
|
||||
return this->getLocalData()->LParenLoc;
|
||||
}
|
||||
|
||||
SourceLocation getRParenLoc() const {
|
||||
return this->getLocalData()->RParenLoc;
|
||||
}
|
||||
|
||||
void setLParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->LParenLoc = Loc;
|
||||
}
|
||||
|
||||
void setRParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->RParenLoc = Loc;
|
||||
}
|
||||
|
@ -1161,8 +1199,7 @@ inline TypeLoc TypeLoc::IgnoreParens() const {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
struct AdjustedLocInfo { }; // Nothing.
|
||||
struct AdjustedLocInfo {}; // Nothing.
|
||||
|
||||
class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
|
||||
AdjustedType, AdjustedLocInfo> {
|
||||
|
@ -1181,9 +1218,7 @@ public:
|
|||
return getTypePtr()->getOriginalType();
|
||||
}
|
||||
|
||||
SourceRange getLocalSourceRange() const {
|
||||
return SourceRange();
|
||||
}
|
||||
SourceRange getLocalSourceRange() const { return {}; }
|
||||
|
||||
unsigned getLocalDataSize() const {
|
||||
// sizeof(AdjustedLocInfo) is 1, but we don't need its address to be unique
|
||||
|
@ -1210,6 +1245,7 @@ public:
|
|||
SourceLocation getSigilLoc() const {
|
||||
return this->getLocalData()->StarLoc;
|
||||
}
|
||||
|
||||
void setSigilLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->StarLoc = Loc;
|
||||
}
|
||||
|
@ -1231,7 +1267,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Wrapper for source info for pointers.
|
||||
class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
|
||||
PointerType> {
|
||||
|
@ -1239,12 +1274,12 @@ public:
|
|||
SourceLocation getStarLoc() const {
|
||||
return getSigilLoc();
|
||||
}
|
||||
|
||||
void setStarLoc(SourceLocation Loc) {
|
||||
setSigilLoc(Loc);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// \brief Wrapper for source info for block pointers.
|
||||
class BlockPointerTypeLoc : public PointerLikeTypeLoc<BlockPointerTypeLoc,
|
||||
BlockPointerType> {
|
||||
|
@ -1252,6 +1287,7 @@ public:
|
|||
SourceLocation getCaretLoc() const {
|
||||
return getSigilLoc();
|
||||
}
|
||||
|
||||
void setCaretLoc(SourceLocation Loc) {
|
||||
setSigilLoc(Loc);
|
||||
}
|
||||
|
@ -1269,6 +1305,7 @@ public:
|
|||
SourceLocation getStarLoc() const {
|
||||
return getSigilLoc();
|
||||
}
|
||||
|
||||
void setStarLoc(SourceLocation Loc) {
|
||||
setSigilLoc(Loc);
|
||||
}
|
||||
|
@ -1276,9 +1313,11 @@ public:
|
|||
const Type *getClass() const {
|
||||
return getTypePtr()->getClass();
|
||||
}
|
||||
|
||||
TypeSourceInfo *getClassTInfo() const {
|
||||
return getLocalData()->ClassTInfo;
|
||||
}
|
||||
|
||||
void setClassTInfo(TypeSourceInfo* TI) {
|
||||
getLocalData()->ClassTInfo = TI;
|
||||
}
|
||||
|
@ -1310,7 +1349,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
|
||||
ReferenceType> {
|
||||
public:
|
||||
|
@ -1327,6 +1365,7 @@ public:
|
|||
SourceLocation getAmpLoc() const {
|
||||
return getSigilLoc();
|
||||
}
|
||||
|
||||
void setAmpLoc(SourceLocation Loc) {
|
||||
setSigilLoc(Loc);
|
||||
}
|
||||
|
@ -1340,12 +1379,12 @@ public:
|
|||
SourceLocation getAmpAmpLoc() const {
|
||||
return getSigilLoc();
|
||||
}
|
||||
|
||||
void setAmpAmpLoc(SourceLocation Loc) {
|
||||
setSigilLoc(Loc);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct FunctionLocInfo {
|
||||
SourceLocation LocalRangeBegin;
|
||||
SourceLocation LParenLoc;
|
||||
|
@ -1371,10 +1410,12 @@ class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
|
|||
// exception specification information.
|
||||
return (SourceRange *)(getParmArray() + getNumParams());
|
||||
}
|
||||
|
||||
public:
|
||||
SourceLocation getLocalRangeBegin() const {
|
||||
return getLocalData()->LocalRangeBegin;
|
||||
}
|
||||
|
||||
void setLocalRangeBegin(SourceLocation L) {
|
||||
getLocalData()->LocalRangeBegin = L;
|
||||
}
|
||||
|
@ -1382,6 +1423,7 @@ public:
|
|||
SourceLocation getLocalRangeEnd() const {
|
||||
return getLocalData()->LocalRangeEnd;
|
||||
}
|
||||
|
||||
void setLocalRangeEnd(SourceLocation L) {
|
||||
getLocalData()->LocalRangeEnd = L;
|
||||
}
|
||||
|
@ -1389,6 +1431,7 @@ public:
|
|||
SourceLocation getLParenLoc() const {
|
||||
return this->getLocalData()->LParenLoc;
|
||||
}
|
||||
|
||||
void setLParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->LParenLoc = Loc;
|
||||
}
|
||||
|
@ -1396,6 +1439,7 @@ public:
|
|||
SourceLocation getRParenLoc() const {
|
||||
return this->getLocalData()->RParenLoc;
|
||||
}
|
||||
|
||||
void setRParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->RParenLoc = Loc;
|
||||
}
|
||||
|
@ -1407,8 +1451,9 @@ public:
|
|||
SourceRange getExceptionSpecRange() const {
|
||||
if (hasExceptionSpec())
|
||||
return *getExceptionSpecRangePtr();
|
||||
return SourceRange();
|
||||
return {};
|
||||
}
|
||||
|
||||
void setExceptionSpecRange(SourceRange R) {
|
||||
if (hasExceptionSpec())
|
||||
*getExceptionSpecRangePtr() = R;
|
||||
|
@ -1428,6 +1473,7 @@ public:
|
|||
return 0;
|
||||
return cast<FunctionProtoType>(getTypePtr())->getNumParams();
|
||||
}
|
||||
|
||||
ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
|
||||
void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
|
||||
|
||||
|
@ -1474,7 +1520,6 @@ class FunctionNoProtoTypeLoc :
|
|||
FunctionNoProtoType> {
|
||||
};
|
||||
|
||||
|
||||
struct ArrayLocInfo {
|
||||
SourceLocation LBracketLoc, RBracketLoc;
|
||||
Expr *Size;
|
||||
|
@ -1489,6 +1534,7 @@ public:
|
|||
SourceLocation getLBracketLoc() const {
|
||||
return getLocalData()->LBracketLoc;
|
||||
}
|
||||
|
||||
void setLBracketLoc(SourceLocation Loc) {
|
||||
getLocalData()->LBracketLoc = Loc;
|
||||
}
|
||||
|
@ -1496,6 +1542,7 @@ public:
|
|||
SourceLocation getRBracketLoc() const {
|
||||
return getLocalData()->RBracketLoc;
|
||||
}
|
||||
|
||||
void setRBracketLoc(SourceLocation Loc) {
|
||||
getLocalData()->RBracketLoc = Loc;
|
||||
}
|
||||
|
@ -1507,6 +1554,7 @@ public:
|
|||
Expr *getSizeExpr() const {
|
||||
return getLocalData()->Size;
|
||||
}
|
||||
|
||||
void setSizeExpr(Expr *Size) {
|
||||
getLocalData()->Size = Size;
|
||||
}
|
||||
|
@ -1557,7 +1605,6 @@ class VariableArrayTypeLoc :
|
|||
VariableArrayType> {
|
||||
};
|
||||
|
||||
|
||||
// Location information for a TemplateName. Rudimentary for now.
|
||||
struct TemplateNameLocInfo {
|
||||
SourceLocation NameLoc;
|
||||
|
@ -1578,6 +1625,7 @@ public:
|
|||
SourceLocation getTemplateKeywordLoc() const {
|
||||
return getLocalData()->TemplateKWLoc;
|
||||
}
|
||||
|
||||
void setTemplateKeywordLoc(SourceLocation Loc) {
|
||||
getLocalData()->TemplateKWLoc = Loc;
|
||||
}
|
||||
|
@ -1585,6 +1633,7 @@ public:
|
|||
SourceLocation getLAngleLoc() const {
|
||||
return getLocalData()->LAngleLoc;
|
||||
}
|
||||
|
||||
void setLAngleLoc(SourceLocation Loc) {
|
||||
getLocalData()->LAngleLoc = Loc;
|
||||
}
|
||||
|
@ -1592,6 +1641,7 @@ public:
|
|||
SourceLocation getRAngleLoc() const {
|
||||
return getLocalData()->RAngleLoc;
|
||||
}
|
||||
|
||||
void setRAngleLoc(SourceLocation Loc) {
|
||||
getLocalData()->RAngleLoc = Loc;
|
||||
}
|
||||
|
@ -1599,9 +1649,11 @@ public:
|
|||
unsigned getNumArgs() const {
|
||||
return getTypePtr()->getNumArgs();
|
||||
}
|
||||
|
||||
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
|
||||
getArgInfos()[i] = AI;
|
||||
}
|
||||
|
||||
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
|
||||
return getArgInfos()[i];
|
||||
}
|
||||
|
@ -1613,6 +1665,7 @@ public:
|
|||
SourceLocation getTemplateNameLoc() const {
|
||||
return getLocalData()->NameLoc;
|
||||
}
|
||||
|
||||
void setTemplateNameLoc(SourceLocation Loc) {
|
||||
getLocalData()->NameLoc = Loc;
|
||||
}
|
||||
|
@ -1675,9 +1728,7 @@ class DependentAddressSpaceTypeLoc
|
|||
DependentAddressSpaceTypeLoc,
|
||||
DependentAddressSpaceType,
|
||||
DependentAddressSpaceLocInfo> {
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
/// The location of the attribute name, i.e.
|
||||
/// int * __attribute__((address_space(11)))
|
||||
/// ^~~~~~~~~~~~~
|
||||
|
@ -1787,6 +1838,7 @@ public:
|
|||
SourceLocation getTypeofLoc() const {
|
||||
return this->getLocalData()->TypeofLoc;
|
||||
}
|
||||
|
||||
void setTypeofLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->TypeofLoc = Loc;
|
||||
}
|
||||
|
@ -1794,6 +1846,7 @@ public:
|
|||
SourceLocation getLParenLoc() const {
|
||||
return this->getLocalData()->LParenLoc;
|
||||
}
|
||||
|
||||
void setLParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->LParenLoc = Loc;
|
||||
}
|
||||
|
@ -1801,6 +1854,7 @@ public:
|
|||
SourceLocation getRParenLoc() const {
|
||||
return this->getLocalData()->RParenLoc;
|
||||
}
|
||||
|
||||
void setRParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->RParenLoc = Loc;
|
||||
}
|
||||
|
@ -1808,6 +1862,7 @@ public:
|
|||
SourceRange getParensRange() const {
|
||||
return SourceRange(getLParenLoc(), getRParenLoc());
|
||||
}
|
||||
|
||||
void setParensRange(SourceRange range) {
|
||||
setLParenLoc(range.getBegin());
|
||||
setRParenLoc(range.getEnd());
|
||||
|
@ -1831,6 +1886,7 @@ public:
|
|||
Expr* getUnderlyingExpr() const {
|
||||
return getTypePtr()->getUnderlyingExpr();
|
||||
}
|
||||
|
||||
// Reimplemented to account for GNU/C++ extension
|
||||
// typeof unary-expression
|
||||
// where there are no parentheses.
|
||||
|
@ -1843,9 +1899,11 @@ public:
|
|||
QualType getUnderlyingType() const {
|
||||
return this->getTypePtr()->getUnderlyingType();
|
||||
}
|
||||
|
||||
TypeSourceInfo* getUnderlyingTInfo() const {
|
||||
return this->getLocalData()->UnderlyingTInfo;
|
||||
}
|
||||
|
||||
void setUnderlyingTInfo(TypeSourceInfo* TI) const {
|
||||
this->getLocalData()->UnderlyingTInfo = TI;
|
||||
}
|
||||
|
@ -1885,6 +1943,7 @@ public:
|
|||
TypeSourceInfo* getUnderlyingTInfo() const {
|
||||
return getLocalData()->UnderlyingTInfo;
|
||||
}
|
||||
|
||||
void setUnderlyingTInfo(TypeSourceInfo *TInfo) {
|
||||
getLocalData()->UnderlyingTInfo = TInfo;
|
||||
}
|
||||
|
@ -1896,6 +1955,7 @@ public:
|
|||
SourceRange getParensRange() const {
|
||||
return SourceRange(getLParenLoc(), getRParenLoc());
|
||||
}
|
||||
|
||||
void setParensRange(SourceRange Range) {
|
||||
setLParenLoc(Range.getBegin());
|
||||
setRParenLoc(Range.getEnd());
|
||||
|
@ -1924,6 +1984,7 @@ public:
|
|||
SourceLocation getTemplateNameLoc() const {
|
||||
return getNameLoc();
|
||||
}
|
||||
|
||||
void setTemplateNameLoc(SourceLocation Loc) {
|
||||
setNameLoc(Loc);
|
||||
}
|
||||
|
@ -1931,6 +1992,7 @@ public:
|
|||
|
||||
struct ElaboratedLocInfo {
|
||||
SourceLocation ElaboratedKWLoc;
|
||||
|
||||
/// \brief Data associated with the nested-name-specifier location.
|
||||
void *QualifierData;
|
||||
};
|
||||
|
@ -1943,6 +2005,7 @@ public:
|
|||
SourceLocation getElaboratedKeywordLoc() const {
|
||||
return this->getLocalData()->ElaboratedKWLoc;
|
||||
}
|
||||
|
||||
void setElaboratedKeywordLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->ElaboratedKWLoc = Loc;
|
||||
}
|
||||
|
@ -2001,6 +2064,7 @@ public:
|
|||
SourceLocation getElaboratedKeywordLoc() const {
|
||||
return this->getLocalData()->ElaboratedKWLoc;
|
||||
}
|
||||
|
||||
void setElaboratedKeywordLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->ElaboratedKWLoc = Loc;
|
||||
}
|
||||
|
@ -2020,6 +2084,7 @@ public:
|
|||
SourceLocation getNameLoc() const {
|
||||
return this->getLocalData()->NameLoc;
|
||||
}
|
||||
|
||||
void setNameLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->NameLoc = Loc;
|
||||
}
|
||||
|
@ -2056,6 +2121,7 @@ public:
|
|||
SourceLocation getElaboratedKeywordLoc() const {
|
||||
return this->getLocalData()->ElaboratedKWLoc;
|
||||
}
|
||||
|
||||
void setElaboratedKeywordLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->ElaboratedKWLoc = Loc;
|
||||
}
|
||||
|
@ -2087,6 +2153,7 @@ public:
|
|||
SourceLocation getTemplateKeywordLoc() const {
|
||||
return getLocalData()->TemplateKWLoc;
|
||||
}
|
||||
|
||||
void setTemplateKeywordLoc(SourceLocation Loc) {
|
||||
getLocalData()->TemplateKWLoc = Loc;
|
||||
}
|
||||
|
@ -2094,6 +2161,7 @@ public:
|
|||
SourceLocation getTemplateNameLoc() const {
|
||||
return this->getLocalData()->NameLoc;
|
||||
}
|
||||
|
||||
void setTemplateNameLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->NameLoc = Loc;
|
||||
}
|
||||
|
@ -2101,6 +2169,7 @@ public:
|
|||
SourceLocation getLAngleLoc() const {
|
||||
return this->getLocalData()->LAngleLoc;
|
||||
}
|
||||
|
||||
void setLAngleLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->LAngleLoc = Loc;
|
||||
}
|
||||
|
@ -2108,6 +2177,7 @@ public:
|
|||
SourceLocation getRAngleLoc() const {
|
||||
return this->getLocalData()->RAngleLoc;
|
||||
}
|
||||
|
||||
void setRAngleLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->RAngleLoc = Loc;
|
||||
}
|
||||
|
@ -2119,6 +2189,7 @@ public:
|
|||
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
|
||||
getArgInfos()[i] = AI;
|
||||
}
|
||||
|
||||
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
|
||||
return getArgInfos()[i];
|
||||
}
|
||||
|
@ -2160,7 +2231,6 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
struct PackExpansionTypeLocInfo {
|
||||
SourceLocation EllipsisLoc;
|
||||
};
|
||||
|
@ -2212,6 +2282,7 @@ public:
|
|||
SourceLocation getKWLoc() const {
|
||||
return this->getLocalData()->KWLoc;
|
||||
}
|
||||
|
||||
void setKWLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->KWLoc = Loc;
|
||||
}
|
||||
|
@ -2219,6 +2290,7 @@ public:
|
|||
SourceLocation getLParenLoc() const {
|
||||
return this->getLocalData()->LParenLoc;
|
||||
}
|
||||
|
||||
void setLParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->LParenLoc = Loc;
|
||||
}
|
||||
|
@ -2226,6 +2298,7 @@ public:
|
|||
SourceLocation getRParenLoc() const {
|
||||
return this->getLocalData()->RParenLoc;
|
||||
}
|
||||
|
||||
void setRParenLoc(SourceLocation Loc) {
|
||||
this->getLocalData()->RParenLoc = Loc;
|
||||
}
|
||||
|
@ -2233,6 +2306,7 @@ public:
|
|||
SourceRange getParensRange() const {
|
||||
return SourceRange(getLParenLoc(), getRParenLoc());
|
||||
}
|
||||
|
||||
void setParensRange(SourceRange Range) {
|
||||
setLParenLoc(Range.getBegin());
|
||||
setRParenLoc(Range.getEnd());
|
||||
|
@ -2287,6 +2361,7 @@ inline T TypeLoc::getAsAdjusted() const {
|
|||
}
|
||||
return Cur.getAs<T>();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_AST_TYPELOC_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- VTTBuilder.h - C++ VTT layout builder --------------------*- C++ -*-=//
|
||||
//===- VTTBuilder.h - C++ VTT layout builder --------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -16,25 +16,31 @@
|
|||
#define LLVM_CLANG_AST_VTTBUILDER_H
|
||||
|
||||
#include "clang/AST/BaseSubobject.h"
|
||||
#include "clang/AST/CXXInheritance.h"
|
||||
#include "clang/AST/GlobalDecl.h"
|
||||
#include "clang/AST/RecordLayout.h"
|
||||
#include "clang/Basic/ABI.h"
|
||||
#include <utility>
|
||||
#include "clang/AST/CharUnits.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class ASTContext;
|
||||
class ASTRecordLayout;
|
||||
class CXXRecordDecl;
|
||||
|
||||
class VTTVTable {
|
||||
llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> BaseAndIsVirtual;
|
||||
CharUnits BaseOffset;
|
||||
|
||||
public:
|
||||
VTTVTable() {}
|
||||
VTTVTable() = default;
|
||||
VTTVTable(const CXXRecordDecl *Base, CharUnits BaseOffset, bool BaseIsVirtual)
|
||||
: BaseAndIsVirtual(Base, BaseIsVirtual), BaseOffset(BaseOffset) {}
|
||||
: BaseAndIsVirtual(Base, BaseIsVirtual), BaseOffset(BaseOffset) {}
|
||||
VTTVTable(BaseSubobject Base, bool BaseIsVirtual)
|
||||
: BaseAndIsVirtual(Base.getBase(), BaseIsVirtual),
|
||||
BaseOffset(Base.getBaseOffset()) {}
|
||||
: BaseAndIsVirtual(Base.getBase(), BaseIsVirtual),
|
||||
BaseOffset(Base.getBaseOffset()) {}
|
||||
|
||||
const CXXRecordDecl *getBase() const {
|
||||
return BaseAndIsVirtual.getPointer();
|
||||
|
@ -57,25 +63,24 @@ struct VTTComponent {
|
|||
uint64_t VTableIndex;
|
||||
BaseSubobject VTableBase;
|
||||
|
||||
VTTComponent() {}
|
||||
VTTComponent() = default;
|
||||
VTTComponent(uint64_t VTableIndex, BaseSubobject VTableBase)
|
||||
: VTableIndex(VTableIndex), VTableBase(VTableBase) {}
|
||||
: VTableIndex(VTableIndex), VTableBase(VTableBase) {}
|
||||
};
|
||||
|
||||
/// \brief Class for building VTT layout information.
|
||||
class VTTBuilder {
|
||||
|
||||
ASTContext &Ctx;
|
||||
|
||||
/// \brief The most derived class for which we're building this vtable.
|
||||
const CXXRecordDecl *MostDerivedClass;
|
||||
|
||||
typedef SmallVector<VTTVTable, 64> VTTVTablesVectorTy;
|
||||
using VTTVTablesVectorTy = SmallVector<VTTVTable, 64>;
|
||||
|
||||
/// \brief The VTT vtables.
|
||||
VTTVTablesVectorTy VTTVTables;
|
||||
|
||||
typedef SmallVector<VTTComponent, 64> VTTComponentsVectorTy;
|
||||
using VTTComponentsVectorTy = SmallVector<VTTComponent, 64>;
|
||||
|
||||
/// \brief The VTT components.
|
||||
VTTComponentsVectorTy VTTComponents;
|
||||
|
@ -83,9 +88,9 @@ class VTTBuilder {
|
|||
/// \brief The AST record layout of the most derived class.
|
||||
const ASTRecordLayout &MostDerivedClassLayout;
|
||||
|
||||
typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
|
||||
using VisitedVirtualBasesSetTy = llvm::SmallPtrSet<const CXXRecordDecl *, 4>;
|
||||
|
||||
typedef llvm::DenseMap<BaseSubobject, uint64_t> AddressPointsMapTy;
|
||||
using AddressPointsMapTy = llvm::DenseMap<BaseSubobject, uint64_t>;
|
||||
|
||||
/// \brief The sub-VTT indices for the bases of the most derived class.
|
||||
llvm::DenseMap<BaseSubobject, uint64_t> SubVTTIndicies;
|
||||
|
@ -153,9 +158,8 @@ public:
|
|||
getSecondaryVirtualPointerIndices() const {
|
||||
return SecondaryVirtualPointerIndices;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_VTTBUILDER_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- TypeLoc.cpp - Type Source Info Wrapper -----------------*- C++ -*-===//
|
||||
//===- TypeLoc.cpp - Type Source Info Wrapper -----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -14,8 +14,19 @@
|
|||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/TypeLocVisitor.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
static const unsigned TypeLocMaxDataAlign = alignof(void *);
|
||||
|
@ -25,16 +36,18 @@ static const unsigned TypeLocMaxDataAlign = alignof(void *);
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
class TypeLocRanger : public TypeLocVisitor<TypeLocRanger, SourceRange> {
|
||||
public:
|
||||
|
||||
class TypeLocRanger : public TypeLocVisitor<TypeLocRanger, SourceRange> {
|
||||
public:
|
||||
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
||||
#define TYPELOC(CLASS, PARENT) \
|
||||
SourceRange Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getLocalSourceRange(); \
|
||||
}
|
||||
SourceRange Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getLocalSourceRange(); \
|
||||
}
|
||||
#include "clang/AST/TypeLocNodes.def"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) {
|
||||
if (TL.isNull()) return SourceRange();
|
||||
|
@ -42,16 +55,18 @@ SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) {
|
|||
}
|
||||
|
||||
namespace {
|
||||
class TypeAligner : public TypeLocVisitor<TypeAligner, unsigned> {
|
||||
public:
|
||||
|
||||
class TypeAligner : public TypeLocVisitor<TypeAligner, unsigned> {
|
||||
public:
|
||||
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
||||
#define TYPELOC(CLASS, PARENT) \
|
||||
unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getLocalDataAlignment(); \
|
||||
}
|
||||
unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getLocalDataAlignment(); \
|
||||
}
|
||||
#include "clang/AST/TypeLocNodes.def"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// \brief Returns the alignment of the type source info data block.
|
||||
unsigned TypeLoc::getLocalAlignmentForType(QualType Ty) {
|
||||
|
@ -60,16 +75,18 @@ unsigned TypeLoc::getLocalAlignmentForType(QualType Ty) {
|
|||
}
|
||||
|
||||
namespace {
|
||||
class TypeSizer : public TypeLocVisitor<TypeSizer, unsigned> {
|
||||
public:
|
||||
|
||||
class TypeSizer : public TypeLocVisitor<TypeSizer, unsigned> {
|
||||
public:
|
||||
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
||||
#define TYPELOC(CLASS, PARENT) \
|
||||
unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getLocalDataSize(); \
|
||||
}
|
||||
unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getLocalDataSize(); \
|
||||
}
|
||||
#include "clang/AST/TypeLocNodes.def"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// \brief Returns the size of the type source info data block.
|
||||
unsigned TypeLoc::getFullDataSizeForType(QualType Ty) {
|
||||
|
@ -88,16 +105,18 @@ unsigned TypeLoc::getFullDataSizeForType(QualType Ty) {
|
|||
}
|
||||
|
||||
namespace {
|
||||
class NextLoc : public TypeLocVisitor<NextLoc, TypeLoc> {
|
||||
public:
|
||||
|
||||
class NextLoc : public TypeLocVisitor<NextLoc, TypeLoc> {
|
||||
public:
|
||||
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
||||
#define TYPELOC(CLASS, PARENT) \
|
||||
TypeLoc Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getNextTypeLoc(); \
|
||||
}
|
||||
TypeLoc Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return TyLoc.getNextTypeLoc(); \
|
||||
}
|
||||
#include "clang/AST/TypeLocNodes.def"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
|
||||
/// TypeLoc is a PointerLoc and next TypeLoc is for "int".
|
||||
|
@ -127,20 +146,22 @@ void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL,
|
|||
}
|
||||
|
||||
namespace {
|
||||
class TypeLocCopier : public TypeLocVisitor<TypeLocCopier> {
|
||||
TypeLoc Source;
|
||||
public:
|
||||
TypeLocCopier(TypeLoc source) : Source(source) { }
|
||||
|
||||
class TypeLocCopier : public TypeLocVisitor<TypeLocCopier> {
|
||||
TypeLoc Source;
|
||||
|
||||
public:
|
||||
TypeLocCopier(TypeLoc source) : Source(source) {}
|
||||
|
||||
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
||||
#define TYPELOC(CLASS, PARENT) \
|
||||
void Visit##CLASS##TypeLoc(CLASS##TypeLoc dest) { \
|
||||
dest.copyLocal(Source.castAs<CLASS##TypeLoc>()); \
|
||||
}
|
||||
void Visit##CLASS##TypeLoc(CLASS##TypeLoc dest) { \
|
||||
dest.copyLocal(Source.castAs<CLASS##TypeLoc>()); \
|
||||
}
|
||||
#include "clang/AST/TypeLocNodes.def"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void TypeLoc::copy(TypeLoc other) {
|
||||
assert(getFullDataSize() == other.getFullDataSize());
|
||||
|
@ -243,22 +264,22 @@ SourceLocation TypeLoc::getEndLoc() const {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
struct TSTChecker : public TypeLocVisitor<TSTChecker, bool> {
|
||||
// Overload resolution does the real work for us.
|
||||
static bool isTypeSpec(TypeSpecTypeLoc _) { return true; }
|
||||
static bool isTypeSpec(TypeLoc _) { return false; }
|
||||
|
||||
struct TSTChecker : public TypeLocVisitor<TSTChecker, bool> {
|
||||
// Overload resolution does the real work for us.
|
||||
static bool isTypeSpec(TypeSpecTypeLoc _) { return true; }
|
||||
static bool isTypeSpec(TypeLoc _) { return false; }
|
||||
|
||||
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
||||
#define TYPELOC(CLASS, PARENT) \
|
||||
bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return isTypeSpec(TyLoc); \
|
||||
}
|
||||
bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
|
||||
return isTypeSpec(TyLoc); \
|
||||
}
|
||||
#include "clang/AST/TypeLocNodes.def"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/// \brief Determines if the given type loc corresponds to a
|
||||
/// TypeSpecTypeLoc. Since there is not actually a TypeSpecType in
|
||||
|
@ -364,7 +385,7 @@ SourceLocation TypeLoc::findNullabilityLoc() const {
|
|||
return attributedLoc.getAttrNameLoc();
|
||||
}
|
||||
|
||||
return SourceLocation();
|
||||
return {};
|
||||
}
|
||||
|
||||
TypeLoc TypeLoc::findExplicitQualifierLoc() const {
|
||||
|
@ -385,7 +406,7 @@ TypeLoc TypeLoc::findExplicitQualifierLoc() const {
|
|||
return atomic;
|
||||
}
|
||||
|
||||
return TypeLoc();
|
||||
return {};
|
||||
}
|
||||
|
||||
void ObjCTypeParamTypeLoc::initializeLocal(ASTContext &Context,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- VTTBuilder.cpp - C++ VTT layout builder --------------------------===//
|
||||
//===- VTTBuilder.cpp - C++ VTT layout builder ----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -14,12 +14,16 @@
|
|||
|
||||
#include "clang/AST/VTTBuilder.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/CXXInheritance.h"
|
||||
#include "clang/AST/BaseSubobject.h"
|
||||
#include "clang/AST/CharUnits.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/RecordLayout.h"
|
||||
#include "clang/Basic/TargetInfo.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
|
@ -28,9 +32,9 @@ using namespace clang;
|
|||
VTTBuilder::VTTBuilder(ASTContext &Ctx,
|
||||
const CXXRecordDecl *MostDerivedClass,
|
||||
bool GenerateDefinition)
|
||||
: Ctx(Ctx), MostDerivedClass(MostDerivedClass),
|
||||
MostDerivedClassLayout(Ctx.getASTRecordLayout(MostDerivedClass)),
|
||||
GenerateDefinition(GenerateDefinition) {
|
||||
: Ctx(Ctx), MostDerivedClass(MostDerivedClass),
|
||||
MostDerivedClassLayout(Ctx.getASTRecordLayout(MostDerivedClass)),
|
||||
GenerateDefinition(GenerateDefinition) {
|
||||
// Lay out this VTT.
|
||||
LayoutVTT(BaseSubobject(MostDerivedClass, CharUnits::Zero()),
|
||||
/*BaseIsVirtual=*/false);
|
||||
|
@ -56,7 +60,7 @@ void VTTBuilder::AddVTablePointer(BaseSubobject Base, uint64_t VTableIndex,
|
|||
void VTTBuilder::LayoutSecondaryVTTs(BaseSubobject Base) {
|
||||
const CXXRecordDecl *RD = Base.getBase();
|
||||
|
||||
for (const auto &I : RD->bases()) {
|
||||
for (const auto &I : RD->bases()) {
|
||||
// Don't layout virtual bases.
|
||||
if (I.isVirtual())
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue