Loading clang/include/clang/AST/Comment.h +10 −12 Original line number Diff line number Diff line Loading @@ -675,6 +675,8 @@ public: } }; enum class ParamCommandPassDirection { In, Out, InOut }; /// Doxygen \\param command. class ParamCommandComment : public BlockCommandComment { private: Loading @@ -692,7 +694,8 @@ public: : BlockCommandComment(CommentKind::ParamCommandComment, LocBegin, LocEnd, CommandID, CommandMarker), ParamIndex(InvalidParamIndex) { ParamCommandCommentBits.Direction = In; ParamCommandCommentBits.Direction = llvm::to_underlying(ParamCommandPassDirection::In); ParamCommandCommentBits.IsDirectionExplicit = false; } Loading @@ -700,24 +703,19 @@ public: return C->getCommentKind() == CommentKind::ParamCommandComment; } enum PassDirection { In, Out, InOut }; static const char *getDirectionAsString(PassDirection D); static const char *getDirectionAsString(ParamCommandPassDirection D); PassDirection getDirection() const LLVM_READONLY { return static_cast<PassDirection>(ParamCommandCommentBits.Direction); ParamCommandPassDirection getDirection() const LLVM_READONLY { return static_cast<ParamCommandPassDirection>( ParamCommandCommentBits.Direction); } bool isDirectionExplicit() const LLVM_READONLY { return ParamCommandCommentBits.IsDirectionExplicit; } void setDirection(PassDirection Direction, bool Explicit) { ParamCommandCommentBits.Direction = Direction; void setDirection(ParamCommandPassDirection Direction, bool Explicit) { ParamCommandCommentBits.Direction = llvm::to_underlying(Direction); ParamCommandCommentBits.IsDirectionExplicit = Explicit; } Loading clang/lib/AST/Comment.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -187,13 +187,14 @@ static bool getFunctionTypeLoc(TypeLoc TL, FunctionTypeLoc &ResFTL) { return false; } const char *ParamCommandComment::getDirectionAsString(PassDirection D) { const char * ParamCommandComment::getDirectionAsString(ParamCommandPassDirection D) { switch (D) { case ParamCommandComment::In: case ParamCommandPassDirection::In: return "[in]"; case ParamCommandComment::Out: case ParamCommandPassDirection::Out: return "[out]"; case ParamCommandComment::InOut: case ParamCommandPassDirection::InOut: return "[in,out]"; } llvm_unreachable("unknown PassDirection"); Loading clang/lib/AST/CommentSema.cpp +15 −14 Original line number Diff line number Diff line Loading @@ -219,12 +219,12 @@ void Sema::checkContainerDecl(const BlockCommandComment *Comment) { /// Turn a string into the corresponding PassDirection or -1 if it's not /// valid. static int getParamPassDirection(StringRef Arg) { return llvm::StringSwitch<int>(Arg) .Case("[in]", ParamCommandComment::In) .Case("[out]", ParamCommandComment::Out) .Cases("[in,out]", "[out,in]", ParamCommandComment::InOut) .Default(-1); static ParamCommandPassDirection getParamPassDirection(StringRef Arg) { return llvm::StringSwitch<ParamCommandPassDirection>(Arg) .Case("[in]", ParamCommandPassDirection::In) .Case("[out]", ParamCommandPassDirection::Out) .Cases("[in,out]", "[out,in]", ParamCommandPassDirection::InOut) .Default(static_cast<ParamCommandPassDirection>(-1)); } void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command, Loading @@ -232,25 +232,25 @@ void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command, SourceLocation ArgLocEnd, StringRef Arg) { std::string ArgLower = Arg.lower(); int Direction = getParamPassDirection(ArgLower); ParamCommandPassDirection Direction = getParamPassDirection(ArgLower); if (Direction == -1) { if (Direction == static_cast<ParamCommandPassDirection>(-1)) { // Try again with whitespace removed. llvm::erase_if(ArgLower, clang::isWhitespace); Direction = getParamPassDirection(ArgLower); SourceRange ArgRange(ArgLocBegin, ArgLocEnd); if (Direction != -1) { const char *FixedName = ParamCommandComment::getDirectionAsString( (ParamCommandComment::PassDirection)Direction); if (Direction != static_cast<ParamCommandPassDirection>(-1)) { const char *FixedName = ParamCommandComment::getDirectionAsString(Direction); Diag(ArgLocBegin, diag::warn_doc_param_spaces_in_direction) << ArgRange << FixItHint::CreateReplacement(ArgRange, FixedName); } else { Diag(ArgLocBegin, diag::warn_doc_param_invalid_direction) << ArgRange; Direction = ParamCommandComment::In; // Sane fall back. Direction = ParamCommandPassDirection::In; // Sane fall back. } } Command->setDirection((ParamCommandComment::PassDirection)Direction, Command->setDirection(Direction, /*Explicit=*/true); } Loading @@ -263,7 +263,8 @@ void Sema::actOnParamCommandParamNameArg(ParamCommandComment *Command, if (!Command->isDirectionExplicit()) { // User didn't provide a direction argument. Command->setDirection(ParamCommandComment::In, /* Explicit = */ false); Command->setDirection(ParamCommandPassDirection::In, /* Explicit = */ false); } auto *A = new (Allocator) Comment::Argument{SourceRange(ArgLocBegin, ArgLocEnd), Arg}; Loading clang/lib/AST/JSONNodeDumper.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -1740,13 +1740,13 @@ void JSONNodeDumper::visitBlockCommandComment( void JSONNodeDumper::visitParamCommandComment( const comments::ParamCommandComment *C, const comments::FullComment *FC) { switch (C->getDirection()) { case comments::ParamCommandComment::In: case comments::ParamCommandPassDirection::In: JOS.attribute("direction", "in"); break; case comments::ParamCommandComment::Out: case comments::ParamCommandPassDirection::Out: JOS.attribute("direction", "out"); break; case comments::ParamCommandComment::InOut: case comments::ParamCommandPassDirection::InOut: JOS.attribute("direction", "in,out"); break; } Loading clang/lib/Index/CommentToXML.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -751,13 +751,13 @@ void CommentASTToXMLConverter::visitParamCommandComment( Result << "<Direction isExplicit=\"" << C->isDirectionExplicit() << "\">"; switch (C->getDirection()) { case ParamCommandComment::In: case ParamCommandPassDirection::In: Result << "in"; break; case ParamCommandComment::Out: case ParamCommandPassDirection::Out: Result << "out"; break; case ParamCommandComment::InOut: case ParamCommandPassDirection::InOut: Result << "in,out"; break; } Loading Loading
clang/include/clang/AST/Comment.h +10 −12 Original line number Diff line number Diff line Loading @@ -675,6 +675,8 @@ public: } }; enum class ParamCommandPassDirection { In, Out, InOut }; /// Doxygen \\param command. class ParamCommandComment : public BlockCommandComment { private: Loading @@ -692,7 +694,8 @@ public: : BlockCommandComment(CommentKind::ParamCommandComment, LocBegin, LocEnd, CommandID, CommandMarker), ParamIndex(InvalidParamIndex) { ParamCommandCommentBits.Direction = In; ParamCommandCommentBits.Direction = llvm::to_underlying(ParamCommandPassDirection::In); ParamCommandCommentBits.IsDirectionExplicit = false; } Loading @@ -700,24 +703,19 @@ public: return C->getCommentKind() == CommentKind::ParamCommandComment; } enum PassDirection { In, Out, InOut }; static const char *getDirectionAsString(PassDirection D); static const char *getDirectionAsString(ParamCommandPassDirection D); PassDirection getDirection() const LLVM_READONLY { return static_cast<PassDirection>(ParamCommandCommentBits.Direction); ParamCommandPassDirection getDirection() const LLVM_READONLY { return static_cast<ParamCommandPassDirection>( ParamCommandCommentBits.Direction); } bool isDirectionExplicit() const LLVM_READONLY { return ParamCommandCommentBits.IsDirectionExplicit; } void setDirection(PassDirection Direction, bool Explicit) { ParamCommandCommentBits.Direction = Direction; void setDirection(ParamCommandPassDirection Direction, bool Explicit) { ParamCommandCommentBits.Direction = llvm::to_underlying(Direction); ParamCommandCommentBits.IsDirectionExplicit = Explicit; } Loading
clang/lib/AST/Comment.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -187,13 +187,14 @@ static bool getFunctionTypeLoc(TypeLoc TL, FunctionTypeLoc &ResFTL) { return false; } const char *ParamCommandComment::getDirectionAsString(PassDirection D) { const char * ParamCommandComment::getDirectionAsString(ParamCommandPassDirection D) { switch (D) { case ParamCommandComment::In: case ParamCommandPassDirection::In: return "[in]"; case ParamCommandComment::Out: case ParamCommandPassDirection::Out: return "[out]"; case ParamCommandComment::InOut: case ParamCommandPassDirection::InOut: return "[in,out]"; } llvm_unreachable("unknown PassDirection"); Loading
clang/lib/AST/CommentSema.cpp +15 −14 Original line number Diff line number Diff line Loading @@ -219,12 +219,12 @@ void Sema::checkContainerDecl(const BlockCommandComment *Comment) { /// Turn a string into the corresponding PassDirection or -1 if it's not /// valid. static int getParamPassDirection(StringRef Arg) { return llvm::StringSwitch<int>(Arg) .Case("[in]", ParamCommandComment::In) .Case("[out]", ParamCommandComment::Out) .Cases("[in,out]", "[out,in]", ParamCommandComment::InOut) .Default(-1); static ParamCommandPassDirection getParamPassDirection(StringRef Arg) { return llvm::StringSwitch<ParamCommandPassDirection>(Arg) .Case("[in]", ParamCommandPassDirection::In) .Case("[out]", ParamCommandPassDirection::Out) .Cases("[in,out]", "[out,in]", ParamCommandPassDirection::InOut) .Default(static_cast<ParamCommandPassDirection>(-1)); } void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command, Loading @@ -232,25 +232,25 @@ void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command, SourceLocation ArgLocEnd, StringRef Arg) { std::string ArgLower = Arg.lower(); int Direction = getParamPassDirection(ArgLower); ParamCommandPassDirection Direction = getParamPassDirection(ArgLower); if (Direction == -1) { if (Direction == static_cast<ParamCommandPassDirection>(-1)) { // Try again with whitespace removed. llvm::erase_if(ArgLower, clang::isWhitespace); Direction = getParamPassDirection(ArgLower); SourceRange ArgRange(ArgLocBegin, ArgLocEnd); if (Direction != -1) { const char *FixedName = ParamCommandComment::getDirectionAsString( (ParamCommandComment::PassDirection)Direction); if (Direction != static_cast<ParamCommandPassDirection>(-1)) { const char *FixedName = ParamCommandComment::getDirectionAsString(Direction); Diag(ArgLocBegin, diag::warn_doc_param_spaces_in_direction) << ArgRange << FixItHint::CreateReplacement(ArgRange, FixedName); } else { Diag(ArgLocBegin, diag::warn_doc_param_invalid_direction) << ArgRange; Direction = ParamCommandComment::In; // Sane fall back. Direction = ParamCommandPassDirection::In; // Sane fall back. } } Command->setDirection((ParamCommandComment::PassDirection)Direction, Command->setDirection(Direction, /*Explicit=*/true); } Loading @@ -263,7 +263,8 @@ void Sema::actOnParamCommandParamNameArg(ParamCommandComment *Command, if (!Command->isDirectionExplicit()) { // User didn't provide a direction argument. Command->setDirection(ParamCommandComment::In, /* Explicit = */ false); Command->setDirection(ParamCommandPassDirection::In, /* Explicit = */ false); } auto *A = new (Allocator) Comment::Argument{SourceRange(ArgLocBegin, ArgLocEnd), Arg}; Loading
clang/lib/AST/JSONNodeDumper.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -1740,13 +1740,13 @@ void JSONNodeDumper::visitBlockCommandComment( void JSONNodeDumper::visitParamCommandComment( const comments::ParamCommandComment *C, const comments::FullComment *FC) { switch (C->getDirection()) { case comments::ParamCommandComment::In: case comments::ParamCommandPassDirection::In: JOS.attribute("direction", "in"); break; case comments::ParamCommandComment::Out: case comments::ParamCommandPassDirection::Out: JOS.attribute("direction", "out"); break; case comments::ParamCommandComment::InOut: case comments::ParamCommandPassDirection::InOut: JOS.attribute("direction", "in,out"); break; } Loading
clang/lib/Index/CommentToXML.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -751,13 +751,13 @@ void CommentASTToXMLConverter::visitParamCommandComment( Result << "<Direction isExplicit=\"" << C->isDirectionExplicit() << "\">"; switch (C->getDirection()) { case ParamCommandComment::In: case ParamCommandPassDirection::In: Result << "in"; break; case ParamCommandComment::Out: case ParamCommandPassDirection::Out: Result << "out"; break; case ParamCommandComment::InOut: case ParamCommandPassDirection::InOut: Result << "in,out"; break; } Loading