[PATCH] D85427: [SyntaxTree][NFC] remove redundant namespace-specifiers

2020-08-07 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba41a0f7339c: [SyntaxTree][NFC] remove redundant 
namespace-specifiers (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85427/new/

https://reviews.llvm.org/D85427

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -40,7 +40,7 @@
 using namespace clang;
 
 namespace {
-static llvm::ArrayRef tokens(syntax::Node *N) {
+static ArrayRef tokens(syntax::Node *N) {
   assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
   if (auto *L = dyn_cast(N))
 return llvm::makeArrayRef(L->token(), 1);
@@ -53,7 +53,7 @@
public ::testing::WithParamInterface {
 protected:
   // Build a syntax tree for the code.
-  syntax::TranslationUnit *buildTree(llvm::StringRef Code,
+  syntax::TranslationUnit *buildTree(StringRef Code,
  const TestClangConfig ) {
 // FIXME: this code is almost the identical to the one in TokensTest. Share
 //it.
@@ -169,7 +169,7 @@
   }
 
   // Adds a file to the test VFS.
-  void addFile(llvm::StringRef Path, llvm::StringRef Contents) {
+  void addFile(StringRef Path, StringRef Contents) {
 if (!FS->addFile(Path, time_t(),
  llvm::MemoryBuffer::getMemBufferCopy(Contents))) {
   ADD_FAILURE() << "could not add a file to VFS: " << Path;
@@ -179,7 +179,7 @@
   /// Finds the deepest node in the tree that covers exactly \p R.
   /// FIXME: implement this efficiently and move to public syntax tree API.
   syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root) {
-llvm::ArrayRef Toks = tokens(Root);
+ArrayRef Toks = tokens(Root);
 
 if (Toks.front().location().isFileID() &&
 Toks.back().location().isFileID() &&
@@ -198,15 +198,14 @@
   }
 
   // Data fields.
-  llvm::IntrusiveRefCntPtr DiagOpts =
-  new DiagnosticOptions();
-  llvm::IntrusiveRefCntPtr Diags =
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr Diags =
   new DiagnosticsEngine(new DiagnosticIDs, DiagOpts.get());
   IntrusiveRefCntPtr FS =
   new llvm::vfs::InMemoryFileSystem;
-  llvm::IntrusiveRefCntPtr FileMgr =
+  IntrusiveRefCntPtr FileMgr =
   new FileManager(FileSystemOptions(), FS);
-  llvm::IntrusiveRefCntPtr SourceMgr =
+  IntrusiveRefCntPtr SourceMgr =
   new SourceManager(*Diags, *FileMgr);
   std::shared_ptr Invocation;
   // Set after calling buildTree().
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -36,11 +36,9 @@
  const TokenBuffer )
 : SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(Tokens) {}
 
-const clang::syntax::TokenBuffer ::Arena::tokenBuffer() const {
-  return Tokens;
-}
+const syntax::TokenBuffer ::Arena::tokenBuffer() const { return Tokens; }
 
-std::pair>
+std::pair>
 syntax::Arena::lexBuffer(std::unique_ptr Input) {
   auto FID = SourceMgr.createFileID(std::move(Input));
   auto It = ExtraTokens.try_emplace(FID, tokenize(FID, SourceMgr, LangOpts));
@@ -135,7 +133,7 @@
 }
 
 namespace {
-static void dumpTokens(llvm::raw_ostream , ArrayRef Tokens,
+static void dumpTokens(raw_ostream , ArrayRef Tokens,
const SourceManager ) {
   assert(!Tokens.empty());
   bool First = true;
@@ -153,7 +151,7 @@
   }
 }
 
-static void dumpTree(llvm::raw_ostream , const syntax::Node *N,
+static void dumpTree(raw_ostream , const syntax::Node *N,
  const syntax::Arena , std::vector IndentMask) {
   std::string Marks;
   if (!N->isOriginal())
@@ -165,13 +163,13 @@
   if (!Marks.empty())
 OS << Marks << ": ";
 
-  if (auto *L = llvm::dyn_cast(N)) {
+  if (auto *L = dyn_cast(N)) {
 dumpTokens(OS, *L->token(), A.sourceManager());
 OS << "\n";
 return;
   }
 
-  auto *T = llvm::cast(N);
+  auto *T = cast(N);
   OS << T->kind() << "\n";
 
   for (auto It = T->firstChild(); It != nullptr; It = It->nextSibling()) {
@@ -205,7 +203,7 @@
   std::string Storage;
   llvm::raw_string_ostream OS(Storage);
   traverse(this, [&](const syntax::Node *N) {
-auto *L = llvm::dyn_cast(N);
+auto *L = dyn_cast(N);
 if (!L)
   return;
 ::dumpTokens(OS, *L->token(), A.sourceManager());
Index: clang/lib/Tooling/Syntax/Nodes.cpp

[PATCH] D85427: [SyntaxTree][NFC] remove redundant namespace-specifiers

2020-08-06 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 283659.
eduucaldas added a comment.

removed namespace specifiers `llvm::`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85427/new/

https://reviews.llvm.org/D85427

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -40,7 +40,7 @@
 using namespace clang;
 
 namespace {
-static llvm::ArrayRef tokens(syntax::Node *N) {
+static ArrayRef tokens(syntax::Node *N) {
   assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
   if (auto *L = dyn_cast(N))
 return llvm::makeArrayRef(L->token(), 1);
@@ -53,7 +53,7 @@
public ::testing::WithParamInterface {
 protected:
   // Build a syntax tree for the code.
-  syntax::TranslationUnit *buildTree(llvm::StringRef Code,
+  syntax::TranslationUnit *buildTree(StringRef Code,
  const TestClangConfig ) {
 // FIXME: this code is almost the identical to the one in TokensTest. Share
 //it.
@@ -169,7 +169,7 @@
   }
 
   // Adds a file to the test VFS.
-  void addFile(llvm::StringRef Path, llvm::StringRef Contents) {
+  void addFile(StringRef Path, StringRef Contents) {
 if (!FS->addFile(Path, time_t(),
  llvm::MemoryBuffer::getMemBufferCopy(Contents))) {
   ADD_FAILURE() << "could not add a file to VFS: " << Path;
@@ -179,7 +179,7 @@
   /// Finds the deepest node in the tree that covers exactly \p R.
   /// FIXME: implement this efficiently and move to public syntax tree API.
   syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root) {
-llvm::ArrayRef Toks = tokens(Root);
+ArrayRef Toks = tokens(Root);
 
 if (Toks.front().location().isFileID() &&
 Toks.back().location().isFileID() &&
@@ -198,15 +198,14 @@
   }
 
   // Data fields.
-  llvm::IntrusiveRefCntPtr DiagOpts =
-  new DiagnosticOptions();
-  llvm::IntrusiveRefCntPtr Diags =
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr Diags =
   new DiagnosticsEngine(new DiagnosticIDs, DiagOpts.get());
   IntrusiveRefCntPtr FS =
   new llvm::vfs::InMemoryFileSystem;
-  llvm::IntrusiveRefCntPtr FileMgr =
+  IntrusiveRefCntPtr FileMgr =
   new FileManager(FileSystemOptions(), FS);
-  llvm::IntrusiveRefCntPtr SourceMgr =
+  IntrusiveRefCntPtr SourceMgr =
   new SourceManager(*Diags, *FileMgr);
   std::shared_ptr Invocation;
   // Set after calling buildTree().
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -36,11 +36,9 @@
  const TokenBuffer )
 : SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(Tokens) {}
 
-const clang::syntax::TokenBuffer ::Arena::tokenBuffer() const {
-  return Tokens;
-}
+const syntax::TokenBuffer ::Arena::tokenBuffer() const { return Tokens; }
 
-std::pair>
+std::pair>
 syntax::Arena::lexBuffer(std::unique_ptr Input) {
   auto FID = SourceMgr.createFileID(std::move(Input));
   auto It = ExtraTokens.try_emplace(FID, tokenize(FID, SourceMgr, LangOpts));
@@ -135,7 +133,7 @@
 }
 
 namespace {
-static void dumpTokens(llvm::raw_ostream , ArrayRef Tokens,
+static void dumpTokens(raw_ostream , ArrayRef Tokens,
const SourceManager ) {
   assert(!Tokens.empty());
   bool First = true;
@@ -153,7 +151,7 @@
   }
 }
 
-static void dumpTree(llvm::raw_ostream , const syntax::Node *N,
+static void dumpTree(raw_ostream , const syntax::Node *N,
  const syntax::Arena , std::vector IndentMask) {
   std::string Marks;
   if (!N->isOriginal())
@@ -165,13 +163,13 @@
   if (!Marks.empty())
 OS << Marks << ": ";
 
-  if (auto *L = llvm::dyn_cast(N)) {
+  if (auto *L = dyn_cast(N)) {
 dumpTokens(OS, *L->token(), A.sourceManager());
 OS << "\n";
 return;
   }
 
-  auto *T = llvm::cast(N);
+  auto *T = cast(N);
   OS << T->kind() << "\n";
 
   for (auto It = T->firstChild(); It != nullptr; It = It->nextSibling()) {
@@ -205,7 +203,7 @@
   std::string Storage;
   llvm::raw_string_ostream OS(Storage);
   traverse(this, [&](const syntax::Node *N) {
-auto *L = llvm::dyn_cast(N);
+auto *L = dyn_cast(N);
 if (!L)
   return;
 ::dumpTokens(OS, *L->token(), A.sourceManager());
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -10,7 +10,7 @@
 
 using 

[PATCH] D85427: [SyntaxTree][NFC] remove redundant namespace-specifiers

2020-08-06 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85427

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -36,9 +36,7 @@
  const TokenBuffer )
 : SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(Tokens) {}
 
-const clang::syntax::TokenBuffer ::Arena::tokenBuffer() const {
-  return Tokens;
-}
+const syntax::TokenBuffer ::Arena::tokenBuffer() const { return Tokens; }
 
 std::pair>
 syntax::Arena::lexBuffer(std::unique_ptr Input) {
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -45,7 +45,7 @@
 using namespace clang;
 
 LLVM_ATTRIBUTE_UNUSED
-static bool isImplicitExpr(clang::Expr *E) { return E->IgnoreImplicit() != E; }
+static bool isImplicitExpr(Expr *E) { return E->IgnoreImplicit() != E; }
 
 namespace {
 /// Get start location of the Declarator from the TypeLoc.
@@ -384,7 +384,7 @@
   }
 
   llvm::ArrayRef getDeclarationRange(Decl *D) {
-llvm::ArrayRef Tokens;
+llvm::ArrayRef Tokens;
 // We want to drop the template parameters for specializations.
 if (const auto *S = llvm::dyn_cast(D))
   Tokens = getRange(S->TypeDecl::getBeginLoc(), S->getEndLoc());
@@ -722,16 +722,16 @@
   syntax::UserDefinedLiteralExpression *
   buildUserDefinedLiteral(UserDefinedLiteral *S) {
 switch (S->getLiteralOperatorKind()) {
-case clang::UserDefinedLiteral::LOK_Integer:
+case UserDefinedLiteral::LOK_Integer:
   return new (allocator()) syntax::IntegerUserDefinedLiteralExpression;
-case clang::UserDefinedLiteral::LOK_Floating:
+case UserDefinedLiteral::LOK_Floating:
   return new (allocator()) syntax::FloatUserDefinedLiteralExpression;
-case clang::UserDefinedLiteral::LOK_Character:
+case UserDefinedLiteral::LOK_Character:
   return new (allocator()) syntax::CharUserDefinedLiteralExpression;
-case clang::UserDefinedLiteral::LOK_String:
+case UserDefinedLiteral::LOK_String:
   return new (allocator()) syntax::StringUserDefinedLiteralExpression;
-case clang::UserDefinedLiteral::LOK_Raw:
-case clang::UserDefinedLiteral::LOK_Template:
+case UserDefinedLiteral::LOK_Raw:
+case UserDefinedLiteral::LOK_Template:
   // For raw literal operator and numeric literal operator template we
   // cannot get the type of the operand in the semantic AST. We get this
   // information from the token. As integer and floating point have the same
Index: clang/include/clang/Tooling/Syntax/Tree.h
===
--- clang/include/clang/Tooling/Syntax/Tree.h
+++ clang/include/clang/Tooling/Syntax/Tree.h
@@ -50,7 +50,7 @@
   /// Add \p Buffer to the underlying source manager, tokenize it and store the
   /// resulting tokens. Useful when there is a need to materialize tokens that
   /// were not written in user code.
-  std::pair>
+  std::pair>
   lexBuffer(std::unique_ptr Buffer);
 
 private:
@@ -58,7 +58,7 @@
   const LangOptions 
   const TokenBuffer 
   /// IDs and storage for additional tokenized files.
-  llvm::DenseMap> ExtraTokens;
+  llvm::DenseMap> ExtraTokens;
   /// Keeps all the allocated nodes and their intermediate data structures.
   llvm::BumpPtrAllocator Allocator;
 };
@@ -139,13 +139,13 @@
 /// A leaf node points to a single token inside the expanded token stream.
 class Leaf final : public Node {
 public:
-  Leaf(const syntax::Token *T);
+  Leaf(const Token *T);
   static bool classof(const Node *N);
 
-  const syntax::Token *token() const { return Tok; }
+  const Token *token() const { return Tok; }
 
 private:
-  const syntax::Token *Tok;
+  const Token *Tok;
 };
 
 /// A node that has children and represents a syntactic language construct.
@@ -167,7 +167,7 @@
 
 protected:
   /// Find the first node with a corresponding role.
-  syntax::Node *findChild(NodeRole R);
+  Node *findChild(NodeRole R);
 
 private:
   /// Prepend \p Child to the list of children and and sets the parent pointer.
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -212,7 +212,7 @@
   static bool classof(const Node *N) {
 return N->kind() <= NodeKind::NestedNameSpecifier;
   }
-  std::vector specifiers();
+  std::vector specifiers();
 };
 
 /// Models an `unqualified-id`. C++