[clang][Sema] Compare SourceLocations directly [NFCI]
authorMikhail Maltsev <mikhail.maltsev@arm.com>
Sat, 9 Jan 2021 14:13:18 +0000 (14:13 +0000)
committerMikhail Maltsev <mikhail.maltsev@arm.com>
Sat, 9 Jan 2021 14:13:18 +0000 (14:13 +0000)
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
clang/lib/Sema/SemaStmt.cpp

index 3a1294c..dd31f3f 100644 (file)
@@ -436,9 +436,7 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc,
          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;
       }
     }
index a47fdf6..b24a8ab 100644 (file)
@@ -672,8 +672,7 @@ static bool CmpCaseVals(const std::pair<llvm::APSInt, CaseStmt*>& 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;
 }