clang  16.0.0git
Classes | Public Member Functions | Friends | List of all members
clang::FullSourceLoc Class Reference

A SourceLocation and its associated SourceManager. More...

#include "clang/Basic/SourceLocation.h"

Inheritance diagram for clang::FullSourceLoc:
Inheritance graph
[legend]
Collaboration diagram for clang::FullSourceLoc:
Collaboration graph
[legend]

Classes

struct  BeforeThanCompare
 Comparison function class, useful for sorting FullSourceLocs. More...
 

Public Member Functions

 FullSourceLoc ()=default
 Creates a FullSourceLoc where isValid() returns false. More...
 
 FullSourceLoc (SourceLocation Loc, const SourceManager &SM)
 
bool hasManager () const
 Checks whether the SourceManager is present. More...
 
const SourceManagergetManager () const
 
FileID getFileID () const
 
FullSourceLoc getExpansionLoc () const
 
FullSourceLoc getSpellingLoc () const
 
FullSourceLoc getFileLoc () const
 
PresumedLoc getPresumedLoc (bool UseLineDirectives=true) const
 
bool isMacroArgExpansion (FullSourceLoc *StartLoc=nullptr) const
 
FullSourceLoc getImmediateMacroCallerLoc () const
 
std::pair< FullSourceLoc, StringRef > getModuleImportLoc () const
 
unsigned getFileOffset () const
 
unsigned getExpansionLineNumber (bool *Invalid=nullptr) const
 
unsigned getExpansionColumnNumber (bool *Invalid=nullptr) const
 
std::pair< FileID, unsignedgetDecomposedExpansionLoc () const
 Decompose the underlying SourceLocation into a raw (FileID + Offset) pair, after walking through all expansion records. More...
 
unsigned getSpellingLineNumber (bool *Invalid=nullptr) const
 
unsigned getSpellingColumnNumber (bool *Invalid=nullptr) const
 
const char * getCharacterData (bool *Invalid=nullptr) const
 
unsigned getLineNumber (bool *Invalid=nullptr) const
 
unsigned getColumnNumber (bool *Invalid=nullptr) const
 
const FileEntrygetFileEntry () const
 
StringRef getBufferData (bool *Invalid=nullptr) const
 Return a StringRef to the source buffer data for the specified FileID. More...
 
std::pair< FileID, unsignedgetDecomposedLoc () const
 Decompose the specified location into a raw FileID + Offset pair. More...
 
bool isInSystemHeader () const
 
bool isBeforeInTranslationUnitThan (SourceLocation Loc) const
 Determines the order of 2 source locations in the translation unit. More...
 
bool isBeforeInTranslationUnitThan (FullSourceLoc Loc) const
 Determines the order of 2 source locations in the translation unit. More...
 
void dump () const
 Prints information about this FullSourceLoc to stderr. More...
 
- Public Member Functions inherited from clang::SourceLocation
bool isFileID () const
 
bool isMacroID () const
 
bool isValid () const
 Return true if this is a valid SourceLocation object. More...
 
bool isInvalid () const
 
SourceLocation getLocWithOffset (IntTy Offset) const
 Return a source location with the specified offset from this SourceLocation. More...
 
UIntTy getRawEncoding () const
 When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it. More...
 
void * getPtrEncoding () const
 When a SourceLocation itself cannot be used, this returns an (opaque) pointer encoding for it. More...
 
unsigned getHashValue () const
 
void print (raw_ostream &OS, const SourceManager &SM) const
 
std::string printToString (const SourceManager &SM) const
 
void dump (const SourceManager &SM) const
 

Friends

bool operator== (const FullSourceLoc &LHS, const FullSourceLoc &RHS)
 
bool operator!= (const FullSourceLoc &LHS, const FullSourceLoc &RHS)
 

Additional Inherited Members

- Public Types inherited from clang::SourceLocation
using UIntTy = uint32_t
 
