Skip to content

Commit c11c78a

Browse files
committed
[clangd] Use llvm::errs() instead of outs() for errors
Summary: errs() is more appropriate for error messages in dexp and clangd-index-server. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83827
1 parent 10fd550 commit c11c78a

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ class Lookup : public Command {
181181

182182
void run() override {
183183
if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
184-
llvm::outs()
184+
llvm::errs()
185185
<< "Missing required argument: please provide id or -name.\n";
186186
return;
187187
}
188188
std::vector<SymbolID> IDs;
189189
if (ID.getNumOccurrences()) {
190190
auto SID = SymbolID::fromStr(ID);
191191
if (!SID) {
192-
llvm::outs() << llvm::toString(SID.takeError()) << "\n";
192+
llvm::errs() << llvm::toString(SID.takeError()) << "\n";
193193
return;
194194
}
195195
IDs.push_back(*SID);
@@ -205,7 +205,7 @@ class Lookup : public Command {
205205
llvm::outs() << toYAML(Sym);
206206
});
207207
if (!FoundSymbol)
208-
llvm::outs() << "not found\n";
208+
llvm::errs() << "not found\n";
209209
}
210210
};
211211

@@ -228,22 +228,22 @@ class Refs : public Command {
228228

229229
void run() override {
230230
if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
231-
llvm::outs()
231+
llvm::errs()
232232
<< "Missing required argument: please provide id or -name.\n";
233233
return;
234234
}
235235
std::vector<SymbolID> IDs;
236236
if (ID.getNumOccurrences()) {
237237
auto SID = SymbolID::fromStr(ID);
238238
if (!SID) {
239-
llvm::outs() << llvm::toString(SID.takeError()) << "\n";
239+
llvm::errs() << llvm::toString(SID.takeError()) << "\n";
240240
return;
241241
}
242242
IDs.push_back(*SID);
243243
} else {
244244
IDs = getSymbolIDsFromIndex(Name, Index);
245245
if (IDs.size() > 1) {
246-
llvm::outs() << llvm::formatv(
246+
llvm::errs() << llvm::formatv(
247247
"The name {0} is ambiguous, found {1} different "
248248
"symbols. Please use id flag to disambiguate.\n",
249249
Name, IDs.size());
@@ -256,7 +256,7 @@ class Refs : public Command {
256256
Index->refs(RefRequest, [&RegexFilter](const Ref &R) {
257257
auto U = URI::parse(R.Location.FileURI);
258258
if (!U) {
259-
llvm::outs() << U.takeError();
259+
llvm::errs() << U.takeError();
260260
return;
261261
}
262262
if (RegexFilter.match(U->body()))
@@ -358,7 +358,7 @@ bool runCommand(std::string Request, const SymbolIndex &Index) {
358358
return Cmd.Implementation()->parseAndRun(FakeArgv, Cmd.Description,
359359
Index);
360360
}
361-
llvm::outs() << "Unknown command. Try 'help'.\n";
361+
llvm::errs() << "Unknown command. Try 'help'.\n";
362362
return false;
363363
}
364364

@@ -380,7 +380,7 @@ int main(int argc, const char *argv[]) {
380380
[&]() { Index = openIndex(IndexLocation); });
381381

382382
if (!Index) {
383-
llvm::outs() << "Failed to open the index.\n";
383+
llvm::errs() << "Failed to open the index.\n";
384384
return -1;
385385
}
386386

‎clang-tools-extra/clangd/index/remote/server/Server.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ int main(int argc, char *argv[]) {
141141
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
142142

143143
if (!llvm::sys::path::is_absolute(IndexRoot)) {
144-
llvm::outs() << "Index root should be an absolute path.\n";
144+
llvm::errs() << "Index root should be an absolute path.\n";
145145
return -1;
146146
}
147147

148148
std::unique_ptr<clang::clangd::SymbolIndex> Index = openIndex(IndexPath);
149149

150150
if (!Index) {
151-
llvm::outs() << "Failed to open the index.\n";
151+
llvm::errs() << "Failed to open the index.\n";
152152
return -1;
153153
}
154154

0 commit comments

Comments
 (0)