clang  14.0.0git
NestedNameSpecifier.h
Go to the documentation of this file.
1 //===- NestedNameSpecifier.h - C++ nested name specifiers -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the NestedNameSpecifier class, which represents
10 // a C++ nested-name-specifier.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
15 #define LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
16 
18 #include "clang/Basic/Diagnostic.h"
20 #include "llvm/ADT/DenseMapInfo.h"
21 #include "llvm/ADT/FoldingSet.h"
22 #include "llvm/ADT/PointerIntPair.h"
23 #include "llvm/Support/Compiler.h"
24 #include <cstdint>
25 #include <cstdlib>
26 #include <utility>
27 
28 namespace clang {
29 
30 class ASTContext;
31 class CXXRecordDecl;
32 class IdentifierInfo;
33 class LangOptions;
34 class NamespaceAliasDecl;
35 class NamespaceDecl;
36 struct PrintingPolicy;
37 class Type;
38 class TypeLoc;
39 
40 /// Represents a C++ nested name specifier, such as
41 /// "\::std::vector<int>::".
42 ///
43 /// C++ nested name specifiers are the prefixes to qualified
44 /// names. For example, "foo::" in "foo::x" is a nested name
45 /// specifier. Nested name specifiers are made up of a sequence of
46 /// specifiers, each of which can be a namespace, type, identifier
47 /// (for dependent names), decltype specifier, or the global specifier ('::').
48 /// The last two specifiers can only appear at the start of a
49 /// nested-namespace-specifier.
50 class NestedNameSpecifier : public llvm::FoldingSetNode {
51  /// Enumeration describing
52  enum StoredSpecifierKind {
53  StoredIdentifier = 0,
54  StoredDecl = 1,
55  StoredTypeSpec = 2,
56  StoredTypeSpecWithTemplate = 3
57  };
58 
59  /// The nested name specifier that precedes this nested name
60  /// specifier.
61  ///
62  /// The pointer is the nested-name-specifier that precedes this
63  /// one. The integer stores one of the first four values of type
64  /// SpecifierKind.
65  llvm::PointerIntPair<NestedNameSpecifier *, 2, StoredSpecifierKind> Prefix;
66 
67  /// The last component in the nested name specifier, which
68  /// can be an identifier, a declaration, or a type.
69  ///
70  /// When the pointer is NULL, this specifier represents the global
71  /// specifier '::'. Otherwise, the pointer is one of
72  /// IdentifierInfo*, Namespace*, or Type*, depending on the kind of
73  /// specifier as encoded within the prefix.
74  void* Specifier = nullptr;
75 
76 public:
77  /// The kind of specifier that completes this nested name
78  /// specifier.
80  /// An identifier, stored as an IdentifierInfo*.
82 
83  /// A namespace, stored as a NamespaceDecl*.
85 
86  /// A namespace alias, stored as a NamespaceAliasDecl*.
88 
89  /// A type, stored as a Type*.
91 
92  /// A type that was preceded by the 'template' keyword,
93  /// stored as a Type*.
95 
96  /// The global specifier '::'. There is no stored value.
98 
99  /// Microsoft's '__super' specifier, stored as a CXXRecordDecl* of
100  /// the class it appeared in.
102  };
103 
104 private:
105  /// Builds the global specifier.
106  NestedNameSpecifier() : Prefix(nullptr, StoredIdentifier) {}
107 
108  /// Copy constructor used internally to clone nested name
109  /// specifiers.
110  NestedNameSpecifier(const NestedNameSpecifier &Other) = default;
111 
112  /// Either find or insert the given nested name specifier
113  /// mockup in the given context.
114  static NestedNameSpecifier *FindOrInsert(const ASTContext &Context,
115  const NestedNameSpecifier &Mockup);
116 
117 public:
118  NestedNameSpecifier &operator=(const NestedNameSpecifier &) = delete;
119 
120  /// Builds a specifier combining a prefix and an identifier.
121  ///
122  /// The prefix must be dependent, since nested name specifiers
123  /// referencing an identifier are only permitted when the identifier
124  /// cannot be resolved.
125  static NestedNameSpecifier *Create(const ASTContext &Context,
126  NestedNameSpecifier *Prefix,
127  IdentifierInfo *II);
128 
129  /// Builds a nested name specifier that names a namespace.
130  static NestedNameSpecifier *Create(const ASTContext &Context,
131  NestedNameSpecifier *Prefix,
132  const NamespaceDecl *NS);
133 
134  /// Builds a nested name specifier that names a namespace alias.
135  static NestedNameSpecifier *Create(const ASTContext &Context,
136  NestedNameSpecifier *Prefix,
137  NamespaceAliasDecl *Alias);
138 
139  /// Builds a nested name specifier that names a type.
140  static NestedNameSpecifier *Create(const ASTContext &Context,
141  NestedNameSpecifier *Prefix,
142  bool Template, const Type *T);
143 
144  /// Builds a specifier that consists of just an identifier.
145  ///
146  /// The nested-name-specifier is assumed to be dependent, but has no
147  /// prefix because the prefix is implied by something outside of the
148  /// nested name specifier, e.g., in "x->Base::f", the "x" has a dependent
149  /// type.
150  static NestedNameSpecifier *Create(const ASTContext &Context,
151  IdentifierInfo *II);
152 
153  /// Returns the nested name specifier representing the global
154  /// scope.
155  static NestedNameSpecifier *GlobalSpecifier(const ASTContext &Context);
156 
157  /// Returns the nested name specifier representing the __super scope
158  /// for the given CXXRecordDecl.
159  static NestedNameSpecifier *SuperSpecifier(const ASTContext &Context,
160  CXXRecordDecl *RD);
161 
162  /// Return the prefix of this nested name specifier.
163  ///
164  /// The prefix contains all of the parts of the nested name
165  /// specifier that preced this current specifier. For example, for a
166  /// nested name specifier that represents "foo::bar::", the current
167  /// specifier will contain "bar::" and the prefix will contain
168  /// "foo::".
169  NestedNameSpecifier *getPrefix() const { return Prefix.getPointer(); }
170 
171  /// Determine what kind of nested name specifier is stored.
172  SpecifierKind getKind() const;
173 
174  /// Retrieve the identifier stored in this nested name
175  /// specifier.
177  if (Prefix.getInt() == StoredIdentifier)
178  return (IdentifierInfo *)Specifier;
179 
180  return nullptr;
181  }
182 
183  /// Retrieve the namespace stored in this nested name
184  /// specifier.
185  NamespaceDecl *getAsNamespace() const;
186 
187  /// Retrieve the namespace alias stored in this nested name
188  /// specifier.
190 
191  /// Retrieve the record declaration stored in this nested name
192  /// specifier.
194 
195  /// Retrieve the type stored in this nested name specifier.
196  const Type *getAsType() const {
197  if (Prefix.getInt() == StoredTypeSpec ||
198  Prefix.getInt() == StoredTypeSpecWithTemplate)
199  return (const Type *)Specifier;
200 
201  return nullptr;
202  }
203 
204  NestedNameSpecifierDependence getDependence() const;
205 
206  /// Whether this nested name specifier refers to a dependent
207  /// type or not.
208  bool isDependent() const;
209 
210  /// Whether this nested name specifier involves a template
211  /// parameter.
212  bool isInstantiationDependent() const;
213 
214  /// Whether this nested-name-specifier contains an unexpanded
215  /// parameter pack (for C++11 variadic templates).
216  bool containsUnexpandedParameterPack() const;
217 
218  /// Whether this nested name specifier contains an error.
219  bool containsErrors() const;
220 
221  /// Print this nested name specifier to the given output stream. If
222  /// `ResolveTemplateArguments` is true, we'll print actual types, e.g.
223  /// `ns::SomeTemplate<int, MyClass>` instead of
224  /// `ns::SomeTemplate<Container::value_type, T>`.
225  void print(raw_ostream &OS, const PrintingPolicy &Policy,
226  bool ResolveTemplateArguments = false) const;
227 
228  void Profile(llvm::FoldingSetNodeID &ID) const {
229  ID.AddPointer(Prefix.getOpaqueValue());
230  ID.AddPointer(Specifier);
231  }
232 
233  /// Dump the nested name specifier to standard output to aid
234  /// in debugging.
235  void dump(const LangOptions &LO) const;
236  void dump() const;
237  void dump(llvm::raw_ostream &OS) const;
238  void dump(llvm::raw_ostream &OS, const LangOptions &LO) const;
239 };
240 
241 /// A C++ nested-name-specifier augmented with source location
242 /// information.
244  NestedNameSpecifier *Qualifier = nullptr;
245  void *Data = nullptr;
246 
247  /// Determines the data length for the last component in the
248  /// given nested-name-specifier.
249  static unsigned getLocalDataLength(NestedNameSpecifier *Qualifier);
250 
251  /// Determines the data length for the entire
252  /// nested-name-specifier.
253  static unsigned getDataLength(NestedNameSpecifier *Qualifier);
254 
255 public:
256  /// Construct an empty nested-name-specifier.
257  NestedNameSpecifierLoc() = default;
258 
259  /// Construct a nested-name-specifier with source location information
260  /// from
262  : Qualifier(Qualifier), Data(Data) {}
263 
264  /// Evaluates true when this nested-name-specifier location is
265  /// non-empty.
266  explicit operator bool() const { return Qualifier; }
267 
268  /// Evaluates true when this nested-name-specifier location is
269  /// empty.
270  bool hasQualifier() const { return Qualifier; }
271 
272  /// Retrieve the nested-name-specifier to which this instance
273  /// refers.
275  return Qualifier;
276  }
277 
278  /// Retrieve the opaque pointer that refers to source-location data.
279  void *getOpaqueData() const { return Data; }
280 
281  /// Retrieve the source range covering the entirety of this
282  /// nested-name-specifier.
283  ///
284  /// For example, if this instance refers to a nested-name-specifier
285  /// \c \::std::vector<int>::, the returned source range would cover
286  /// from the initial '::' to the last '::'.
287  SourceRange getSourceRange() const LLVM_READONLY;
288 
289  /// Retrieve the source range covering just the last part of
290  /// this nested-name-specifier, not including the prefix.
291  ///
292  /// For example, if this instance refers to a nested-name-specifier
293  /// \c \::std::vector<int>::, the returned source range would cover
294  /// from "vector" to the last '::'.
296 
297  /// Retrieve the location of the beginning of this
298  /// nested-name-specifier.
300  return getSourceRange().getBegin();
301  }
302 
303  /// Retrieve the location of the end of this
304  /// nested-name-specifier.
306  return getSourceRange().getEnd();
307  }
308 
309  /// Retrieve the location of the beginning of this
310  /// component of the nested-name-specifier.
312  return getLocalSourceRange().getBegin();
313  }
314 
315  /// Retrieve the location of the end of this component of the
316  /// nested-name-specifier.
318  return getLocalSourceRange().getEnd();
319  }
320 
321  /// Return the prefix of this nested-name-specifier.
322  ///
323  /// For example, if this instance refers to a nested-name-specifier
324  /// \c \::std::vector<int>::, the prefix is \c \::std::. Note that the
325  /// returned prefix may be empty, if this is the first component of
326  /// the nested-name-specifier.
328  if (!Qualifier)
329  return *this;
330 
331  return NestedNameSpecifierLoc(Qualifier->getPrefix(), Data);
332  }
333 
334  /// For a nested-name-specifier that refers to a type,
335  /// retrieve the type with source-location information.
336  TypeLoc getTypeLoc() const;
337 
338  /// Determines the data length for the entire
339  /// nested-name-specifier.
340  unsigned getDataLength() const { return getDataLength(Qualifier); }
341 
344  return X.Qualifier == Y.Qualifier && X.Data == Y.Data;
345  }
346 
349  return !(X == Y);
350  }
351 };
352 
353 /// Class that aids in the construction of nested-name-specifiers along
354 /// with source-location information for all of the components of the
355 /// nested-name-specifier.
357  /// The current representation of the nested-name-specifier we're
358  /// building.
359  NestedNameSpecifier *Representation = nullptr;
360 
361  /// Buffer used to store source-location information for the
362  /// nested-name-specifier.
363  ///
364  /// Note that we explicitly manage the buffer (rather than using a
365  /// SmallVector) because \c Declarator expects it to be possible to memcpy()
366  /// a \c CXXScopeSpec, and CXXScopeSpec uses a NestedNameSpecifierLocBuilder.
367  char *Buffer = nullptr;
368 
369  /// The size of the buffer used to store source-location information
370  /// for the nested-name-specifier.
371  unsigned BufferSize = 0;
372 
373  /// The capacity of the buffer used to store source-location
374  /// information for the nested-name-specifier.
375  unsigned BufferCapacity = 0;
376 
377 public:
378  NestedNameSpecifierLocBuilder() = default;
380 
383 
385  if (BufferCapacity)
386  free(Buffer);
387  }
388 
389  /// Retrieve the representation of the nested-name-specifier.
390  NestedNameSpecifier *getRepresentation() const { return Representation; }
391 
392  /// Extend the current nested-name-specifier by another
393  /// nested-name-specifier component of the form 'type::'.
394  ///
395  /// \param Context The AST context in which this nested-name-specifier
396  /// resides.
397  ///
398  /// \param TemplateKWLoc The location of the 'template' keyword, if present.
399  ///
400  /// \param TL The TypeLoc that describes the type preceding the '::'.
401  ///
402  /// \param ColonColonLoc The location of the trailing '::'.
403  void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL,
404  SourceLocation ColonColonLoc);
405 
406  /// Extend the current nested-name-specifier by another
407  /// nested-name-specifier component of the form 'identifier::'.
408  ///
409  /// \param Context The AST context in which this nested-name-specifier
410  /// resides.
411  ///
412  /// \param Identifier The identifier.
413  ///
414  /// \param IdentifierLoc The location of the identifier.
415  ///
416  /// \param ColonColonLoc The location of the trailing '::'.
417  void Extend(ASTContext &Context, IdentifierInfo *Identifier,
419 
420  /// Extend the current nested-name-specifier by another
421  /// nested-name-specifier component of the form 'namespace::'.
422  ///
423  /// \param Context The AST context in which this nested-name-specifier
424  /// resides.
425  ///
426  /// \param Namespace The namespace.
427  ///
428  /// \param NamespaceLoc The location of the namespace name.
429  ///
430  /// \param ColonColonLoc The location of the trailing '::'.
431  void Extend(ASTContext &Context, NamespaceDecl *Namespace,
432  SourceLocation NamespaceLoc, SourceLocation ColonColonLoc);
433 
434  /// Extend the current nested-name-specifier by another
435  /// nested-name-specifier component of the form 'namespace-alias::'.
436  ///
437  /// \param Context The AST context in which this nested-name-specifier
438  /// resides.
439  ///
440  /// \param Alias The namespace alias.
441  ///
442  /// \param AliasLoc The location of the namespace alias
443  /// name.
444  ///
445  /// \param ColonColonLoc The location of the trailing '::'.
446  void Extend(ASTContext &Context, NamespaceAliasDecl *Alias,
447  SourceLocation AliasLoc, SourceLocation ColonColonLoc);
448 
449  /// Turn this (empty) nested-name-specifier into the global
450  /// nested-name-specifier '::'.
451  void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc);
452 
453  /// Turns this (empty) nested-name-specifier into '__super'
454  /// nested-name-specifier.
455  ///
456  /// \param Context The AST context in which this nested-name-specifier
457  /// resides.
458  ///
459  /// \param RD The declaration of the class in which nested-name-specifier
460  /// appeared.
461  ///
462  /// \param SuperLoc The location of the '__super' keyword.
463  /// name.
464  ///
465  /// \param ColonColonLoc The location of the trailing '::'.
466  void MakeSuper(ASTContext &Context, CXXRecordDecl *RD,
467  SourceLocation SuperLoc, SourceLocation ColonColonLoc);
468 
469  /// Make a new nested-name-specifier from incomplete source-location
470  /// information.
471  ///
472  /// This routine should be used very, very rarely, in cases where we
473  /// need to synthesize a nested-name-specifier. Most code should instead use
474  /// \c Adopt() with a proper \c NestedNameSpecifierLoc.
475  void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier,
476  SourceRange R);
477 
478  /// Adopt an existing nested-name-specifier (with source-range
479  /// information).
480  void Adopt(NestedNameSpecifierLoc Other);
481 
482  /// Retrieve the source range covered by this nested-name-specifier.
483  SourceRange getSourceRange() const LLVM_READONLY {
484  return NestedNameSpecifierLoc(Representation, Buffer).getSourceRange();
485  }
486 
487  /// Retrieve a nested-name-specifier with location information,
488  /// copied into the given AST context.
489  ///
490  /// \param Context The context into which this nested-name-specifier will be
491  /// copied.
493 
494  /// Retrieve a nested-name-specifier with location
495  /// information based on the information in this builder.
496  ///
497  /// This loc will contain references to the builder's internal data and may
498  /// be invalidated by any change to the builder.
500  return NestedNameSpecifierLoc(Representation, Buffer);
501  }
502 
503  /// Clear out this builder, and prepare it to build another
504  /// nested-name-specifier with source-location information.
505  void Clear() {
506  Representation = nullptr;
507  BufferSize = 0;
508  }
509 
510  /// Retrieve the underlying buffer.
511  ///
512  /// \returns A pair containing a pointer to the buffer of source-location
513  /// data and the size of the source-location data that resides in that
514  /// buffer.
515  std::pair<char *, unsigned> getBuffer() const {
516  return std::make_pair(Buffer, BufferSize);
517  }
518 };
519 
520 /// Insertion operator for diagnostics. This allows sending
521 /// NestedNameSpecifiers into a diagnostic with <<.
523  NestedNameSpecifier *NNS) {
524  DB.AddTaggedVal(reinterpret_cast<uint64_t>(NNS),
526  return DB;
527 }
528 
529 } // namespace clang
530 
531 namespace llvm {
532 
533 template <> struct DenseMapInfo<clang::NestedNameSpecifierLoc> {
536 
538  return clang::NestedNameSpecifierLoc(FirstInfo::getEmptyKey(),
539  SecondInfo::getEmptyKey());
540  }
541 
543  return clang::NestedNameSpecifierLoc(FirstInfo::getTombstoneKey(),
544  SecondInfo::getTombstoneKey());
545  }
546 
547  static unsigned getHashValue(const clang::NestedNameSpecifierLoc &PairVal) {
548  return hash_combine(
549  FirstInfo::getHashValue(PairVal.getNestedNameSpecifier()),
550  SecondInfo::getHashValue(PairVal.getOpaqueData()));
551  }
552 
553  static bool isEqual(const clang::NestedNameSpecifierLoc &LHS,
554  const clang::NestedNameSpecifierLoc &RHS) {
555  return LHS == RHS;
556  }
557 };
558 } // namespace llvm
559 
560 #endif // LLVM_CLANG_AST_NESTEDNAMESPECIFIER_H
clang::NestedNameSpecifier::Create
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Definition: NestedNameSpecifier.cpp:59
clang::NestedNameSpecifierLoc::getLocalEndLoc
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
Definition: NestedNameSpecifier.h:317
clang::NestedNameSpecifier::Identifier
@ Identifier
An identifier, stored as an IdentifierInfo*.
Definition: NestedNameSpecifier.h:81
llvm
Definition: Dominators.h:30
clang::NestedNameSpecifier::getAsRecordDecl
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
Definition: NestedNameSpecifier.cpp:185
clang::NestedNameSpecifier::Super
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
Definition: NestedNameSpecifier.h:101
llvm::DenseMapInfo< clang::NestedNameSpecifierLoc >::isEqual
static bool isEqual(const clang::NestedNameSpecifierLoc &LHS, const clang::NestedNameSpecifierLoc &RHS)
Definition: NestedNameSpecifier.h:553
clang::NestedNameSpecifierLoc::operator!=
friend bool operator!=(NestedNameSpecifierLoc X, NestedNameSpecifierLoc Y)
Definition: NestedNameSpecifier.h:347
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:2986
clang::NestedNameSpecifier::isDependent
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
Definition: NestedNameSpecifier.cpp:234
DependenceFlags.h
clang::NestedNameSpecifierLocBuilder::Adopt
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: NestedNameSpecifier.cpp:672
clang::NestedNameSpecifier::NamespaceAlias
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
Definition: NestedNameSpecifier.h:87
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:221
clang::NestedNameSpecifier::isInstantiationDependent
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
Definition: NestedNameSpecifier.cpp:238
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::NestedNameSpecifierLoc::getEndLoc
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
Definition: NestedNameSpecifier.h:305
clang::NestedNameSpecifierLoc::getLocalBeginLoc
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Definition: NestedNameSpecifier.h:311
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:59
Identifier
StringRef Identifier
Definition: Format.cpp:2341
clang::NestedNameSpecifierLocBuilder::MakeGlobal
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: NestedNameSpecifier.cpp:611
clang::NestedNameSpecifierLoc::NestedNameSpecifierLoc
NestedNameSpecifierLoc()=default
Construct an empty nested-name-specifier.
clang::StreamingDiagnostic::AddTaggedVal
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
Definition: Diagnostic.h:1182
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::NestedNameSpecifierLoc::operator==
friend bool operator==(NestedNameSpecifierLoc X, NestedNameSpecifierLoc Y)
Definition: NestedNameSpecifier.h:342
llvm::DenseMapInfo
Definition: TypeOrdering.h:37
clang::NestedNameSpecifier::Namespace
@ Namespace
A namespace, stored as a NamespaceDecl*.
Definition: NestedNameSpecifier.h:84
clang::NestedNameSpecifier::containsUnexpandedParameterPack
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
Definition: NestedNameSpecifier.cpp:242
clang::NestedNameSpecifierLocBuilder::Clear
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
Definition: NestedNameSpecifier.h:505
clang::NestedNameSpecifierLoc::getLocalSourceRange
SourceRange getLocalSourceRange() const
Retrieve the source range covering just the last part of this nested-name-specifier,...
Definition: NestedNameSpecifier.cpp:422
clang::NestedNameSpecifier::getAsIdentifier
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
Definition: NestedNameSpecifier.h:176
clang::NestedNameSpecifier::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: NestedNameSpecifier.h:228
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:222
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::StreamingDiagnostic
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1108
Diagnostic.h
clang::NestedNameSpecifierLoc::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Definition: NestedNameSpecifier.cpp:410
clang::NestedNameSpecifier::containsErrors
bool containsErrors() const
Whether this nested name specifier contains an error.
Definition: NestedNameSpecifier.cpp:246
clang::NestedNameSpecifierLocBuilder::MakeSuper
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: NestedNameSpecifier.cpp:620
bool
#define bool
Definition: stdbool.h:15
clang::NestedNameSpecifierLocBuilder::getTemporary
NestedNameSpecifierLoc getTemporary() const
Retrieve a nested-name-specifier with location information based on the information in this builder.
Definition: NestedNameSpecifier.h:499
clang::NestedNameSpecifier::Global
@ Global
The global specifier '::'. There is no stored value.
Definition: NestedNameSpecifier.h:97
clang::NestedNameSpecifierLocBuilder::NestedNameSpecifierLocBuilder
NestedNameSpecifierLocBuilder()=default
clang::NestedNameSpecifier::operator=
NestedNameSpecifier & operator=(const NestedNameSpecifier &)=delete
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::operator<<
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
Definition: ASTContext.cpp:11777
clang::NestedNameSpecifierLocBuilder
Class that aids in the construction of nested-name-specifiers along with source-location information ...
Definition: NestedNameSpecifier.h:356
clang::NestedNameSpecifier::TypeSpecWithTemplate
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
Definition: NestedNameSpecifier.h:94
clang::NestedNameSpecifierLocBuilder::operator=
NestedNameSpecifierLocBuilder & operator=(const NestedNameSpecifierLocBuilder &Other)
Definition: NestedNameSpecifier.cpp:526
clang::NestedNameSpecifierLocBuilder::Extend
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
Definition: NestedNameSpecifier.cpp:563
clang::format::hash_combine
static void hash_combine(std::size_t &seed, const T &v)
Definition: UnwrappedLineParser.cpp:579
clang::NestedNameSpecifierLoc::getOpaqueData
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
Definition: NestedNameSpecifier.h:279
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
SourceLocation.h
clang::NestedNameSpecifier::getAsNamespaceAlias
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
Definition: NestedNameSpecifier.cpp:177
clang::NestedNameSpecifier::print
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
Definition: NestedNameSpecifier.cpp:252
clang::NestedNameSpecifier::getAsNamespace
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
Definition: NestedNameSpecifier.cpp:169
llvm::DenseMapInfo< clang::NestedNameSpecifierLoc >::getTombstoneKey
static clang::NestedNameSpecifierLoc getTombstoneKey()
Definition: NestedNameSpecifier.h:542
clang::NestedNameSpecifier::getDependence
NestedNameSpecifierDependence getDependence() const
Definition: NestedNameSpecifier.cpp:201
Specifier
const NestedNameSpecifier * Specifier
Definition: USRLocFinder.cpp:173
llvm::DenseMapInfo< clang::NestedNameSpecifierLoc >::getHashValue
static unsigned getHashValue(const clang::NestedNameSpecifierLoc &PairVal)
Definition: NestedNameSpecifier.h:547
clang::NestedNameSpecifierLocBuilder::getBuffer
std::pair< char *, unsigned > getBuffer() const
Retrieve the underlying buffer.
Definition: NestedNameSpecifier.h:515
clang::NestedNameSpecifierLoc::NestedNameSpecifierLoc
NestedNameSpecifierLoc(NestedNameSpecifier *Qualifier, void *Data)
Construct a nested-name-specifier with source location information from.
Definition: NestedNameSpecifier.h:261
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::NestedNameSpecifierLocBuilder::getRepresentation
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
Definition: NestedNameSpecifier.h:390
clang::NestedNameSpecifierLoc::getPrefix
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
Definition: NestedNameSpecifier.h:327
clang::NestedNameSpecifier::SuperSpecifier
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
Definition: NestedNameSpecifier.cpp:134
clang::NestedNameSpecifierLocBuilder::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covered by this nested-name-specifier.
Definition: NestedNameSpecifier.h:483
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
clang::NestedNameSpecifierLoc::getDataLength
unsigned getDataLength() const
Determines the data length for the entire nested-name-specifier.
Definition: NestedNameSpecifier.h:340
llvm::DenseMapInfo< clang::NestedNameSpecifierLoc >::getEmptyKey
static clang::NestedNameSpecifierLoc getEmptyKey()
Definition: NestedNameSpecifier.h:537
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang
Definition: CalledOnceCheck.h:17
clang::NestedNameSpecifierLoc::hasQualifier
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is empty.
Definition: NestedNameSpecifier.h:270
clang::NestedNameSpecifier::getAsType
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Definition: NestedNameSpecifier.h:196
clang::NestedNameSpecifierLoc::getNestedNameSpecifier
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Definition: NestedNameSpecifier.h:274
clang::NestedNameSpecifier::getPrefix
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Definition: NestedNameSpecifier.h:169
clang::NestedNameSpecifier::SpecifierKind
SpecifierKind
The kind of specifier that completes this nested name specifier.
Definition: NestedNameSpecifier.h:79
clang::NestedNameSpecifierLocBuilder::MakeTrivial
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: NestedNameSpecifier.cpp:631
clang::NestedNameSpecifier::GlobalSpecifier
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
Definition: NestedNameSpecifier.cpp:126
clang::NestedNameSpecifier::dump
void dump() const
Definition: NestedNameSpecifier.cpp:343
clang::NestedNameSpecifier::TypeSpec
@ TypeSpec
A type, stored as a Type*.
Definition: NestedNameSpecifier.h:90
clang::NestedNameSpecifierLocBuilder::~NestedNameSpecifierLocBuilder
~NestedNameSpecifierLocBuilder()
Definition: NestedNameSpecifier.h:384
clang::NestedNameSpecifierLoc::getTypeLoc
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
Definition: NestedNameSpecifier.cpp:453
clang::NestedNameSpecifierLoc::getBeginLoc
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
Definition: NestedNameSpecifier.h:299
clang::NestedNameSpecifier::getKind
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Definition: NestedNameSpecifier.cpp:143
clang::IdentifierLoc
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:187
clang::NamespaceDecl
Represent a C++ namespace.
Definition: Decl.h:542
clang::NestedNameSpecifierLocBuilder::getWithLocInContext
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition: NestedNameSpecifier.cpp:692
Type
MatchType Type
Definition: ASTMatchFinder.cpp:70
clang::DiagnosticsEngine::ak_nestednamespec
@ ak_nestednamespec
NestedNameSpecifier *.
Definition: Diagnostic.h:238