using IntTy = int32_t
 
- Static Public Member Functions inherited from clang::SourceLocation
static SourceLocation getFromRawEncoding (UIntTy Encoding)
 Turn a raw encoding of a SourceLocation object into a real SourceLocation. More...
 
static SourceLocation getFromPtrEncoding (const void *Encoding)
 Turn a pointer encoding of a SourceLocation object back into a real SourceLocation. More...
 
static bool isPairOfFileLocations (SourceLocation Start, SourceLocation End)
 

Detailed Description

A SourceLocation and its associated SourceManager.

This is useful for argument passing to functions that expect both objects.

This class does not guarantee the presence of either the SourceManager or a valid SourceLocation. Clients should use isValid() and hasManager() before calling the member functions.

Definition at line 368 of file SourceLocation.h.

Constructor & Destructor Documentation

◆ FullSourceLoc() [1/2]

clang::FullSourceLoc::FullSourceLoc ( )
default

Creates a FullSourceLoc where isValid() returns false.

◆ FullSourceLoc() [2/2]

clang::FullSourceLoc::FullSourceLoc ( SourceLocation  Loc,
const SourceManager SM 
)
inlineexplicit

Definition at line 375 of file SourceLocation.h.

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void FullSourceLoc::dump ( ) const

Prints information about this FullSourceLoc to stderr.

This is useful for debugging.

Definition at line 260 of file SourceLocation.cpp.

◆ getBufferData()

StringRef FullSourceLoc::getBufferData ( bool Invalid = nullptr) const

Return a StringRef to the source buffer data for the specified FileID.

Definition at line 269 of file SourceLocation.cpp.

Referenced by EmitAlphaCounter().

◆ getCharacterData()

const char * FullSourceLoc::getCharacterData ( bool Invalid = nullptr) const

Definition at line 264 of file SourceLocation.cpp.

◆ getColumnNumber()

unsigned FullSourceLoc::getColumnNumber ( bool Invalid = nullptr) const

Definition at line 220 of file SourceLocation.cpp.

Referenced by clang::TextDiagnostic::emitDiagnosticLoc().

◆ getDecomposedExpansionLoc()

std::pair< FileID, unsigned > FullSourceLoc::getDecomposedExpansionLoc ( ) const

Decompose the underlying SourceLocation into a raw (FileID + Offset) pair, after walking through all expansion records.

See also
SourceManager::getDecomposedExpansionLoc

Definition at line 169 of file SourceLocation.cpp.

Referenced by adjustColumnPos().

◆ getDecomposedLoc()

std::pair< FileID, unsigned > FullSourceLoc::getDecomposedLoc ( ) const

Decompose the specified location into a raw FileID + Offset pair.

The first element is the FileID, the second is the offset from the start of the buffer of the location.

Definition at line 274 of file SourceLocation.cpp.

Referenced by clang::tooling::AtomicChange::AtomicChange(), compareCrossTUSourceLocs(), and EmitAlphaCounter().

◆ getExpansionColumnNumber()

unsigned FullSourceLoc::getExpansionColumnNumber ( bool Invalid = nullptr) const

Definition at line 235 of file SourceLocation.cpp.

Referenced by adjustColumnPos(), and clang::markup::EmitLocation().

◆ getExpansionLineNumber()

unsigned FullSourceLoc::getExpansionLineNumber ( bool Invalid = nullptr) const

Definition at line 230 of file SourceLocation.cpp.

Referenced by clang::markup::EmitLocation().

◆ getExpansionLoc()

FullSourceLoc FullSourceLoc::getExpansionLoc ( ) const

◆ getFileEntry()

const FileEntry * FullSourceLoc::getFileEntry ( ) const

Definition at line 225 of file SourceLocation.cpp.

Referenced by clang::TextDiagnostic::emitDiagnosticLoc().

◆ getFileID()

FileID FullSourceLoc::getFileID ( ) const

◆ getFileLoc()

