-//===--- TypeLoc.h - Type Source Info Wrapper -------------------*- C++ -*-===//
+//===- TypeLoc.h - Type Source Info Wrapper ---------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// 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)
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.
///
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();
SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getBeginLoc(), getEndLoc());
}
+
SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
/// no direct qualifiers.
class UnqualTypeLoc : public TypeLoc {
public:
- UnqualTypeLoc() {}
+ UnqualTypeLoc() = default;
UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
const Type *getTypePtr() const {
private:
friend class TypeLoc;
+
static bool isKind(const TypeLoc &TL) {
return !TL.getType().hasLocalQualifiers();
}
/// type qualifiers.
class QualifiedTypeLoc : public TypeLoc {
public:
- SourceRange getLocalSourceRange() const {
- return SourceRange();
- }
+ SourceRange getLocalSourceRange() const { return {}; }
UnqualTypeLoc getUnqualifiedLoc() const {
unsigned align =
private:
friend class TypeLoc;
+
static bool isKind(const TypeLoc &TL) {
return TL.getType().hasLocalQualifiers();
}
/// 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());
return std::max(unsigned(alignof(LocalData)),
asDerived()->getExtraLocalDataAlignment());
}
+
unsigned getLocalDataSize() const {
unsigned size = sizeof(LocalData);
unsigned extraAlign = asDerived()->getExtraLocalDataAlignment();
return TypeLoc::getLocalAlignmentForType(T);
}
- TypeLoc getNextTypeLoc(HasNoInnerType _) const {
- return TypeLoc();
- }
+ TypeLoc getNextTypeLoc(HasNoInnerType _) const { return {}; }
TypeLoc getNextTypeLoc(QualType T) const {
return TypeLoc(T, getNonLocalData());
template <class Base, class Derived, class TypeClass>
class InheritingConcreteTypeLoc : public Base {
friend class TypeLoc;
+
static bool classofType(const Type *Ty) {
return TypeClass::classof(Ty);
}
}
};
-
struct TypeSpecLocInfo {
SourceLocation NameLoc;
};
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;
};
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()) {
else
return TSS_unspecified;
}
+
bool hasWrittenSignSpec() const {
return getWrittenSignSpec() != TSS_unspecified;
}
+
void setWrittenSignSpec(TypeSpecifierSign written) {
if (needsExtraLocalData())
getWrittenBuiltinSpecs().Sign = written;
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;
else
return false;
}
+
void setModeAttr(bool written) {
if (needsExtraLocalData())
getWrittenBuiltinSpecs().ModeAttr = written;
}
};
-
/// \brief Wrapper for source info for typedefs.
class TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
TypedefTypeLoc,
*((SourceLocation*)this->getExtraLocalData()) :
SourceLocation();
}
+
void setProtocolLAngleLoc(SourceLocation Loc) {
*((SourceLocation*)this->getExtraLocalData()) = Loc;
}
*((SourceLocation*)this->getExtraLocalData() + 1) :
SourceLocation();
}
+
void setProtocolRAngleLoc(SourceLocation Loc) {
*((SourceLocation*)this->getExtraLocalData() + 1) = Loc;
}
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;
// as well.
return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
}
+
unsigned getExtraLocalDataAlignment() const {
return alignof(SourceLocation);
}
+
SourceRange getLocalSourceRange() const {
SourceLocation start = getNameLoc();
SourceLocation end = getProtocolRAngleLoc();
}
};
-
struct ObjCObjectTypeLocInfo {
SourceLocation TypeArgsLAngleLoc;
SourceLocation TypeArgsRAngleLoc;
SourceLocation getTypeArgsLAngleLoc() const {
return this->getLocalData()->TypeArgsLAngleLoc;
}
+
void setTypeArgsLAngleLoc(SourceLocation Loc) {
this->getLocalData()->TypeArgsLAngleLoc = Loc;
}
SourceLocation getTypeArgsRAngleLoc() const {
return this->getLocalData()->TypeArgsRAngleLoc;
}
+
void setTypeArgsRAngleLoc(SourceLocation Loc) {
this->getLocalData()->TypeArgsRAngleLoc = Loc;
}
SourceLocation getProtocolLAngleLoc() const {
return this->getLocalData()->ProtocolLAngleLoc;
}
+
void setProtocolLAngleLoc(SourceLocation Loc) {
this->getLocalData()->ProtocolLAngleLoc = Loc;
}
SourceLocation getProtocolRAngleLoc() const {
return this->getLocalData()->ProtocolRAngleLoc;
}
+
void setProtocolRAngleLoc(SourceLocation Loc) {
this->getLocalData()->ProtocolRAngleLoc = Loc;
}
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;
}
};
-
struct ObjCInterfaceLocInfo {
SourceLocation NameLoc;
SourceLocation NameEndLoc;
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;
}
return *this;
}
-
-struct AdjustedLocInfo { }; // Nothing.
+struct AdjustedLocInfo {}; // Nothing.
class AdjustedTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AdjustedTypeLoc,
AdjustedType, AdjustedLocInfo> {
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
SourceLocation getSigilLoc() const {
return this->getLocalData()->StarLoc;
}
+
void setSigilLoc(SourceLocation Loc) {
this->getLocalData()->StarLoc = Loc;
}
}
};
-
/// \brief Wrapper for source info for pointers.
class PointerTypeLoc : public PointerLikeTypeLoc<PointerTypeLoc,
PointerType> {
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> {
SourceLocation getCaretLoc() const {
return getSigilLoc();
}
+
void setCaretLoc(SourceLocation Loc) {
setSigilLoc(Loc);
}
SourceLocation getStarLoc() const {
return getSigilLoc();
}
+
void setStarLoc(SourceLocation Loc) {
setSigilLoc(Loc);
}
const Type *getClass() const {
return getTypePtr()->getClass();
}
+
TypeSourceInfo *getClassTInfo() const {
return getLocalData()->ClassTInfo;
}
+
void setClassTInfo(TypeSourceInfo* TI) {
getLocalData()->ClassTInfo = TI;
}
}
};
-
class ReferenceTypeLoc : public PointerLikeTypeLoc<ReferenceTypeLoc,
ReferenceType> {
public:
SourceLocation getAmpLoc() const {
return getSigilLoc();
}
+
void setAmpLoc(SourceLocation Loc) {
setSigilLoc(Loc);
}
SourceLocation getAmpAmpLoc() const {
return getSigilLoc();
}
+
void setAmpAmpLoc(SourceLocation Loc) {
setSigilLoc(Loc);
}
};
-
struct FunctionLocInfo {
SourceLocation LocalRangeBegin;
SourceLocation LParenLoc;
// exception specification information.
return (SourceRange *)(getParmArray() + getNumParams());
}
+
public:
SourceLocation getLocalRangeBegin() const {
return getLocalData()->LocalRangeBegin;
}
+
void setLocalRangeBegin(SourceLocation L) {
getLocalData()->LocalRangeBegin = L;
}
SourceLocation getLocalRangeEnd() const {
return getLocalData()->LocalRangeEnd;
}
+
void setLocalRangeEnd(SourceLocation L) {
getLocalData()->LocalRangeEnd = L;
}
SourceLocation getLParenLoc() const {
return this->getLocalData()->LParenLoc;
}
+
void setLParenLoc(SourceLocation Loc) {
this->getLocalData()->LParenLoc = Loc;
}
SourceLocation getRParenLoc() const {
return this->getLocalData()->RParenLoc;
}
+
void setRParenLoc(SourceLocation Loc) {
this->getLocalData()->RParenLoc = Loc;
}
SourceRange getExceptionSpecRange() const {
if (hasExceptionSpec())
return *getExceptionSpecRangePtr();
- return SourceRange();
+ return {};
}
+
void setExceptionSpecRange(SourceRange R) {
if (hasExceptionSpec())
*getExceptionSpecRangePtr() = R;
return 0;
return cast<FunctionProtoType>(getTypePtr())->getNumParams();
}
+
ParmVarDecl *getParam(unsigned i) const { return getParmArray()[i]; }
void setParam(unsigned i, ParmVarDecl *VD) { getParmArray()[i] = VD; }
FunctionNoProtoType> {
};
-
struct ArrayLocInfo {
SourceLocation LBracketLoc, RBracketLoc;
Expr *Size;
SourceLocation getLBracketLoc() const {
return getLocalData()->LBracketLoc;
}
+
void setLBracketLoc(SourceLocation Loc) {
getLocalData()->LBracketLoc = Loc;
}
SourceLocation getRBracketLoc() const {
return getLocalData()->RBracketLoc;
}
+
void setRBracketLoc(SourceLocation Loc) {
getLocalData()->RBracketLoc = Loc;
}
Expr *getSizeExpr() const {
return getLocalData()->Size;
}
+
void setSizeExpr(Expr *Size) {
getLocalData()->Size = Size;
}
VariableArrayType> {
};
-
// Location information for a TemplateName. Rudimentary for now.
struct TemplateNameLocInfo {
SourceLocation NameLoc;
SourceLocation getTemplateKeywordLoc() const {
return getLocalData()->TemplateKWLoc;
}
+
void setTemplateKeywordLoc(SourceLocation Loc) {
getLocalData()->TemplateKWLoc = Loc;
}
SourceLocation getLAngleLoc() const {
return getLocalData()->LAngleLoc;
}
+
void setLAngleLoc(SourceLocation Loc) {
getLocalData()->LAngleLoc = Loc;
}
SourceLocation getRAngleLoc() const {
return getLocalData()->RAngleLoc;
}
+
void setRAngleLoc(SourceLocation Loc) {
getLocalData()->RAngleLoc = Loc;
}
unsigned getNumArgs() const {
return getTypePtr()->getNumArgs();
}
+
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
getArgInfos()[i] = AI;
}
+
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
return getArgInfos()[i];
}
SourceLocation getTemplateNameLoc() const {
return getLocalData()->NameLoc;
}
+
void setTemplateNameLoc(SourceLocation Loc) {
getLocalData()->NameLoc = Loc;
}
DependentAddressSpaceTypeLoc,
DependentAddressSpaceType,
DependentAddressSpaceLocInfo> {
-
- public:
-
+public:
/// The location of the attribute name, i.e.
/// int * __attribute__((address_space(11)))
/// ^~~~~~~~~~~~~
SourceLocation getTypeofLoc() const {
return this->getLocalData()->TypeofLoc;
}
+
void setTypeofLoc(SourceLocation Loc) {
this->getLocalData()->TypeofLoc = Loc;
}
SourceLocation getLParenLoc() const {
return this->getLocalData()->LParenLoc;
}
+
void setLParenLoc(SourceLocation Loc) {
this->getLocalData()->LParenLoc = Loc;
}
SourceLocation getRParenLoc() const {
return this->getLocalData()->RParenLoc;
}
+
void setRParenLoc(SourceLocation Loc) {
this->getLocalData()->RParenLoc = Loc;
}
SourceRange getParensRange() const {
return SourceRange(getLParenLoc(), getRParenLoc());
}
+
void setParensRange(SourceRange range) {
setLParenLoc(range.getBegin());
setRParenLoc(range.getEnd());
Expr* getUnderlyingExpr() const {
return getTypePtr()->getUnderlyingExpr();
}
+
// Reimplemented to account for GNU/C++ extension
// typeof unary-expression
// where there are no parentheses.
QualType getUnderlyingType() const {
return this->getTypePtr()->getUnderlyingType();
}
+
TypeSourceInfo* getUnderlyingTInfo() const {
return this->getLocalData()->UnderlyingTInfo;
}
+
void setUnderlyingTInfo(TypeSourceInfo* TI) const {
this->getLocalData()->UnderlyingTInfo = TI;
}
TypeSourceInfo* getUnderlyingTInfo() const {
return getLocalData()->UnderlyingTInfo;
}
+
void setUnderlyingTInfo(TypeSourceInfo *TInfo) {
getLocalData()->UnderlyingTInfo = TInfo;
}
SourceRange getParensRange() const {
return SourceRange(getLParenLoc(), getRParenLoc());
}
+
void setParensRange(SourceRange Range) {
setLParenLoc(Range.getBegin());
setRParenLoc(Range.getEnd());
SourceLocation getTemplateNameLoc() const {
return getNameLoc();
}
+
void setTemplateNameLoc(SourceLocation Loc) {
setNameLoc(Loc);
}
struct ElaboratedLocInfo {
SourceLocation ElaboratedKWLoc;
+
/// \brief Data associated with the nested-name-specifier location.
void *QualifierData;
};
SourceLocation getElaboratedKeywordLoc() const {
return this->getLocalData()->ElaboratedKWLoc;
}
+
void setElaboratedKeywordLoc(SourceLocation Loc) {
this->getLocalData()->ElaboratedKWLoc = Loc;
}
SourceLocation getElaboratedKeywordLoc() const {
return this->getLocalData()->ElaboratedKWLoc;
}
+
void setElaboratedKeywordLoc(SourceLocation Loc) {
this->getLocalData()->ElaboratedKWLoc = Loc;
}
SourceLocation getNameLoc() const {
return this->getLocalData()->NameLoc;
}
+
void setNameLoc(SourceLocation Loc) {
this->getLocalData()->NameLoc = Loc;
}
SourceLocation getElaboratedKeywordLoc() const {
return this->getLocalData()->ElaboratedKWLoc;
}
+
void setElaboratedKeywordLoc(SourceLocation Loc) {
this->getLocalData()->ElaboratedKWLoc = Loc;
}
SourceLocation getTemplateKeywordLoc() const {
return getLocalData()->TemplateKWLoc;
}
+
void setTemplateKeywordLoc(SourceLocation Loc) {
getLocalData()->TemplateKWLoc = Loc;
}
SourceLocation getTemplateNameLoc() const {
return this->getLocalData()->NameLoc;
}
+
void setTemplateNameLoc(SourceLocation Loc) {
this->getLocalData()->NameLoc = Loc;
}
SourceLocation getLAngleLoc() const {
return this->getLocalData()->LAngleLoc;
}
+
void setLAngleLoc(SourceLocation Loc) {
this->getLocalData()->LAngleLoc = Loc;
}
SourceLocation getRAngleLoc() const {
return this->getLocalData()->RAngleLoc;
}
+
void setRAngleLoc(SourceLocation Loc) {
this->getLocalData()->RAngleLoc = Loc;
}
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI) {
getArgInfos()[i] = AI;
}
+
TemplateArgumentLocInfo getArgLocInfo(unsigned i) const {
return getArgInfos()[i];
}
}
};
-
struct PackExpansionTypeLocInfo {
SourceLocation EllipsisLoc;
};
SourceLocation getKWLoc() const {
return this->getLocalData()->KWLoc;
}
+
void setKWLoc(SourceLocation Loc) {
this->getLocalData()->KWLoc = Loc;
}
SourceLocation getLParenLoc() const {
return this->getLocalData()->LParenLoc;
}
+
void setLParenLoc(SourceLocation Loc) {
this->getLocalData()->LParenLoc = Loc;
}
SourceLocation getRParenLoc() const {
return this->getLocalData()->RParenLoc;
}
+
void setRParenLoc(SourceLocation Loc) {
this->getLocalData()->RParenLoc = Loc;
}
SourceRange getParensRange() const {
return SourceRange(getLParenLoc(), getRParenLoc());
}
+
void setParensRange(SourceRange Range) {
setLParenLoc(Range.getBegin());
setRParenLoc(Range.getEnd());
}
return Cur.getAs<T>();
}
-}
-#endif
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_TYPELOC_H
-//===--- TypeLoc.cpp - Type Source Info Wrapper -----------------*- C++ -*-===//
+//===- TypeLoc.cpp - Type Source Info Wrapper -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
#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 *);
//===----------------------------------------------------------------------===//
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();
}
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) {
}
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) {
}
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".
}
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());
}
}
-
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
return attributedLoc.getAttrNameLoc();
}
- return SourceLocation();
+ return {};
}
TypeLoc TypeLoc::findExplicitQualifierLoc() const {
return atomic;
}
- return TypeLoc();
+ return {};
}
void ObjCTypeParamTypeLoc::initializeLocal(ASTContext &Context,