From 9f76788b0930ed48f5f20a25f1b30d63c8486531 Mon Sep 17 00:00:00 2001 From: Mikhail Maltsev Date: Sat, 9 Jan 2021 14:13:18 +0000 Subject: [PATCH] [clang][Sema] Compare SourceLocations directly [NFCI] 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. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D94231 --- clang/lib/Sema/SemaDecl.cpp | 4 +--- clang/lib/Sema/SemaStmt.cpp | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 3a1294c..dd31f3f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -436,9 +436,7 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Res != ResEnd; ++Res) { if (isa(*Res) || isa(*Res) || (AllowDeducedTemplate && getAsTypeTemplateDecl(*Res))) { - if (!IIDecl || - (*Res)->getLocation().getRawEncoding() < - IIDecl->getLocation().getRawEncoding()) + if (!IIDecl || (*Res)->getLocation() < IIDecl->getLocation()) IIDecl = *Res; } } diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index a47fdf6..b24a8ab 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -672,8 +672,7 @@ static bool CmpCaseVals(const std::pair& lhs, 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; } -- 2.7.4