FullSourceLoc FullSourceLoc::getFileLoc ( ) const

Definition at line 178 of file SourceLocation.cpp.

Referenced by clang::DiagnosticRenderer::emitDiagnostic().

◆ getFileOffset()

unsigned FullSourceLoc::getFileOffset ( ) const

Definition at line 210 of file SourceLocation.cpp.

◆ getImmediateMacroCallerLoc()

FullSourceLoc FullSourceLoc::getImmediateMacroCallerLoc ( ) const

Definition at line 195 of file SourceLocation.cpp.

◆ getLineNumber()

unsigned FullSourceLoc::getLineNumber ( bool Invalid = nullptr) const

◆ getManager()

const SourceManager& clang::FullSourceLoc::getManager ( ) const
inline

◆ getModuleImportLoc()

std::pair< FullSourceLoc, StringRef > FullSourceLoc::getModuleImportLoc ( ) const

Definition at line 200 of file SourceLocation.cpp.

◆ getPresumedLoc()

PresumedLoc FullSourceLoc::getPresumedLoc ( bool  UseLineDirectives = true) const

Definition at line 183 of file SourceLocation.cpp.

Referenced by clang::DiagnosticRenderer::emitDiagnostic().

◆ getSpellingColumnNumber()

unsigned FullSourceLoc::getSpellingColumnNumber ( bool Invalid = nullptr) const

Definition at line 245 of file SourceLocation.cpp.

◆ getSpellingLineNumber()

unsigned FullSourceLoc::getSpellingLineNumber ( bool Invalid = nullptr) const

Definition at line 240 of file SourceLocation.cpp.

◆ getSpellingLoc()

FullSourceLoc FullSourceLoc::getSpellingLoc ( ) const

◆ hasManager()

bool clang::FullSourceLoc::hasManager ( ) const
inline

Checks whether the SourceManager is present.

Definition at line 379 of file SourceLocation.h.

Referenced by clang::DiagnosticRenderer::emitDiagnostic(), and clang::operator<<().

◆ isBeforeInTranslationUnitThan() [1/2]

bool clang::FullSourceLoc::isBeforeInTranslationUnitThan ( FullSourceLoc  Loc) const
inline

Determines the order of 2 source locations in the translation unit.

Returns
true if this source location comes before 'Loc', false otherwise.

Definition at line 437 of file SourceLocation.h.

References isBeforeInTranslationUnitThan(), and clang::SourceLocation::isValid().

◆ isBeforeInTranslationUnitThan() [2/2]

bool FullSourceLoc::isBeforeInTranslationUnitThan ( SourceLocation  Loc) const

Determines the order of 2 source locations in the translation unit.

Returns
true if this source location comes before 'Loc', false otherwise.

Definition at line 255 of file SourceLocation.cpp.

Referenced by clang::arcmt::CapturedDiagList::clearDiagnostic(), compareCall(), compareControlFlow(), compareCrossTUSourceLocs(), comparePiece(), clang::arcmt::CapturedDiagList::hasDiagnostic(), isBeforeInTranslationUnitThan(), and clang::FullSourceLoc::BeforeThanCompare::operator()().

◆ isInSystemHeader()

bool FullSourceLoc::isInSystemHeader ( ) const

Definition at line 250 of file SourceLocation.cpp.

◆ isMacroArgExpansion()

bool FullSourceLoc::isMacroArgExpansion ( FullSourceLoc StartLoc = nullptr) const

Definition at line 190 of file SourceLocation.cpp.

Referenced by checkRangesForMacroArgExpansion().

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const FullSourceLoc LHS,
const FullSourceLoc RHS 
)
friend

Definition at line 462 of file SourceLocation.h.

◆ operator==

bool operator== ( const FullSourceLoc LHS,
const FullSourceLoc RHS 
)
friend

Definition at line 456 of file SourceLocation.h.


The documentation for this class was generated from the following files: