Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions clang/include/clang/Basic/SourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1409,10 +1409,15 @@ class SourceManager : public RefCountedBase<SourceManager> {
/// before calling this method.
unsigned getColumnNumber(FileID FID, unsigned FilePos,
bool *Invalid = nullptr) const;
unsigned getColumnNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
unsigned getSpellingColumnNumber(SourceLocation Loc,
bool *Invalid = nullptr) const;
bool *Invalid = nullptr) const {
return getColumnNumber(getSpellingLoc(Loc), Invalid);
}
unsigned getExpansionColumnNumber(SourceLocation Loc,
bool *Invalid = nullptr) const;
bool *Invalid = nullptr) const {
return getColumnNumber(getExpansionLoc(Loc), Invalid);
}
unsigned getPresumedColumnNumber(SourceLocation Loc,
bool *Invalid = nullptr) const;

Expand All @@ -1423,8 +1428,15 @@ class SourceManager : public RefCountedBase<SourceManager> {
/// MemoryBuffer, so this is not cheap: use only when about to emit a
/// diagnostic.
unsigned getLineNumber(FileID FID, unsigned FilePos, bool *Invalid = nullptr) const;
unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
unsigned getExpansionLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
unsigned getLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
unsigned getSpellingLineNumber(SourceLocation Loc,
bool *Invalid = nullptr) const {
return getLineNumber(getSpellingLoc(Loc), Invalid);
}
unsigned getExpansionLineNumber(SourceLocation Loc,
bool *Invalid = nullptr) const {
return getLineNumber(getExpansionLoc(Loc), Invalid);
}
unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;

/// Return the filename or buffer identifier of the buffer the
Expand Down
27 changes: 8 additions & 19 deletions clang/lib/Basic/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,17 +1159,11 @@ static bool isInvalid(LocType Loc, bool *Invalid) {
return MyInvalid;
}

unsigned SourceManager::getSpellingColumnNumber(SourceLocation Loc,
bool *Invalid) const {
if (isInvalid(Loc, Invalid)) return 0;
FileIDAndOffset LocInfo = getDecomposedSpellingLoc(Loc);
return getColumnNumber(LocInfo.first, LocInfo.second, Invalid);
}

unsigned SourceManager::getExpansionColumnNumber(SourceLocation Loc,
bool *Invalid) const {
unsigned SourceManager::getColumnNumber(SourceLocation Loc,
bool *Invalid) const {
assert(Loc.isFileID());
if (isInvalid(Loc, Invalid)) return 0;
FileIDAndOffset LocInfo = getDecomposedExpansionLoc(Loc);
FileIDAndOffset LocInfo = getDecomposedLoc(Loc);
return getColumnNumber(LocInfo.first, LocInfo.second, Invalid);
}

Expand Down Expand Up @@ -1367,18 +1361,13 @@ unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos,
return LineNo;
}

unsigned SourceManager::getSpellingLineNumber(SourceLocation Loc,
bool *Invalid) const {
if (isInvalid(Loc, Invalid)) return 0;
FileIDAndOffset LocInfo = getDecomposedSpellingLoc(Loc);
return getLineNumber(LocInfo.first, LocInfo.second);
}
unsigned SourceManager::getExpansionLineNumber(SourceLocation Loc,
bool *Invalid) const {
unsigned SourceManager::getLineNumber(SourceLocation Loc, bool *Invalid) const {
assert(Loc.isFileID());
if (isInvalid(Loc, Invalid)) return 0;
FileIDAndOffset LocInfo = getDecomposedExpansionLoc(Loc);
FileIDAndOffset LocInfo = getDecomposedLoc(Loc);
return getLineNumber(LocInfo.first, LocInfo.second);
}

unsigned SourceManager::getPresumedLineNumber(SourceLocation Loc,
bool *Invalid) const {
PresumedLoc PLoc = getPresumedLoc(Loc);
Expand Down
Loading