@@ -1437,8 +1437,8 @@ SourceManager::getFileCharacteristic(SourceLocation Loc) const {
1437
1437
// / Return the filename or buffer identifier of the buffer the location is in.
1438
1438
// / Note that this name does not respect \#line directives. Use getPresumedLoc
1439
1439
// / for normal clients.
1440
- const char * SourceManager::getBufferName (SourceLocation Loc,
1441
- bool *Invalid) const {
1440
+ StringRef SourceManager::getBufferName (SourceLocation Loc,
1441
+ bool *Invalid) const {
1442
1442
if (isInvalid (Loc, Invalid)) return " <invalid loc>" ;
1443
1443
1444
1444
return getBuffer (getFileID (Loc), Invalid)->getBufferIdentifier ();
@@ -1470,7 +1470,7 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc,
1470
1470
// To get the source name, first consult the FileEntry (if one exists)
1471
1471
// before the MemBuffer as this will avoid unnecessarily paging in the
1472
1472
// MemBuffer.
1473
- const char * Filename;
1473
+ StringRef Filename;
1474
1474
if (C->OrigEntry )
1475
1475
Filename = C->OrigEntry ->getName ();
1476
1476
else
@@ -1513,7 +1513,7 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc,
1513
1513
}
1514
1514
}
1515
1515
1516
- return PresumedLoc (Filename, LineNo, ColNo, IncludeLoc);
1516
+ return PresumedLoc (Filename. data () , LineNo, ColNo, IncludeLoc);
1517
1517
}
1518
1518
1519
1519
// / \brief Returns whether the PresumedLoc for a given SourceLocation is
@@ -2095,10 +2095,10 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
2095
2095
2096
2096
// Clear the lookup cache, it depends on a common location.
2097
2097
IsBeforeInTUCache.clear ();
2098
- const char * LB = getBuffer (LOffs.first )->getBufferIdentifier ();
2099
- const char * RB = getBuffer (ROffs.first )->getBufferIdentifier ();
2100
- bool LIsBuiltins = strcmp ( " <built-in>" , LB) == 0 ;
2101
- bool RIsBuiltins = strcmp ( " <built-in>" , RB) == 0 ;
2098
+ StringRef LB = getBuffer (LOffs.first )->getBufferIdentifier ();
2099
+ StringRef RB = getBuffer (ROffs.first )->getBufferIdentifier ();
2100
+ bool LIsBuiltins = LB == " <built-in>" ;
2101
+ bool RIsBuiltins = RB == " <built-in>" ;
2102
2102
// Sort built-in before non-built-in.
2103
2103
if (LIsBuiltins || RIsBuiltins) {
2104
2104
if (LIsBuiltins != RIsBuiltins)
@@ -2107,17 +2107,17 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
2107
2107
// lower IDs come first.
2108
2108
return LOffs.first < ROffs.first ;
2109
2109
}
2110
- bool LIsAsm = strcmp ( " <inline asm>" , LB) == 0 ;
2111
- bool RIsAsm = strcmp ( " <inline asm>" , RB) == 0 ;
2110
+ bool LIsAsm = LB == " <inline asm>" ;
2111
+ bool RIsAsm = RB == " <inline asm>" ;
2112
2112
// Sort assembler after built-ins, but before the rest.
2113
2113
if (LIsAsm || RIsAsm) {
2114
2114
if (LIsAsm != RIsAsm)
2115
2115
return RIsAsm;
2116
2116
assert (LOffs.first == ROffs.first );
2117
2117
return false ;
2118
2118
}
2119
- bool LIsScratch = strcmp ( " <scratch space>" , LB) == 0 ;
2120
- bool RIsScratch = strcmp ( " <scratch space>" , RB) == 0 ;
2119
+ bool LIsScratch = LB == " <scratch space>" ;
2120
+ bool RIsScratch = RB == " <scratch space>" ;
2121
2121
// Sort scratch after inline asm, but before the rest.
2122
2122
if (LIsScratch || RIsScratch) {
2123
2123
if (LIsScratch != RIsScratch)
0 commit comments