2016-05-20 16:04:36 +08:00
|
|
|
//===-- SymbolInfo.h - Symbol Info ------------------------------*- C++ -*-===//
|
2016-04-27 22:27:05 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2016-04-27 22:27:05 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-05-13 17:27:54 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
|
2016-04-27 22:27:05 +08:00
|
|
|
|
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2016-05-11 16:38:21 +08:00
|
|
|
#include "llvm/Support/YAMLTraits.h"
|
2016-04-29 18:16:28 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2016-04-27 22:27:05 +08:00
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace find_all_symbols {
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Describes a named symbol from a header.
|
2017-03-09 18:47:44 +08:00
|
|
|
/// Symbols with the same qualified name and type (e.g. function overloads)
|
|
|
|
/// that appear in the same header are represented by a single SymbolInfo.
|
|
|
|
///
|
|
|
|
/// TODO: keep track of instances, e.g. overload locations and signatures.
|
2016-05-11 16:38:21 +08:00
|
|
|
class SymbolInfo {
|
|
|
|
public:
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// The SymbolInfo Type.
|
2016-05-13 17:15:37 +08:00
|
|
|
enum class SymbolKind {
|
2016-04-27 22:27:05 +08:00
|
|
|
Function,
|
|
|
|
Class,
|
|
|
|
Variable,
|
|
|
|
TypedefName,
|
2016-05-13 17:15:37 +08:00
|
|
|
EnumDecl,
|
|
|
|
EnumConstantDecl,
|
2016-05-20 16:04:36 +08:00
|
|
|
Macro,
|
2016-05-11 16:38:21 +08:00
|
|
|
Unknown,
|
2016-04-27 22:27:05 +08:00
|
|
|
};
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// The Context Type.
|
2016-05-13 17:15:37 +08:00
|
|
|
enum class ContextType {
|
2016-04-27 22:27:05 +08:00
|
|
|
Namespace, // Symbols declared in a namespace.
|
|
|
|
Record, // Symbols declared in a class.
|
2016-05-13 17:15:37 +08:00
|
|
|
EnumDecl, // Enum constants declared in a enum declaration.
|
2016-04-27 22:27:05 +08:00
|
|
|
};
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// A pair of <ContextType, ContextName>.
|
2016-05-11 16:38:21 +08:00
|
|
|
typedef std::pair<ContextType, std::string> Context;
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
// Signals are signals gathered by observing how a symbol is used.
|
2017-02-28 16:13:15 +08:00
|
|
|
// These are used to rank results.
|
|
|
|
struct Signals {
|
|
|
|
Signals() {}
|
|
|
|
Signals(unsigned Seen, unsigned Used) : Seen(Seen), Used(Used) {}
|
|
|
|
|
|
|
|
// Number of times this symbol was visible to a TU.
|
|
|
|
unsigned Seen = 0;
|
|
|
|
|
|
|
|
// Number of times this symbol was referenced a TU's main file.
|
|
|
|
unsigned Used = 0;
|
|
|
|
|
|
|
|
Signals &operator+=(const Signals &RHS);
|
|
|
|
Signals operator+(const Signals &RHS) const;
|
2017-02-28 18:13:26 +08:00
|
|
|
bool operator==(const Signals &RHS) const;
|
2017-02-28 16:13:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
using SignalMap = std::map<SymbolInfo, Signals>;
|
|
|
|
|
2016-05-11 16:38:21 +08:00
|
|
|
// The default constructor is required by YAML traits in
|
|
|
|
// LLVM_YAML_IS_DOCUMENT_LIST_VECTOR.
|
2017-03-09 18:47:44 +08:00
|
|
|
SymbolInfo() : Type(SymbolKind::Unknown) {}
|
2016-05-11 16:38:21 +08:00
|
|
|
|
|
|
|
SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath,
|
2017-03-09 18:47:44 +08:00
|
|
|
const std::vector<Context> &Contexts);
|
2016-05-11 16:38:21 +08:00
|
|
|
|
2020-01-29 03:23:46 +08:00
|
|
|
void SetFilePath(llvm::StringRef Path) { FilePath = std::string(Path); }
|
2016-09-08 00:34:35 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Get symbol name.
|
2016-05-31 22:40:10 +08:00
|
|
|
llvm::StringRef getName() const { return Name; }
|
2016-05-11 16:38:21 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Get the fully-qualified symbol name.
|
2016-07-08 17:10:29 +08:00
|
|
|
std::string getQualifiedName() const;
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Get symbol type.
|
2016-05-31 22:40:10 +08:00
|
|
|
SymbolKind getSymbolKind() const { return Type; }
|
2016-05-11 16:38:21 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Get a relative file path where symbol comes from.
|
2016-05-31 22:40:10 +08:00
|
|
|
llvm::StringRef getFilePath() const { return FilePath; }
|
2016-05-11 16:38:21 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Get symbol contexts.
|
2016-05-31 22:40:10 +08:00
|
|
|
const std::vector<SymbolInfo::Context> &getContexts() const {
|
|
|
|
return Contexts;
|
|
|
|
}
|
2016-05-11 16:38:21 +08:00
|
|
|
|
|
|
|
bool operator<(const SymbolInfo &Symbol) const;
|
|
|
|
|
|
|
|
bool operator==(const SymbolInfo &Symbol) const;
|
|
|
|
|
|
|
|
private:
|
2017-02-28 16:13:15 +08:00
|
|
|
friend struct llvm::yaml::MappingTraits<struct SymbolAndSignals>;
|
2016-05-11 16:38:21 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Identifier name.
|
2016-04-27 22:27:05 +08:00
|
|
|
std::string Name;
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Symbol type.
|
2016-04-27 22:27:05 +08:00
|
|
|
SymbolKind Type;
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// The file path where the symbol comes from. It's a relative file
|
2016-05-11 19:50:08 +08:00
|
|
|
/// path based on the build directory.
|
2016-04-27 22:27:05 +08:00
|
|
|
std::string FilePath;
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Contains information about symbol contexts. Context information is
|
2016-04-27 22:27:05 +08:00
|
|
|
/// 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<Context> Contexts;
|
2017-02-28 16:13:15 +08:00
|
|
|
};
|
2016-05-31 20:01:48 +08:00
|
|
|
|
2017-02-28 16:13:15 +08:00
|
|
|
struct SymbolAndSignals {
|
|
|
|
SymbolInfo Symbol;
|
|
|
|
SymbolInfo::Signals Signals;
|
2017-02-28 18:13:26 +08:00
|
|
|
bool operator==(const SymbolAndSignals& RHS) const;
|
2016-04-27 22:27:05 +08:00
|
|
|
};
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Write SymbolInfos to a stream (YAML format).
|
2016-04-29 18:16:28 +08:00
|
|
|
bool WriteSymbolInfosToStream(llvm::raw_ostream &OS,
|
2017-02-28 16:13:15 +08:00
|
|
|
const SymbolInfo::SignalMap &Symbols);
|
2016-04-27 22:27:05 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Read SymbolInfos from a YAML document.
|
2017-02-28 16:13:15 +08:00
|
|
|
std::vector<SymbolAndSignals> ReadSymbolInfosFromYAML(llvm::StringRef Yaml);
|
2016-04-27 22:27:05 +08:00
|
|
|
|
|
|
|
} // namespace find_all_symbols
|
|
|
|
} // namespace clang
|
|
|
|
|
2016-05-13 17:27:54 +08:00
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
|