clang  14.0.0git
SourceLocation.h
Go to the documentation of this file.
1 //===- SourceLocation.h - Compact identifier for Source Files ---*- 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 /// \file
10 /// Defines the clang::SourceLocation class and associated facilities.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_BASIC_SOURCELOCATION_H
15 #define LLVM_CLANG_BASIC_SOURCELOCATION_H
16 
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/StringRef.h"
19 #include <cassert>
20 #include <cstdint>
21 #include <string>
22 #include <utility>
23 
24 namespace llvm {
25 
26 template <typename T> struct DenseMapInfo;
27 
28 class FoldingSetNodeID;
29 template <typename T> struct FoldingSetTrait;
30 
31 } // namespace llvm
32 
33 namespace clang {
34 
35 class SourceManager;
36 
37 /// An opaque identifier used by SourceManager which refers to a
38 /// source file (MemoryBuffer) along with its \#include path and \#line data.
39 ///
40 class FileID {
41  /// A mostly-opaque identifier, where 0 is "invalid", >0 is
42  /// this module, and <-1 is something loaded from another module.
43  int ID = 0;
44 
45 public:
46  bool isValid() const { return ID != 0; }
47  bool isInvalid() const { return ID == 0; }
48 
49  bool operator==(const FileID &RHS) const { return ID == RHS.ID; }
50  bool operator<(const FileID &RHS) const { return ID < RHS.ID; }
51  bool operator<=(const FileID &RHS) const { return ID <= RHS.ID; }
52  bool operator!=(const FileID &RHS) const { return !(*this == RHS); }
53  bool operator>(const FileID &RHS) const { return RHS < *this; }
54  bool operator>=(const FileID &RHS) const { return RHS <= *this; }
55 
56  static FileID getSentinel() { return get(-1); }
57  unsigned getHashValue() const { return static_cast<unsigned>(ID); }
58 
59 private:
60  friend class ASTWriter;
61  friend class ASTReader;
62  friend class SourceManager;
63 
64  static FileID get(int V) {
65  FileID F;
66  F.ID = V;
67  return F;
68  }
69 
70  int getOpaqueValue() const { return ID; }
71 };
72 
73 /// Encodes a location in the source. The SourceManager can decode this
74 /// to get at the full include stack, line and column information.
75 ///
76 /// Technically, a source location is simply an offset into the manager's view
77 /// of the input source, which is all input buffers (including macro
78 /// expansions) concatenated in an effectively arbitrary order. The manager
79 /// actually maintains two blocks of input buffers. One, starting at offset
80 /// 0 and growing upwards, contains all buffers from this module. The other,
81 /// starting at the highest possible offset and growing downwards, contains
82 /// buffers of loaded modules.
83 ///
84 /// In addition, one bit of SourceLocation is used for quick access to the
85 /// information whether the location is in a file or a macro expansion.
86 ///
87 /// It is important that this type remains small. It is currently 32 bits wide.
89  friend class ASTReader;
90  friend class ASTWriter;
91  friend class SourceManager;
93 
94 public:
95  using UIntTy = uint32_t;
96  using IntTy = int32_t;
97 
98 private:
99  UIntTy ID = 0;
100 
101  enum : UIntTy { MacroIDBit = 1ULL << (8 * sizeof(UIntTy) - 1) };
102 
103 public:
104  bool isFileID() const { return (ID & MacroIDBit) == 0; }
105  bool isMacroID() const { return (ID & MacroIDBit) != 0; }
106 
107  /// Return true if this is a valid SourceLocation object.
108  ///
109  /// Invalid SourceLocations are often used when events have no corresponding
110  /// location in the source (e.g. a diagnostic is required for a command line
111  /// option).
112  bool isValid() const { return ID != 0; }
113  bool isInvalid() const { return ID == 0; }
114 
115 private:
116  /// Return the offset into the manager's global input view.
117  UIntTy getOffset() const { return ID & ~MacroIDBit; }
118 
119  static SourceLocation getFileLoc(UIntTy ID) {
120  assert((ID & MacroIDBit) == 0 && "Ran out of source locations!");
121  SourceLocation L;
122  L.ID = ID;
123  return L;
124  }
125 
126  static SourceLocation getMacroLoc(UIntTy ID) {
127  assert((ID & MacroIDBit) == 0 && "Ran out of source locations!");
128  SourceLocation L;
129  L.ID = MacroIDBit | ID;
130  return L;
131  }
132 
133 public:
134  /// Return a source location with the specified offset from this
135  /// SourceLocation.
137  assert(((getOffset()+Offset) & MacroIDBit) == 0 && "offset overflow");
138  SourceLocation L;
139  L.ID = ID+Offset;
140  return L;
141  }
142 
143  /// When a SourceLocation itself cannot be used, this returns
144  /// an (opaque) 32-bit integer encoding for it.
145  ///
146  /// This should only be passed to SourceLocation::getFromRawEncoding, it
147  /// should not be inspected directly.
148  UIntTy getRawEncoding() const { return ID; }
149 
150  /// Turn a raw encoding of a SourceLocation object into
151  /// a real SourceLocation.
152  ///
153  /// \see getRawEncoding.
156  X.ID = Encoding;
157  return X;
158  }
159 
160  /// When a SourceLocation itself cannot be used, this returns
161  /// an (opaque) pointer encoding for it.
162  ///
163  /// This should only be passed to SourceLocation::getFromPtrEncoding, it
164  /// should not be inspected directly.
165  void* getPtrEncoding() const {
166  // Double cast to avoid a warning "cast to pointer from integer of different
167  // size".
168  return (void*)(uintptr_t)getRawEncoding();
169  }
170 
171  /// Turn a pointer encoding of a SourceLocation object back
172  /// into a real SourceLocation.
175  }
176 
178  return Start.isValid() && Start.isFileID() && End.isValid() &&
179  End.isFileID();
180  }
181 
182  unsigned getHashValue() const;
183  void print(raw_ostream &OS, const SourceManager &SM) const;
185  void dump(const SourceManager &SM) const;
186 };
187 
188 inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
189  return LHS.getRawEncoding() == RHS.getRawEncoding();
190 }
191 
192 inline bool operator!=(const SourceLocation &LHS, const SourceLocation &RHS) {
193  return !(LHS == RHS);
194 }
195 
196 // Ordering is meaningful only if LHS and RHS have the same FileID!
197 // Otherwise use SourceManager::isBeforeInTranslationUnit().
198 inline bool operator<(const SourceLocation &LHS, const SourceLocation &RHS) {
199  return LHS.getRawEncoding() < RHS.getRawEncoding();
200 }
201 inline bool operator>(const SourceLocation &LHS, const SourceLocation &RHS) {
202  return LHS.getRawEncoding() > RHS.getRawEncoding();
203 }
204 inline bool operator<=(const SourceLocation &LHS, const SourceLocation &RHS) {
205  return LHS.getRawEncoding() <= RHS.getRawEncoding();
206 }
207 inline bool operator>=(const SourceLocation &LHS, const SourceLocation &RHS) {
208  return LHS.getRawEncoding() >= RHS.getRawEncoding();
209 }
210 
211 /// A trivial tuple used to represent a source range.
212 class SourceRange {
213  SourceLocation B;
214  SourceLocation E;
215 
216 public:
217  SourceRange() = default;
218  SourceRange(SourceLocation loc) : B(loc), E(loc) {}
219  SourceRange(SourceLocation begin, SourceLocation end) : B(begin), E(end) {}
220 
221  SourceLocation getBegin() const { return B; }
222  SourceLocation getEnd() const { return E; }
223 
224  void setBegin(SourceLocation b) { B = b; }
225  void setEnd(SourceLocation e) { E = e; }
226 
227  bool isValid() const { return B.isValid() && E.isValid(); }
228  bool isInvalid() const { return !isValid(); }
229 
230  bool operator==(const SourceRange &X) const {
231  return B == X.B && E == X.E;
232  }
233 
234  bool operator!=(const SourceRange &X) const {
235  return B != X.B || E != X.E;
236  }
237 
238  // Returns true iff other is wholly contained within this range.
239  bool fullyContains(const SourceRange &other) const {
240  return B <= other.B && E >= other.E;
241  }
242 
243  void print(raw_ostream &OS, const SourceManager &SM) const;
245  void dump(const SourceManager &SM) const;
246 };
247 
248 /// Represents a character-granular source range.
249 ///
250 /// The underlying SourceRange can either specify the starting/ending character
251 /// of the range, or it can specify the start of the range and the start of the
252 /// last token of the range (a "token range"). In the token range case, the
253 /// size of the last token must be measured to determine the actual end of the
254 /// range.
256  SourceRange Range;
257  bool IsTokenRange = false;
258 
259 public:
260  CharSourceRange() = default;
261  CharSourceRange(SourceRange R, bool ITR) : Range(R), IsTokenRange(ITR) {}
262 
264  return CharSourceRange(R, true);
265  }
266 
268  return CharSourceRange(R, false);
269  }
270 
272  return getTokenRange(SourceRange(B, E));
273  }
274 
276  return getCharRange(SourceRange(B, E));
277  }
278 
279  /// Return true if the end of this range specifies the start of
280  /// the last token. Return false if the end of this range specifies the last
281  /// character in the range.
282  bool isTokenRange() const { return IsTokenRange; }
283  bool isCharRange() const { return !IsTokenRange; }
284 
285  SourceLocation getBegin() const { return Range.getBegin(); }
286  SourceLocation getEnd() const { return Range.getEnd(); }
287  SourceRange getAsRange() const { return Range; }
288 
289  void setBegin(SourceLocation b) { Range.setBegin(b); }
290  void setEnd(SourceLocation e) { Range.setEnd(e); }
291  void setTokenRange(bool TR) { IsTokenRange = TR; }
292 
293  bool isValid() const { return Range.isValid(); }
294  bool isInvalid() const { return !isValid(); }
295 };
296 
297 /// Represents an unpacked "presumed" location which can be presented
298 /// to the user.
299 ///
300 /// A 'presumed' location can be modified by \#line and GNU line marker
301 /// directives and is always the expansion point of a normal location.
302 ///
303 /// You can get a PresumedLoc from a SourceLocation with SourceManager.
304 class PresumedLoc {
305  const char *Filename = nullptr;
306  FileID ID;
307  unsigned Line, Col;
308  SourceLocation IncludeLoc;
309 
310 public:
311  PresumedLoc() = default;
312  PresumedLoc(const char *FN, FileID FID, unsigned Ln, unsigned Co,
313  SourceLocation IL)
314  : Filename(FN), ID(FID), Line(Ln), Col(Co), IncludeLoc(IL) {}
315 
316  /// Return true if this object is invalid or uninitialized.
317  ///
318  /// This occurs when created with invalid source locations or when walking
319  /// off the top of a \#include stack.
320  bool isInvalid() const { return Filename == nullptr; }
321  bool isValid() const { return Filename != nullptr; }
322 
323  /// Return the presumed filename of this location.
324  ///
325  /// This can be affected by \#line etc.
326  const char *getFilename() const {
327  assert(isValid());
328  return Filename;
329  }
330 
331  FileID getFileID() const {
332  assert(isValid());
333  return ID;
334  }
335 
336  /// Return the presumed line number of this location.
337  ///
338  /// This can be affected by \#line etc.
339  unsigned getLine() const {
340  assert(isValid());
341  return Line;
342  }
343 
344  /// Return the presumed column number of this location.
345  ///
346  /// This cannot be affected by \#line, but is packaged here for convenience.
347  unsigned getColumn() const {
348  assert(isValid());
349  return Col;
350  }
351 
352  /// Return the presumed include location of this location.
353  ///
354  /// This can be affected by GNU linemarker directives.
356  assert(isValid());
357  return IncludeLoc;
358  }
359 };
360 
361 class FileEntry;
362 
363 /// A SourceLocation and its associated SourceManager.
364 ///
365 /// This is useful for argument passing to functions that expect both objects.
366 ///
367 /// This class does not guarantee the presence of either the SourceManager or
368 /// a valid SourceLocation. Clients should use `isValid()` and `hasManager()`
369 /// before calling the member functions.
371  const SourceManager *SrcMgr = nullptr;
372 
373 public:
374  /// Creates a FullSourceLoc where isValid() returns \c false.
375  FullSourceLoc() = default;
376 
378  : SourceLocation(Loc), SrcMgr(&SM) {}
379 
380  /// Checks whether the SourceManager is present.
381  bool hasManager() const { return SrcMgr != nullptr; }
382 
383  /// \pre hasManager()
384  const SourceManager &getManager() const {
385  assert(SrcMgr && "SourceManager is NULL.");
386  return *SrcMgr;
387  }
388 
389  FileID getFileID() const;
390 
393  FullSourceLoc getFileLoc() const;
394  PresumedLoc getPresumedLoc(bool UseLineDirectives = true) const;
395  bool isMacroArgExpansion(FullSourceLoc *StartLoc = nullptr) const;
397  std::pair<FullSourceLoc, StringRef> getModuleImportLoc() const;
398  unsigned getFileOffset() const;
399 
400  unsigned getExpansionLineNumber(bool *Invalid = nullptr) const;
401  unsigned getExpansionColumnNumber(bool *Invalid = nullptr) const;
402 
403  unsigned getSpellingLineNumber(bool *Invalid = nullptr) const;
404  unsigned getSpellingColumnNumber(bool *Invalid = nullptr) const;
405 
406  const char *getCharacterData(bool *Invalid = nullptr) const;
407 
408  unsigned getLineNumber(bool *Invalid = nullptr) const;
409  unsigned getColumnNumber(bool *Invalid = nullptr) const;
410 
411  const FileEntry *getFileEntry() const;
412 
413  /// Return a StringRef to the source buffer data for the
414  /// specified FileID.
415  StringRef getBufferData(bool *Invalid = nullptr) const;
416 
417  /// Decompose the specified location into a raw FileID + Offset pair.
418  ///
419  /// The first element is the FileID, the second is the offset from the
420  /// start of the buffer of the location.
421  std::pair<FileID, unsigned> getDecomposedLoc() const;
422 
423  bool isInSystemHeader() const;
424 
425  /// Determines the order of 2 source locations in the translation unit.
426  ///
427  /// \returns true if this source location comes before 'Loc', false otherwise.
429 
430  /// Determines the order of 2 source locations in the translation unit.
431  ///
432  /// \returns true if this source location comes before 'Loc', false otherwise.
434  assert(Loc.isValid());
435  assert(SrcMgr == Loc.SrcMgr && "Loc comes from another SourceManager!");
437  }
438 
439  /// Comparison function class, useful for sorting FullSourceLocs.
441  bool operator()(const FullSourceLoc& lhs, const FullSourceLoc& rhs) const {
442  return lhs.isBeforeInTranslationUnitThan(rhs);
443  }
444  };
445 
446  /// Prints information about this FullSourceLoc to stderr.
447  ///
448  /// This is useful for debugging.
449  void dump() const;
450 
451  friend bool
452  operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
453  return LHS.getRawEncoding() == RHS.getRawEncoding() &&
454  LHS.SrcMgr == RHS.SrcMgr;
455  }
456 
457  friend bool
458  operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
459  return !(LHS == RHS);
460  }
461 };
462 
463 } // namespace clang
464 
465 namespace llvm {
466 
467  /// Define DenseMapInfo so that FileID's can be used as keys in DenseMap and
468  /// DenseSets.
469  template <>
470  struct DenseMapInfo<clang::FileID> {
472  return {};
473  }
474 
477  }
478 
479  static unsigned getHashValue(clang::FileID S) {
480  return S.getHashValue();
481  }
482 
483  static bool isEqual(clang::FileID LHS, clang::FileID RHS) {
484  return LHS == RHS;
485  }
486  };
487 
488  /// Define DenseMapInfo so that SourceLocation's can be used as keys in
489  /// DenseMap and DenseSet. This trait class is eqivalent to
490  /// DenseMapInfo<unsigned> which uses SourceLocation::ID is used as a key.
491  template <> struct DenseMapInfo<clang::SourceLocation> {
493  constexpr clang::SourceLocation::UIntTy Zero = 0;
495  }
496 
498  constexpr clang::SourceLocation::UIntTy Zero = 0;
500  }
501 
502  static unsigned getHashValue(clang::SourceLocation Loc) {
503  return Loc.getHashValue();
504  }
505 
507  return LHS == RHS;
508  }
509  };
510 
511  // Allow calling FoldingSetNodeID::Add with SourceLocation object as parameter
512  template <> struct FoldingSetTrait<clang::SourceLocation> {
513  static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID);
514  };
515 
516 } // namespace llvm
517 
518 #endif // LLVM_CLANG_BASIC_SOURCELOCATION_H
clang::operator!=
bool operator!=(CanQual< T > x, CanQual< U > y)
Definition: CanonicalType.h:207
clang::SourceRange::setBegin
void setBegin(SourceLocation b)
Definition: SourceLocation.h:224
clang::FullSourceLoc::isMacroArgExpansion
bool isMacroArgExpansion(FullSourceLoc *StartLoc=nullptr) const
Definition: SourceLocation.cpp:186
clang::FullSourceLoc::getManager
const SourceManager & getManager() const
Definition: SourceLocation.h:384
clang::FullSourceLoc::hasManager
bool hasManager() const
Checks whether the SourceManager is present.
Definition: SourceLocation.h:381
llvm
Definition: Dominators.h:30
clang::CharSourceRange::isCharRange
bool isCharRange() const
Definition: SourceLocation.h:283
clang::SourceRange::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:228
clang::CharSourceRange::getCharRange
static CharSourceRange getCharRange(SourceLocation B, SourceLocation E)
Definition: SourceLocation.h:275
clang::CharSourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:285
clang::SourceLocation::getPtrEncoding
void * getPtrEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) pointer encoding for it.
Definition: SourceLocation.h:165
clang::SourceRange::operator!=
bool operator!=(const SourceRange &X) const
Definition: SourceLocation.h:234
clang::FullSourceLoc::getFileEntry
const FileEntry * getFileEntry() const
Definition: SourceLocation.cpp:221
clang::FullSourceLoc
A SourceLocation and its associated SourceManager.
Definition: SourceLocation.h:370
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::PresumedLoc::getLine
unsigned getLine() const
Return the presumed line number of this location.
Definition: SourceLocation.h:339
clang::SourceLocation::getFromPtrEncoding
static SourceLocation getFromPtrEncoding(const void *Encoding)
Turn a pointer encoding of a SourceLocation object back into a real SourceLocation.
Definition: SourceLocation.h:173
clang::CharSourceRange::CharSourceRange
CharSourceRange(SourceRange R, bool ITR)
Definition: SourceLocation.h:261
clang::FullSourceLoc::isBeforeInTranslationUnitThan
bool isBeforeInTranslationUnitThan(SourceLocation Loc) const
Determines the order of 2 source locations in the translation unit.
Definition: SourceLocation.cpp:251
clang::FileID::getSentinel
static FileID getSentinel()
Definition: SourceLocation.h:56
clang::SourceRange::dump
void dump(const SourceManager &SM) const
Definition: SourceLocation.cpp:101
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::SourceLocation::getLocWithOffset
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
Definition: SourceLocation.h:136
llvm::DenseMapInfo< clang::SourceLocation >::isEqual
static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS)
Definition: SourceLocation.h:506
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:221
clang::FullSourceLoc::getModuleImportLoc
std::pair< FullSourceLoc, StringRef > getModuleImportLoc() const
Definition: SourceLocation.cpp:196
clang::FullSourceLoc::isBeforeInTranslationUnitThan
bool isBeforeInTranslationUnitThan(FullSourceLoc Loc) const
Determines the order of 2 source locations in the translation unit.
Definition: SourceLocation.h:433
clang::CharSourceRange::getTokenRange
static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E)
Definition: SourceLocation.h:271
Filename
StringRef Filename
Definition: Format.cpp:2333
clang::SourceRange::isValid
bool isValid() const
Definition: SourceLocation.h:227
clang::PresumedLoc::getIncludeLoc
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
Definition: SourceLocation.h:355
clang::SourceRange::printToString
std::string printToString(const SourceManager &SM) const
Definition: SourceLocation.cpp:148
clang::PresumedLoc::PresumedLoc
PresumedLoc(const char *FN, FileID FID, unsigned Ln, unsigned Co, SourceLocation IL)
Definition: SourceLocation.h:312
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::CharSourceRange::setTokenRange
void setTokenRange(bool TR)
Definition: SourceLocation.h:291
End
SourceLocation End
Definition: USRLocFinder.cpp:167
b
__device__ __2f16 b
Definition: __clang_hip_libdevice_declares.h:314
llvm::DenseMapInfo< clang::SourceLocation >::getHashValue
static unsigned getHashValue(clang::SourceLocation Loc)
Definition: SourceLocation.h:502
clang::SourceRange::SourceRange
SourceRange(SourceLocation begin, SourceLocation end)
Definition: SourceLocation.h:219
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:626
clang::FileID::getHashValue
unsigned getHashValue() const
Definition: SourceLocation.h:57
Offset
unsigned Offset
Definition: Format.cpp:2335
clang::FullSourceLoc::getFileOffset
unsigned getFileOffset() const
Definition: SourceLocation.cpp:206
llvm::DenseMapInfo
Definition: TypeOrdering.h:37
clang::SourceLocation::IntTy
int32_t IntTy
Definition: SourceLocation.h:96
clang::FullSourceLoc::getExpansionLineNumber
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
Definition: SourceLocation.cpp:226
clang::CharSourceRange::getCharRange
static CharSourceRange getCharRange(SourceRange R)
Definition: SourceLocation.h:267
clang::FullSourceLoc::getBufferData
StringRef getBufferData(bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
Definition: SourceLocation.cpp:265
V
#define V(N, I)
Definition: ASTContext.h:3113
clang::FileID::operator>
bool operator>(const FileID &RHS) const
Definition: SourceLocation.h:53
clang::SourceLocation::print
void print(raw_ostream &OS, const SourceManager &SM) const
Definition: SourceLocation.cpp:62
clang::operator>
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:546
clang::PresumedLoc::getFileID
FileID getFileID() const
Definition: SourceLocation.h:331
clang::FullSourceLoc::FullSourceLoc
FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
Definition: SourceLocation.h:377
clang::CharSourceRange::getAsRange
SourceRange getAsRange() const
Definition: SourceLocation.h:287
clang::format::encoding::Encoding
Encoding
Definition: Encoding.h:27
clang::PresumedLoc::getFilename
const char * getFilename() const
Return the presumed filename of this location.
Definition: SourceLocation.h:326
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:222
clang::FullSourceLoc::getSpellingLoc
FullSourceLoc getSpellingLoc() const
Definition: SourceLocation.cpp:169
clang::FileID::isValid
bool isValid() const
Definition: SourceLocation.h:46
clang::FileID::operator!=
bool operator!=(const FileID &RHS) const
Definition: SourceLocation.h:52
clang::FullSourceLoc::getSpellingColumnNumber
unsigned getSpellingColumnNumber(bool *Invalid=nullptr) const
Definition: SourceLocation.cpp:241
clang::CharSourceRange::CharSourceRange
CharSourceRange()=default
llvm::DenseMapInfo< clang::FileID >::getHashValue
static unsigned getHashValue(clang::FileID S)
Definition: SourceLocation.h:479
uintptr_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:124
clang::interp::Zero
bool Zero(InterpState &S, CodePtr OpPC)
Definition: Interp.h:814
llvm::DenseMapInfo< clang::SourceLocation >::getTombstoneKey
static clang::SourceLocation getTombstoneKey()
Definition: SourceLocation.h:497
clang::SourceLocation::getHashValue
unsigned getHashValue() const
Definition: SourceLocation.cpp:53
clang::FileID::operator==
bool operator==(const FileID &RHS) const
Definition: SourceLocation.h:49
clang::SourceRange::setEnd
void setEnd(SourceLocation e)
Definition: SourceLocation.h:225
clang::SourceLocation::isFileID
bool isFileID() const
Definition: SourceLocation.h:104
clang::PresumedLoc::getColumn
unsigned getColumn() const
Return the presumed column number of this location.
Definition: SourceLocation.h:347
clang::FullSourceLoc::FullSourceLoc
FullSourceLoc()=default
Creates a FullSourceLoc where isValid() returns false.
clang::ASTWriter
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:99
llvm::FoldingSetTrait
Definition: SourceLocation.h:29
clang::SourceLocation::dump
void dump(const SourceManager &SM) const
Definition: SourceLocation.cpp:96
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system).
Definition: FileEntry.h:331
clang::FullSourceLoc::operator==
friend bool operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
Definition: SourceLocation.h:452
clang::SourceRange::SourceRange
SourceRange()=default
clang::PresumedLoc::isInvalid
bool isInvalid() const
Return true if this object is invalid or uninitialized.
Definition: SourceLocation.h:320
clang::FileID::operator>=
bool operator>=(const FileID &RHS) const
Definition: SourceLocation.h:54
clang::operator<=
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:552
clang::FullSourceLoc::getExpansionLoc
FullSourceLoc getExpansionLoc() const
Definition: SourceLocation.cpp:164
clang::SourceRange::fullyContains
bool fullyContains(const SourceRange &other) const
Definition: SourceLocation.h:239
clang::CharSourceRange::isTokenRange
bool isTokenRange() const
Return true if the end of this range specifies the start of the last token.
Definition: SourceLocation.h:282
clang::FullSourceLoc::getImmediateMacroCallerLoc
FullSourceLoc getImmediateMacroCallerLoc() const
Definition: SourceLocation.cpp:191
clang::CharSourceRange::getTokenRange
static CharSourceRange getTokenRange(SourceRange R)
Definition: SourceLocation.h:263
clang::SourceLocation::isPairOfFileLocations
static bool isPairOfFileLocations(SourceLocation Start, SourceLocation End)
Definition: SourceLocation.h:177
clang::FullSourceLoc::dump
void dump() const
Prints information about this FullSourceLoc to stderr.
Definition: SourceLocation.cpp:256
clang::CharSourceRange
Represents a character-granular source range.
Definition: SourceLocation.h:255
clang::FullSourceLoc::isInSystemHeader
bool isInSystemHeader() const
Definition: SourceLocation.cpp:246
clang::FullSourceLoc::getFileLoc
FullSourceLoc getFileLoc() const
Definition: SourceLocation.cpp:174
LLVM.h
clang::FullSourceLoc::BeforeThanCompare
Comparison function class, useful for sorting FullSourceLocs.
Definition: SourceLocation.h:440
clang::CharSourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:286
clang::CharSourceRange::setBegin
void setBegin(SourceLocation b)
Definition: SourceLocation.h:289
llvm::DenseMapInfo< clang::FileID >::isEqual
static bool isEqual(clang::FileID LHS, clang::FileID RHS)
Definition: SourceLocation.h:483
clang::FullSourceLoc::getFileID
FileID getFileID() const
Definition: SourceLocation.cpp:159
clang::SourceLocation::getFromRawEncoding
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Definition: SourceLocation.h:154
clang::SourceLocation::isMacroID
bool isMacroID() const
Definition: SourceLocation.h:105
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:342
clang::FullSourceLoc::getSpellingLineNumber
unsigned getSpellingLineNumber(bool *Invalid=nullptr) const
Definition: SourceLocation.cpp:236
clang::PresumedLoc::isValid
bool isValid() const
Definition: SourceLocation.h:321
clang::FileID::operator<=
bool operator<=(const FileID &RHS) const
Definition: SourceLocation.h:51
clang::CharSourceRange::isValid
bool isValid() const
Definition: SourceLocation.h:293
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:113
clang::FullSourceLoc::operator!=
friend bool operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS)
Definition: SourceLocation.h:458
clang
Definition: CalledOnceCheck.h:17
clang::SourceRange::SourceRange
SourceRange(SourceLocation loc)
Definition: SourceLocation.h:218
llvm::DenseMapInfo< clang::FileID >::getTombstoneKey
static clang::FileID getTombstoneKey()
Definition: SourceLocation.h:475
clang::operator<
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:540
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:40
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:112
clang::FileID::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:47
clang::FileID::operator<
bool operator<(const FileID &RHS) const
Definition: SourceLocation.h:50
llvm::DenseMapInfo< clang::SourceLocation >::getEmptyKey
static clang::SourceLocation getEmptyKey()
Definition: SourceLocation.h:492
clang::FullSourceLoc::getPresumedLoc
PresumedLoc getPresumedLoc(bool UseLineDirectives=true) const
Definition: SourceLocation.cpp:179
clang::PresumedLoc
Represents an unpacked "presumed" location which can be presented to the user.
Definition: SourceLocation.h:304
clang::operator>=
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:558
SM
#define SM(sm)
Definition: Cuda.cpp:78
clang::CharSourceRange::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:294
clang::FullSourceLoc::getLineNumber
unsigned getLineNumber(bool *Invalid=nullptr) const
Definition: SourceLocation.cpp:211
clang::FullSourceLoc::getDecomposedLoc
std::pair< FileID, unsigned > getDecomposedLoc() const
Decompose the specified location into a raw FileID + Offset pair.
Definition: SourceLocation.cpp:270
clang::SourceRange::operator==
bool operator==(const SourceRange &X) const
Definition: SourceLocation.h:230
clang::FullSourceLoc::BeforeThanCompare::operator()
bool operator()(const FullSourceLoc &lhs, const FullSourceLoc &rhs) const
Definition: SourceLocation.h:441
llvm::DenseMapInfo< clang::FileID >::getEmptyKey
static clang::FileID getEmptyKey()
Definition: SourceLocation.h:471
clang::SourceRange::print
void print(raw_ostream &OS, const SourceManager &SM) const
Definition: SourceLocation.cpp:136
clang::operator==
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition: CallGraph.h:207
clang::CharSourceRange::setEnd
void setEnd(SourceLocation e)
Definition: SourceLocation.h:290
clang::SourceLocation::UIntTy
uint32_t UIntTy
Definition: SourceLocation.h:95
clang::FullSourceLoc::getCharacterData
const char * getCharacterData(bool *Invalid=nullptr) const
Definition: SourceLocation.cpp:260
clang::SourceLocation::getRawEncoding
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
Definition: SourceLocation.h:148
clang::PresumedLoc::PresumedLoc
PresumedLoc()=default
clang::FullSourceLoc::getExpansionColumnNumber
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
Definition: SourceLocation.cpp:231
clang::SourceLocation::printToString
std::string printToString(const SourceManager &SM) const
Definition: SourceLocation.cpp:89
clang::FullSourceLoc::getColumnNumber
unsigned getColumnNumber(bool *Invalid=nullptr) const
Definition: SourceLocation.cpp:216