Переглянути джерело

[clang][Index] Replace CodegenNameGenerator with ASTNameGenerator

Follow-up to: 3ff8c3b73f6, d5d15b4c1fd

Should be NFC since the original patch just moved the code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371117 91177308-0d34-0410-b5e6-96231b3b80d8
Jan Korous 6 роки тому
батько
коміт
59563d29f6

+ 0 - 52
include/clang/Index/CodegenNameGenerator.h

@@ -1,52 +0,0 @@
-//===- CodegenNameGenerator.h - Codegen name generation -------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Determines the name that the symbol will get for code generation.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H
-#define LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H
-
-#include "clang/AST/Mangle.h"
-#include "clang/Basic/LLVM.h"
-#include <memory>
-#include <string>
-#include <vector>
-
-namespace clang {
-  class ASTContext;
-  class Decl;
-
-namespace index {
-
-class CodegenNameGenerator {
-public:
-  explicit CodegenNameGenerator(ASTContext &Ctx);
-  ~CodegenNameGenerator();
-
-  /// \returns true on failure to produce a name for the given decl, false on
-  /// success.
-  bool writeName(const Decl *D, raw_ostream &OS);
-
-  /// Version of \c writeName function that returns a string.
-  std::string getName(const Decl *D);
-
-  /// This can return multiple mangled names when applicable, e.g. for C++
-  /// constructors/destructors.
-  std::vector<std::string> getAllManglings(const Decl *D);
-
-private:
-  struct Implementation;
-  std::unique_ptr<ASTNameGenerator> Impl;
-};
-
-} // namespace index
-} // namespace clang
-
-#endif // LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H

+ 0 - 1
lib/Index/CMakeLists.txt

@@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
   )
   )
 
 
 add_clang_library(clangIndex
 add_clang_library(clangIndex
-  CodegenNameGenerator.cpp
   CommentToXML.cpp
   CommentToXML.cpp
   FileIndexRecord.cpp
   FileIndexRecord.cpp
   IndexBody.cpp
   IndexBody.cpp

+ 0 - 36
lib/Index/CodegenNameGenerator.cpp

@@ -1,36 +0,0 @@
-//===- CodegenNameGenerator.cpp - Codegen name generation -----------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Determines the name that the symbol will get for code generation.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Index/CodegenNameGenerator.h"
-#include "clang/AST/ASTContext.h"
-
-using namespace clang;
-using namespace clang::index;
-
-CodegenNameGenerator::CodegenNameGenerator(ASTContext &Ctx)
-  : Impl(new ASTNameGenerator(Ctx)) {
-}
-
-CodegenNameGenerator::~CodegenNameGenerator() {
-}
-
-bool CodegenNameGenerator::writeName(const Decl *D, raw_ostream &OS) {
-  return Impl->writeName(D, OS);
-}
-
-std::string CodegenNameGenerator::getName(const Decl *D) {
-  return Impl->getName(D);
-}
-
-std::vector<std::string> CodegenNameGenerator::getAllManglings(const Decl *D) {
-  return Impl->getAllManglings(D);
-}

+ 4 - 4
tools/c-index-test/core_main.cpp

@@ -6,6 +6,7 @@
 //
 //
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
+#include "clang/AST/Mangle.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
 #include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/ASTUnit.h"
@@ -15,7 +16,6 @@
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/USRGeneration.h"
 #include "clang/Index/USRGeneration.h"
-#include "clang/Index/CodegenNameGenerator.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CommandLine.h"
@@ -79,7 +79,7 @@ namespace {
 
 
 class PrintIndexDataConsumer : public IndexDataConsumer {
 class PrintIndexDataConsumer : public IndexDataConsumer {
   raw_ostream &OS;
   raw_ostream &OS;
-  std::unique_ptr<CodegenNameGenerator> CGNameGen;
+  std::unique_ptr<ASTNameGenerator> ASTNameGen;
   std::shared_ptr<Preprocessor> PP;
   std::shared_ptr<Preprocessor> PP;
 
 
 public:
 public:
@@ -87,7 +87,7 @@ public:
   }
   }
 
 
   void initialize(ASTContext &Ctx) override {
   void initialize(ASTContext &Ctx) override {
-    CGNameGen.reset(new CodegenNameGenerator(Ctx));
+    ASTNameGen.reset(new ASTNameGenerator(Ctx));
   }
   }
 
 
   void setPreprocessor(std::shared_ptr<Preprocessor> PP) override {
   void setPreprocessor(std::shared_ptr<Preprocessor> PP) override {
@@ -112,7 +112,7 @@ public:
     printSymbolNameAndUSR(D, Ctx, OS);
     printSymbolNameAndUSR(D, Ctx, OS);
     OS << " | ";
     OS << " | ";
 
 
-    if (CGNameGen->writeName(D, OS))
+    if (ASTNameGen->writeName(D, OS))
       OS << "<no-cgname>";
       OS << "<no-cgname>";
     OS << " | ";
     OS << " | ";
 
 

+ 7 - 7
tools/libclang/CIndex.cpp

@@ -21,6 +21,7 @@
 #include "CXType.h"
 #include "CXType.h"
 #include "CursorVisitor.h"
 #include "CursorVisitor.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Mangle.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticCategories.h"
 #include "clang/Basic/DiagnosticCategories.h"
@@ -30,7 +31,6 @@
 #include "clang/Basic/Version.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Index/CodegenNameGenerator.h"
 #include "clang/Index/CommentToXML.h"
 #include "clang/Index/CommentToXML.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Lexer.h"
@@ -4737,8 +4737,8 @@ CXString clang_Cursor_getMangling(CXCursor C) {
     return cxstring::createEmpty();
     return cxstring::createEmpty();
 
 
   ASTContext &Ctx = D->getASTContext();
   ASTContext &Ctx = D->getASTContext();
-  index::CodegenNameGenerator CGNameGen(Ctx);
-  return cxstring::createDup(CGNameGen.getName(D));
+  ASTNameGenerator ASTNameGen(Ctx);
+  return cxstring::createDup(ASTNameGen.getName(D));
 }
 }
 
 
 CXStringSet *clang_Cursor_getCXXManglings(CXCursor C) {
 CXStringSet *clang_Cursor_getCXXManglings(CXCursor C) {
@@ -4750,8 +4750,8 @@ CXStringSet *clang_Cursor_getCXXManglings(CXCursor C) {
     return nullptr;
     return nullptr;
 
 
   ASTContext &Ctx = D->getASTContext();
   ASTContext &Ctx = D->getASTContext();
-  index::CodegenNameGenerator CGNameGen(Ctx);
-  std::vector<std::string> Manglings = CGNameGen.getAllManglings(D);
+  ASTNameGenerator ASTNameGen(Ctx);
+  std::vector<std::string> Manglings = ASTNameGen.getAllManglings(D);
   return cxstring::createSet(Manglings);
   return cxstring::createSet(Manglings);
 }
 }
 
 
@@ -4764,8 +4764,8 @@ CXStringSet *clang_Cursor_getObjCManglings(CXCursor C) {
     return nullptr;
     return nullptr;
 
 
   ASTContext &Ctx = D->getASTContext();
   ASTContext &Ctx = D->getASTContext();
-  index::CodegenNameGenerator CGNameGen(Ctx);
-  std::vector<std::string> Manglings = CGNameGen.getAllManglings(D);
+  ASTNameGenerator ASTNameGen(Ctx);
+  std::vector<std::string> Manglings = ASTNameGen.getAllManglings(D);
   return cxstring::createSet(Manglings);
   return cxstring::createSet(Manglings);
 }
 }