Skip to content

Commit

Permalink
fix(cxx_extractor): compile fix when absl::string_view != std::string…
Browse files Browse the repository at this point in the history
…_view (#5588)
  • Loading branch information
shahms committed Apr 19, 2023
1 parent 33ef4d5 commit 0389aa8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions kythe/cxx/extractor/cxx_extractor.cc
Expand Up @@ -21,6 +21,7 @@
#include <unistd.h>

#include <memory>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <unordered_map>
Expand Down Expand Up @@ -91,8 +92,8 @@ bool IsSpecialBufferName(llvm::StringRef id) {
id == "<built-in>" || id == "<command line>";
}

bool IsStdinPath(absl::string_view path) {
return path == "-" || path == "<stdin>" || absl::StartsWith(path, "<stdin:");
bool IsStdinPath(llvm::StringRef path) {
return path == "-" || path == "<stdin>" || path.starts_with("<stdin:");
}

absl::string_view GetPathForProto(
Expand All @@ -116,8 +117,8 @@ absl::string_view GetPathForProto(
}

// Returns a normalized, lexically-cleaned path.
std::string RelativizePath(absl::string_view path) {
if (absl::StartsWith(path, kBuiltinResourceDirectory)) {
std::string RelativizePath(llvm::StringRef path) {
if (path.starts_with(kBuiltinResourceDirectory)) {
return std::string(path);
}
if (IsStdinPath(path)) {
Expand All @@ -128,7 +129,8 @@ std::string RelativizePath(absl::string_view path) {
LOG(WARNING) << "Unable to create PathCleaner:" << cleaner.status();
return std::string(path);
}
absl::StatusOr<std::string> relative = cleaner->Relativize(path);
absl::StatusOr<std::string> relative =
cleaner->Relativize({path.data(), path.size()});
if (!relative.ok()) {
LOG(WARNING) << "Unable to relativize path:" << relative.status();
return std::string(path);
Expand All @@ -137,9 +139,7 @@ std::string RelativizePath(absl::string_view path) {
}

// Returns a normalized path, removing the leading "./" if any.
std::string NormalizePath(absl::string_view path) {
return RelativizePath(path);
}
std::string NormalizePath(llvm::StringRef path) { return RelativizePath(path); }

class RequiredRoots {
public:
Expand Down

0 comments on commit 0389aa8

Please sign in to comment.