[PATCH] D94231: [clang][Sema] Compare SourceLocations directly [NFCI]
Mikhail Maltsev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 7 05:38:42 PST 2021
miyuki created this revision.
miyuki added reviewers: dexonsmith, aprantl, rsmith.
miyuki requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The ordered comparison operators are defined for the SourceLocation
class, so SourceLocation objects can be compared directly. There is no
need to extract the internal representation for comparison.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94231
Files:
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaStmt.cpp
Index: clang/lib/Sema/SemaStmt.cpp
===================================================================
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -672,8 +672,7 @@
return true;
if (lhs.first == rhs.first &&
- lhs.second->getCaseLoc().getRawEncoding()
- < rhs.second->getCaseLoc().getRawEncoding())
+ lhs.second->getCaseLoc() < rhs.second->getCaseLoc())
return true;
return false;
}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -436,9 +436,7 @@
Res != ResEnd; ++Res) {
if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) ||
(AllowDeducedTemplate && getAsTypeTemplateDecl(*Res))) {
- if (!IIDecl ||
- (*Res)->getLocation().getRawEncoding() <
- IIDecl->getLocation().getRawEncoding())
+ if (!IIDecl || (*Res)->getLocation() < IIDecl->getLocation())
IIDecl = *Res;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94231.315112.patch
Type: text/x-patch
Size: 1041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210107/f836293b/attachment-0001.bin>
More information about the cfe-commits
mailing list