//===-- SymbolInfo.h - find all symbols--------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOL_INFO_H #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOL_INFO_H #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" #include #include #include namespace clang { namespace find_all_symbols { /// \brief Contains all information for a Symbol. struct SymbolInfo { enum SymbolKind { Function, Class, Variable, TypedefName, }; enum ContextType { Namespace, // Symbols declared in a namespace. Record, // Symbols declared in a class. }; /// \brief Identifier name. std::string Name; /// \brief Symbol type. SymbolKind Type; /// \brief The file path where the symbol comes from. std::string FilePath; /// \brief A pair of . typedef std::pair Context; /// \brief Contains information about symbol contexts. Context information is /// stored from the inner-most level to outer-most level. /// /// For example, if a symbol 'x' is declared as: /// namespace na { namespace nb { class A { int x; } } } /// The contexts would be { {RECORD, "A"}, {NAMESPACE, "nb"}, {NAMESPACE, /// "na"} }. /// The name of an anonymous namespace is "". /// /// If the symbol is declared in `TranslationUnitDecl`, it has no context. std::vector Contexts; /// \brief The 1-based line number of of the symbol's declaration. int LineNumber; struct FunctionInfo { std::string ReturnType; std::vector ParameterTypes; }; struct TypedefNameInfo { std::string UnderlyingType; }; struct VariableInfo { std::string Type; }; /// \brief The function information. llvm::Optional FunctionInfos; /// \brief The typedef information. llvm::Optional TypedefNameInfos; /// \brief The variable information. llvm::Optional VariableInfos; bool operator==(const SymbolInfo &Symbol) const; bool operator<(const SymbolInfo &Symbol) const; }; /// \brief Write SymbolInfos to a stream (YAML format). bool WriteSymbolInfosToStream(llvm::raw_ostream &OS, const std::set &Symbols); /// \brief Read SymbolInfos from a YAML document. std::vector ReadSymbolInfosFromYAML(llvm::StringRef Yaml); } // namespace find_all_symbols } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOL_INFO_H