Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Frontend/PrintPreprocessedOutput.cpp
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | public: | ||||
/// @param Tok Token where to move to. | /// @param Tok Token where to move to. | ||||
/// @param RequireStartOfLine Whether the next line depends on being in the | /// @param RequireStartOfLine Whether the next line depends on being in the | ||||
/// first column, such as a directive. | /// first column, such as a directive. | ||||
/// | /// | ||||
/// @return Whether column adjustments are necessary. | /// @return Whether column adjustments are necessary. | ||||
bool MoveToLine(const Token &Tok, bool RequireStartOfLine) { | bool MoveToLine(const Token &Tok, bool RequireStartOfLine) { | ||||
PresumedLoc PLoc = SM.getPresumedLoc(Tok.getLocation()); | PresumedLoc PLoc = SM.getPresumedLoc(Tok.getLocation()); | ||||
unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine; | unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine; | ||||
bool IsFirstInFile = Tok.isAtStartOfLine() && PLoc.getLine() == 1; | bool IsFirstInFile = | ||||
Tok.isAtStartOfLine() && PLoc.isValid() && PLoc.getLine() == 1; | |||||
return MoveToLine(TargetLine, RequireStartOfLine) || IsFirstInFile; | return MoveToLine(TargetLine, RequireStartOfLine) || IsFirstInFile; | ||||
} | } | ||||
/// Move to the line of the provided source location. Returns true if a new | /// Move to the line of the provided source location. Returns true if a new | ||||
/// line was inserted. | /// line was inserted. | ||||
bool MoveToLine(SourceLocation Loc, bool RequireStartOfLine) { | bool MoveToLine(SourceLocation Loc, bool RequireStartOfLine) { | ||||
PresumedLoc PLoc = SM.getPresumedLoc(Loc); | PresumedLoc PLoc = SM.getPresumedLoc(Loc); | ||||
unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine; | unsigned TargetLine = PLoc.isValid() ? PLoc.getLine() : CurLine; | ||||
▲ Show 20 Lines • Show All 826 Lines • Show Last 20 Lines |