clang 10.0.0git

Public Member Functions | Friends | List of all members
clang::syntax::FileRange Struct Reference

A half-open character range inside a particular file, the start offset is included and the end offset is excluded from the range. More...

`#include "clang/Tooling/Syntax/Tokens.h"`

## Public Member Functions
| FileRange (FileID File, unsigned BeginOffset, unsigned EndOffset)
| EXPECTS: File.isValid() && Begin <= End. More...
| FileRange (const SourceManager &SM, SourceLocation BeginLoc, unsigned Length)
| EXPECTS: BeginLoc.isValid() && BeginLoc.isFileID(). More...
| FileRange (const SourceManager &SM, SourceLocation BeginLoc, SourceLocation EndLoc)
| EXPECTS: BeginLoc.isValid() && BeginLoc.isFileID(), Begin <= End and files are the same. More...
FileID | file () const
unsigned | beginOffset () const
| Start is a start offset (inclusive) in the corresponding file. More...
unsigned | endOffset () const
| End offset (exclusive) in the corresponding file. More...
unsigned | length () const
bool | contains (unsigned Offset) const
| Check if `Offset` is inside the range. More...
bool | touches (unsigned Offset) const
| Check `Offset` is inside the range or equal to its endpoint. More...
llvm::StringRef | text (const SourceManager &SM) const
| Gets the substring that this FileRange refers to. More...
CharSourceRange | toCharRange (const SourceManager &SM) const
| Convert to the clang range. More...

## Friends
bool | operator== (const FileRange &L, const FileRange &R)
bool | operator!= (const FileRange &L, const FileRange &R)

## Detailed Description

A half-open character range inside a particular file, the start offset is included and the end offset is excluded from the range.

Definition at line 51 of file Tokens.h.

## Constructor & Destructor Documentation

## ◆ FileRange() [1/3]

FileRange::FileRange | ( | FileID | File,
|  | unsigned | BeginOffset,
|  | unsigned | EndOffset
| ) |  |

EXPECTS: File.isValid() && Begin <= End.

Definition at line 78 of file Tokens.cpp.

References clang::FileID::isValid().

## ◆ FileRange() [2/3]

FileRange::FileRange | ( | const SourceManager & | SM,
|  | SourceLocation | BeginLoc,
|  | unsigned | Length
| ) |  |

EXPECTS: BeginLoc.isValid() && BeginLoc.isFileID().

Definition at line 84 of file Tokens.cpp.

References clang::SourceManager::getDecomposedLoc(), clang::SourceLocation::isFileID(), and clang::SourceLocation::isValid().

## ◆ FileRange() [3/3]

FileRange::FileRange | ( | const SourceManager & | SM,
|  | SourceLocation | BeginLoc,
|  | SourceLocation | EndLoc
| ) |  |

EXPECTS: BeginLoc.isValid() && BeginLoc.isFileID(), Begin <= End and files are the same.

Definition at line 92 of file Tokens.cpp.

References clang::SourceManager::getDecomposedLoc(), clang::SourceManager::getFileID(), clang::SourceManager::getFileOffset(), clang::SourceLocation::isFileID(), and clang::SourceLocation::isValid().

## Member Function Documentation

## ◆ beginOffset()

unsigned clang::syntax::FileRange::beginOffset | ( |  | ) | const
| inline

Start is a start offset (inclusive) in the corresponding file.

Definition at line 63 of file Tokens.h.

Referenced by clang::syntax::operator<<().

## ◆ contains()

bool clang::syntax::FileRange::contains | ( | unsigned | Offset | ) | const
| inline

Check if `Offset` is inside the range.

Definition at line 70 of file Tokens.h.

## ◆ endOffset()

unsigned clang::syntax::FileRange::endOffset | ( |  | ) | const
| inline

End offset (exclusive) in the corresponding file.

Definition at line 65 of file Tokens.h.

Referenced by clang::syntax::operator<<().

## ◆ file()

FileID clang::syntax::FileRange::file | ( |  | ) | const
| inline

Definition at line 61 of file Tokens.h.

Referenced by clang::syntax::operator<<().

## ◆ length()

unsigned clang::syntax::FileRange::length | ( |  | ) | const
| inline

Definition at line 67 of file Tokens.h.

Referenced by text().

## ◆ text()

llvm::StringRef FileRange::text | ( | const SourceManager & | SM | ) | const

Gets the substring that this FileRange refers to.

Definition at line 112 of file Tokens.cpp.

References clang::SourceManager::getBufferData(), length(), and Text.

Referenced by clang::syntax::Token::length(), and touches().

## ◆ toCharRange()

CharSourceRange FileRange::toCharRange | ( | const SourceManager & | SM | ) | const

Convert to the clang range.

The returned range is always a char range, never a token range.

Definition at line 138 of file Tokens.cpp.

References clang::SourceManager::getComposedLoc(), and clang::syntax::Token::location().

Referenced by touches().

## ◆ touches()

bool clang::syntax::FileRange::touches | ( | unsigned | Offset | ) | const
| inline

Check `Offset` is inside the range or equal to its endpoint.

Definition at line 74 of file Tokens.h.

References text(), and toCharRange().

## Friends And Related Function Documentation

## ◆ operator!=

bool operator!= | ( | const FileRange & | L,
|  | const FileRange & | R
| ) |  |
| friend

Definition at line 88 of file Tokens.h.

## ◆ operator==

bool operator== | ( | const FileRange & | L,
|  | const FileRange & | R
| ) |  |
| friend

Definition at line 85 of file Tokens.h.

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

- include/clang/Tooling/Syntax/Tokens.h
- lib/Tooling/Syntax/Tokens.cpp