Skip to content

Commit 545a7ea

Browse files
Kevin Freikevinfrei
authored andcommitted
Switch from StringRef to std::string in PluginProps::GetCachePath
1 parent 06d33ba commit 545a7ea

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,19 @@ class PluginProperties : public Properties {
5757
return urls;
5858
}
5959

60-
llvm::Expected<llvm::StringRef> GetCachePath() {
60+
llvm::Expected<std::string> GetCachePath() {
6161
OptionValueString *s =
6262
m_collection_sp->GetPropertyAtIndexAsOptionValueString(
6363
ePropertySymbolCachePath);
6464
// If we don't have a valid cache location, use the default one.
6565
if (!s || !s->GetCurrentValueAsRef().size()) {
6666
llvm::Expected<std::string> maybeCachePath =
6767
llvm::getDefaultDebuginfodCacheDirectory();
68-
if (!maybeCachePath) {
68+
if (!maybeCachePath)
6969
return maybeCachePath;
70-
}
71-
m_cache_path = *maybeCachePath;
72-
return llvm::StringRef(m_cache_path);
70+
return *maybeCachePath;
7371
}
74-
return s->GetCurrentValueAsRef();
72+
return s->GetCurrentValue();
7573
}
7674

7775
std::chrono::milliseconds GetTimeout() const {
@@ -96,7 +94,6 @@ class PluginProperties : public Properties {
9694
}
9795
// Storage for the StringRef's used within the Debuginfod library.
9896
Args m_server_urls;
99-
std::string m_cache_path;
10097
};
10198

10299
} // namespace
@@ -157,12 +154,11 @@ GetFileForModule(const ModuleSpec &module_spec,
157154
// Grab LLDB's Debuginfod overrides from the
158155
// plugin.symbol-locator.debuginfod.* settings.
159156
PluginProperties &plugin_props = GetGlobalPluginProperties();
160-
llvm::Expected<llvm::StringRef> cache_path_or_err =
161-
plugin_props.GetCachePath();
157+
llvm::Expected<std::string> cache_path_or_err = plugin_props.GetCachePath();
162158
// A cache location is *required*.
163159
if (!cache_path_or_err)
164160
return {};
165-
llvm::StringRef cache_path = *cache_path_or_err;
161+
std::string cache_path = *cache_path_or_err;
166162
llvm::SmallVector<llvm::StringRef> debuginfod_urls =
167163
llvm::getDefaultDebuginfodUrls();
168164
std::chrono::milliseconds timeout = plugin_props.GetTimeout();

llvm/include/llvm/Debuginfod/Debuginfod.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool canUseDebuginfod();
4646
/// environment variable.
4747
SmallVector<StringRef> getDefaultDebuginfodUrls();
4848

49-
/// Creates the cache-key for a given Debuginfod UrlPath
49+
/// Returns the cache key for a given debuginfod URL path.
5050
std::string getDebuginfodCacheKey(StringRef UrlPath);
5151

5252
/// Sets the list of debuginfod server URLs to query. This overrides the
@@ -61,7 +61,8 @@ Expected<std::string> getDefaultDebuginfodCacheDirectory();
6161
/// DEBUGINFOD_TIMEOUT environment variable, default is 90 seconds (90000 ms).
6262
std::chrono::milliseconds getDefaultDebuginfodTimeout();
6363

64-
/// Get the full UrlPath for a source request of a given BuildID and file path.
64+
/// Get the full URL path for a source request of a given BuildID and file
65+
/// path.
6566
std::string getDebuginfodSourceUrlPath(object::BuildIDRef ID,
6667
StringRef SourceFilePath);
6768

@@ -70,14 +71,14 @@ std::string getDebuginfodSourceUrlPath(object::BuildIDRef ID,
7071
Expected<std::string> getCachedOrDownloadSource(object::BuildIDRef ID,
7172
StringRef SourceFilePath);
7273

73-
/// Get the full UrlPath for an Executable request of a given BuildID.
74+
/// Get the full URL path for an executable request of a given BuildID.
7475
std::string getDebuginfodExecutableUrlPath(object::BuildIDRef ID);
7576

7677
/// Fetches an executable by searching the default local cache directory and
7778
/// server URLs.
7879
Expected<std::string> getCachedOrDownloadExecutable(object::BuildIDRef ID);
7980

80-
/// Get the full UrlPath for a debug binary request of a given BuildID.
81+
/// Get the full URL path for a debug binary request of a given BuildID.
8182
std::string getDebuginfodDebuginfoUrlPath(object::BuildIDRef ID);
8283

8384
/// Fetches a debug binary by searching the default local cache directory and

0 commit comments

Comments
 (0)