From 99d1b295031ea4e74630914c14f94d919aa8e8dc Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sat, 1 Oct 2016 16:38:28 +0000 Subject: Use StringRef for MemoryBuffer identifier API (NFC) llvm-svn: 283043 --- clang/lib/Basic/SourceManager.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'clang/lib/Basic/SourceManager.cpp') diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 605f990e41d..5dcb8811e27 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1437,8 +1437,8 @@ SourceManager::getFileCharacteristic(SourceLocation Loc) const { /// Return the filename or buffer identifier of the buffer the location is in. /// Note that this name does not respect \#line directives. Use getPresumedLoc /// for normal clients. -const char *SourceManager::getBufferName(SourceLocation Loc, - bool *Invalid) const { +StringRef SourceManager::getBufferName(SourceLocation Loc, + bool *Invalid) const { if (isInvalid(Loc, Invalid)) return ""; return getBuffer(getFileID(Loc), Invalid)->getBufferIdentifier(); @@ -1470,7 +1470,7 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc, // To get the source name, first consult the FileEntry (if one exists) // before the MemBuffer as this will avoid unnecessarily paging in the // MemBuffer. - const char *Filename; + StringRef Filename; if (C->OrigEntry) Filename = C->OrigEntry->getName(); else @@ -1513,7 +1513,7 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc, } } - return PresumedLoc(Filename, LineNo, ColNo, IncludeLoc); + return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc); } /// \brief Returns whether the PresumedLoc for a given SourceLocation is @@ -2095,10 +2095,10 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS, // Clear the lookup cache, it depends on a common location. IsBeforeInTUCache.clear(); - const char *LB = getBuffer(LOffs.first)->getBufferIdentifier(); - const char *RB = getBuffer(ROffs.first)->getBufferIdentifier(); - bool LIsBuiltins = strcmp("", LB) == 0; - bool RIsBuiltins = strcmp("", RB) == 0; + StringRef LB = getBuffer(LOffs.first)->getBufferIdentifier(); + StringRef RB = getBuffer(ROffs.first)->getBufferIdentifier(); + bool LIsBuiltins = LB == ""; + bool RIsBuiltins = RB == ""; // Sort built-in before non-built-in. if (LIsBuiltins || RIsBuiltins) { if (LIsBuiltins != RIsBuiltins) @@ -2107,8 +2107,8 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS, // lower IDs come first. return LOffs.first < ROffs.first; } - bool LIsAsm = strcmp("", LB) == 0; - bool RIsAsm = strcmp("", RB) == 0; + bool LIsAsm = LB == ""; + bool RIsAsm = RB == ""; // Sort assembler after built-ins, but before the rest. if (LIsAsm || RIsAsm) { if (LIsAsm != RIsAsm) @@ -2116,8 +2116,8 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS, assert(LOffs.first == ROffs.first); return false; } - bool LIsScratch = strcmp("", LB) == 0; - bool RIsScratch = strcmp("", RB) == 0; + bool LIsScratch = LB == ""; + bool RIsScratch = RB == ""; // Sort scratch after inline asm, but before the rest. if (LIsScratch || RIsScratch) { if (LIsScratch != RIsScratch) -- cgit v1.2.3