summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-doc/Serialize.cpp
diff options
context:
space:
mode:
authorDiego Astiazaran <diegoaat97@gmail.com>2019-08-09 17:49:41 +0000
committerDiego Astiazaran <diegoaat97@gmail.com>2019-08-09 17:49:41 +0000
commit665e9676c257124b97a469b98a05c42df9b99d1d (patch)
treef8d104607da2485119a540c893c342dc635a1677 /clang-tools-extra/clang-doc/Serialize.cpp
parent2bf522aea62e4fb653cacb68072167d25149099e (diff)
downloadbcm5719-llvm-665e9676c257124b97a469b98a05c42df9b99d1d.tar.gz
bcm5719-llvm-665e9676c257124b97a469b98a05c42df9b99d1d.zip
[clang-format] Add link to source code in file definitions
Two command line options have been added to clang-doc. --repository=<string> - URL of repository that hosts code; used for links to definition locations. --source-root=<string> - Directory where processed files are stored. Links to definition locations will only be generated if the file is in this dir. If the file is in the source-root and a repository options is passed; a link to the source code will be rendered by the HTML generator. Differential Revision: https://reviews.llvm.org/D65483 llvm-svn: 368460
Diffstat (limited to 'clang-tools-extra/clang-doc/Serialize.cpp')
-rw-r--r--clang-tools-extra/clang-doc/Serialize.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index 72a86ee30a4..26f22a9b852 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -348,19 +348,21 @@ static void populateInfo(Info &I, const T *D, const FullComment *C,
template <typename T>
static void populateSymbolInfo(SymbolInfo &I, const T *D, const FullComment *C,
int LineNumber, StringRef Filename,
+ bool IsFileInRootDir,
bool &IsInAnonymousNamespace) {
populateInfo(I, D, C, IsInAnonymousNamespace);
if (D->isThisDeclarationADefinition())
- I.DefLoc.emplace(LineNumber, Filename);
+ I.DefLoc.emplace(LineNumber, Filename, IsFileInRootDir);
else
- I.Loc.emplace_back(LineNumber, Filename);
+ I.Loc.emplace_back(LineNumber, Filename, IsFileInRootDir);
}
static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D,
const FullComment *FC, int LineNumber,
- StringRef Filename,
+ StringRef Filename, bool IsFileInRootDir,
bool &IsInAnonymousNamespace) {
- populateSymbolInfo(I, D, FC, LineNumber, Filename, IsInAnonymousNamespace);
+ populateSymbolInfo(I, D, FC, LineNumber, Filename, IsFileInRootDir,
+ IsInAnonymousNamespace);
if (const auto *T = getDeclForType(D->getReturnType())) {
if (dyn_cast<EnumDecl>(T))
I.ReturnType = TypeInfo(getUSRForDecl(T), T->getNameAsString(),
@@ -376,7 +378,7 @@ static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D,
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
emitInfo(const NamespaceDecl *D, const FullComment *FC, int LineNumber,
- llvm::StringRef File, bool PublicOnly) {
+ llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
auto I = llvm::make_unique<NamespaceInfo>();
bool IsInAnonymousNamespace = false;
populateInfo(*I, D, FC, IsInAnonymousNamespace);
@@ -402,10 +404,11 @@ emitInfo(const NamespaceDecl *D, const FullComment *FC, int LineNumber,
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
- llvm::StringRef File, bool PublicOnly) {
+ llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
auto I = llvm::make_unique<RecordInfo>();
bool IsInAnonymousNamespace = false;
- populateSymbolInfo(*I, D, FC, LineNumber, File, IsInAnonymousNamespace);
+ populateSymbolInfo(*I, D, FC, LineNumber, File, IsFileInRootDir,
+ IsInAnonymousNamespace);
if (PublicOnly && ((IsInAnonymousNamespace ||
!isPublic(D->getAccess(), D->getLinkageInternal()))))
return {};
@@ -452,10 +455,11 @@ emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
emitInfo(const FunctionDecl *D, const FullComment *FC, int LineNumber,
- llvm::StringRef File, bool PublicOnly) {
+ llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
FunctionInfo Func;
bool IsInAnonymousNamespace = false;
- populateFunctionInfo(Func, D, FC, LineNumber, File, IsInAnonymousNamespace);
+ populateFunctionInfo(Func, D, FC, LineNumber, File, IsFileInRootDir,
+ IsInAnonymousNamespace);
if (PublicOnly && ((IsInAnonymousNamespace ||
!isPublic(D->getAccess(), D->getLinkageInternal()))))
return {};
@@ -477,10 +481,11 @@ emitInfo(const FunctionDecl *D, const FullComment *FC, int LineNumber,
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
emitInfo(const CXXMethodDecl *D, const FullComment *FC, int LineNumber,
- llvm::StringRef File, bool PublicOnly) {
+ llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
FunctionInfo Func;
bool IsInAnonymousNamespace = false;
- populateFunctionInfo(Func, D, FC, LineNumber, File, IsInAnonymousNamespace);
+ populateFunctionInfo(Func, D, FC, LineNumber, File, IsFileInRootDir,
+ IsInAnonymousNamespace);
if (PublicOnly && ((IsInAnonymousNamespace ||
!isPublic(D->getAccess(), D->getLinkageInternal()))))
return {};
@@ -511,10 +516,11 @@ emitInfo(const CXXMethodDecl *D, const FullComment *FC, int LineNumber,
std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>>
emitInfo(const EnumDecl *D, const FullComment *FC, int LineNumber,
- llvm::StringRef File, bool PublicOnly) {
+ llvm::StringRef File, bool IsFileInRootDir, bool PublicOnly) {
EnumInfo Enum;
bool IsInAnonymousNamespace = false;
- populateSymbolInfo(Enum, D, FC, LineNumber, File, IsInAnonymousNamespace);
+ populateSymbolInfo(Enum, D, FC, LineNumber, File, IsFileInRootDir,
+ IsInAnonymousNamespace);
if (PublicOnly && ((IsInAnonymousNamespace ||
!isPublic(D->getAccess(), D->getLinkageInternal()))))
return {};
OpenPOWER on IntegriCloud