clang 23.0.0git
clang::CharSourceRange Class Reference

Represents a byte-granular source range. More...

#include "clang/Basic/SourceLocation.h"

Public Member Functions

 CharSourceRange ()=default
 CharSourceRange (SourceRange R, bool ITR)
bool isTokenRange () const
 Return true if the end of this range specifies the start of the last token.
bool isCharRange () const
SourceLocation getBegin () const
SourceLocation getEnd () const
SourceRange getAsRange () const
void setBegin (SourceLocation b)
void setEnd (SourceLocation e)
void setTokenRange (bool TR)
bool isValid () const
bool isInvalid () const

Static Public Member Functions

static CharSourceRange getTokenRange (SourceRange R)
static CharSourceRange getCharRange (SourceRange R)
static CharSourceRange getTokenRange (SourceLocation B, SourceLocation E)
static CharSourceRange getCharRange (SourceLocation B, SourceLocation E)

Detailed Description

Represents a byte-granular source range.

The underlying SourceRange can either specify the starting/ending byte of the range, or it can specify the start of the range and the start of the last token of the range (a "token range"). In the token range case, the size of the last token must be measured to determine the actual end of the range.

CharSourceRange is interpreted differently depending on whether it is a TokenRange or a CharRange. For a TokenRange, the range contains the endpoint, i.e. the token containing the end SourceLocation. For a CharRange, the range doesn't contain the endpoint, i.e. it ends at the byte before the end SourceLocation. This allows representing a point CharRange [begin, begin) that points at the empty range right in front of the begin SourceLocation.

Definition at line 276 of file SourceLocation.h.

Constructor & Destructor Documentation

◆ CharSourceRange() [1/2]

clang::CharSourceRange::CharSourceRange ( )
default

◆ CharSourceRange() [2/2]

clang::CharSourceRange::CharSourceRange ( SourceRange R,
bool ITR )
inline

Definition at line 282 of file SourceLocation.h.

Member Function Documentation

◆ getAsRange()

SourceRange clang::CharSourceRange::getAsRange ( ) const
inline

Definition at line 308 of file SourceLocation.h.

◆ getBegin()

◆ getCharRange() [1/2]

CharSourceRange clang::CharSourceRange::getCharRange ( SourceLocation B,
SourceLocation E )
inlinestatic

Definition at line 296 of file SourceLocation.h.

References CharSourceRange(), and getCharRange().

◆ getCharRange() [2/2]

CharSourceRange clang::CharSourceRange::getCharRange ( SourceRange R)
inlinestatic

◆ getEnd()

◆ getTokenRange() [1/2]

CharSourceRange clang::CharSourceRange::getTokenRange ( SourceLocation B,
SourceLocation E )
inlinestatic

Definition at line 292 of file SourceLocation.h.

References CharSourceRange(), and getTokenRange().

◆ getTokenRange() [2/2]

CharSourceRange clang::CharSourceRange::getTokenRange ( SourceRange R)
inlinestatic

Definition at line 284 of file SourceLocation.h.

References CharSourceRange().

Referenced by clang::transformer::after(), AnalyzeImplicitConversions(), clang::Sema::CheckConversionDeclarator(), clang::SemaCodeCompletion::CodeCompleteMemberReferenceExpr(), constructDebugPieceForTrackedCondition(), clang::FixItHint::CreateRemoval(), clang::tooling::createRenameAtomicChanges(), clang::FixItHint::CreateReplacement(), DiagnoseBaseOrMemInitializerOrder(), diagnoseXorMisusedAsPow(), clang::tooling::getAssociatedRange(), GetDefaultValueString(), clang::tooling::getExtendedRange(), getLiteralInfo(), getRangeForSplitTokens(), clang::Rewriter::getRangeSize(), clang::Rewriter::getRewrittenText(), clang::tooling::fixit::internal::getSourceRange(), clang::tooling::fixit::internal::getSourceRange(), clang::tooling::fixit::internal::getSourceRange(), clang::tooling::getText(), getTokenRange(), clang::Rewriter::IncreaseIndentation(), clang::edit::Commit::insertFromRange(), clang::edit::Commit::insertWrap(), clang::tooling::maybeExtendRange(), clang::transformer::member(), clang::transformer::merge(), clang::transformer::name(), clang::transformer::node(), clang::operator<<(), clang::operator<<(), clang::operator<<(), clang::ento::ConditionBRVisitor::patternMatch(), printExprAsWritten(), clang::edit::Commit::remove(), clang::edit::Commit::replace(), clang::tooling::Replacement::Replacement(), clang::tooling::replaceStmtWithStmt(), clang::tooling::replaceStmtWithText(), clang::edit::Commit::replaceWithInner(), rewriteToArraySubscriptSet(), rewriteToDictionaryLiteral(), rewriteToDictionarySubscriptSet(), rewriteToNumberLiteral(), rewriteToSubscriptGetCommon(), clang::tooling::ReplaceNodeWithTemplate::run(), clang::tooling::ReplaceStmtWithText::run(), and clang::ConversionFixItGenerator::tryToFixConversion().

◆ isCharRange()

bool clang::CharSourceRange::isCharRange ( ) const
inline

Definition at line 304 of file SourceLocation.h.

Referenced by clang::markup::EmitRange(), and clang::ThreadFlow::setRange().

◆ isInvalid()

bool clang::CharSourceRange::isInvalid ( ) const
inline

◆ isTokenRange()

bool clang::CharSourceRange::isTokenRange ( ) const
inline

Return true if the end of this range specifies the start of the last token.

Return false if the end of this range specifies the first byte after the range.

Definition at line 303 of file SourceLocation.h.

Referenced by clang::TextDiagnostic::emitDiagnosticLoc(), clang::SourceManager::getExpansionRange(), clang::SourceManager::getExpansionRange(), clang::FixItRewriter::HandleDiagnostic(), and retrieveMacroLocation().

◆ isValid()

bool clang::CharSourceRange::isValid ( ) const
inline

◆ setBegin()

void clang::CharSourceRange::setBegin ( SourceLocation b)
inline

Definition at line 310 of file SourceLocation.h.

References b.

Referenced by clang::SourceManager::getExpansionRange().

◆ setEnd()

void clang::CharSourceRange::setEnd ( SourceLocation e)
inline

Definition at line 311 of file SourceLocation.h.

Referenced by clang::SourceManager::getExpansionRange().

◆ setTokenRange()

void clang::CharSourceRange::setTokenRange ( bool TR)
inline

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