forked from OSchip/llvm-project
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318813
This commit is contained in:
parent
4aef6a08aa
commit
21fadadbf3
|
@ -1,4 +1,4 @@
|
|||
//===-- DeclarationName.h - Representation of declaration names -*- C++ -*-===//
|
||||
//===- DeclarationName.h - Representation of declaration names --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -10,36 +10,42 @@
|
|||
// This file declares the DeclarationName and DeclarationNameTable classes.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_AST_DECLARATIONNAME_H
|
||||
#define LLVM_CLANG_AST_DECLARATIONNAME_H
|
||||
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Basic/PartialDiagnostic.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/DenseMapInfo.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
||||
namespace llvm {
|
||||
template <typename T> struct DenseMapInfo;
|
||||
}
|
||||
#include "llvm/Support/type_traits.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
class CXXDeductionGuideNameExtra;
|
||||
class CXXLiteralOperatorIdName;
|
||||
class CXXOperatorIdName;
|
||||
class CXXSpecialName;
|
||||
class DeclarationNameExtra;
|
||||
class IdentifierInfo;
|
||||
class MultiKeywordSelector;
|
||||
enum OverloadedOperatorKind : int;
|
||||
struct PrintingPolicy;
|
||||
class QualType;
|
||||
class TemplateDecl;
|
||||
class Type;
|
||||
class TypeSourceInfo;
|
||||
class UsingDirectiveDecl;
|
||||
|
||||
template <typename> class CanQual;
|
||||
typedef CanQual<Type> CanQualType;
|
||||
class ASTContext;
|
||||
template <typename> class CanQual;
|
||||
class CXXDeductionGuideNameExtra;
|
||||
class CXXLiteralOperatorIdName;
|
||||
class CXXOperatorIdName;
|
||||
class CXXSpecialName;
|
||||
class DeclarationNameExtra;
|
||||
class IdentifierInfo;
|
||||
class MultiKeywordSelector;
|
||||
enum OverloadedOperatorKind : int;
|
||||
struct PrintingPolicy;
|
||||
class QualType;
|
||||
class TemplateDecl;
|
||||
class Type;
|
||||
class TypeSourceInfo;
|
||||
class UsingDirectiveDecl;
|
||||
|
||||
using CanQualType = CanQual<Type>;
|
||||
|
||||
/// DeclarationName - The name of a declaration. In the common case,
|
||||
/// this just stores an IdentifierInfo pointer to a normal
|
||||
|
@ -63,9 +69,13 @@ public:
|
|||
CXXLiteralOperatorName,
|
||||
CXXUsingDirective
|
||||
};
|
||||
|
||||
static const unsigned NumNameKinds = CXXUsingDirective + 1;
|
||||
|
||||
private:
|
||||
friend class DeclarationNameTable;
|
||||
friend class NamedDecl;
|
||||
|
||||
/// StoredNameKind - The kind of name that is actually stored in the
|
||||
/// upper bits of the Ptr field. This is only used internally.
|
||||
///
|
||||
|
@ -99,7 +109,18 @@ private:
|
|||
/// DeclarationNameExtra structure, whose first value will tell us
|
||||
/// whether this is an Objective-C selector, C++ operator-id name,
|
||||
/// or special C++ name.
|
||||
uintptr_t Ptr;
|
||||
uintptr_t Ptr = 0;
|
||||
|
||||
// Construct a declaration name from the name of a C++ constructor,
|
||||
// destructor, or conversion function.
|
||||
DeclarationName(DeclarationNameExtra *Name)
|
||||
: Ptr(reinterpret_cast<uintptr_t>(Name)) {
|
||||
assert((Ptr & PtrMask) == 0 && "Improperly aligned DeclarationNameExtra");
|
||||
Ptr |= StoredDeclarationNameExtra;
|
||||
}
|
||||
|
||||
/// Construct a declaration name from a raw pointer.
|
||||
DeclarationName(uintptr_t Ptr) : Ptr(Ptr) {}
|
||||
|
||||
/// getStoredNameKind - Return the kind of object that is stored in
|
||||
/// Ptr.
|
||||
|
@ -146,36 +167,22 @@ private:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// Construct a declaration name from the name of a C++ constructor,
|
||||
// destructor, or conversion function.
|
||||
DeclarationName(DeclarationNameExtra *Name)
|
||||
: Ptr(reinterpret_cast<uintptr_t>(Name)) {
|
||||
assert((Ptr & PtrMask) == 0 && "Improperly aligned DeclarationNameExtra");
|
||||
Ptr |= StoredDeclarationNameExtra;
|
||||
}
|
||||
|
||||
/// Construct a declaration name from a raw pointer.
|
||||
DeclarationName(uintptr_t Ptr) : Ptr(Ptr) { }
|
||||
|
||||
friend class DeclarationNameTable;
|
||||
friend class NamedDecl;
|
||||
|
||||
/// getFETokenInfoAsVoidSlow - Retrieves the front end-specified pointer
|
||||
/// for this name as a void pointer if it's not an identifier.
|
||||
void *getFETokenInfoAsVoidSlow() const;
|
||||
|
||||
public:
|
||||
/// DeclarationName - Used to create an empty selector.
|
||||
DeclarationName() : Ptr(0) { }
|
||||
DeclarationName() = default;
|
||||
|
||||
// Construct a declaration name from an IdentifierInfo *.
|
||||
DeclarationName(const IdentifierInfo *II)
|
||||
: Ptr(reinterpret_cast<uintptr_t>(II)) {
|
||||
: Ptr(reinterpret_cast<uintptr_t>(II)) {
|
||||
assert((Ptr & PtrMask) == 0 && "Improperly aligned IdentifierInfo");
|
||||
}
|
||||
|
||||
// Construct a declaration name from an Objective-C selector.
|
||||
DeclarationName(Selector Sel) : Ptr(Sel.InfoPtr) { }
|
||||
DeclarationName(Selector Sel) : Ptr(Sel.InfoPtr) {}
|
||||
|
||||
/// getUsingDirectiveName - Return name for all using-directives.
|
||||
static DeclarationName getUsingDirectiveName();
|
||||
|
@ -344,16 +351,24 @@ inline bool operator>=(DeclarationName LHS, DeclarationName RHS) {
|
|||
/// getCXXConstructorName).
|
||||
class DeclarationNameTable {
|
||||
const ASTContext &Ctx;
|
||||
void *CXXSpecialNamesImpl; // Actually a FoldingSet<CXXSpecialName> *
|
||||
CXXOperatorIdName *CXXOperatorNames; // Operator names
|
||||
void *CXXLiteralOperatorNames; // Actually a CXXOperatorIdName*
|
||||
void *CXXDeductionGuideNames; // FoldingSet<CXXDeductionGuideNameExtra> *
|
||||
|
||||
DeclarationNameTable(const DeclarationNameTable&) = delete;
|
||||
void operator=(const DeclarationNameTable&) = delete;
|
||||
// Actually a FoldingSet<CXXSpecialName> *
|
||||
void *CXXSpecialNamesImpl;
|
||||
|
||||
// Operator names
|
||||
CXXOperatorIdName *CXXOperatorNames;
|
||||
|
||||
// Actually a CXXOperatorIdName*
|
||||
void *CXXLiteralOperatorNames;
|
||||
|
||||
// FoldingSet<CXXDeductionGuideNameExtra> *
|
||||
void *CXXDeductionGuideNames;
|
||||
|
||||
public:
|
||||
DeclarationNameTable(const ASTContext &C);
|
||||
DeclarationNameTable(const DeclarationNameTable &) = delete;
|
||||
DeclarationNameTable &operator=(const DeclarationNameTable &) = delete;
|
||||
|
||||
~DeclarationNameTable();
|
||||
|
||||
/// getIdentifier - Create a declaration name that is a simple
|
||||
|
@ -428,10 +443,10 @@ struct DeclarationNameLoc {
|
|||
};
|
||||
|
||||
DeclarationNameLoc(DeclarationName Name);
|
||||
|
||||
// FIXME: this should go away once all DNLocs are properly initialized.
|
||||
DeclarationNameLoc() { memset((void*) this, 0, sizeof(*this)); }
|
||||
}; // struct DeclarationNameLoc
|
||||
|
||||
};
|
||||
|
||||
/// DeclarationNameInfo - A collector data type for bundling together
|
||||
/// a DeclarationName and the correspnding source/type location info.
|
||||
|
@ -439,29 +454,33 @@ struct DeclarationNameInfo {
|
|||
private:
|
||||
/// Name - The declaration name, also encoding name kind.
|
||||
DeclarationName Name;
|
||||
|
||||
/// Loc - The main source location for the declaration name.
|
||||
SourceLocation NameLoc;
|
||||
|
||||
/// Info - Further source/type location info for special kinds of names.
|
||||
DeclarationNameLoc LocInfo;
|
||||
|
||||
public:
|
||||
// FIXME: remove it.
|
||||
DeclarationNameInfo() {}
|
||||
DeclarationNameInfo() = default;
|
||||
|
||||
DeclarationNameInfo(DeclarationName Name, SourceLocation NameLoc)
|
||||
: Name(Name), NameLoc(NameLoc), LocInfo(Name) {}
|
||||
: Name(Name), NameLoc(NameLoc), LocInfo(Name) {}
|
||||
|
||||
DeclarationNameInfo(DeclarationName Name, SourceLocation NameLoc,
|
||||
DeclarationNameLoc LocInfo)
|
||||
: Name(Name), NameLoc(NameLoc), LocInfo(LocInfo) {}
|
||||
: Name(Name), NameLoc(NameLoc), LocInfo(LocInfo) {}
|
||||
|
||||
/// getName - Returns the embedded declaration name.
|
||||
DeclarationName getName() const { return Name; }
|
||||
|
||||
/// setName - Sets the embedded declaration name.
|
||||
void setName(DeclarationName N) { Name = N; }
|
||||
|
||||
/// getLoc - Returns the main location of the declaration name.
|
||||
SourceLocation getLoc() const { return NameLoc; }
|
||||
|
||||
/// setLoc - Sets the main location of the declaration name.
|
||||
void setLoc(SourceLocation L) { NameLoc = L; }
|
||||
|
||||
|
@ -477,6 +496,7 @@ public:
|
|||
Name.getNameKind() == DeclarationName::CXXConversionFunctionName);
|
||||
return LocInfo.NamedType.TInfo;
|
||||
}
|
||||
|
||||
/// setNamedTypeInfo - Sets the source type info associated to
|
||||
/// the name. Assumes it is a constructor, destructor or conversion.
|
||||
void setNamedTypeInfo(TypeSourceInfo *TInfo) {
|
||||
|
@ -495,6 +515,7 @@ public:
|
|||
SourceLocation::getFromRawEncoding(LocInfo.CXXOperatorName.EndOpNameLoc)
|
||||
);
|
||||
}
|
||||
|
||||
/// setCXXOperatorNameRange - Sets the range of the operator name
|
||||
/// (without the operator keyword). Assumes it is a C++ operator.
|
||||
void setCXXOperatorNameRange(SourceRange R) {
|
||||
|
@ -511,6 +532,7 @@ public:
|
|||
return SourceLocation::
|
||||
getFromRawEncoding(LocInfo.CXXLiteralOperatorName.OpNameLoc);
|
||||
}
|
||||
|
||||
/// setCXXLiteralOperatorNameLoc - Sets the location of the literal
|
||||
/// operator name (not the operator keyword).
|
||||
/// Assumes it is a literal operator.
|
||||
|
@ -534,15 +556,19 @@ public:
|
|||
|
||||
/// getBeginLoc - Retrieve the location of the first token.
|
||||
SourceLocation getBeginLoc() const { return NameLoc; }
|
||||
|
||||
/// getEndLoc - Retrieve the location of the last token.
|
||||
SourceLocation getEndLoc() const;
|
||||
|
||||
/// getSourceRange - The range of the declaration name.
|
||||
SourceRange getSourceRange() const LLVM_READONLY {
|
||||
return SourceRange(getLocStart(), getLocEnd());
|
||||
}
|
||||
|
||||
SourceLocation getLocStart() const LLVM_READONLY {
|
||||
return getBeginLoc();
|
||||
}
|
||||
|
||||
SourceLocation getLocEnd() const LLVM_READONLY {
|
||||
SourceLocation EndLoc = getEndLoc();
|
||||
return EndLoc.isValid() ? EndLoc : getLocStart();
|
||||
|
@ -573,9 +599,10 @@ inline raw_ostream &operator<<(raw_ostream &OS,
|
|||
return OS;
|
||||
}
|
||||
|
||||
} // end namespace clang
|
||||
} // namespace clang
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// Define DenseMapInfo so that DeclarationNames can be used as keys
|
||||
/// in DenseMap and DenseSets.
|
||||
template<>
|
||||
|
@ -601,6 +628,6 @@ struct DenseMapInfo<clang::DeclarationName> {
|
|||
template <>
|
||||
struct isPodLike<clang::DeclarationName> { static const bool value = true; };
|
||||
|
||||
} // end namespace llvm
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_DECLARATIONNAME_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- NestedNameSpecifier.h - C++ nested name specifiers -----*- C++ -*-===//
|
||||
//===- NestedNameSpecifier.h - C++ nested name specifiers -------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -11,25 +11,30 @@
|
|||
// a C++ nested-name-specifier.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
|
||||
#define LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
|
||||
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class ASTContext;
|
||||
class CXXRecordDecl;
|
||||
class IdentifierInfo;
|
||||
class LangOptions;
|
||||
class NamespaceAliasDecl;
|
||||
class NamespaceDecl;
|
||||
class IdentifierInfo;
|
||||
struct PrintingPolicy;
|
||||
class Type;
|
||||
class TypeLoc;
|
||||
class LangOptions;
|
||||
|
||||
/// \brief Represents a C++ nested name specifier, such as
|
||||
/// "\::std::vector<int>::".
|
||||
|
@ -42,7 +47,6 @@ class LangOptions;
|
|||
/// The last two specifiers can only appear at the start of a
|
||||
/// nested-namespace-specifier.
|
||||
class NestedNameSpecifier : public llvm::FoldingSetNode {
|
||||
|
||||
/// \brief Enumeration describing
|
||||
enum StoredSpecifierKind {
|
||||
StoredIdentifier = 0,
|
||||
|
@ -66,7 +70,7 @@ class NestedNameSpecifier : public llvm::FoldingSetNode {
|
|||
/// specifier '::'. Otherwise, the pointer is one of
|
||||
/// IdentifierInfo*, Namespace*, or Type*, depending on the kind of
|
||||
/// specifier as encoded within the prefix.
|
||||
void* Specifier;
|
||||
void* Specifier = nullptr;
|
||||
|
||||
public:
|
||||
/// \brief The kind of specifier that completes this nested name
|
||||
|
@ -74,17 +78,23 @@ public:
|
|||
enum SpecifierKind {
|
||||
/// \brief An identifier, stored as an IdentifierInfo*.
|
||||
Identifier,
|
||||
|
||||
/// \brief A namespace, stored as a NamespaceDecl*.
|
||||
Namespace,
|
||||
|
||||
/// \brief A namespace alias, stored as a NamespaceAliasDecl*.
|
||||
NamespaceAlias,
|
||||
|
||||
/// \brief A type, stored as a Type*.
|
||||
TypeSpec,
|
||||
|
||||
/// \brief A type that was preceded by the 'template' keyword,
|
||||
/// stored as a Type*.
|
||||
TypeSpecWithTemplate,
|
||||
|
||||
/// \brief The global specifier '::'. There is no stored value.
|
||||
Global,
|
||||
|
||||
/// \brief Microsoft's '__super' specifier, stored as a CXXRecordDecl* of
|
||||
/// the class it appeared in.
|
||||
Super
|
||||
|
@ -92,17 +102,11 @@ public:
|
|||
|
||||
private:
|
||||
/// \brief Builds the global specifier.
|
||||
NestedNameSpecifier()
|
||||
: Prefix(nullptr, StoredIdentifier), Specifier(nullptr) {}
|
||||
NestedNameSpecifier() : Prefix(nullptr, StoredIdentifier) {}
|
||||
|
||||
/// \brief Copy constructor used internally to clone nested name
|
||||
/// specifiers.
|
||||
NestedNameSpecifier(const NestedNameSpecifier &Other)
|
||||
: llvm::FoldingSetNode(Other), Prefix(Other.Prefix),
|
||||
Specifier(Other.Specifier) {
|
||||
}
|
||||
|
||||
void operator=(const NestedNameSpecifier &) = delete;
|
||||
NestedNameSpecifier(const NestedNameSpecifier &Other) = default;
|
||||
|
||||
/// \brief Either find or insert the given nested name specifier
|
||||
/// mockup in the given context.
|
||||
|
@ -110,6 +114,8 @@ private:
|
|||
const NestedNameSpecifier &Mockup);
|
||||
|
||||
public:
|
||||
NestedNameSpecifier &operator=(const NestedNameSpecifier &) = delete;
|
||||
|
||||
/// \brief Builds a specifier combining a prefix and an identifier.
|
||||
///
|
||||
/// The prefix must be dependent, since nested name specifiers
|
||||
|
@ -224,8 +230,8 @@ public:
|
|||
/// \brief A C++ nested-name-specifier augmented with source location
|
||||
/// information.
|
||||
class NestedNameSpecifierLoc {
|
||||
NestedNameSpecifier *Qualifier;
|
||||
void *Data;
|
||||
NestedNameSpecifier *Qualifier = nullptr;
|
||||
void *Data = nullptr;
|
||||
|
||||
/// \brief Determines the data length for the last component in the
|
||||
/// given nested-name-specifier.
|
||||
|
@ -237,12 +243,12 @@ class NestedNameSpecifierLoc {
|
|||
|
||||
public:
|
||||
/// \brief Construct an empty nested-name-specifier.
|
||||
NestedNameSpecifierLoc() : Qualifier(nullptr), Data(nullptr) { }
|
||||
NestedNameSpecifierLoc() = default;
|
||||
|
||||
/// \brief Construct a nested-name-specifier with source location information
|
||||
/// from
|
||||
NestedNameSpecifierLoc(NestedNameSpecifier *Qualifier, void *Data)
|
||||
: Qualifier(Qualifier), Data(Data) { }
|
||||
: Qualifier(Qualifier), Data(Data) {}
|
||||
|
||||
/// \brief Evalutes true when this nested-name-specifier location is
|
||||
/// non-empty.
|
||||
|
@ -339,7 +345,7 @@ public:
|
|||
class NestedNameSpecifierLocBuilder {
|
||||
/// \brief The current representation of the nested-name-specifier we're
|
||||
/// building.
|
||||
NestedNameSpecifier *Representation;
|
||||
NestedNameSpecifier *Representation = nullptr;
|
||||
|
||||
/// \brief Buffer used to store source-location information for the
|
||||
/// nested-name-specifier.
|
||||
|
@ -347,21 +353,18 @@ class NestedNameSpecifierLocBuilder {
|
|||
/// Note that we explicitly manage the buffer (rather than using a
|
||||
/// SmallVector) because \c Declarator expects it to be possible to memcpy()
|
||||
/// a \c CXXScopeSpec, and CXXScopeSpec uses a NestedNameSpecifierLocBuilder.
|
||||
char *Buffer;
|
||||
char *Buffer = nullptr;
|
||||
|
||||
/// \brief The size of the buffer used to store source-location information
|
||||
/// for the nested-name-specifier.
|
||||
unsigned BufferSize;
|
||||
unsigned BufferSize = 0;
|
||||
|
||||
/// \brief The capacity of the buffer used to store source-location
|
||||
/// information for the nested-name-specifier.
|
||||
unsigned BufferCapacity;
|
||||
unsigned BufferCapacity = 0;
|
||||
|
||||
public:
|
||||
NestedNameSpecifierLocBuilder()
|
||||
: Representation(nullptr), Buffer(nullptr), BufferSize(0),
|
||||
BufferCapacity(0) {}
|
||||
|
||||
NestedNameSpecifierLocBuilder() = default;
|
||||
NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other);
|
||||
|
||||
NestedNameSpecifierLocBuilder &
|
||||
|
@ -451,6 +454,7 @@ public:
|
|||
/// \param ColonColonLoc The location of the trailing '::'.
|
||||
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD,
|
||||
SourceLocation SuperLoc, SourceLocation ColonColonLoc);
|
||||
|
||||
/// \brief Make a new nested-name-specifier from incomplete source-location
|
||||
/// information.
|
||||
///
|
||||
|
@ -511,6 +515,6 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
|
|||
return DB;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- StmtIterator.h - Iterators for Statements --------------*- C++ -*-===//
|
||||
//===- StmtIterator.h - Iterators for Statements ----------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -14,31 +14,38 @@
|
|||
#ifndef LLVM_CLANG_AST_STMTITERATOR_H
|
||||
#define LLVM_CLANG_AST_STMTITERATOR_H
|
||||
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class Stmt;
|
||||
class Decl;
|
||||
class Stmt;
|
||||
class VariableArrayType;
|
||||
|
||||
class StmtIteratorBase {
|
||||
protected:
|
||||
enum { StmtMode = 0x0, SizeOfTypeVAMode = 0x1, DeclGroupMode = 0x2,
|
||||
Flags = 0x3 };
|
||||
enum {
|
||||
StmtMode = 0x0,
|
||||
SizeOfTypeVAMode = 0x1,
|
||||
DeclGroupMode = 0x2,
|
||||
Flags = 0x3
|
||||
};
|
||||
|
||||
union {
|
||||
Stmt **stmt;
|
||||
Decl **DGI;
|
||||
};
|
||||
uintptr_t RawVAPtr;
|
||||
uintptr_t RawVAPtr = 0;
|
||||
Decl **DGE;
|
||||
|
||||
StmtIteratorBase(Stmt **s) : stmt(s) {}
|
||||
StmtIteratorBase(const VariableArrayType *t);
|
||||
StmtIteratorBase(Decl **dgi, Decl **dge);
|
||||
StmtIteratorBase() : stmt(nullptr) {}
|
||||
|
||||
bool inDeclGroup() const {
|
||||
return (RawVAPtr & Flags) == DeclGroupMode;
|
||||
}
|
||||
|
@ -56,7 +63,7 @@ protected:
|
|||
}
|
||||
|
||||
void setVAPtr(const VariableArrayType *P) {
|
||||
assert (inDeclGroup() || inSizeOfTypeVA());
|
||||
assert(inDeclGroup() || inSizeOfTypeVA());
|
||||
RawVAPtr = reinterpret_cast<uintptr_t>(P) | (RawVAPtr & Flags);
|
||||
}
|
||||
|
||||
|
@ -65,14 +72,8 @@ protected:
|
|||
void NextVA();
|
||||
|
||||
Stmt*& GetDeclExpr() const;
|
||||
|
||||
StmtIteratorBase(Stmt **s) : stmt(s), RawVAPtr(0) {}
|
||||
StmtIteratorBase(const VariableArrayType *t);
|
||||
StmtIteratorBase(Decl **dgi, Decl **dge);
|
||||
StmtIteratorBase() : stmt(nullptr), RawVAPtr(0) {}
|
||||
};
|
||||
|
||||
|
||||
template <typename DERIVED, typename REFERENCE>
|
||||
class StmtIteratorImpl : public StmtIteratorBase,
|
||||
public std::iterator<std::forward_iterator_tag,
|
||||
|
@ -80,8 +81,9 @@ class StmtIteratorImpl : public StmtIteratorBase,
|
|||
REFERENCE, REFERENCE> {
|
||||
protected:
|
||||
StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {}
|
||||
|
||||
public:
|
||||
StmtIteratorImpl() {}
|
||||
StmtIteratorImpl() = default;
|
||||
StmtIteratorImpl(Stmt **s) : StmtIteratorBase(s) {}
|
||||
StmtIteratorImpl(Decl **dgi, Decl **dge) : StmtIteratorBase(dgi, dge) {}
|
||||
StmtIteratorImpl(const VariableArrayType *t) : StmtIteratorBase(t) {}
|
||||
|
@ -120,16 +122,13 @@ public:
|
|||
|
||||
struct ConstStmtIterator;
|
||||
|
||||
struct StmtIterator : public StmtIteratorImpl<StmtIterator,Stmt*&> {
|
||||
explicit StmtIterator() : StmtIteratorImpl<StmtIterator,Stmt*&>() {}
|
||||
|
||||
StmtIterator(Stmt** S) : StmtIteratorImpl<StmtIterator,Stmt*&>(S) {}
|
||||
|
||||
struct StmtIterator : public StmtIteratorImpl<StmtIterator, Stmt*&> {
|
||||
explicit StmtIterator() = default;
|
||||
StmtIterator(Stmt** S) : StmtIteratorImpl<StmtIterator, Stmt*&>(S) {}
|
||||
StmtIterator(Decl** dgi, Decl** dge)
|
||||
: StmtIteratorImpl<StmtIterator,Stmt*&>(dgi, dge) {}
|
||||
|
||||
: StmtIteratorImpl<StmtIterator, Stmt*&>(dgi, dge) {}
|
||||
StmtIterator(const VariableArrayType *t)
|
||||
: StmtIteratorImpl<StmtIterator,Stmt*&>(t) {}
|
||||
: StmtIteratorImpl<StmtIterator, Stmt*&>(t) {}
|
||||
|
||||
private:
|
||||
StmtIterator(const StmtIteratorBase &RHS)
|
||||
|
@ -141,11 +140,9 @@ private:
|
|||
|
||||
struct ConstStmtIterator : public StmtIteratorImpl<ConstStmtIterator,
|
||||
const Stmt*> {
|
||||
explicit ConstStmtIterator() :
|
||||
StmtIteratorImpl<ConstStmtIterator,const Stmt*>() {}
|
||||
|
||||
ConstStmtIterator(const StmtIterator& RHS) :
|
||||
StmtIteratorImpl<ConstStmtIterator,const Stmt*>(RHS) {}
|
||||
explicit ConstStmtIterator() = default;
|
||||
ConstStmtIterator(const StmtIterator& RHS)
|
||||
: StmtIteratorImpl<ConstStmtIterator, const Stmt*>(RHS) {}
|
||||
|
||||
ConstStmtIterator(Stmt * const *S)
|
||||
: StmtIteratorImpl<ConstStmtIterator, const Stmt *>(
|
||||
|
@ -155,6 +152,7 @@ struct ConstStmtIterator : public StmtIteratorImpl<ConstStmtIterator,
|
|||
inline StmtIterator cast_away_const(const ConstStmtIterator &RHS) {
|
||||
return RHS;
|
||||
}
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_AST_STMTITERATOR_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===-- TemplateBase.h - Core classes for C++ templates ---------*- C++ -*-===//
|
||||
//===- TemplateBase.h - Core classes for C++ templates ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -15,21 +15,32 @@
|
|||
#ifndef LLVM_CLANG_AST_TEMPLATEBASE_H
|
||||
#define LLVM_CLANG_AST_TEMPLATEBASE_H
|
||||
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/APInt.h"
|
||||
#include "llvm/ADT/APSInt.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/None.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/TrailingObjects.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace llvm {
|
||||
class FoldingSetNodeID;
|
||||
}
|
||||
|
||||
class FoldingSetNodeID;
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
namespace clang {
|
||||
|
||||
class ASTContext;
|
||||
class DiagnosticBuilder;
|
||||
class Expr;
|
||||
struct PrintingPolicy;
|
||||
|
@ -44,29 +55,37 @@ public:
|
|||
/// \brief Represents an empty template argument, e.g., one that has not
|
||||
/// been deduced.
|
||||
Null = 0,
|
||||
|
||||
/// The template argument is a type.
|
||||
Type,
|
||||
|
||||
/// The template argument is a declaration that was provided for a pointer,
|
||||
/// reference, or pointer to member non-type template parameter.
|
||||
Declaration,
|
||||
|
||||
/// The template argument is a null pointer or null pointer to member that
|
||||
/// was provided for a non-type template parameter.
|
||||
NullPtr,
|
||||
|
||||
/// The template argument is an integral value stored in an llvm::APSInt
|
||||
/// that was provided for an integral non-type template parameter.
|
||||
Integral,
|
||||
|
||||
/// The template argument is a template name that was provided for a
|
||||
/// template template parameter.
|
||||
Template,
|
||||
|
||||
/// The template argument is a pack expansion of a template name that was
|
||||
/// provided for a template template parameter.
|
||||
TemplateExpansion,
|
||||
|
||||
/// The template argument is an expression, and we've not resolved it to one
|
||||
/// of the other forms yet, either because it's dependent or because we're
|
||||
/// representing a non-canonical template argument (for instance, in a
|
||||
/// TemplateSpecializationType). Also used to represent a non-dependent
|
||||
/// __uuidof expression (a Microsoft extension).
|
||||
Expression,
|
||||
|
||||
/// The template argument is actually a parameter pack. Arguments are stored
|
||||
/// in the Args struct.
|
||||
Pack
|
||||
|
@ -88,8 +107,11 @@ private:
|
|||
unsigned BitWidth : 31;
|
||||
unsigned IsUnsigned : 1;
|
||||
union {
|
||||
uint64_t VAL; ///< Used to store the <= 64 bits integer value.
|
||||
const uint64_t *pVal; ///< Used to store the >64 bits integer value.
|
||||
/// Used to store the <= 64 bits integer value.
|
||||
uint64_t VAL;
|
||||
|
||||
/// Used to store the >64 bits integer value.
|
||||
const uint64_t *pVal;
|
||||
};
|
||||
void *Type;
|
||||
};
|
||||
|
@ -115,8 +137,6 @@ private:
|
|||
struct TV TypeOrValue;
|
||||
};
|
||||
|
||||
TemplateArgument(TemplateName, bool) = delete;
|
||||
|
||||
public:
|
||||
/// \brief Construct an empty, invalid template argument.
|
||||
constexpr TemplateArgument() : TypeOrValue({Null, 0}) {}
|
||||
|
@ -202,6 +222,8 @@ public:
|
|||
this->Args.NumArgs = Args.size();
|
||||
}
|
||||
|
||||
TemplateArgument(TemplateName, bool) = delete;
|
||||
|
||||
static TemplateArgument getEmptyPack() { return TemplateArgument(None); }
|
||||
|
||||
/// \brief Create a new template argument pack by copying the given set of
|
||||
|
@ -278,7 +300,9 @@ public:
|
|||
// FIXME: Provide a way to read the integral data without copying the value.
|
||||
llvm::APSInt getAsIntegral() const {
|
||||
assert(getKind() == Integral && "Unexpected kind");
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
if (Integer.BitWidth <= 64)
|
||||
return APSInt(APInt(Integer.BitWidth, Integer.VAL), Integer.IsUnsigned);
|
||||
|
||||
|
@ -309,7 +333,7 @@ public:
|
|||
}
|
||||
|
||||
/// \brief Iterator that traverses the elements of a template argument pack.
|
||||
typedef const TemplateArgument * pack_iterator;
|
||||
using pack_iterator = const TemplateArgument *;
|
||||
|
||||
/// \brief Iterator referencing the first argument of a template argument
|
||||
/// pack.
|
||||
|
@ -368,7 +392,6 @@ public:
|
|||
/// Location information for a TemplateArgument.
|
||||
struct TemplateArgumentLocInfo {
|
||||
private:
|
||||
|
||||
struct T {
|
||||
// FIXME: We'd like to just use the qualifier in the TemplateName,
|
||||
// but template arguments get canonicalized too quickly.
|
||||
|
@ -393,8 +416,7 @@ public:
|
|||
|
||||
TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc,
|
||||
SourceLocation TemplateNameLoc,
|
||||
SourceLocation EllipsisLoc)
|
||||
{
|
||||
SourceLocation EllipsisLoc) {
|
||||
Template.Qualifier = QualifierLoc.getNestedNameSpecifier();
|
||||
Template.QualifierLocData = QualifierLoc.getOpaqueData();
|
||||
Template.TemplateNameLoc = TemplateNameLoc.getRawEncoding();
|
||||
|
@ -434,16 +456,15 @@ public:
|
|||
|
||||
TemplateArgumentLoc(const TemplateArgument &Argument,
|
||||
TemplateArgumentLocInfo Opaque)
|
||||
: Argument(Argument), LocInfo(Opaque) {
|
||||
}
|
||||
: Argument(Argument), LocInfo(Opaque) {}
|
||||
|
||||
TemplateArgumentLoc(const TemplateArgument &Argument, TypeSourceInfo *TInfo)
|
||||
: Argument(Argument), LocInfo(TInfo) {
|
||||
: Argument(Argument), LocInfo(TInfo) {
|
||||
assert(Argument.getKind() == TemplateArgument::Type);
|
||||
}
|
||||
|
||||
TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E)
|
||||
: Argument(Argument), LocInfo(E) {
|
||||
: Argument(Argument), LocInfo(E) {
|
||||
assert(Argument.getKind() == TemplateArgument::Expression);
|
||||
}
|
||||
|
||||
|
@ -451,7 +472,8 @@ public:
|
|||
NestedNameSpecifierLoc QualifierLoc,
|
||||
SourceLocation TemplateNameLoc,
|
||||
SourceLocation EllipsisLoc = SourceLocation())
|
||||
: Argument(Argument), LocInfo(QualifierLoc, TemplateNameLoc, EllipsisLoc) {
|
||||
: Argument(Argument),
|
||||
LocInfo(QualifierLoc, TemplateNameLoc, EllipsisLoc) {
|
||||
assert(Argument.getKind() == TemplateArgument::Template ||
|
||||
Argument.getKind() == TemplateArgument::TemplateExpansion);
|
||||
}
|
||||
|
@ -526,16 +548,16 @@ class TemplateArgumentListInfo {
|
|||
SourceLocation LAngleLoc;
|
||||
SourceLocation RAngleLoc;
|
||||
|
||||
// This can leak if used in an AST node, use ASTTemplateArgumentListInfo
|
||||
// instead.
|
||||
void *operator new(size_t bytes, ASTContext &C) = delete;
|
||||
|
||||
public:
|
||||
TemplateArgumentListInfo() {}
|
||||
TemplateArgumentListInfo() = default;
|
||||
|
||||
TemplateArgumentListInfo(SourceLocation LAngleLoc,
|
||||
SourceLocation RAngleLoc)
|
||||
: LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {}
|
||||
: LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {}
|
||||
|
||||
// This can leak if used in an AST node, use ASTTemplateArgumentListInfo
|
||||
// instead.
|
||||
void *operator new(size_t bytes, ASTContext &C) = delete;
|
||||
|
||||
SourceLocation getLAngleLoc() const { return LAngleLoc; }
|
||||
SourceLocation getRAngleLoc() const { return RAngleLoc; }
|
||||
|
@ -574,8 +596,8 @@ struct ASTTemplateArgumentListInfo final
|
|||
: private llvm::TrailingObjects<ASTTemplateArgumentListInfo,
|
||||
TemplateArgumentLoc> {
|
||||
private:
|
||||
friend TrailingObjects;
|
||||
friend class ASTNodeImporter;
|
||||
friend TrailingObjects;
|
||||
|
||||
ASTTemplateArgumentListInfo(const TemplateArgumentListInfo &List);
|
||||
|
||||
|
@ -668,6 +690,6 @@ inline const TemplateArgument &
|
|||
return getArgs()[Idx];
|
||||
}
|
||||
|
||||
} // end namespace clang
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_TEMPLATEBASE_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- TemplateName.h - C++ Template Name Representation-------*- C++ -*-===//
|
||||
//===- TemplateName.h - C++ Template Name Representation --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -14,10 +14,12 @@
|
|||
#ifndef LLVM_CLANG_AST_TEMPLATENAME_H
|
||||
#define LLVM_CLANG_AST_TEMPLATENAME_H
|
||||
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/PointerUnion.h"
|
||||
#include "llvm/Support/PointerLikeTypeTraits.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace clang {
|
||||
|
||||
|
@ -94,7 +96,7 @@ class OverloadedTemplateStorage : public UncommonTemplateNameStorage {
|
|||
friend class ASTContext;
|
||||
|
||||
OverloadedTemplateStorage(unsigned size)
|
||||
: UncommonTemplateNameStorage(Overloaded, size) { }
|
||||
: UncommonTemplateNameStorage(Overloaded, size) {}
|
||||
|
||||
NamedDecl **getStorage() {
|
||||
return reinterpret_cast<NamedDecl **>(this + 1);
|
||||
|
@ -104,7 +106,7 @@ class OverloadedTemplateStorage : public UncommonTemplateNameStorage {
|
|||
}
|
||||
|
||||
public:
|
||||
typedef NamedDecl *const *iterator;
|
||||
using iterator = NamedDecl *const *;
|
||||
|
||||
iterator begin() const { return getStorage(); }
|
||||
iterator end() const { return getStorage() + size(); }
|
||||
|
@ -126,8 +128,8 @@ public:
|
|||
SubstTemplateTemplateParmPackStorage(TemplateTemplateParmDecl *Parameter,
|
||||
unsigned Size,
|
||||
const TemplateArgument *Arguments)
|
||||
: UncommonTemplateNameStorage(SubstTemplateTemplateParmPack, Size),
|
||||
Parameter(Parameter), Arguments(Arguments) { }
|
||||
: UncommonTemplateNameStorage(SubstTemplateTemplateParmPack, Size),
|
||||
Parameter(Parameter), Arguments(Arguments) {}
|
||||
|
||||
/// \brief Retrieve the template template parameter pack being substituted.
|
||||
TemplateTemplateParmDecl *getParameterPack() const {
|
||||
|
@ -174,10 +176,9 @@ public:
|
|||
/// specifier in the typedef. "apply" is a nested template, and can
|
||||
/// only be understood in the context of
|
||||
class TemplateName {
|
||||
typedef llvm::PointerUnion4<TemplateDecl *,
|
||||
UncommonTemplateNameStorage *,
|
||||
QualifiedTemplateName *,
|
||||
DependentTemplateName *> StorageType;
|
||||
using StorageType =
|
||||
llvm::PointerUnion4<TemplateDecl *, UncommonTemplateNameStorage *,
|
||||
QualifiedTemplateName *, DependentTemplateName *>;
|
||||
|
||||
StorageType Storage;
|
||||
|
||||
|
@ -188,24 +189,29 @@ public:
|
|||
enum NameKind {
|
||||
/// \brief A single template declaration.
|
||||
Template,
|
||||
|
||||
/// \brief A set of overloaded template declarations.
|
||||
OverloadedTemplate,
|
||||
|
||||
/// \brief A qualified template name, where the qualification is kept
|
||||
/// to describe the source code as written.
|
||||
QualifiedTemplate,
|
||||
|
||||
/// \brief A dependent template name that has not been resolved to a
|
||||
/// template (or set of templates).
|
||||
DependentTemplate,
|
||||
|
||||
/// \brief A template template parameter that has been substituted
|
||||
/// for some other template name.
|
||||
SubstTemplateTemplateParm,
|
||||
|
||||
/// \brief A template template parameter pack that has been substituted for
|
||||
/// a template template argument pack, but has not yet been expanded into
|
||||
/// individual arguments.
|
||||
SubstTemplateTemplateParmPack
|
||||
};
|
||||
|
||||
TemplateName() : Storage() { }
|
||||
TemplateName() = default;
|
||||
explicit TemplateName(TemplateDecl *Template);
|
||||
explicit TemplateName(OverloadedTemplateStorage *Storage);
|
||||
explicit TemplateName(SubstTemplateTemplateParmStorage *Storage);
|
||||
|
@ -325,8 +331,8 @@ class SubstTemplateTemplateParmStorage
|
|||
|
||||
SubstTemplateTemplateParmStorage(TemplateTemplateParmDecl *parameter,
|
||||
TemplateName replacement)
|
||||
: UncommonTemplateNameStorage(SubstTemplateTemplateParm, 0),
|
||||
Parameter(parameter), Replacement(replacement) {}
|
||||
: UncommonTemplateNameStorage(SubstTemplateTemplateParm, 0),
|
||||
Parameter(parameter), Replacement(replacement) {}
|
||||
|
||||
public:
|
||||
TemplateTemplateParmDecl *getParameter() const { return Parameter; }
|
||||
|
@ -358,6 +364,8 @@ inline TemplateName TemplateName::getUnderlying() const {
|
|||
/// manner, it is to TemplateName what ElaboratedType is to Type,
|
||||
/// providing extra syntactic sugar for downstream clients.
|
||||
class QualifiedTemplateName : public llvm::FoldingSetNode {
|
||||
friend class ASTContext;
|
||||
|
||||
/// \brief The nested name specifier that qualifies the template name.
|
||||
///
|
||||
/// The bit is used to indicate whether the "template" keyword was
|
||||
|
@ -371,12 +379,9 @@ class QualifiedTemplateName : public llvm::FoldingSetNode {
|
|||
/// that this qualified name refers to.
|
||||
TemplateDecl *Template;
|
||||
|
||||
friend class ASTContext;
|
||||
|
||||
QualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword,
|
||||
TemplateDecl *Template)
|
||||
: Qualifier(NNS, TemplateKeyword? 1 : 0),
|
||||
Template(Template) { }
|
||||
: Qualifier(NNS, TemplateKeyword? 1 : 0), Template(Template) {}
|
||||
|
||||
public:
|
||||
/// \brief Return the nested name specifier that qualifies this name.
|
||||
|
@ -415,6 +420,8 @@ public:
|
|||
/// where "MetaFun::" is the nested name specifier and "apply" is the
|
||||
/// template name referenced. The "template" keyword is implied.
|
||||
class DependentTemplateName : public llvm::FoldingSetNode {
|
||||
friend class ASTContext;
|
||||
|
||||
/// \brief The nested name specifier that qualifies the template
|
||||
/// name.
|
||||
///
|
||||
|
@ -444,29 +451,27 @@ class DependentTemplateName : public llvm::FoldingSetNode {
|
|||
/// canonical.
|
||||
TemplateName CanonicalTemplateName;
|
||||
|
||||
friend class ASTContext;
|
||||
|
||||
DependentTemplateName(NestedNameSpecifier *Qualifier,
|
||||
const IdentifierInfo *Identifier)
|
||||
: Qualifier(Qualifier, false), Identifier(Identifier),
|
||||
CanonicalTemplateName(this) { }
|
||||
: Qualifier(Qualifier, false), Identifier(Identifier),
|
||||
CanonicalTemplateName(this) {}
|
||||
|
||||
DependentTemplateName(NestedNameSpecifier *Qualifier,
|
||||
const IdentifierInfo *Identifier,
|
||||
TemplateName Canon)
|
||||
: Qualifier(Qualifier, false), Identifier(Identifier),
|
||||
CanonicalTemplateName(Canon) { }
|
||||
: Qualifier(Qualifier, false), Identifier(Identifier),
|
||||
CanonicalTemplateName(Canon) {}
|
||||
|
||||
DependentTemplateName(NestedNameSpecifier *Qualifier,
|
||||
OverloadedOperatorKind Operator)
|
||||
: Qualifier(Qualifier, true), Operator(Operator),
|
||||
CanonicalTemplateName(this) { }
|
||||
: Qualifier(Qualifier, true), Operator(Operator),
|
||||
CanonicalTemplateName(this) {}
|
||||
|
||||
DependentTemplateName(NestedNameSpecifier *Qualifier,
|
||||
OverloadedOperatorKind Operator,
|
||||
TemplateName Canon)
|
||||
: Qualifier(Qualifier, true), Operator(Operator),
|
||||
CanonicalTemplateName(Canon) { }
|
||||
: Qualifier(Qualifier, true), Operator(Operator),
|
||||
CanonicalTemplateName(Canon) {}
|
||||
|
||||
public:
|
||||
/// \brief Return the nested name specifier that qualifies this name.
|
||||
|
@ -514,7 +519,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // end namespace clang.
|
||||
} // namespace clang.
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -533,6 +538,6 @@ struct PointerLikeTypeTraits<clang::TemplateName> {
|
|||
enum { NumLowBitsAvailable = 0 };
|
||||
};
|
||||
|
||||
} // end namespace llvm.
|
||||
} // namespace llvm.
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_TEMPLATENAME_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===-- UnresolvedSet.h - Unresolved sets of declarations ------*- C++ -*-===//
|
||||
//===- UnresolvedSet.h - Unresolved sets of declarations --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -17,20 +17,25 @@
|
|||
|
||||
#include "clang/AST/DeclAccessPair.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class NamedDecl;
|
||||
|
||||
/// The iterator over UnresolvedSets. Serves as both the const and
|
||||
/// non-const iterator.
|
||||
class UnresolvedSetIterator : public llvm::iterator_adaptor_base<
|
||||
UnresolvedSetIterator, DeclAccessPair *,
|
||||
std::random_access_iterator_tag, NamedDecl *,
|
||||
std::ptrdiff_t, NamedDecl *, NamedDecl *> {
|
||||
friend class UnresolvedSetImpl;
|
||||
friend class ASTUnresolvedSet;
|
||||
friend class OverloadExpr;
|
||||
friend class UnresolvedSetImpl;
|
||||
|
||||
explicit UnresolvedSetIterator(DeclAccessPair *Iter)
|
||||
: iterator_adaptor_base(Iter) {}
|
||||
|
@ -54,12 +59,13 @@ public:
|
|||
|
||||
/// \brief A set of unresolved declarations.
|
||||
class UnresolvedSetImpl {
|
||||
typedef SmallVectorImpl<DeclAccessPair> DeclsTy;
|
||||
using DeclsTy = SmallVectorImpl<DeclAccessPair>;
|
||||
|
||||
// Don't allow direct construction, and only permit subclassing by
|
||||
// UnresolvedSet.
|
||||
private:
|
||||
template <unsigned N> friend class UnresolvedSet;
|
||||
|
||||
UnresolvedSetImpl() = default;
|
||||
UnresolvedSetImpl(const UnresolvedSetImpl &) = default;
|
||||
UnresolvedSetImpl &operator=(const UnresolvedSetImpl &) = default;
|
||||
|
@ -71,8 +77,8 @@ private:
|
|||
public:
|
||||
// We don't currently support assignment through this iterator, so we might
|
||||
// as well use the same implementation twice.
|
||||
typedef UnresolvedSetIterator iterator;
|
||||
typedef UnresolvedSetIterator const_iterator;
|
||||
using iterator = UnresolvedSetIterator;
|
||||
using const_iterator = UnresolvedSetIterator;
|
||||
|
||||
iterator begin() { return iterator(decls().begin()); }
|
||||
iterator end() { return iterator(decls().end()); }
|
||||
|
@ -140,7 +146,7 @@ template <unsigned InlineCapacity> class UnresolvedSet :
|
|||
SmallVector<DeclAccessPair, InlineCapacity> Decls;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_UNRESOLVEDSET_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===-- DeclarationName.cpp - Declaration names implementation --*- C++ -*-===//
|
||||
//===- DeclarationName.cpp - Declaration names implementation -------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -11,20 +11,36 @@
|
|||
// classes.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/DeclarationName.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/PrettyPrinter.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/AST/TypeOrdering.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/OperatorKinds.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
namespace clang {
|
||||
|
||||
/// CXXSpecialName - Records the type associated with one of the
|
||||
/// "special" kinds of declaration names in C++, e.g., constructors,
|
||||
/// destructors, and conversion functions.
|
||||
|
@ -89,6 +105,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace clang
|
||||
|
||||
static int compareInt(unsigned A, unsigned B) {
|
||||
return (A < B ? -1 : (A > B ? 1 : 0));
|
||||
}
|
||||
|
@ -197,10 +215,9 @@ void DeclarationName::print(raw_ostream &OS, const PrintingPolicy &Policy) {
|
|||
case DeclarationName::CXXConstructorName:
|
||||
return printCXXConstructorDestructorName(N.getCXXNameType(), OS, Policy);
|
||||
|
||||
case DeclarationName::CXXDestructorName: {
|
||||
case DeclarationName::CXXDestructorName:
|
||||
OS << '~';
|
||||
return printCXXConstructorDestructorName(N.getCXXNameType(), OS, Policy);
|
||||
}
|
||||
|
||||
case DeclarationName::CXXDeductionGuideName:
|
||||
OS << "<deduction guide for ";
|
||||
|
@ -250,13 +267,15 @@ void DeclarationName::print(raw_ostream &OS, const PrintingPolicy &Policy) {
|
|||
llvm_unreachable("Unexpected declaration name kind");
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
|
||||
raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
|
||||
LangOptions LO;
|
||||
N.print(OS, PrintingPolicy(LO));
|
||||
return OS;
|
||||
}
|
||||
|
||||
} // end namespace clang
|
||||
} // namespace clang
|
||||
|
||||
DeclarationName::NameKind DeclarationName::getNameKind() const {
|
||||
switch (getStoredNameKind()) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- NestedNameSpecifier.cpp - C++ nested name specifiers -----*- C++ -*-=//
|
||||
//===- NestedNameSpecifier.cpp - C++ nested name specifiers ---------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -11,16 +11,28 @@
|
|||
// a C++ nested-name-specifier.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/PrettyPrinter.h"
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "llvm/Support/AlignOf.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
|
@ -375,22 +387,20 @@ NestedNameSpecifierLoc::getDataLength(NestedNameSpecifier *Qualifier) {
|
|||
return Length;
|
||||
}
|
||||
|
||||
namespace {
|
||||
/// \brief Load a (possibly unaligned) source location from a given address
|
||||
/// and offset.
|
||||
SourceLocation LoadSourceLocation(void *Data, unsigned Offset) {
|
||||
unsigned Raw;
|
||||
memcpy(&Raw, static_cast<char *>(Data) + Offset, sizeof(unsigned));
|
||||
return SourceLocation::getFromRawEncoding(Raw);
|
||||
}
|
||||
/// \brief Load a (possibly unaligned) source location from a given address
|
||||
/// and offset.
|
||||
static SourceLocation LoadSourceLocation(void *Data, unsigned Offset) {
|
||||
unsigned Raw;
|
||||
memcpy(&Raw, static_cast<char *>(Data) + Offset, sizeof(unsigned));
|
||||
return SourceLocation::getFromRawEncoding(Raw);
|
||||
}
|
||||
|
||||
/// \brief Load a (possibly unaligned) pointer from a given address and
|
||||
/// offset.
|
||||
void *LoadPointer(void *Data, unsigned Offset) {
|
||||
void *Result;
|
||||
memcpy(&Result, static_cast<char *>(Data) + Offset, sizeof(void*));
|
||||
return Result;
|
||||
}
|
||||
/// \brief Load a (possibly unaligned) pointer from a given address and
|
||||
/// offset.
|
||||
static void *LoadPointer(void *Data, unsigned Offset) {
|
||||
void *Result;
|
||||
memcpy(&Result, static_cast<char *>(Data) + Offset, sizeof(void*));
|
||||
return Result;
|
||||
}
|
||||
|
||||
SourceRange NestedNameSpecifierLoc::getSourceRange() const {
|
||||
|
@ -446,53 +456,49 @@ TypeLoc NestedNameSpecifierLoc::getTypeLoc() const {
|
|||
return TypeLoc(Qualifier->getAsType(), TypeData);
|
||||
}
|
||||
|
||||
namespace {
|
||||
void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize,
|
||||
static void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize,
|
||||
unsigned &BufferCapacity) {
|
||||
if (Start == End)
|
||||
return;
|
||||
if (Start == End)
|
||||
return;
|
||||
|
||||
if (BufferSize + (End - Start) > BufferCapacity) {
|
||||
// Reallocate the buffer.
|
||||
unsigned NewCapacity = std::max(
|
||||
(unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2),
|
||||
(unsigned)(BufferSize + (End - Start)));
|
||||
char *NewBuffer = static_cast<char *>(malloc(NewCapacity));
|
||||
if (BufferCapacity) {
|
||||
memcpy(NewBuffer, Buffer, BufferSize);
|
||||
free(Buffer);
|
||||
}
|
||||
Buffer = NewBuffer;
|
||||
BufferCapacity = NewCapacity;
|
||||
if (BufferSize + (End - Start) > BufferCapacity) {
|
||||
// Reallocate the buffer.
|
||||
unsigned NewCapacity = std::max(
|
||||
(unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2),
|
||||
(unsigned)(BufferSize + (End - Start)));
|
||||
char *NewBuffer = static_cast<char *>(malloc(NewCapacity));
|
||||
if (BufferCapacity) {
|
||||
memcpy(NewBuffer, Buffer, BufferSize);
|
||||
free(Buffer);
|
||||
}
|
||||
|
||||
memcpy(Buffer + BufferSize, Start, End - Start);
|
||||
BufferSize += End-Start;
|
||||
Buffer = NewBuffer;
|
||||
BufferCapacity = NewCapacity;
|
||||
}
|
||||
|
||||
memcpy(Buffer + BufferSize, Start, End - Start);
|
||||
BufferSize += End-Start;
|
||||
}
|
||||
|
||||
/// \brief Save a source location to the given buffer.
|
||||
void SaveSourceLocation(SourceLocation Loc, char *&Buffer,
|
||||
unsigned &BufferSize, unsigned &BufferCapacity) {
|
||||
unsigned Raw = Loc.getRawEncoding();
|
||||
Append(reinterpret_cast<char *>(&Raw),
|
||||
reinterpret_cast<char *>(&Raw) + sizeof(unsigned),
|
||||
Buffer, BufferSize, BufferCapacity);
|
||||
}
|
||||
/// \brief Save a source location to the given buffer.
|
||||
static void SaveSourceLocation(SourceLocation Loc, char *&Buffer,
|
||||
unsigned &BufferSize, unsigned &BufferCapacity) {
|
||||
unsigned Raw = Loc.getRawEncoding();
|
||||
Append(reinterpret_cast<char *>(&Raw),
|
||||
reinterpret_cast<char *>(&Raw) + sizeof(unsigned),
|
||||
Buffer, BufferSize, BufferCapacity);
|
||||
}
|
||||
|
||||
/// \brief Save a pointer to the given buffer.
|
||||
void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize,
|
||||
unsigned &BufferCapacity) {
|
||||
Append(reinterpret_cast<char *>(&Ptr),
|
||||
reinterpret_cast<char *>(&Ptr) + sizeof(void *),
|
||||
Buffer, BufferSize, BufferCapacity);
|
||||
}
|
||||
/// \brief Save a pointer to the given buffer.
|
||||
static void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize,
|
||||
unsigned &BufferCapacity) {
|
||||
Append(reinterpret_cast<char *>(&Ptr),
|
||||
reinterpret_cast<char *>(&Ptr) + sizeof(void *),
|
||||
Buffer, BufferSize, BufferCapacity);
|
||||
}
|
||||
|
||||
NestedNameSpecifierLocBuilder::
|
||||
NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
|
||||
: Representation(Other.Representation), Buffer(nullptr),
|
||||
BufferSize(0), BufferCapacity(0)
|
||||
{
|
||||
: Representation(Other.Representation) {
|
||||
if (!Other.Buffer)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- StmtIterator.cpp - Iterators for Statements ------------------------===//
|
||||
//===- StmtIterator.cpp - Iterators for Statements ------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -13,6 +13,11 @@
|
|||
|
||||
#include "clang/AST/StmtIterator.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
|
@ -31,7 +36,7 @@ static inline const VariableArrayType *FindVA(const Type* t) {
|
|||
}
|
||||
|
||||
void StmtIteratorBase::NextVA() {
|
||||
assert (getVAPtr());
|
||||
assert(getVAPtr());
|
||||
|
||||
const VariableArrayType *p = getVAPtr();
|
||||
p = FindVA(p->getElementType().getTypePtr());
|
||||
|
@ -93,22 +98,22 @@ bool StmtIteratorBase::HandleDecl(Decl* D) {
|
|||
}
|
||||
|
||||
StmtIteratorBase::StmtIteratorBase(Decl** dgi, Decl** dge)
|
||||
: DGI(dgi), RawVAPtr(DeclGroupMode), DGE(dge) {
|
||||
: DGI(dgi), RawVAPtr(DeclGroupMode), DGE(dge) {
|
||||
NextDecl(false);
|
||||
}
|
||||
|
||||
StmtIteratorBase::StmtIteratorBase(const VariableArrayType* t)
|
||||
: DGI(nullptr), RawVAPtr(SizeOfTypeVAMode) {
|
||||
: DGI(nullptr), RawVAPtr(SizeOfTypeVAMode) {
|
||||
RawVAPtr |= reinterpret_cast<uintptr_t>(t);
|
||||
}
|
||||
|
||||
Stmt*& StmtIteratorBase::GetDeclExpr() const {
|
||||
if (const VariableArrayType* VAPtr = getVAPtr()) {
|
||||
assert (VAPtr->SizeExpr);
|
||||
assert(VAPtr->SizeExpr);
|
||||
return const_cast<Stmt*&>(VAPtr->SizeExpr);
|
||||
}
|
||||
|
||||
assert (inDeclGroup());
|
||||
assert(inDeclGroup());
|
||||
VarDecl* VD = cast<VarDecl>(*DGI);
|
||||
return *VD->getInitAddress();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- TemplateBase.cpp - Common template AST class implementation ------===//
|
||||
//===- TemplateBase.cpp - Common template AST class implementation --------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -14,17 +14,32 @@
|
|||
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/ExprCXX.h"
|
||||
#include "clang/AST/PrettyPrinter.h"
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/APSInt.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/None.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
|
@ -37,7 +52,7 @@ using namespace clang;
|
|||
/// \param Policy the printing policy for EnumConstantDecl printing.
|
||||
static void printIntegral(const TemplateArgument &TemplArg,
|
||||
raw_ostream &Out, const PrintingPolicy& Policy) {
|
||||
const ::clang::Type *T = TemplArg.getIntegralType().getTypePtr();
|
||||
const Type *T = TemplArg.getIntegralType().getTypePtr();
|
||||
const llvm::APSInt &Val = TemplArg.getAsIntegral();
|
||||
|
||||
if (const EnumType *ET = T->getAs<EnumType>()) {
|
||||
|
@ -415,10 +430,9 @@ void TemplateArgument::print(const PrintingPolicy &Policy,
|
|||
Out << "...";
|
||||
break;
|
||||
|
||||
case Integral: {
|
||||
case Integral:
|
||||
printIntegral(*this, Out, Policy);
|
||||
break;
|
||||
}
|
||||
|
||||
case Expression:
|
||||
getAsExpr()->printPretty(Out, nullptr, Policy);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- TemplateName.cpp - C++ Template Name Representation---------------===//
|
||||
//===- TemplateName.cpp - C++ Template Name Representation ----------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -12,15 +12,24 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/PrettyPrinter.h"
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/OperatorKinds.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
using namespace clang;
|
||||
using namespace llvm;
|
||||
|
||||
TemplateArgument
|
||||
SubstTemplateTemplateParmPackStorage::getArgumentPack() const {
|
||||
|
@ -226,7 +235,7 @@ TemplateName::print(raw_ostream &OS, const PrintingPolicy &Policy,
|
|||
const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
|
||||
TemplateName N) {
|
||||
std::string NameStr;
|
||||
raw_string_ostream OS(NameStr);
|
||||
llvm::raw_string_ostream OS(NameStr);
|
||||
LangOptions LO;
|
||||
LO.CPlusPlus = true;
|
||||
LO.Bool = true;
|
||||
|
|
Loading…
Reference in New Issue