summaryrefslogtreecommitdiffstats
path: root/debian/patches/stringref.patch
blob: 171dca28e34f54425afc4194481eff2285ad2326 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From 53487d209729d5781007dc0fd6076dc585cb3727 Mon Sep 17 00:00:00 2001
From: Andrea Bocci <andrea.bocci@cern.ch>
Date: Fri, 28 Feb 2020 17:45:03 +0100
Subject: [PATCH] Add explicit conversion from llvm::StringRef to std::string

llvm/llvm-project@777180a makes the llvm::StringRef conversion operator
to std::string explicit.
These changes add a call to the str() method to perform the conversion.

Signed-off-by: Andrea Bocci <andrea.bocci@cern.ch>
---
 iwyu_driver.cc       | 2 +-
 iwyu_globals.cc      | 4 ++--
 iwyu_lexer_utils.cc  | 2 +-
 iwyu_location_util.h | 2 +-
 iwyu_output.cc       | 2 +-
 iwyu_path_util.cc    | 6 +++---
 iwyu_preprocessor.cc | 4 ++--
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/iwyu_driver.cc b/iwyu_driver.cc
index bd163144..42fea35b 100644
--- a/iwyu_driver.cc
+++ b/iwyu_driver.cc
@@ -79,7 +79,7 @@ std::string GetExecutablePath(const char *Argv0) {
 }
 
 const char *SaveStringInSet(std::set<std::string> &SavedStrings, StringRef S) {
-  return SavedStrings.insert(S).first->c_str();
+  return SavedStrings.insert(S.str()).first->c_str();
 }
 
 void ExpandArgsFromBuf(const char *Arg,
diff --git a/iwyu_globals.cc b/iwyu_globals.cc
index 0f58b4dc..26998966 100644
--- a/iwyu_globals.cc
+++ b/iwyu_globals.cc
@@ -293,7 +293,7 @@ static vector<HeaderSearchPath> ComputeHeaderSearchPaths(
   for (auto it = header_search->system_dir_begin();
        it != header_search->system_dir_end(); ++it) {
     if (const DirectoryEntry* entry = it->getDir()) {
-      const string path = NormalizeDirPath(MakeAbsolutePath(entry->getName()));
+      const string path = NormalizeDirPath(MakeAbsolutePath(entry->getName().str()));
       search_path_map[path] = HeaderSearchPath::kSystemPath;
     }
   }
@@ -303,7 +303,7 @@ static vector<HeaderSearchPath> ComputeHeaderSearchPaths(
       // search_dir_begin()/end() includes both system and user paths.
       // If it's a system path, it's already in the map, so everything
       // new is a user path.  The insert only 'takes' for new entries.
-      const string path = NormalizeDirPath(MakeAbsolutePath(entry->getName()));
+      const string path = NormalizeDirPath(MakeAbsolutePath(entry->getName().str()));
       search_path_map.insert(make_pair(path, HeaderSearchPath::kUserPath));
     }
   }
diff --git a/iwyu_lexer_utils.cc b/iwyu_lexer_utils.cc
index fcea2d28..648c9da8 100644
--- a/iwyu_lexer_utils.cc
+++ b/iwyu_lexer_utils.cc
@@ -70,7 +70,7 @@ SourceLocation GetLocationAfter(
 string GetIncludeNameAsWritten(
     SourceLocation include_loc,
     const CharacterDataGetterInterface& data_getter) {
-  const string data = GetSourceTextUntilEndOfLine(include_loc, data_getter);
+  const string data = GetSourceTextUntilEndOfLine(include_loc, data_getter).str();
   if (data.empty())
     return data;
   string::size_type endpos = string::npos;
diff --git a/iwyu_location_util.h b/iwyu_location_util.h
index 3892a424..6f8cf81c 100644
--- a/iwyu_location_util.h
+++ b/iwyu_location_util.h
@@ -89,7 +89,7 @@ bool IsInScratchSpace(clang::SourceLocation loc);
 
 inline string GetFilePath(const clang::FileEntry* file) {
   return (IsBuiltinFile(file) ? "<built-in>" :
-          NormalizeFilePath(file->getName()));
+          NormalizeFilePath(file->getName().str()));
 }
 
 //------------------------------------------------------------
diff --git a/iwyu_output.cc b/iwyu_output.cc
index ca145710..8666c26c 100644
--- a/iwyu_output.cc
+++ b/iwyu_output.cc
@@ -168,7 +168,7 @@ string GetKindName(const clang::TagDecl* tag_decl) {
   if (const FakeNamedDecl* fake = FakeNamedDeclIfItIsOne(named_decl)) {
     return fake->kind_name();
   }
-  return tag_decl->getKindName();
+  return tag_decl->getKindName().str();
 }
 
 string GetQualifiedNameAsString(const clang::NamedDecl* named_decl) {
diff --git a/iwyu_path_util.cc b/iwyu_path_util.cc
index ab4fc800..9987ea47 100644
--- a/iwyu_path_util.cc
+++ b/iwyu_path_util.cc
@@ -134,7 +134,7 @@ string NormalizeFilePath(const string& path) {
   std::replace(normalized.begin(), normalized.end(), '\\', '/');
 #endif
 
-  return normalized.str();
+  return normalized.str().str();
 }
 
 string NormalizeDirPath(const string& path) {
@@ -154,14 +154,14 @@ string MakeAbsolutePath(const string& path) {
   std::error_code error = llvm::sys::fs::make_absolute(absolute_path);
   CHECK_(!error);
 
-  return absolute_path.str();
+  return absolute_path.str().str();
 }
 
 string MakeAbsolutePath(const string& base_path, const string& relative_path) {
   llvm::SmallString<128> absolute_path(base_path);
   llvm::sys::path::append(absolute_path, relative_path);
 
-  return absolute_path.str();
+  return absolute_path.str().str();
 }
 
 string GetParentPath(const string& path) {
diff --git a/iwyu_preprocessor.cc b/iwyu_preprocessor.cc
index 58e78595..88b93144 100644
--- a/iwyu_preprocessor.cc
+++ b/iwyu_preprocessor.cc
@@ -313,7 +313,7 @@ void IwyuPreprocessorInfo::ProcessHeadernameDirectivesInFile(
       break;
     }
     const string filename = GetSourceTextUntilEndOfLine(current_loc,
-                                                        DefaultDataGetter());
+                                                        DefaultDataGetter()).str();
     // Use "" or <> based on where the file lives.
     string quoted_private_include;
     if (IsSystemIncludeFile(GetFilePath(current_loc)))
@@ -332,7 +332,7 @@ void IwyuPreprocessorInfo::ProcessHeadernameDirectivesInFile(
     }
 
     string after_text = GetSourceTextUntilEndOfLine(current_loc,
-                                                    DefaultDataGetter());
+                                                    DefaultDataGetter()).str();
     const string::size_type close_brace_pos = after_text.find('}');
     if (close_brace_pos == string::npos) {
       Warn(current_loc, "@headername directive missing a closing brace");