================
@@ -908,19 +908,23 @@ getExpansionLocSlowCase(SourceLocation Loc) const {
SourceLocation SourceManager::getSpellingLocSlowCase(SourceLocation Loc) const
{
do {
- FileIDAndOffset LocInfo = getDecomposedLoc(Loc);
- Loc = getSLocEntry(LocInfo.first).getExpansion().getSpellingLoc();
- Loc = Loc.getLocWithOffset(LocInfo.second);
+ const SLocEntry &Entry = getSLocEntry(getFileID(Loc));
+ Loc = Entry.getExpansion().getSpellingLoc().getLocWithOffset(
+ Loc.getOffset() - Entry.getOffset());
} while (!Loc.isFileID());
return Loc;
}
SourceLocation SourceManager::getFileLocSlowCase(SourceLocation Loc) const {
do {
- if (isMacroArgExpansion(Loc))
- Loc = getImmediateSpellingLoc(Loc);
- else
- Loc = getImmediateExpansionRange(Loc).getBegin();
+ const SLocEntry &Entry = getSLocEntry(getFileID(Loc));
+ const ExpansionInfo &ExpInfo = Entry.getExpansion();
+ if (ExpInfo.isMacroArgExpansion()) {
+ Loc = ExpInfo.getSpellingLoc().getLocWithOffset(Loc.getOffset() -
+ Entry.getOffset());
+ } else {
+ Loc = ExpInfo.getExpansionLocStart();
+ }
----------------
SergejSalnikov wrote:
Probably you are correct.
But it looks nicer that way. The performance depends how macro heavy is the
source code. I bet you can save a few seconds on the large codebases.
https://github.com/llvm/llvm-project/pull/164269
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits