github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang-tools-extra/clang-doc/BitcodeReader.cpp clang-tools-extra/clang-doc/BitcodeWriter.cpp clang-tools-extra/clang-doc/Mapper.cpp clang-tools-extra/clang-doc/Mapper.h clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/Serialize.cpp clang-tools-extra/clang-doc/Serialize.h clang-tools-extra/clang-doc/YAMLGenerator.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp index c9f588303..66110cdfb 100644 --- a/clang-tools-extra/clang-doc/BitcodeReader.cpp +++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -85,7 +85,7 @@ llvm::Error decodeRecord(const Record &R, std::optional<Location> &Field, if (R[0] > INT_MAX) return llvm::createStringError(llvm::inconvertibleErrorCode(), "integer too large to parse"); - Field.emplace((int)R[0], (int) R[1], Blob, (bool)R[2]); + Field.emplace((int)R[0], (int)R[1], Blob, (bool)R[2]); return llvm::Error::success(); } diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index 4dadff41e..c210338f7 100644 --- a/clang-tools-extra/clang-doc/Mapper.cpp +++ b/clang-tools-extra/clang-doc/Mapper.cpp @@ -33,13 +33,10 @@ Location MapASTVisitor::getDeclLocation(const NamedDecl *D) const { llvm::SmallString<128> File = getFile(D, D->getASTContext(), CDCtx.SourceRoot, IsFileInRootDir); ASTContext &Context = D->getASTContext(); - int Start = Context.getSourceManager() - .getPresumedLoc(D->getBeginLoc()) - .getLine(); - int End = Context.getSourceManager() - .getPresumedLoc(D->getEndLoc()) - .getLine(); - + int Start = + Context.getSourceManager().getPresumedLoc(D->getBeginLoc()).getLine(); + int End = Context.getSourceManager().getPresumedLoc(D->getEndLoc()).getLine(); + return Location(Start, End, File, IsFileInRootDir); } diff --git a/clang-tools-extra/clang-doc/Mapper.h b/clang-tools-extra/clang-doc/Mapper.h index 3c3ebdb68..36322ea2b 100644 --- a/clang-tools-extra/clang-doc/Mapper.h +++ b/clang-tools-extra/clang-doc/Mapper.h @@ -46,9 +46,9 @@ private: template <typename T> bool mapDecl(const T *D, bool IsDefinition); int getLine(const NamedDecl *D, const ASTContext &Context) const; - + Location getDeclLocation(const NamedDecl *D) const; - + llvm::SmallString<128> getFile(const NamedDecl *D, const ASTContext &Context, StringRef RootDir, bool &IsFileInRootDir) const; diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h index 53a62edf3..eebf0c799 100644 --- a/clang-tools-extra/clang-doc/Representation.h +++ b/clang-tools-extra/clang-doc/Representation.h @@ -238,9 +238,8 @@ struct MemberTypeInfo : public FieldTypeInfo { }; struct Location { - Location(int StartLineNumber = 0, - int EndLineNumber = 0, StringRef Filename = StringRef(), - bool IsFileInRootDir = false) + Location(int StartLineNumber = 0, int EndLineNumber = 0, + StringRef Filename = StringRef(), bool IsFileInRootDir = false) : StartLineNumber(StartLineNumber), EndLineNumber(EndLineNumber), Filename(Filename), IsFileInRootDir(IsFileInRootDir) {} @@ -263,7 +262,7 @@ struct Location { std::tie(Other.StartLineNumber, Other.Filename); } - int StartLineNumber = 0; // Line number of this Location. + int StartLineNumber = 0; // Line number of this Location. int EndLineNumber = 0; SmallString<32> Filename; // File for this Location. bool IsFileInRootDir = false; // Indicates if file is inside root directory diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp index aa3dff1d2..a00e3093c 100644 --- a/clang-tools-extra/clang-doc/Serialize.cpp +++ b/clang-tools-extra/clang-doc/Serialize.cpp @@ -527,8 +527,7 @@ 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, - Location Loc, - bool &IsInAnonymousNamespace) { + Location Loc, bool &IsInAnonymousNamespace) { populateInfo(I, D, C, IsInAnonymousNamespace); if (D->isThisDeclarationADefinition()) I.DefLoc = Loc; @@ -537,8 +536,7 @@ static void populateSymbolInfo(SymbolInfo &I, const T *D, const FullComment *C, } static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D, - const FullComment *FC, - Location Loc, + const FullComment *FC, Location Loc, bool &IsInAnonymousNamespace) { populateSymbolInfo(I, D, FC, Loc, IsInAnonymousNamespace); auto &LO = D->getLangOpts(); @@ -639,7 +637,7 @@ parseBases(RecordInfo &I, const CXXRecordDecl *D, bool IsFileInRootDir, } std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc, +emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc, bool PublicOnly) { auto I = std::make_unique<NamespaceInfo>(); bool IsInAnonymousNamespace = false; @@ -660,8 +658,8 @@ emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc, } std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const RecordDecl *D, const FullComment *FC, - Location Loc, bool PublicOnly) { +emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc, + bool PublicOnly) { auto I = std::make_unique<RecordInfo>(); bool IsInAnonymousNamespace = false; populateSymbolInfo(*I, D, FC, Loc, IsInAnonymousNamespace); @@ -726,28 +724,28 @@ emitInfo(const RecordDecl *D, const FullComment *FC, } std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const FunctionDecl *D, const FullComment *FC, - Location Loc, bool PublicOnly) { +emitInfo(const FunctionDecl *D, const FullComment *FC, Location Loc, + bool PublicOnly) { FunctionInfo Func; bool IsInAnonymousNamespace = false; populateFunctionInfo(Func, D, FC, Loc, IsInAnonymousNamespace); Func.Access = clang::AccessSpecifier::AS_none; if (!shouldSerializeInfo(PublicOnly, IsInAnonymousNamespace, D)) return {}; - + // Info is wrapped in its parent scope so is returned in the second position. return {nullptr, MakeAndInsertIntoParent<FunctionInfo &&>(std::move(Func))}; } std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const CXXMethodDecl *D, const FullComment *FC, - Location Loc, bool PublicOnly) { +emitInfo(const CXXMethodDecl *D, const FullComment *FC, Location Loc, + bool PublicOnly) { FunctionInfo Func; bool IsInAnonymousNamespace = false; populateFunctionInfo(Func, D, FC, Loc, IsInAnonymousNamespace); if (!shouldSerializeInfo(PublicOnly, IsInAnonymousNamespace, D)) return {}; - + Func.IsMethod = true; const NamedDecl *Parent = nullptr; @@ -768,21 +766,21 @@ emitInfo(const CXXMethodDecl *D, const FullComment *FC, } std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const TypedefDecl *D, const FullComment *FC, Location Loc, +emitInfo(const TypedefDecl *D, const FullComment *FC, Location Loc, bool PublicOnly) { - + TypedefInfo Info; - ASTContext& Context = D->getASTContext(); + ASTContext &Context = D->getASTContext(); bool IsInAnonymousNamespace = false; populateInfo(Info, D, FC, IsInAnonymousNamespace); - + if (!shouldSerializeInfo(PublicOnly, IsInAnonymousNamespace, D)) return {}; - + Info.DefLoc = Loc; auto &LO = D->getLangOpts(); Info.Underlying = getTypeInfoForType(D->getUnderlyingType(), LO); - + if (Info.Underlying.Type.Name.empty()) { // Typedef for an unnamed type. This is like "typedef struct { } Foo;" // The record serializer explicitly checks for this syntax and constructs @@ -804,8 +802,8 @@ emitInfo(const TypedefDecl *D, const FullComment *FC, Location Loc, // A type alias is a C++ "using" declaration for a type. It gets mapped to a // TypedefInfo with the IsUsing flag set. std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const TypeAliasDecl *D, const FullComment *FC, - Location Loc, bool PublicOnly) { +emitInfo(const TypeAliasDecl *D, const FullComment *FC, Location Loc, + bool PublicOnly) { TypedefInfo Info; bool IsInAnonymousNamespace = false; @@ -823,15 +821,15 @@ emitInfo(const TypeAliasDecl *D, const FullComment *FC, } std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const EnumDecl *D, const FullComment *FC, Location Loc, +emitInfo(const EnumDecl *D, const FullComment *FC, Location Loc, bool PublicOnly) { EnumInfo Enum; bool IsInAnonymousNamespace = false; populateSymbolInfo(Enum, D, FC, Loc, IsInAnonymousNamespace); - + if (!shouldSerializeInfo(PublicOnly, IsInAnonymousNamespace, D)) return {}; - + Enum.Scoped = D->isScoped(); if (D->isFixed()) { auto Name = D->getIntegerType().getAsString(); diff --git a/clang-tools-extra/clang-doc/Serialize.h b/clang-tools-extra/clang-doc/Serialize.h index 8874299e9..bdf969aa5 100644 --- a/clang-tools-extra/clang-doc/Serialize.h +++ b/clang-tools-extra/clang-doc/Serialize.h @@ -37,31 +37,31 @@ namespace serialize { // its parent scope. For NamespaceDecl and RecordDecl both elements are not // nullptr. std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc, +emitInfo(const NamespaceDecl *D, const FullComment *FC, Location Loc, bool PublicOnly); std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc, +emitInfo(const RecordDecl *D, const FullComment *FC, Location Loc, bool PublicOnly); std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const EnumDecl *D, const FullComment *FC, Location Loc, +emitInfo(const EnumDecl *D, const FullComment *FC, Location Loc, bool PublicOnly); std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const FunctionDecl *D, const FullComment *FC, Location Loc, +emitInfo(const FunctionDecl *D, const FullComment *FC, Location Loc, bool PublicOnly); std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const CXXMethodDecl *D, const FullComment *FC, Location Loc, +emitInfo(const CXXMethodDecl *D, const FullComment *FC, Location Loc, bool PublicOnly); std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const TypedefDecl *D, const FullComment *FC, Location Loc, +emitInfo(const TypedefDecl *D, const FullComment *FC, Location Loc, bool PublicOnly); std::pair<std::unique_ptr<Info>, std::unique_ptr<Info>> -emitInfo(const TypeAliasDecl *D, const FullComment *FC, Location Loc, +emitInfo(const TypeAliasDecl *D, const FullComment *FC, Location Loc, bool PublicOnly); // Function to hash a given USR value for storage. `````````` </details> https://github.com/llvm/llvm-project/pull/135081 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits