MCPcopy Create free account
hub / github.com/ablab/spades / getLineAndColumn

Method getLineAndColumn

ext/src/llvm/SourceMgr.cpp:179–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179std::pair<unsigned, unsigned>
180SourceMgr::getLineAndColumn(SMLoc Loc, unsigned BufferID) const {
181 if (!BufferID)
182 BufferID = FindBufferContainingLoc(Loc);
183 assert(BufferID && "Invalid Location!");
184
185 auto &SB = getBufferInfo(BufferID);
186 const char *Ptr = Loc.getPointer();
187
188 unsigned LineNo = SB.getLineNumber(Ptr);
189 const char *BufStart = SB.Buffer->getBufferStart();
190 size_t NewlineOffs = StringRef(BufStart, Ptr - BufStart).find_last_of("\n\r");
191 if (NewlineOffs == StringRef::npos)
192 NewlineOffs = ~(size_t)0;
193 return std::make_pair(LineNo, Ptr - BufStart - NewlineOffs);
194}
195
196/// Given a line and column number in a mapped buffer, turn it into an SMLoc.
197/// This will return a null SMLoc if the line/column location is invalid.

Callers

nothing calls this directly

Calls 6

assertClass · 0.85
getLineNumberMethod · 0.80
StringRefClass · 0.70
getPointerMethod · 0.45
getBufferStartMethod · 0.45
find_last_ofMethod · 0.45

Tested by

no test coverage detected