26#include "llvm/ADT/FoldingSet.h" 
   27#include "llvm/Support/Compiler.h" 
   28#include "llvm/Support/ErrorHandling.h" 
   29#include "llvm/Support/raw_ostream.h" 
   38NestedNameSpecifier::MakeNamespaceAndPrefixStorage(
 
   41  llvm::FoldingSetNodeID 
ID;
 
   44  void *InsertPos = 
nullptr;
 
   45  NamespaceAndPrefixStorage *S =
 
   46      Ctx.NamespaceAndPrefixStorages.FindNodeOrInsertPos(ID, InsertPos);
 
   48    S = 
new (Ctx, 
alignof(NamespaceAndPrefixStorage))
 
   49        NamespaceAndPrefixStorage(
Namespace, Prefix);
 
   50    Ctx.NamespaceAndPrefixStorages.InsertNode(S, InsertPos);
 
   67  llvm_unreachable(
"Invalid NNS Kind!");
 
 
   75    return NestedNameSpecifierDependence::None;
 
   79               ? NestedNameSpecifierDependence::DependentInstantiation |
 
   80                     NestedNameSpecifierDependence::Dependent
 
   81               : NestedNameSpecifierDependence::None;
 
   86  llvm_unreachable(
"Invalid NNS Kind!");
 
 
   92                                bool ResolveTemplateArguments,
 
   93                                bool PrintFinalScopeResOp)
 const {
 
   97    Prefix.
print(OS, Policy);
 
   98    if (
const auto *NS = dyn_cast<NamespaceDecl>(
Namespace)) {
 
   99      assert(!NS->isAnonymousNamespace());
 
  102      OS << cast<NamespaceAliasDecl>(
Namespace)->getName();
 
  121  if (PrintFinalScopeResOp)
 
 
  148  return First.getLocalSourceRange().getBegin();
 
 
  151static void Append(
char *Start, 
char *End, 
char *&Buffer, 
unsigned &BufferSize,
 
  152                   unsigned &BufferCapacity) {
 
  156  if (BufferSize + (End - Start) > BufferCapacity) {
 
  158    unsigned NewCapacity = std::max(
 
  159        (
unsigned)(BufferCapacity ? BufferCapacity * 2 : 
sizeof(
void *) * 2),
 
  160        (
unsigned)(BufferSize + (End - Start)));
 
  161    if (!BufferCapacity) {
 
  162      char *NewBuffer = 
static_cast<char *
>(llvm::safe_malloc(NewCapacity));
 
  164        memcpy(NewBuffer, Buffer, BufferSize);
 
  167      Buffer = 
static_cast<char *
>(llvm::safe_realloc(Buffer, NewCapacity));
 
  169    BufferCapacity = NewCapacity;
 
  171  assert(Buffer && Start && End && End > Start && 
"Illegal memory buffer copy");
 
  172  memcpy(Buffer + BufferSize, Start, End - Start);
 
  173  BufferSize += End - Start;
 
 
  178                               unsigned &BufferSize, 
unsigned &BufferCapacity) {
 
  180  Append(
reinterpret_cast<char *
>(&Raw),
 
  181         reinterpret_cast<char *
>(&Raw) + 
sizeof(Raw), Buffer, BufferSize,
 
 
  186static void SavePointer(
void *Ptr, 
char *&Buffer, 
unsigned &BufferSize,
 
  187                        unsigned &BufferCapacity) {
 
  188  Append(
reinterpret_cast<char *
>(&Ptr),
 
  189         reinterpret_cast<char *
>(&Ptr) + 
sizeof(
void *),
 
  190         Buffer, BufferSize, BufferCapacity);
 
 
  195    : Representation(
Other.Representation) {
 
  199  if (
Other.BufferCapacity == 0) {
 
  201    Buffer = Other.Buffer;
 
  202    BufferSize = Other.BufferSize;
 
 
  214  Representation = 
Other.Representation;
 
  216  if (Buffer && 
Other.Buffer && BufferCapacity >= 
Other.BufferSize) {
 
  218    BufferSize = 
Other.BufferSize;
 
  224  if (BufferCapacity) {
 
  236  if (
Other.BufferCapacity == 0) {
 
  238    Buffer = 
Other.Buffer;
 
  239    BufferSize = 
Other.BufferSize;
 
 
  252  assert(!Representation);
 
 
  273  assert(!Representation && 
"Already have a nested-name-specifier!?");
 
 
  290void NestedNameSpecifierLocBuilder::PushTrivial(
ASTContext &Context,
 
  295  switch (Qualifier.getKind()) {
 
  299    auto [_1, Prefix] = Qualifier.getAsNamespaceAndPrefix();
 
  300    PushTrivial(Context, Prefix, R.
getBegin());
 
  323    Representation = std::nullopt;
 
  331  Representation = 
Other.getNestedNameSpecifier();
 
  332  Buffer = 
static_cast<char *
>(
Other.getOpaqueData());
 
  333  BufferSize = 
Other.getDataLength();
 
 
  344  if (BufferCapacity == 0)
 
  350  void *Mem = Context.Allocate(BufferSize, 
alignof(
void *));
 
  351  memcpy(Mem, Buffer, BufferSize);
 
 
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
static void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize, unsigned &BufferCapacity)
static void SaveSourceLocation(SourceLocation Loc, char *&Buffer, unsigned &BufferSize, unsigned &BufferCapacity)
Save a source location to the given buffer.
static void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize, unsigned &BufferCapacity)
Save a pointer to the given buffer.
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a C++ struct/union/class.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents C++ namespaces and their aliases.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
NestedNameSpecifierLocBuilder & operator=(const NestedNameSpecifierLocBuilder &Other)
void Make(ASTContext &Context, TypeLoc TL, SourceLocation ColonColonLoc)
Make a nested-name-specifier of the form 'type::'.
void MakeMicrosoftSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
NestedNameSpecifierLocBuilder()=default
void Extend(ASTContext &Context, const NamespaceBaseDecl *Namespace, SourceLocation NamespaceLoc, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'name...
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifierLoc()=default
Construct an empty nested-name-specifier.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
static constexpr NestedNameSpecifier getGlobal()
void dump(llvm::raw_ostream *OS=nullptr, const LangOptions *LO=nullptr) const
Dump the nested name specifier to aid in debugging.
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
bool isFullyQualified() const
Whether this nested name specifier starts with a '::'.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) const
Print this nested name specifier to the given output stream.
NestedNameSpecifierDependence getDependence() const
const Type * getAsType() const
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
A (possibly-)qualified type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Encodes a location in the source.
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Base wrapper for a particular "section" of type source info.
void * getOpaqueData() const
Get the pointer where source information is stored.
const Type * getTypePtr() const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
The JSON file list parser is used to communicate input to InstallAPI.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
NestedNameSpecifierDependence toNestedNameSpecifierDependence(TypeDependence D)
@ Other
Other implicit parameter.
void Profile(llvm::FoldingSetNodeID &ID)
NestedNameSpecifier Prefix
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.