summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-doc
diff options
context:
space:
mode:
authorDiego Astiazaran <diegoaat97@gmail.com>2019-08-15 23:04:27 +0000
committerDiego Astiazaran <diegoaat97@gmail.com>2019-08-15 23:04:27 +0000
commit6a29ae4bde963b4f271bd9c0dfb0edd4c0de893c (patch)
tree01dc5ba80a5a4769e609e483c9f45aff436bc53c /clang-tools-extra/clang-doc
parent75344955fcd43b67cedec8d5b29ad3419b5aaa81 (diff)
downloadbcm5719-llvm-6a29ae4bde963b4f271bd9c0dfb0edd4c0de893c.tar.gz
bcm5719-llvm-6a29ae4bde963b4f271bd9c0dfb0edd4c0de893c.zip
[clang-doc] Fix bitcode writer for access specifiers
Bitcode writer was not emitting the corresponding record for the Access attribute of a FunctionInfo. This has been added. AS_none was being used as the default value for any AcesssSpecifier attribute (in FunctionInfo and MemberTypeInfo), this has been changed to AS_public because this is the enum value that evaluates to 0. The bitcode writer doesn't write values that are 0 so if an attribute was set to AS_public, this value is not written and after reading the bitcode it would have the default value which is AS_none. This is why the default value is now AS_public. Differential Revision: https://reviews.llvm.org/D66151 llvm-svn: 369063
Diffstat (limited to 'clang-tools-extra/clang-doc')
-rw-r--r--clang-tools-extra/clang-doc/BitcodeWriter.cpp1
-rw-r--r--clang-tools-extra/clang-doc/Representation.h14
-rw-r--r--clang-tools-extra/clang-doc/Serialize.cpp3
-rw-r--r--clang-tools-extra/clang-doc/YAMLGenerator.cpp6
4 files changed, 17 insertions, 7 deletions
diff --git a/clang-tools-extra/clang-doc/BitcodeWriter.cpp b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
index 5142f1df6ee..56aa9e56602 100644
--- a/clang-tools-extra/clang-doc/BitcodeWriter.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
@@ -510,6 +510,7 @@ void ClangDocBitcodeWriter::emitBlock(const FunctionInfo &I) {
emitBlock(N, FieldId::F_namespace);
for (const auto &CI : I.Description)
emitBlock(CI);
+ emitRecord(I.Access, FUNCTION_ACCESS);
emitRecord(I.IsMethod, FUNCTION_IS_METHOD);
if (I.DefLoc)
emitRecord(I.DefLoc.getValue(), FUNCTION_DEFLOCATION);
diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h
index 4be3f42fed2..1772b88e5fa 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -198,10 +198,11 @@ struct MemberTypeInfo : public FieldTypeInfo {
std::tie(Other.Type, Other.Name, Other.Access);
}
- AccessSpecifier Access = AccessSpecifier::AS_none; // Access level associated
- // with this info (public,
- // protected, private,
- // none).
+ // Access level associated with this info (public, protected, private, none).
+ // AS_public is set as default because the bitcode writer requires the enum
+ // with value 0 to be used as the default.
+ // (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
+ AccessSpecifier Access = AccessSpecifier::AS_public;
};
struct Location {
@@ -312,7 +313,10 @@ struct FunctionInfo : public SymbolInfo {
TypeInfo ReturnType; // Info about the return type of this function.
llvm::SmallVector<FieldTypeInfo, 4> Params; // List of parameters.
// Access level for this method (public, private, protected, none).
- AccessSpecifier Access = AccessSpecifier::AS_none;
+ // AS_public is set as default because the bitcode writer requires the enum
+ // with value 0 to be used as the default.
+ // (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
+ AccessSpecifier Access = AccessSpecifier::AS_public;
};
// TODO: Expand to allow for documenting templating, inheritance access,
diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp
index cc937b678fb..140f40fe0a8 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -463,12 +463,11 @@ emitInfo(const FunctionDecl *D, const FullComment *FC, int LineNumber,
bool IsInAnonymousNamespace = false;
populateFunctionInfo(Func, D, FC, LineNumber, File, IsFileInRootDir,
IsInAnonymousNamespace);
+ Func.Access = clang::AccessSpecifier::AS_none;
if (PublicOnly && ((IsInAnonymousNamespace ||
!isPublic(D->getAccess(), D->getLinkageInternal()))))
return {};
- Func.Access = clang::AccessSpecifier::AS_none;
-
// Wrap in enclosing scope
auto ParentI = std::make_unique<NamespaceInfo>();
if (!Func.Namespace.empty())
diff --git a/clang-tools-extra/clang-doc/YAMLGenerator.cpp b/clang-tools-extra/clang-doc/YAMLGenerator.cpp
index 2449ee057d0..45649622665 100644
--- a/clang-tools-extra/clang-doc/YAMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/YAMLGenerator.cpp
@@ -174,6 +174,9 @@ template <> struct MappingTraits<FieldTypeInfo> {
template <> struct MappingTraits<MemberTypeInfo> {
static void mapping(IO &IO, MemberTypeInfo &I) {
FieldTypeInfoMapping(IO, I);
+ // clang::AccessSpecifier::AS_none is used as the default here because it's
+ // the AS that shouldn't be part of the output. Even though AS_public is the
+ // default in the struct, it should be displayed in the YAML output.
IO.mapOptional("Access", I.Access, clang::AccessSpecifier::AS_none);
}
};
@@ -218,6 +221,9 @@ template <> struct MappingTraits<FunctionInfo> {
IO.mapOptional("Parent", I.Parent, Reference());
IO.mapOptional("Params", I.Params);
IO.mapOptional("ReturnType", I.ReturnType);
+ // clang::AccessSpecifier::AS_none is used as the default here because it's
+ // the AS that shouldn't be part of the output. Even though AS_public is the
+ // default in the struct, it should be displayed in the YAML output.
IO.mapOptional("Access", I.Access, clang::AccessSpecifier::AS_none);
}
};
OpenPOWER on IntegriCloud