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