forked from OSchip/llvm-project
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317854
This commit is contained in:
parent
a73960213e
commit
8998f10e55
|
@ -1,4 +1,4 @@
|
||||||
//===-- ASTUnresolvedSet.h - Unresolved sets of declarations ---*- C++ -*-===//
|
//===- ASTUnresolvedSet.h - Unresolved sets of declarations -----*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -16,14 +16,22 @@
|
||||||
#define LLVM_CLANG_AST_ASTUNRESOLVEDSET_H
|
#define LLVM_CLANG_AST_ASTUNRESOLVEDSET_H
|
||||||
|
|
||||||
#include "clang/AST/ASTVector.h"
|
#include "clang/AST/ASTVector.h"
|
||||||
|
#include "clang/AST/DeclAccessPair.h"
|
||||||
#include "clang/AST/UnresolvedSet.h"
|
#include "clang/AST/UnresolvedSet.h"
|
||||||
|
#include "clang/Basic/Specifiers.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
|
class NamedDecl;
|
||||||
|
|
||||||
/// \brief An UnresolvedSet-like class which uses the ASTContext's allocator.
|
/// \brief An UnresolvedSet-like class which uses the ASTContext's allocator.
|
||||||
class ASTUnresolvedSet {
|
class ASTUnresolvedSet {
|
||||||
|
friend class LazyASTUnresolvedSet;
|
||||||
|
|
||||||
struct DeclsTy : ASTVector<DeclAccessPair> {
|
struct DeclsTy : ASTVector<DeclAccessPair> {
|
||||||
DeclsTy() {}
|
DeclsTy() = default;
|
||||||
DeclsTy(ASTContext &C, unsigned N) : ASTVector<DeclAccessPair>(C, N) {}
|
DeclsTy(ASTContext &C, unsigned N) : ASTVector<DeclAccessPair>(C, N) {}
|
||||||
|
|
||||||
bool isLazy() const { return getTag(); }
|
bool isLazy() const { return getTag(); }
|
||||||
|
@ -32,14 +40,12 @@ class ASTUnresolvedSet {
|
||||||
|
|
||||||
DeclsTy Decls;
|
DeclsTy Decls;
|
||||||
|
|
||||||
friend class LazyASTUnresolvedSet;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ASTUnresolvedSet() {}
|
ASTUnresolvedSet() = default;
|
||||||
ASTUnresolvedSet(ASTContext &C, unsigned N) : Decls(C, N) {}
|
ASTUnresolvedSet(ASTContext &C, unsigned N) : Decls(C, N) {}
|
||||||
|
|
||||||
typedef UnresolvedSetIterator iterator;
|
using iterator = UnresolvedSetIterator;
|
||||||
typedef UnresolvedSetIterator const_iterator;
|
using const_iterator = UnresolvedSetIterator;
|
||||||
|
|
||||||
iterator begin() { return iterator(Decls.begin()); }
|
iterator begin() { return iterator(Decls.begin()); }
|
||||||
iterator end() { return iterator(Decls.end()); }
|
iterator end() { return iterator(Decls.end()); }
|
||||||
|
@ -98,13 +104,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void reserve(ASTContext &C, unsigned N) { Impl.reserve(C, N); }
|
void reserve(ASTContext &C, unsigned N) { Impl.reserve(C, N); }
|
||||||
|
|
||||||
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS) {
|
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS) {
|
||||||
assert(Impl.empty() || Impl.Decls.isLazy());
|
assert(Impl.empty() || Impl.Decls.isLazy());
|
||||||
Impl.Decls.setLazy(true);
|
Impl.Decls.setLazy(true);
|
||||||
Impl.addDecl(C, reinterpret_cast<NamedDecl*>(ID << 2), AS);
|
Impl.addDecl(C, reinterpret_cast<NamedDecl *>(ID << 2), AS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_ASTUNRESOLVEDSET_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===- ASTVector.h - Vector that uses ASTContext for allocation --*- C++ -*-=//
|
//===- ASTVector.h - Vector that uses ASTContext for allocation ---*- C++ -*-=//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -18,22 +18,26 @@
|
||||||
#ifndef LLVM_CLANG_AST_ASTVECTOR_H
|
#ifndef LLVM_CLANG_AST_ASTVECTOR_H
|
||||||
#define LLVM_CLANG_AST_ASTVECTOR_H
|
#define LLVM_CLANG_AST_ASTVECTOR_H
|
||||||
|
|
||||||
#include "clang/AST/AttrIterator.h"
|
|
||||||
#include "llvm/ADT/PointerIntPair.h"
|
#include "llvm/ADT/PointerIntPair.h"
|
||||||
#include "llvm/Support/type_traits.h"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class ASTContext;
|
|
||||||
|
class ASTContext;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ASTVector {
|
class ASTVector {
|
||||||
private:
|
private:
|
||||||
T *Begin, *End;
|
T *Begin = nullptr;
|
||||||
llvm::PointerIntPair<T*, 1, bool> Capacity;
|
T *End = nullptr;
|
||||||
|
llvm::PointerIntPair<T *, 1, bool> Capacity;
|
||||||
|
|
||||||
void setEnd(T *P) { this->End = P; }
|
void setEnd(T *P) { this->End = P; }
|
||||||
|
|
||||||
|
@ -45,7 +49,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Default ctor - Initialize to empty.
|
// Default ctor - Initialize to empty.
|
||||||
ASTVector() : Begin(nullptr), End(nullptr), Capacity(nullptr, false) {}
|
ASTVector() : Capacity(nullptr, false) {}
|
||||||
|
|
||||||
ASTVector(ASTVector &&O) : Begin(O.Begin), End(O.End), Capacity(O.Capacity) {
|
ASTVector(ASTVector &&O) : Begin(O.Begin), End(O.End), Capacity(O.Capacity) {
|
||||||
O.Begin = O.End = nullptr;
|
O.Begin = O.End = nullptr;
|
||||||
|
@ -53,14 +57,15 @@ public:
|
||||||
O.Capacity.setInt(false);
|
O.Capacity.setInt(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTVector(const ASTContext &C, unsigned N)
|
ASTVector(const ASTContext &C, unsigned N) : Capacity(nullptr, false) {
|
||||||
: Begin(nullptr), End(nullptr), Capacity(nullptr, false) {
|
|
||||||
reserve(C, N);
|
reserve(C, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTVector &operator=(ASTVector &&RHS) {
|
ASTVector &operator=(ASTVector &&RHS) {
|
||||||
ASTVector O(std::move(RHS));
|
ASTVector O(std::move(RHS));
|
||||||
|
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
swap(Begin, O.Begin);
|
swap(Begin, O.Begin);
|
||||||
swap(End, O.End);
|
swap(End, O.End);
|
||||||
swap(Capacity, O.Capacity);
|
swap(Capacity, O.Capacity);
|
||||||
|
@ -74,19 +79,19 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef size_t size_type;
|
using size_type = size_t;
|
||||||
typedef ptrdiff_t difference_type;
|
using difference_type = ptrdiff_t;
|
||||||
typedef T value_type;
|
using value_type = T;
|
||||||
typedef T* iterator;
|
using iterator = T *;
|
||||||
typedef const T* const_iterator;
|
using const_iterator = const T *;
|
||||||
|
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
|
||||||
typedef T& reference;
|
using reference = T &;
|
||||||
typedef const T& const_reference;
|
using const_reference = const T &;
|
||||||
typedef T* pointer;
|
using pointer = T *;
|
||||||
typedef const T* const_pointer;
|
using const_pointer = const T *;
|
||||||
|
|
||||||
// forward iterator creation methods.
|
// forward iterator creation methods.
|
||||||
iterator begin() { return Begin; }
|
iterator begin() { return Begin; }
|
||||||
|
@ -175,7 +180,6 @@ public:
|
||||||
size_t capacity() const { return this->capacity_ptr() - Begin; }
|
size_t capacity() const { return this->capacity_ptr() - Begin; }
|
||||||
|
|
||||||
/// append - Add the specified range to the end of the SmallVector.
|
/// append - Add the specified range to the end of the SmallVector.
|
||||||
///
|
|
||||||
template<typename in_iter>
|
template<typename in_iter>
|
||||||
void append(const ASTContext &C, in_iter in_start, in_iter in_end) {
|
void append(const ASTContext &C, in_iter in_start, in_iter in_end) {
|
||||||
size_type NumInputs = std::distance(in_start, in_end);
|
size_type NumInputs = std::distance(in_start, in_end);
|
||||||
|
@ -195,7 +199,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// append - Add the specified range to the end of the SmallVector.
|
/// append - Add the specified range to the end of the SmallVector.
|
||||||
///
|
|
||||||
void append(const ASTContext &C, size_type NumInputs, const T &Elt) {
|
void append(const ASTContext &C, size_type NumInputs, const T &Elt) {
|
||||||
// Grow allocated space if needed.
|
// Grow allocated space if needed.
|
||||||
if (NumInputs > size_type(this->capacity_ptr()-this->end()))
|
if (NumInputs > size_type(this->capacity_ptr()-this->end()))
|
||||||
|
@ -368,6 +371,7 @@ protected:
|
||||||
const_iterator capacity_ptr() const {
|
const_iterator capacity_ptr() const {
|
||||||
return (iterator) Capacity.getPointer();
|
return (iterator) Capacity.getPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator capacity_ptr() { return (iterator)Capacity.getPointer(); }
|
iterator capacity_ptr() { return (iterator)Capacity.getPointer(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -401,5 +405,6 @@ void ASTVector<T>::grow(const ASTContext &C, size_t MinSize) {
|
||||||
Capacity.setPointer(Begin+NewCapacity);
|
Capacity.setPointer(Begin+NewCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end: clang namespace
|
} // namespace clang
|
||||||
#endif
|
|
||||||
|
#endif // LLVM_CLANG_AST_ASTVECTOR_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- AttrIterator.h - Classes for attribute iteration -------*- C++ -*-===//
|
//===- AttrIterator.h - Classes for attribute iteration ---------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -15,16 +15,23 @@
|
||||||
#define LLVM_CLANG_AST_ATTRITERATOR_H
|
#define LLVM_CLANG_AST_ATTRITERATOR_H
|
||||||
|
|
||||||
#include "clang/Basic/LLVM.h"
|
#include "clang/Basic/LLVM.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/Support/Casting.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class ASTContext;
|
|
||||||
class Attr;
|
class ASTContext;
|
||||||
}
|
class Attr;
|
||||||
|
|
||||||
|
} // namespace clang
|
||||||
|
|
||||||
// Defined in ASTContext.h
|
// Defined in ASTContext.h
|
||||||
void *operator new(size_t Bytes, const clang::ASTContext &C,
|
void *operator new(size_t Bytes, const clang::ASTContext &C,
|
||||||
size_t Alignment = 8);
|
size_t Alignment = 8);
|
||||||
|
|
||||||
// FIXME: Being forced to not have a default argument here due to redeclaration
|
// FIXME: Being forced to not have a default argument here due to redeclaration
|
||||||
// rules on default arguments sucks
|
// rules on default arguments sucks
|
||||||
void *operator new[](size_t Bytes, const clang::ASTContext &C,
|
void *operator new[](size_t Bytes, const clang::ASTContext &C,
|
||||||
|
@ -39,13 +46,13 @@ void operator delete[](void *Ptr, const clang::ASTContext &C, size_t);
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
/// AttrVec - A vector of Attr, which is how they are stored on the AST.
|
/// AttrVec - A vector of Attr, which is how they are stored on the AST.
|
||||||
typedef SmallVector<Attr *, 4> AttrVec;
|
using AttrVec = SmallVector<Attr *, 4>;
|
||||||
|
|
||||||
/// specific_attr_iterator - Iterates over a subrange of an AttrVec, only
|
/// specific_attr_iterator - Iterates over a subrange of an AttrVec, only
|
||||||
/// providing attributes that are of a specific type.
|
/// providing attributes that are of a specific type.
|
||||||
template <typename SpecificAttr, typename Container = AttrVec>
|
template <typename SpecificAttr, typename Container = AttrVec>
|
||||||
class specific_attr_iterator {
|
class specific_attr_iterator {
|
||||||
typedef typename Container::const_iterator Iterator;
|
using Iterator = typename Container::const_iterator;
|
||||||
|
|
||||||
/// Current - The current, underlying iterator.
|
/// Current - The current, underlying iterator.
|
||||||
/// In order to ensure we don't dereference an invalid iterator unless
|
/// In order to ensure we don't dereference an invalid iterator unless
|
||||||
|
@ -67,14 +74,14 @@ class specific_attr_iterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef SpecificAttr* value_type;
|
using value_type = SpecificAttr *;
|
||||||
typedef SpecificAttr* reference;
|
using reference = SpecificAttr *;
|
||||||
typedef SpecificAttr* pointer;
|
using pointer = SpecificAttr *;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
typedef std::ptrdiff_t difference_type;
|
using difference_type = std::ptrdiff_t;
|
||||||
|
|
||||||
specific_attr_iterator() : Current() { }
|
specific_attr_iterator() = default;
|
||||||
explicit specific_attr_iterator(Iterator i) : Current(i) { }
|
explicit specific_attr_iterator(Iterator i) : Current(i) {}
|
||||||
|
|
||||||
reference operator*() const {
|
reference operator*() const {
|
||||||
AdvanceToNext();
|
AdvanceToNext();
|
||||||
|
@ -136,6 +143,6 @@ inline SpecificAttr *getSpecificAttr(const Container& container) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_ATTRITERATOR_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- BaseSubobject.h - BaseSubobject class ----------------------------===//
|
//===- BaseSubobject.h - BaseSubobject class --------------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -15,12 +15,15 @@
|
||||||
#define LLVM_CLANG_AST_BASESUBOBJECT_H
|
#define LLVM_CLANG_AST_BASESUBOBJECT_H
|
||||||
|
|
||||||
#include "clang/AST/CharUnits.h"
|
#include "clang/AST/CharUnits.h"
|
||||||
#include "clang/AST/DeclCXX.h"
|
#include "llvm/ADT/DenseMapInfo.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
|
||||||
#include "llvm/Support/DataTypes.h"
|
|
||||||
#include "llvm/Support/type_traits.h"
|
#include "llvm/Support/type_traits.h"
|
||||||
|
#include <cstdint>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
|
class CXXRecordDecl;
|
||||||
|
|
||||||
// BaseSubobject - Uniquely identifies a direct or indirect base class.
|
// BaseSubobject - Uniquely identifies a direct or indirect base class.
|
||||||
// Stores both the base class decl and the offset from the most derived class to
|
// Stores both the base class decl and the offset from the most derived class to
|
||||||
// the base class. Used for vtable and VTT generation.
|
// the base class. Used for vtable and VTT generation.
|
||||||
|
@ -32,9 +35,9 @@ class BaseSubobject {
|
||||||
CharUnits BaseOffset;
|
CharUnits BaseOffset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseSubobject() { }
|
BaseSubobject() = default;
|
||||||
BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
|
BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
|
||||||
: Base(Base), BaseOffset(BaseOffset) { }
|
: Base(Base), BaseOffset(BaseOffset) {}
|
||||||
|
|
||||||
/// getBase - Returns the base class declaration.
|
/// getBase - Returns the base class declaration.
|
||||||
const CXXRecordDecl *getBase() const { return Base; }
|
const CXXRecordDecl *getBase() const { return Base; }
|
||||||
|
@ -47,7 +50,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
@ -65,7 +68,8 @@ template<> struct DenseMapInfo<clang::BaseSubobject> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned getHashValue(const clang::BaseSubobject &Base) {
|
static unsigned getHashValue(const clang::BaseSubobject &Base) {
|
||||||
typedef std::pair<const clang::CXXRecordDecl *, clang::CharUnits> PairTy;
|
using PairTy = std::pair<const clang::CXXRecordDecl *, clang::CharUnits>;
|
||||||
|
|
||||||
return DenseMapInfo<PairTy>::getHashValue(PairTy(Base.getBase(),
|
return DenseMapInfo<PairTy>::getHashValue(PairTy(Base.getBase(),
|
||||||
Base.getBaseOffset()));
|
Base.getBaseOffset()));
|
||||||
}
|
}
|
||||||
|
@ -81,6 +85,6 @@ template <> struct isPodLike<clang::BaseSubobject> {
|
||||||
static const bool value = true;
|
static const bool value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_BASESUBOBJECT_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- CommentVisitor.h - Visitor for Comment subclasses ------*- C++ -*-===//
|
//===- CommentVisitor.h - Visitor for Comment subclasses --------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
namespace clang {
|
namespace clang {
|
||||||
namespace comments {
|
namespace comments {
|
||||||
|
|
||||||
template <typename T> struct make_ptr { typedef T *type; };
|
template <typename T> struct make_ptr { using type = T *; };
|
||||||
template <typename T> struct make_const_ptr { typedef const T *type; };
|
template <typename T> struct make_const_ptr { using type = const T *; };
|
||||||
|
|
||||||
template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
|
template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
|
||||||
class CommentVisitorBase {
|
class CommentVisitorBase {
|
||||||
|
@ -64,7 +64,7 @@ template<typename ImplClass, typename RetTy=void>
|
||||||
class ConstCommentVisitor :
|
class ConstCommentVisitor :
|
||||||
public CommentVisitorBase<make_const_ptr, ImplClass, RetTy> {};
|
public CommentVisitorBase<make_const_ptr, ImplClass, RetTy> {};
|
||||||
|
|
||||||
} // end namespace comments
|
} // namespace comments
|
||||||
} // end namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_COMMENTVISITOR_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===-- DeclFriend.h - Classes for C++ friend declarations -*- C++ -*------===//
|
//===- DeclFriend.h - Classes for C++ friend declarations -------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -15,16 +15,30 @@
|
||||||
#ifndef LLVM_CLANG_AST_DECLFRIEND_H
|
#ifndef LLVM_CLANG_AST_DECLFRIEND_H
|
||||||
#define LLVM_CLANG_AST_DECLFRIEND_H
|
#define LLVM_CLANG_AST_DECLFRIEND_H
|
||||||
|
|
||||||
|
#include "clang/AST/Decl.h"
|
||||||
|
#include "clang/AST/DeclBase.h"
|
||||||
#include "clang/AST/DeclCXX.h"
|
#include "clang/AST/DeclCXX.h"
|
||||||
#include "clang/AST/DeclTemplate.h"
|
#include "clang/AST/DeclTemplate.h"
|
||||||
|
#include "clang/AST/ExternalASTSource.h"
|
||||||
#include "clang/AST/TypeLoc.h"
|
#include "clang/AST/TypeLoc.h"
|
||||||
|
#include "clang/Basic/LLVM.h"
|
||||||
|
#include "clang/Basic/SourceLocation.h"
|
||||||
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
|
#include "llvm/ADT/None.h"
|
||||||
|
#include "llvm/ADT/PointerUnion.h"
|
||||||
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/TrailingObjects.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
|
class ASTContext;
|
||||||
|
|
||||||
/// FriendDecl - Represents the declaration of a friend entity,
|
/// FriendDecl - Represents the declaration of a friend entity,
|
||||||
/// which can be a function, a type, or a templated function or type.
|
/// which can be a function, a type, or a templated function or type.
|
||||||
// For example:
|
/// For example:
|
||||||
///
|
///
|
||||||
/// @code
|
/// @code
|
||||||
/// template <typename T> class A {
|
/// template <typename T> class A {
|
||||||
|
@ -41,10 +55,14 @@ class FriendDecl final
|
||||||
: public Decl,
|
: public Decl,
|
||||||
private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> {
|
private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> {
|
||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef llvm::PointerUnion<NamedDecl*,TypeSourceInfo*> FriendUnion;
|
using FriendUnion = llvm::PointerUnion<NamedDecl *, TypeSourceInfo *>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class CXXRecordDecl;
|
||||||
|
friend class CXXRecordDecl::friend_iterator;
|
||||||
|
|
||||||
// The declaration that's a friend of this class.
|
// The declaration that's a friend of this class.
|
||||||
FriendUnion Friend;
|
FriendUnion Friend;
|
||||||
|
|
||||||
|
@ -64,35 +82,33 @@ private:
|
||||||
// template <class T> friend class A<T>::B;
|
// template <class T> friend class A<T>::B;
|
||||||
unsigned NumTPLists : 31;
|
unsigned NumTPLists : 31;
|
||||||
|
|
||||||
friend class CXXRecordDecl::friend_iterator;
|
|
||||||
friend class CXXRecordDecl;
|
|
||||||
|
|
||||||
FriendDecl(DeclContext *DC, SourceLocation L, FriendUnion Friend,
|
FriendDecl(DeclContext *DC, SourceLocation L, FriendUnion Friend,
|
||||||
SourceLocation FriendL,
|
SourceLocation FriendL,
|
||||||
ArrayRef<TemplateParameterList*> FriendTypeTPLists)
|
ArrayRef<TemplateParameterList *> FriendTypeTPLists)
|
||||||
: Decl(Decl::Friend, DC, L),
|
: Decl(Decl::Friend, DC, L), Friend(Friend), FriendLoc(FriendL),
|
||||||
Friend(Friend),
|
UnsupportedFriend(false), NumTPLists(FriendTypeTPLists.size()) {
|
||||||
NextFriend(),
|
|
||||||
FriendLoc(FriendL),
|
|
||||||
UnsupportedFriend(false),
|
|
||||||
NumTPLists(FriendTypeTPLists.size()) {
|
|
||||||
for (unsigned i = 0; i < NumTPLists; ++i)
|
for (unsigned i = 0; i < NumTPLists; ++i)
|
||||||
getTrailingObjects<TemplateParameterList *>()[i] = FriendTypeTPLists[i];
|
getTrailingObjects<TemplateParameterList *>()[i] = FriendTypeTPLists[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists)
|
FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists)
|
||||||
: Decl(Decl::Friend, Empty), NextFriend(),
|
: Decl(Decl::Friend, Empty), UnsupportedFriend(false),
|
||||||
UnsupportedFriend(false),
|
NumTPLists(NumFriendTypeTPLists) {}
|
||||||
NumTPLists(NumFriendTypeTPLists) { }
|
|
||||||
|
|
||||||
FriendDecl *getNextFriend() {
|
FriendDecl *getNextFriend() {
|
||||||
if (!NextFriend.isOffset())
|
if (!NextFriend.isOffset())
|
||||||
return cast_or_null<FriendDecl>(NextFriend.get(nullptr));
|
return cast_or_null<FriendDecl>(NextFriend.get(nullptr));
|
||||||
return getNextFriendSlowCase();
|
return getNextFriendSlowCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendDecl *getNextFriendSlowCase();
|
FriendDecl *getNextFriendSlowCase();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
friend class ASTDeclReader;
|
||||||
|
friend class ASTDeclWriter;
|
||||||
|
friend class ASTNodeImporter;
|
||||||
|
friend TrailingObjects;
|
||||||
|
|
||||||
static FriendDecl *Create(ASTContext &C, DeclContext *DC,
|
static FriendDecl *Create(ASTContext &C, DeclContext *DC,
|
||||||
SourceLocation L, FriendUnion Friend_,
|
SourceLocation L, FriendUnion Friend_,
|
||||||
SourceLocation FriendL,
|
SourceLocation FriendL,
|
||||||
|
@ -108,9 +124,11 @@ public:
|
||||||
TypeSourceInfo *getFriendType() const {
|
TypeSourceInfo *getFriendType() const {
|
||||||
return Friend.dyn_cast<TypeSourceInfo*>();
|
return Friend.dyn_cast<TypeSourceInfo*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getFriendTypeNumTemplateParameterLists() const {
|
unsigned getFriendTypeNumTemplateParameterLists() const {
|
||||||
return NumTPLists;
|
return NumTPLists;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateParameterList *getFriendTypeTemplateParameterList(unsigned N) const {
|
TemplateParameterList *getFriendTypeTemplateParameterList(unsigned N) const {
|
||||||
assert(N < NumTPLists);
|
assert(N < NumTPLists);
|
||||||
return getTrailingObjects<TemplateParameterList *>()[N];
|
return getTrailingObjects<TemplateParameterList *>()[N];
|
||||||
|
@ -119,7 +137,7 @@ public:
|
||||||
/// If this friend declaration doesn't name a type, return the inner
|
/// If this friend declaration doesn't name a type, return the inner
|
||||||
/// declaration.
|
/// declaration.
|
||||||
NamedDecl *getFriendDecl() const {
|
NamedDecl *getFriendDecl() const {
|
||||||
return Friend.dyn_cast<NamedDecl*>();
|
return Friend.dyn_cast<NamedDecl *>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the location of the 'friend' keyword.
|
/// Retrieves the location of the 'friend' keyword.
|
||||||
|
@ -164,27 +182,24 @@ public:
|
||||||
// Implement isa/cast/dyncast/etc.
|
// Implement isa/cast/dyncast/etc.
|
||||||
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
|
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
|
||||||
static bool classofKind(Kind K) { return K == Decl::Friend; }
|
static bool classofKind(Kind K) { return K == Decl::Friend; }
|
||||||
|
|
||||||
friend class ASTDeclReader;
|
|
||||||
friend class ASTDeclWriter;
|
|
||||||
friend class ASTNodeImporter;
|
|
||||||
friend TrailingObjects;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An iterator over the friend declarations of a class.
|
/// An iterator over the friend declarations of a class.
|
||||||
class CXXRecordDecl::friend_iterator {
|
class CXXRecordDecl::friend_iterator {
|
||||||
|
friend class CXXRecordDecl;
|
||||||
|
|
||||||
FriendDecl *Ptr;
|
FriendDecl *Ptr;
|
||||||
|
|
||||||
friend class CXXRecordDecl;
|
|
||||||
explicit friend_iterator(FriendDecl *Ptr) : Ptr(Ptr) {}
|
explicit friend_iterator(FriendDecl *Ptr) : Ptr(Ptr) {}
|
||||||
public:
|
|
||||||
friend_iterator() {}
|
|
||||||
|
|
||||||
typedef FriendDecl *value_type;
|
public:
|
||||||
typedef FriendDecl *reference;
|
friend_iterator() = default;
|
||||||
typedef FriendDecl *pointer;
|
|
||||||
typedef int difference_type;
|
using value_type = FriendDecl *;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
using reference = FriendDecl *;
|
||||||
|
using pointer = FriendDecl *;
|
||||||
|
using difference_type = int;
|
||||||
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
reference operator*() const { return Ptr; }
|
reference operator*() const { return Ptr; }
|
||||||
|
|
||||||
|
@ -240,6 +255,6 @@ inline void CXXRecordDecl::pushFriendDecl(FriendDecl *FD) {
|
||||||
data().FirstFriend = FD;
|
data().FirstFriend = FD;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace clang
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_DECLFRIEND_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- DeclGroup.h - Classes for representing groups of Decls -*- C++ -*-===//
|
//===- DeclGroup.h - Classes for representing groups of Decls ---*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -14,26 +14,26 @@
|
||||||
#ifndef LLVM_CLANG_AST_DECLGROUP_H
|
#ifndef LLVM_CLANG_AST_DECLGROUP_H
|
||||||
#define LLVM_CLANG_AST_DECLGROUP_H
|
#define LLVM_CLANG_AST_DECLGROUP_H
|
||||||
|
|
||||||
#include "llvm/Support/DataTypes.h"
|
|
||||||
#include "llvm/Support/TrailingObjects.h"
|
#include "llvm/Support/TrailingObjects.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
class ASTContext;
|
class ASTContext;
|
||||||
class Decl;
|
class Decl;
|
||||||
class DeclGroup;
|
|
||||||
class DeclGroupIterator;
|
|
||||||
|
|
||||||
class DeclGroup final : private llvm::TrailingObjects<DeclGroup, Decl *> {
|
class DeclGroup final : private llvm::TrailingObjects<DeclGroup, Decl *> {
|
||||||
// FIXME: Include a TypeSpecifier object.
|
// FIXME: Include a TypeSpecifier object.
|
||||||
unsigned NumDecls;
|
unsigned NumDecls = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeclGroup() : NumDecls(0) {}
|
DeclGroup() = default;
|
||||||
DeclGroup(unsigned numdecls, Decl** decls);
|
DeclGroup(unsigned numdecls, Decl** decls);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
friend TrailingObjects;
|
||||||
|
|
||||||
static DeclGroup *Create(ASTContext &C, Decl **Decls, unsigned NumDecls);
|
static DeclGroup *Create(ASTContext &C, Decl **Decls, unsigned NumDecls);
|
||||||
|
|
||||||
unsigned size() const { return NumDecls; }
|
unsigned size() const { return NumDecls; }
|
||||||
|
@ -47,23 +47,21 @@ public:
|
||||||
assert (i < NumDecls && "Out-of-bounds access.");
|
assert (i < NumDecls && "Out-of-bounds access.");
|
||||||
return getTrailingObjects<Decl *>()[i];
|
return getTrailingObjects<Decl *>()[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
friend TrailingObjects;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeclGroupRef {
|
class DeclGroupRef {
|
||||||
// Note this is not a PointerIntPair because we need the address of the
|
// Note this is not a PointerIntPair because we need the address of the
|
||||||
// non-group case to be valid as a Decl** for iteration.
|
// non-group case to be valid as a Decl** for iteration.
|
||||||
enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 };
|
enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 };
|
||||||
Decl* D;
|
|
||||||
|
Decl* D = nullptr;
|
||||||
|
|
||||||
Kind getKind() const {
|
Kind getKind() const {
|
||||||
return (Kind) (reinterpret_cast<uintptr_t>(D) & Mask);
|
return (Kind) (reinterpret_cast<uintptr_t>(D) & Mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeclGroupRef() : D(nullptr) {}
|
DeclGroupRef() = default;
|
||||||
|
|
||||||
explicit DeclGroupRef(Decl* d) : D(d) {}
|
explicit DeclGroupRef(Decl* d) : D(d) {}
|
||||||
explicit DeclGroupRef(DeclGroup* dg)
|
explicit DeclGroupRef(DeclGroup* dg)
|
||||||
: D((Decl*) (reinterpret_cast<uintptr_t>(dg) | DeclGroupKind)) {}
|
: D((Decl*) (reinterpret_cast<uintptr_t>(dg) | DeclGroupKind)) {}
|
||||||
|
@ -76,8 +74,8 @@ public:
|
||||||
return DeclGroupRef(DeclGroup::Create(C, Decls, NumDecls));
|
return DeclGroupRef(DeclGroup::Create(C, Decls, NumDecls));
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef Decl** iterator;
|
using iterator = Decl **;
|
||||||
typedef Decl* const * const_iterator;
|
using const_iterator = Decl * const *;
|
||||||
|
|
||||||
bool isNull() const { return D == nullptr; }
|
bool isNull() const { return D == nullptr; }
|
||||||
bool isSingleDecl() const { return getKind() == SingleDeclKind; }
|
bool isSingleDecl() const { return getKind() == SingleDeclKind; }
|
||||||
|
@ -133,9 +131,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end clang namespace
|
} // namespace clang
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
// DeclGroupRef is "like a pointer", implement PointerLikeTypeTraits.
|
// DeclGroupRef is "like a pointer", implement PointerLikeTypeTraits.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct PointerLikeTypeTraits;
|
struct PointerLikeTypeTraits;
|
||||||
|
@ -144,10 +143,14 @@ namespace llvm {
|
||||||
static inline void *getAsVoidPointer(clang::DeclGroupRef P) {
|
static inline void *getAsVoidPointer(clang::DeclGroupRef P) {
|
||||||
return P.getAsOpaquePtr();
|
return P.getAsOpaquePtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline clang::DeclGroupRef getFromVoidPointer(void *P) {
|
static inline clang::DeclGroupRef getFromVoidPointer(void *P) {
|
||||||
return clang::DeclGroupRef::getFromOpaquePtr(P);
|
return clang::DeclGroupRef::getFromOpaquePtr(P);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { NumLowBitsAvailable = 0 };
|
enum { NumLowBitsAvailable = 0 };
|
||||||
};
|
};
|
||||||
}
|
|
||||||
#endif
|
} // namespace llvm
|
||||||
|
|
||||||
|
#endif // LLVM_CLANG_AST_DECLGROUP_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- DeclVisitor.h - Visitor for Decl subclasses ------------*- C++ -*-===//
|
//===- DeclVisitor.h - Visitor for Decl subclasses --------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -10,27 +10,30 @@
|
||||||
// This file defines the DeclVisitor interface.
|
// This file defines the DeclVisitor interface.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef LLVM_CLANG_AST_DECLVISITOR_H
|
#ifndef LLVM_CLANG_AST_DECLVISITOR_H
|
||||||
#define LLVM_CLANG_AST_DECLVISITOR_H
|
#define LLVM_CLANG_AST_DECLVISITOR_H
|
||||||
|
|
||||||
#include "clang/AST/Decl.h"
|
#include "clang/AST/Decl.h"
|
||||||
|
#include "clang/AST/DeclBase.h"
|
||||||
#include "clang/AST/DeclCXX.h"
|
#include "clang/AST/DeclCXX.h"
|
||||||
#include "clang/AST/DeclFriend.h"
|
#include "clang/AST/DeclFriend.h"
|
||||||
#include "clang/AST/DeclObjC.h"
|
#include "clang/AST/DeclObjC.h"
|
||||||
#include "clang/AST/DeclOpenMP.h"
|
#include "clang/AST/DeclOpenMP.h"
|
||||||
#include "clang/AST/DeclTemplate.h"
|
#include "clang/AST/DeclTemplate.h"
|
||||||
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
namespace declvisitor {
|
namespace declvisitor {
|
||||||
|
|
||||||
template <typename T> struct make_ptr { typedef T *type; };
|
template <typename T> struct make_ptr { using type = T *; };
|
||||||
template <typename T> struct make_const_ptr { typedef const T *type; };
|
template <typename T> struct make_const_ptr { using type = const T *; };
|
||||||
|
|
||||||
/// \brief A simple visitor class that helps create declaration visitors.
|
/// \brief A simple visitor class that helps create declaration visitors.
|
||||||
template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
|
template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
|
||||||
class Base {
|
class Base {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#define PTR(CLASS) typename Ptr<CLASS>::type
|
#define PTR(CLASS) typename Ptr<CLASS>::type
|
||||||
#define DISPATCH(NAME, CLASS) \
|
#define DISPATCH(NAME, CLASS) \
|
||||||
return static_cast<ImplClass*>(this)->Visit##NAME(static_cast<PTR(CLASS)>(D))
|
return static_cast<ImplClass*>(this)->Visit##NAME(static_cast<PTR(CLASS)>(D))
|
||||||
|
@ -57,23 +60,23 @@ public:
|
||||||
#undef DISPATCH
|
#undef DISPATCH
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace declvisitor
|
} // namespace declvisitor
|
||||||
|
|
||||||
/// \brief A simple visitor class that helps create declaration visitors.
|
/// \brief A simple visitor class that helps create declaration visitors.
|
||||||
///
|
///
|
||||||
/// This class does not preserve constness of Decl pointers (see also
|
/// This class does not preserve constness of Decl pointers (see also
|
||||||
/// ConstDeclVisitor).
|
/// ConstDeclVisitor).
|
||||||
template<typename ImplClass, typename RetTy=void>
|
template<typename ImplClass, typename RetTy = void>
|
||||||
class DeclVisitor
|
class DeclVisitor
|
||||||
: public declvisitor::Base<declvisitor::make_ptr, ImplClass, RetTy> {};
|
: public declvisitor::Base<declvisitor::make_ptr, ImplClass, RetTy> {};
|
||||||
|
|
||||||
/// \brief A simple visitor class that helps create declaration visitors.
|
/// \brief A simple visitor class that helps create declaration visitors.
|
||||||
///
|
///
|
||||||
/// This class preserves constness of Decl pointers (see also DeclVisitor).
|
/// This class preserves constness of Decl pointers (see also DeclVisitor).
|
||||||
template<typename ImplClass, typename RetTy=void>
|
template<typename ImplClass, typename RetTy = void>
|
||||||
class ConstDeclVisitor
|
class ConstDeclVisitor
|
||||||
: public declvisitor::Base<declvisitor::make_const_ptr, ImplClass, RetTy> {};
|
: public declvisitor::Base<declvisitor::make_const_ptr, ImplClass, RetTy> {};
|
||||||
|
|
||||||
} // end namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
#endif // LLVM_CLANG_AST_DECLVISITOR_H
|
#endif // LLVM_CLANG_AST_DECLVISITOR_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===-- DependentDiagnostic.h - Dependently-generated diagnostics -*- C++ -*-=//
|
//==- DependentDiagnostic.h - Dependently-generated diagnostics --*- C++ -*-==//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -23,6 +23,9 @@
|
||||||
#include "clang/AST/Type.h"
|
#include "clang/AST/Type.h"
|
||||||
#include "clang/Basic/PartialDiagnostic.h"
|
#include "clang/Basic/PartialDiagnostic.h"
|
||||||
#include "clang/Basic/SourceLocation.h"
|
#include "clang/Basic/SourceLocation.h"
|
||||||
|
#include "clang/Basic/Specifiers.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
|
@ -94,6 +97,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class DeclContext::ddiag_iterator;
|
||||||
|
friend class DependentStoredDeclsMap;
|
||||||
|
|
||||||
DependentDiagnostic(const PartialDiagnostic &PDiag,
|
DependentDiagnostic(const PartialDiagnostic &PDiag,
|
||||||
PartialDiagnostic::Storage *Storage)
|
PartialDiagnostic::Storage *Storage)
|
||||||
: Diag(PDiag, Storage) {}
|
: Diag(PDiag, Storage) {}
|
||||||
|
@ -102,8 +108,6 @@ private:
|
||||||
DeclContext *Parent,
|
DeclContext *Parent,
|
||||||
const PartialDiagnostic &PDiag);
|
const PartialDiagnostic &PDiag);
|
||||||
|
|
||||||
friend class DependentStoredDeclsMap;
|
|
||||||
friend class DeclContext::ddiag_iterator;
|
|
||||||
DependentDiagnostic *NextDiagnostic;
|
DependentDiagnostic *NextDiagnostic;
|
||||||
|
|
||||||
PartialDiagnostic Diag;
|
PartialDiagnostic Diag;
|
||||||
|
@ -118,19 +122,17 @@ private:
|
||||||
} AccessData;
|
} AccessData;
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
|
||||||
|
|
||||||
/// An iterator over the dependent diagnostics in a dependent context.
|
/// An iterator over the dependent diagnostics in a dependent context.
|
||||||
class DeclContext::ddiag_iterator {
|
class DeclContext::ddiag_iterator {
|
||||||
public:
|
public:
|
||||||
ddiag_iterator() : Ptr(nullptr) {}
|
ddiag_iterator() = default;
|
||||||
explicit ddiag_iterator(DependentDiagnostic *Ptr) : Ptr(Ptr) {}
|
explicit ddiag_iterator(DependentDiagnostic *Ptr) : Ptr(Ptr) {}
|
||||||
|
|
||||||
typedef DependentDiagnostic *value_type;
|
using value_type = DependentDiagnostic *;
|
||||||
typedef DependentDiagnostic *reference;
|
using reference = DependentDiagnostic *;
|
||||||
typedef DependentDiagnostic *pointer;
|
using pointer = DependentDiagnostic *;
|
||||||
typedef int difference_type;
|
using difference_type = int;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
reference operator*() const { return Ptr; }
|
reference operator*() const { return Ptr; }
|
||||||
|
|
||||||
|
@ -168,7 +170,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DependentDiagnostic *Ptr;
|
DependentDiagnostic *Ptr = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline DeclContext::ddiag_range DeclContext::ddiags() const {
|
inline DeclContext::ddiag_range DeclContext::ddiags() const {
|
||||||
|
@ -184,6 +186,6 @@ inline DeclContext::ddiag_range DeclContext::ddiags() const {
|
||||||
return ddiag_range(ddiag_iterator(Map->FirstDiagnostic), ddiag_iterator());
|
return ddiag_range(ddiag_iterator(Map->FirstDiagnostic), ddiag_iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace clang
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_DEPENDENTDIAGNOSTIC_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- RecordLayout.h - Layout information for a struct/union -*- C++ -*-===//
|
//===- RecordLayout.h - Layout information for a struct/union ---*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -14,15 +14,20 @@
|
||||||
#ifndef LLVM_CLANG_AST_RECORDLAYOUT_H
|
#ifndef LLVM_CLANG_AST_RECORDLAYOUT_H
|
||||||
#define LLVM_CLANG_AST_RECORDLAYOUT_H
|
#define LLVM_CLANG_AST_RECORDLAYOUT_H
|
||||||
|
|
||||||
|
#include "clang/AST/ASTVector.h"
|
||||||
#include "clang/AST/CharUnits.h"
|
#include "clang/AST/CharUnits.h"
|
||||||
#include "clang/AST/DeclCXX.h"
|
#include "clang/AST/DeclCXX.h"
|
||||||
|
#include "clang/Basic/LLVM.h"
|
||||||
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
|
#include "llvm/ADT/PointerIntPair.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class ASTContext;
|
|
||||||
class FieldDecl;
|
class ASTContext;
|
||||||
class RecordDecl;
|
class CXXRecordDecl;
|
||||||
class CXXRecordDecl;
|
|
||||||
|
|
||||||
/// ASTRecordLayout -
|
/// ASTRecordLayout -
|
||||||
/// This class contains layout information for one RecordDecl,
|
/// This class contains layout information for one RecordDecl,
|
||||||
|
@ -42,21 +47,21 @@ public:
|
||||||
/// Whether this virtual base requires a vtordisp field in the
|
/// Whether this virtual base requires a vtordisp field in the
|
||||||
/// Microsoft ABI. These fields are required for certain operations
|
/// Microsoft ABI. These fields are required for certain operations
|
||||||
/// in constructors and destructors.
|
/// in constructors and destructors.
|
||||||
bool HasVtorDisp;
|
bool HasVtorDisp = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
VBaseInfo() = default;
|
||||||
|
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp)
|
||||||
|
: VBaseOffset(VBaseOffset), HasVtorDisp(hasVtorDisp) {}
|
||||||
|
|
||||||
bool hasVtorDisp() const { return HasVtorDisp; }
|
bool hasVtorDisp() const { return HasVtorDisp; }
|
||||||
|
|
||||||
VBaseInfo() : HasVtorDisp(false) {}
|
|
||||||
|
|
||||||
VBaseInfo(CharUnits VBaseOffset, bool hasVtorDisp) :
|
|
||||||
VBaseOffset(VBaseOffset), HasVtorDisp(hasVtorDisp) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef llvm::DenseMap<const CXXRecordDecl *, VBaseInfo>
|
using VBaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, VBaseInfo>;
|
||||||
VBaseOffsetsMapTy;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class ASTContext;
|
||||||
|
|
||||||
/// Size - Size of record in characters.
|
/// Size - Size of record in characters.
|
||||||
CharUnits Size;
|
CharUnits Size;
|
||||||
|
|
||||||
|
@ -117,7 +122,7 @@ private:
|
||||||
const CXXRecordDecl *BaseSharingVBPtr;
|
const CXXRecordDecl *BaseSharingVBPtr;
|
||||||
|
|
||||||
/// FIXME: This should really use a SmallPtrMap, once we have one in LLVM :)
|
/// FIXME: This should really use a SmallPtrMap, once we have one in LLVM :)
|
||||||
typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits> BaseOffsetsMapTy;
|
using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>;
|
||||||
|
|
||||||
/// BaseOffsets - Contains a map from base classes to their offset.
|
/// BaseOffsets - Contains a map from base classes to their offset.
|
||||||
BaseOffsetsMapTy BaseOffsets;
|
BaseOffsetsMapTy BaseOffsets;
|
||||||
|
@ -128,16 +133,15 @@ private:
|
||||||
|
|
||||||
/// CXXInfo - If the record layout is for a C++ record, this will have
|
/// CXXInfo - If the record layout is for a C++ record, this will have
|
||||||
/// C++ specific information about the record.
|
/// C++ specific information about the record.
|
||||||
CXXRecordLayoutInfo *CXXInfo;
|
CXXRecordLayoutInfo *CXXInfo = nullptr;
|
||||||
|
|
||||||
friend class ASTContext;
|
|
||||||
|
|
||||||
ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment,
|
ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment,
|
||||||
CharUnits requiredAlignment, CharUnits datasize,
|
CharUnits requiredAlignment, CharUnits datasize,
|
||||||
ArrayRef<uint64_t> fieldoffsets);
|
ArrayRef<uint64_t> fieldoffsets);
|
||||||
|
|
||||||
|
using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
|
||||||
|
|
||||||
// Constructor for C++ records.
|
// Constructor for C++ records.
|
||||||
typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
|
|
||||||
ASTRecordLayout(const ASTContext &Ctx,
|
ASTRecordLayout(const ASTContext &Ctx,
|
||||||
CharUnits size, CharUnits alignment,
|
CharUnits size, CharUnits alignment,
|
||||||
CharUnits requiredAlignment,
|
CharUnits requiredAlignment,
|
||||||
|
@ -159,9 +163,9 @@ private:
|
||||||
|
|
||||||
void Destroy(ASTContext &Ctx);
|
void Destroy(ASTContext &Ctx);
|
||||||
|
|
||||||
ASTRecordLayout(const ASTRecordLayout &) = delete;
|
|
||||||
void operator=(const ASTRecordLayout &) = delete;
|
|
||||||
public:
|
public:
|
||||||
|
ASTRecordLayout(const ASTRecordLayout &) = delete;
|
||||||
|
ASTRecordLayout &operator=(const ASTRecordLayout &) = delete;
|
||||||
|
|
||||||
/// getAlignment - Get the record alignment in characters.
|
/// getAlignment - Get the record alignment in characters.
|
||||||
CharUnits getAlignment() const { return Alignment; }
|
CharUnits getAlignment() const { return Alignment; }
|
||||||
|
@ -305,6 +309,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_RECORDLAYOUT_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===-- Redeclarable.h - Base for Decls that can be redeclared -*- C++ -*-====//
|
//===- Redeclarable.h - Base for Decls that can be redeclared --*- C++ -*-====//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -15,11 +15,18 @@
|
||||||
#define LLVM_CLANG_AST_REDECLARABLE_H
|
#define LLVM_CLANG_AST_REDECLARABLE_H
|
||||||
|
|
||||||
#include "clang/AST/ExternalASTSource.h"
|
#include "clang/AST/ExternalASTSource.h"
|
||||||
|
#include "llvm/ADT/DenseMapInfo.h"
|
||||||
|
#include "llvm/ADT/PointerUnion.h"
|
||||||
|
#include "llvm/ADT/iterator_range.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
class ASTContext;
|
class ASTContext;
|
||||||
|
class Decl;
|
||||||
|
|
||||||
// Some notes on redeclarables:
|
// Some notes on redeclarables:
|
||||||
//
|
//
|
||||||
|
@ -82,21 +89,21 @@ protected:
|
||||||
class DeclLink {
|
class DeclLink {
|
||||||
/// A pointer to a known latest declaration, either statically known or
|
/// A pointer to a known latest declaration, either statically known or
|
||||||
/// generationally updated as decls are added by an external source.
|
/// generationally updated as decls are added by an external source.
|
||||||
typedef LazyGenerationalUpdatePtr<const Decl*, Decl*,
|
using KnownLatest =
|
||||||
&ExternalASTSource::CompleteRedeclChain>
|
LazyGenerationalUpdatePtr<const Decl *, Decl *,
|
||||||
KnownLatest;
|
&ExternalASTSource::CompleteRedeclChain>;
|
||||||
|
|
||||||
/// We store a pointer to the ASTContext in the UninitializedLatest
|
/// We store a pointer to the ASTContext in the UninitializedLatest
|
||||||
/// pointer, but to avoid circular type dependencies when we steal the low
|
/// pointer, but to avoid circular type dependencies when we steal the low
|
||||||
/// bits of this pointer, we use a raw void* here.
|
/// bits of this pointer, we use a raw void* here.
|
||||||
typedef const void *UninitializedLatest;
|
using UninitializedLatest = const void *;
|
||||||
|
|
||||||
typedef Decl *Previous;
|
using Previous = Decl *;
|
||||||
|
|
||||||
/// A pointer to either an uninitialized latest declaration (where either
|
/// A pointer to either an uninitialized latest declaration (where either
|
||||||
/// we've not yet set the previous decl or there isn't one), or to a known
|
/// we've not yet set the previous decl or there isn't one), or to a known
|
||||||
/// previous declaration.
|
/// previous declaration.
|
||||||
typedef llvm::PointerUnion<Previous, UninitializedLatest> NotKnownLatest;
|
using NotKnownLatest = llvm::PointerUnion<Previous, UninitializedLatest>;
|
||||||
|
|
||||||
mutable llvm::PointerUnion<NotKnownLatest, KnownLatest> Next;
|
mutable llvm::PointerUnion<NotKnownLatest, KnownLatest> Next;
|
||||||
|
|
||||||
|
@ -106,8 +113,7 @@ protected:
|
||||||
|
|
||||||
DeclLink(LatestTag, const ASTContext &Ctx)
|
DeclLink(LatestTag, const ASTContext &Ctx)
|
||||||
: Next(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
|
: Next(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
|
||||||
DeclLink(PreviousTag, decl_type *D)
|
DeclLink(PreviousTag, decl_type *D) : Next(NotKnownLatest(Previous(D))) {}
|
||||||
: Next(NotKnownLatest(Previous(D))) {}
|
|
||||||
|
|
||||||
bool NextIsPrevious() const {
|
bool NextIsPrevious() const {
|
||||||
return Next.is<NotKnownLatest>() &&
|
return Next.is<NotKnownLatest>() &&
|
||||||
|
@ -182,6 +188,7 @@ protected:
|
||||||
///
|
///
|
||||||
/// If there is only one declaration, it is <pointer to self, true>
|
/// If there is only one declaration, it is <pointer to self, true>
|
||||||
DeclLink RedeclLink;
|
DeclLink RedeclLink;
|
||||||
|
|
||||||
decl_type *First;
|
decl_type *First;
|
||||||
|
|
||||||
decl_type *getNextRedeclaration() const {
|
decl_type *getNextRedeclaration() const {
|
||||||
|
@ -189,8 +196,12 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
friend class ASTDeclReader;
|
||||||
|
friend class ASTDeclWriter;
|
||||||
|
|
||||||
Redeclarable(const ASTContext &Ctx)
|
Redeclarable(const ASTContext &Ctx)
|
||||||
: RedeclLink(LatestDeclLink(Ctx)), First(static_cast<decl_type *>(this)) {}
|
: RedeclLink(LatestDeclLink(Ctx)),
|
||||||
|
First(static_cast<decl_type *>(this)) {}
|
||||||
|
|
||||||
/// \brief Return the previous declaration of this declaration or NULL if this
|
/// \brief Return the previous declaration of this declaration or NULL if this
|
||||||
/// is the first declaration.
|
/// is the first declaration.
|
||||||
|
@ -232,20 +243,19 @@ public:
|
||||||
/// \brief Iterates through all the redeclarations of the same decl.
|
/// \brief Iterates through all the redeclarations of the same decl.
|
||||||
class redecl_iterator {
|
class redecl_iterator {
|
||||||
/// Current - The current declaration.
|
/// Current - The current declaration.
|
||||||
decl_type *Current;
|
decl_type *Current = nullptr;
|
||||||
decl_type *Starter;
|
decl_type *Starter;
|
||||||
bool PassedFirst;
|
bool PassedFirst = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef decl_type* value_type;
|
using value_type = decl_type *;
|
||||||
typedef decl_type* reference;
|
using reference = decl_type *;
|
||||||
typedef decl_type* pointer;
|
using pointer = decl_type *;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
typedef std::ptrdiff_t difference_type;
|
using difference_type = std::ptrdiff_t;
|
||||||
|
|
||||||
redecl_iterator() : Current(nullptr) { }
|
redecl_iterator() = default;
|
||||||
explicit redecl_iterator(decl_type *C)
|
explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
|
||||||
: Current(C), Starter(C), PassedFirst(false) { }
|
|
||||||
|
|
||||||
reference operator*() const { return Current; }
|
reference operator*() const { return Current; }
|
||||||
pointer operator->() const { return Current; }
|
pointer operator->() const { return Current; }
|
||||||
|
@ -282,7 +292,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef llvm::iterator_range<redecl_iterator> redecl_range;
|
using redecl_range = llvm::iterator_range<redecl_iterator>;
|
||||||
|
|
||||||
/// \brief Returns an iterator range for all the redeclarations of the same
|
/// \brief Returns an iterator range for all the redeclarations of the same
|
||||||
/// decl. It will iterate at least once (when this decl is the only one).
|
/// decl. It will iterate at least once (when this decl is the only one).
|
||||||
|
@ -294,9 +304,6 @@ public:
|
||||||
|
|
||||||
redecl_iterator redecls_begin() const { return redecls().begin(); }
|
redecl_iterator redecls_begin() const { return redecls().begin(); }
|
||||||
redecl_iterator redecls_end() const { return redecls().end(); }
|
redecl_iterator redecls_end() const { return redecls().end(); }
|
||||||
|
|
||||||
friend class ASTDeclReader;
|
|
||||||
friend class ASTDeclWriter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Get the primary declaration for a declaration from an AST file. That
|
/// \brief Get the primary declaration for a declaration from an AST file. That
|
||||||
|
@ -309,7 +316,7 @@ Decl *getPrimaryMergedDecl(Decl *D);
|
||||||
template<typename decl_type>
|
template<typename decl_type>
|
||||||
class Mergeable {
|
class Mergeable {
|
||||||
public:
|
public:
|
||||||
Mergeable() {}
|
Mergeable() = default;
|
||||||
|
|
||||||
/// \brief Return the first declaration of this declaration or itself if this
|
/// \brief Return the first declaration of this declaration or itself if this
|
||||||
/// is the only declaration.
|
/// is the only declaration.
|
||||||
|
@ -344,7 +351,7 @@ public:
|
||||||
/// remember to call getCanonicalDecl() everywhere.
|
/// remember to call getCanonicalDecl() everywhere.
|
||||||
template <typename decl_type> class CanonicalDeclPtr {
|
template <typename decl_type> class CanonicalDeclPtr {
|
||||||
public:
|
public:
|
||||||
CanonicalDeclPtr() : Ptr(nullptr) {}
|
CanonicalDeclPtr() = default;
|
||||||
CanonicalDeclPtr(decl_type *Ptr)
|
CanonicalDeclPtr(decl_type *Ptr)
|
||||||
: Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
|
: Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
|
||||||
CanonicalDeclPtr(const CanonicalDeclPtr &) = default;
|
CanonicalDeclPtr(const CanonicalDeclPtr &) = default;
|
||||||
|
@ -362,11 +369,13 @@ public:
|
||||||
private:
|
private:
|
||||||
friend struct llvm::DenseMapInfo<CanonicalDeclPtr<decl_type>>;
|
friend struct llvm::DenseMapInfo<CanonicalDeclPtr<decl_type>>;
|
||||||
|
|
||||||
decl_type *Ptr;
|
decl_type *Ptr = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
template <typename decl_type>
|
template <typename decl_type>
|
||||||
struct DenseMapInfo<clang::CanonicalDeclPtr<decl_type>> {
|
struct DenseMapInfo<clang::CanonicalDeclPtr<decl_type>> {
|
||||||
using CanonicalDeclPtr = clang::CanonicalDeclPtr<decl_type>;
|
using CanonicalDeclPtr = clang::CanonicalDeclPtr<decl_type>;
|
||||||
|
@ -395,6 +404,7 @@ struct DenseMapInfo<clang::CanonicalDeclPtr<decl_type>> {
|
||||||
return BaseInfo::isEqual(LHS, RHS);
|
return BaseInfo::isEqual(LHS, RHS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_REDECLARABLE_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- StmtGraphTraits.h - Graph Traits for the class Stmt ----*- C++ -*-===//
|
//===- StmtGraphTraits.h - Graph Traits for the class Stmt ------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -21,13 +21,10 @@
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
//template <typename T> struct GraphTraits;
|
template <> struct GraphTraits<clang::Stmt *> {
|
||||||
|
using NodeRef = clang::Stmt *;
|
||||||
|
using ChildIteratorType = clang::Stmt::child_iterator;
|
||||||
template <> struct GraphTraits<clang::Stmt*> {
|
using nodes_iterator = llvm::df_iterator<clang::Stmt *>;
|
||||||
typedef clang::Stmt * NodeRef;
|
|
||||||
typedef clang::Stmt::child_iterator ChildIteratorType;
|
|
||||||
typedef llvm::df_iterator<clang::Stmt*> nodes_iterator;
|
|
||||||
|
|
||||||
static NodeRef getEntryNode(clang::Stmt *S) { return S; }
|
static NodeRef getEntryNode(clang::Stmt *S) { return S; }
|
||||||
|
|
||||||
|
@ -50,11 +47,10 @@ template <> struct GraphTraits<clang::Stmt*> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <> struct GraphTraits<const clang::Stmt *> {
|
||||||
template <> struct GraphTraits<const clang::Stmt*> {
|
using NodeRef = const clang::Stmt *;
|
||||||
typedef const clang::Stmt * NodeRef;
|
using ChildIteratorType = clang::Stmt::const_child_iterator;
|
||||||
typedef clang::Stmt::const_child_iterator ChildIteratorType;
|
using nodes_iterator = llvm::df_iterator<const clang::Stmt *>;
|
||||||
typedef llvm::df_iterator<const clang::Stmt*> nodes_iterator;
|
|
||||||
|
|
||||||
static NodeRef getEntryNode(const clang::Stmt *S) { return S; }
|
static NodeRef getEntryNode(const clang::Stmt *S) { return S; }
|
||||||
|
|
||||||
|
@ -77,7 +73,6 @@ template <> struct GraphTraits<const clang::Stmt*> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace llvm
|
||||||
|
|
||||||
} // end namespace llvm
|
#endif // LLVM_CLANG_AST_STMTGRAPHTRAITS_H
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- StmtVisitor.h - Visitor for Stmt subclasses ------------*- C++ -*-===//
|
//===- StmtVisitor.h - Visitor for Stmt subclasses --------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -17,14 +17,19 @@
|
||||||
#include "clang/AST/ExprCXX.h"
|
#include "clang/AST/ExprCXX.h"
|
||||||
#include "clang/AST/ExprObjC.h"
|
#include "clang/AST/ExprObjC.h"
|
||||||
#include "clang/AST/ExprOpenMP.h"
|
#include "clang/AST/ExprOpenMP.h"
|
||||||
|
#include "clang/AST/Stmt.h"
|
||||||
#include "clang/AST/StmtCXX.h"
|
#include "clang/AST/StmtCXX.h"
|
||||||
#include "clang/AST/StmtObjC.h"
|
#include "clang/AST/StmtObjC.h"
|
||||||
#include "clang/AST/StmtOpenMP.h"
|
#include "clang/AST/StmtOpenMP.h"
|
||||||
|
#include "clang/Basic/LLVM.h"
|
||||||
|
#include "llvm/Support/Casting.h"
|
||||||
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
template <typename T> struct make_ptr { typedef T *type; };
|
template <typename T> struct make_ptr { using type = T *; };
|
||||||
template <typename T> struct make_const_ptr { typedef const T *type; };
|
template <typename T> struct make_const_ptr { using type = const T *; };
|
||||||
|
|
||||||
/// StmtVisitorBase - This class implements a simple visitor for Stmt
|
/// StmtVisitorBase - This class implements a simple visitor for Stmt
|
||||||
/// subclasses. Since Expr derives from Stmt, this also includes support for
|
/// subclasses. Since Expr derives from Stmt, this also includes support for
|
||||||
|
@ -33,14 +38,12 @@ template<template <typename> class Ptr, typename ImplClass, typename RetTy=void,
|
||||||
class... ParamTys>
|
class... ParamTys>
|
||||||
class StmtVisitorBase {
|
class StmtVisitorBase {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#define PTR(CLASS) typename Ptr<CLASS>::type
|
#define PTR(CLASS) typename Ptr<CLASS>::type
|
||||||
#define DISPATCH(NAME, CLASS) \
|
#define DISPATCH(NAME, CLASS) \
|
||||||
return static_cast<ImplClass*>(this)->Visit ## NAME( \
|
return static_cast<ImplClass*>(this)->Visit ## NAME( \
|
||||||
static_cast<PTR(CLASS)>(S), std::forward<ParamTys>(P)...)
|
static_cast<PTR(CLASS)>(S), std::forward<ParamTys>(P)...)
|
||||||
|
|
||||||
RetTy Visit(PTR(Stmt) S, ParamTys... P) {
|
RetTy Visit(PTR(Stmt) S, ParamTys... P) {
|
||||||
|
|
||||||
// If we have a binary expr, dispatch to the subcode of the binop. A smart
|
// If we have a binary expr, dispatch to the subcode of the binop. A smart
|
||||||
// optimizer (e.g. LLVM) will fold this comparison into the switch stmt
|
// optimizer (e.g. LLVM) will fold this comparison into the switch stmt
|
||||||
// below.
|
// below.
|
||||||
|
@ -224,6 +227,6 @@ template<class ImplClass, typename RetTy = void>
|
||||||
class ConstOMPClauseVisitor :
|
class ConstOMPClauseVisitor :
|
||||||
public OMPClauseVisitorBase <ImplClass, make_const_ptr, RetTy> {};
|
public OMPClauseVisitorBase <ImplClass, make_const_ptr, RetTy> {};
|
||||||
|
|
||||||
} // end namespace clang
|
} // namespace clang
|
||||||
|
|
||||||
#endif
|
#endif // LLVM_CLANG_AST_STMTVISITOR_H
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- DeclFriend.cpp - C++ Friend Declaration AST Node Implementation --===//
|
//===- DeclFriend.cpp - C++ Friend Declaration AST Node Implementation ----===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -12,12 +12,20 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "clang/AST/ASTContext.h"
|
|
||||||
#include "clang/AST/DeclFriend.h"
|
#include "clang/AST/DeclFriend.h"
|
||||||
|
#include "clang/AST/Decl.h"
|
||||||
|
#include "clang/AST/DeclBase.h"
|
||||||
|
#include "clang/AST/DeclCXX.h"
|
||||||
|
#include "clang/AST/ASTContext.h"
|
||||||
#include "clang/AST/DeclTemplate.h"
|
#include "clang/AST/DeclTemplate.h"
|
||||||
|
#include "clang/Basic/LLVM.h"
|
||||||
|
#include "llvm/Support/Casting.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
void FriendDecl::anchor() { }
|
void FriendDecl::anchor() {}
|
||||||
|
|
||||||
FriendDecl *FriendDecl::getNextFriendSlowCase() {
|
FriendDecl *FriendDecl::getNextFriendSlowCase() {
|
||||||
return cast_or_null<FriendDecl>(
|
return cast_or_null<FriendDecl>(
|
||||||
|
@ -28,9 +36,9 @@ FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
|
||||||
SourceLocation L,
|
SourceLocation L,
|
||||||
FriendUnion Friend,
|
FriendUnion Friend,
|
||||||
SourceLocation FriendL,
|
SourceLocation FriendL,
|
||||||
ArrayRef<TemplateParameterList*> FriendTypeTPLists) {
|
ArrayRef<TemplateParameterList *> FriendTypeTPLists) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (Friend.is<NamedDecl*>()) {
|
if (Friend.is<NamedDecl *>()) {
|
||||||
NamedDecl *D = Friend.get<NamedDecl*>();
|
NamedDecl *D = Friend.get<NamedDecl*>();
|
||||||
assert(isa<FunctionDecl>(D) ||
|
assert(isa<FunctionDecl>(D) ||
|
||||||
isa<CXXRecordDecl>(D) ||
|
isa<CXXRecordDecl>(D) ||
|
||||||
|
@ -42,7 +50,7 @@ FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
|
||||||
assert(D->getFriendObjectKind() ||
|
assert(D->getFriendObjectKind() ||
|
||||||
(cast<CXXRecordDecl>(DC)->getTemplateSpecializationKind()));
|
(cast<CXXRecordDecl>(DC)->getTemplateSpecializationKind()));
|
||||||
// These template parameters are for friend types only.
|
// These template parameters are for friend types only.
|
||||||
assert(FriendTypeTPLists.size() == 0);
|
assert(FriendTypeTPLists.empty());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===--- DeclGroup.cpp - Classes for representing groups of Decls -*- C++ -*-==//
|
//===- DeclGroup.cpp - Classes for representing groups of Decls -----------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
#include "clang/AST/DeclGroup.h"
|
#include "clang/AST/DeclGroup.h"
|
||||||
#include "clang/AST/ASTContext.h"
|
#include "clang/AST/ASTContext.h"
|
||||||
#include "clang/AST/Decl.h"
|
#include <cassert>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {
|
DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//===-- RecordLayout.cpp - Layout information for a struct/union -*- C++ -*-==//
|
//===- RecordLayout.cpp - Layout information for a struct/union -----------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
|
@ -11,9 +11,11 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "clang/AST/ASTContext.h"
|
|
||||||
#include "clang/AST/RecordLayout.h"
|
#include "clang/AST/RecordLayout.h"
|
||||||
|
#include "clang/AST/ASTContext.h"
|
||||||
|
#include "clang/Basic/TargetCXXABI.h"
|
||||||
#include "clang/Basic/TargetInfo.h"
|
#include "clang/Basic/TargetInfo.h"
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
|
||||||
CharUnits datasize,
|
CharUnits datasize,
|
||||||
ArrayRef<uint64_t> fieldoffsets)
|
ArrayRef<uint64_t> fieldoffsets)
|
||||||
: Size(size), DataSize(datasize), Alignment(alignment),
|
: Size(size), DataSize(datasize), Alignment(alignment),
|
||||||
RequiredAlignment(requiredAlignment), CXXInfo(nullptr) {
|
RequiredAlignment(requiredAlignment) {
|
||||||
FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
|
FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +75,6 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
|
||||||
CXXInfo->EndsWithZeroSizedObject = EndsWithZeroSizedObject;
|
CXXInfo->EndsWithZeroSizedObject = EndsWithZeroSizedObject;
|
||||||
CXXInfo->LeadsWithZeroSizedBase = LeadsWithZeroSizedBase;
|
CXXInfo->LeadsWithZeroSizedBase = LeadsWithZeroSizedBase;
|
||||||
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (const CXXRecordDecl *PrimaryBase = getPrimaryBase()) {
|
if (const CXXRecordDecl *PrimaryBase = getPrimaryBase()) {
|
||||||
if (isPrimaryBaseVirtual()) {
|
if (isPrimaryBaseVirtual()) {
|
||||||
|
|
Loading…
Reference in New Issue