[clangd] Remove 'using namespace llvm' from .cpp files. NFC
The new guideline is to qualify with 'llvm::' explicitly both in
'.h' and '.cpp' files. This simplifies moving the code between
header and source files and is easier to keep consistent.
llvm-svn: 350531
diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp
index c43d72c..06f822b 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -17,7 +17,6 @@
#include "clang/Lex/HeaderSearch.h"
#include "llvm/Support/Path.h"
-using namespace llvm;
namespace clang {
namespace clangd {
namespace {
@@ -30,9 +29,10 @@
// Record existing #includes - both written and resolved paths. Only #includes
// in the main file are collected.
void InclusionDirective(SourceLocation HashLoc, const Token & /*IncludeTok*/,
- StringRef FileName, bool IsAngled,
+ llvm::StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange, const FileEntry *File,
- StringRef /*SearchPath*/, StringRef /*RelativePath*/,
+ llvm::StringRef /*SearchPath*/,
+ llvm::StringRef /*RelativePath*/,
const Module * /*Imported*/,
SrcMgr::CharacteristicKind FileKind) override {
if (SM.isWrittenInMainFile(HashLoc)) {
@@ -65,13 +65,13 @@
} // namespace
-bool isLiteralInclude(StringRef Include) {
+bool isLiteralInclude(llvm::StringRef Include) {
return Include.startswith("<") || Include.startswith("\"");
}
bool HeaderFile::valid() const {
return (Verbatim && isLiteralInclude(File)) ||
- (!Verbatim && sys::path::is_absolute(File));
+ (!Verbatim && llvm::sys::path::is_absolute(File));
}
std::unique_ptr<PPCallbacks>
@@ -80,9 +80,9 @@
return llvm::make_unique<RecordHeaders>(SM, Out);
}
-void IncludeStructure::recordInclude(StringRef IncludingName,
- StringRef IncludedName,
- StringRef IncludedRealName) {
+void IncludeStructure::recordInclude(llvm::StringRef IncludingName,
+ llvm::StringRef IncludedName,
+ llvm::StringRef IncludedRealName) {
auto Child = fileIndex(IncludedName);
if (!IncludedRealName.empty() && RealPathNames[Child].empty())
RealPathNames[Child] = IncludedRealName;
@@ -90,19 +90,20 @@
IncludeChildren[Parent].push_back(Child);
}
-unsigned IncludeStructure::fileIndex(StringRef Name) {
+unsigned IncludeStructure::fileIndex(llvm::StringRef Name) {
auto R = NameToIndex.try_emplace(Name, RealPathNames.size());
if (R.second)
RealPathNames.emplace_back();
return R.first->getValue();
}
-StringMap<unsigned> IncludeStructure::includeDepth(StringRef Root) const {
+llvm::StringMap<unsigned>
+IncludeStructure::includeDepth(llvm::StringRef Root) const {
// Include depth 0 is the main file only.
- StringMap<unsigned> Result;
+ llvm::StringMap<unsigned> Result;
Result[Root] = 0;
std::vector<unsigned> CurrentLevel;
- DenseSet<unsigned> Seen;
+ llvm::DenseSet<unsigned> Seen;
auto It = NameToIndex.find(Root);
if (It != NameToIndex.end()) {
CurrentLevel.push_back(It->second);
@@ -142,7 +143,7 @@
assert(DeclaringHeader.valid() && InsertedHeader.valid());
if (FileName == DeclaringHeader.File || FileName == InsertedHeader.File)
return false;
- auto Included = [&](StringRef Header) {
+ auto Included = [&](llvm::StringRef Header) {
return IncludedHeaders.find(Header) != IncludedHeaders.end();
};
return !Included(DeclaringHeader.File) && !Included(InsertedHeader.File);
@@ -164,8 +165,9 @@
return Suggested;
}
-Optional<TextEdit> IncludeInserter::insert(StringRef VerbatimHeader) const {
- Optional<TextEdit> Edit = None;
+llvm::Optional<TextEdit>
+IncludeInserter::insert(llvm::StringRef VerbatimHeader) const {
+ llvm::Optional<TextEdit> Edit = None;
if (auto Insertion = Inserter.insert(VerbatimHeader.trim("\"<>"),
VerbatimHeader.startswith("<")))
Edit = replacementToEdit(Code, *Insertion);