Author: Simon Pilgrim Date: 2021-08-20T12:32:29+01:00 New Revision: 5b72fb866c16d63a3403848f0a4f04f522da8ba3
URL: https://github.com/llvm/llvm-project/commit/5b72fb866c16d63a3403848f0a4f04f522da8ba3 DIFF: https://github.com/llvm/llvm-project/commit/5b72fb866c16d63a3403848f0a4f04f522da8ba3.diff LOG: [AST] getDeclLocForCommentSearch - remove dead return. NFC. Don't use an else-block as the previous if-block always returns, and remove the (now more obvious) dead return {}. Added: Modified: clang/lib/AST/ASTContext.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4c9dc42c5b5dd..cf5be0c3219a6 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -172,29 +172,28 @@ static SourceLocation getDeclLocForCommentSearch(const Decl *D, // Allow association with Y across {} in `typedef struct X {} Y`. isa<TypedefDecl>(D)) return D->getBeginLoc(); - else { - const SourceLocation DeclLoc = D->getLocation(); - if (DeclLoc.isMacroID()) { - if (isa<TypedefDecl>(D)) { - // If location of the typedef name is in a macro, it is because being - // declared via a macro. Try using declaration's starting location as - // the "declaration location". - return D->getBeginLoc(); - } else if (const auto *TD = dyn_cast<TagDecl>(D)) { - // If location of the tag decl is inside a macro, but the spelling of - // the tag name comes from a macro argument, it looks like a special - // macro like NS_ENUM is being used to define the tag decl. In that - // case, adjust the source location to the expansion loc so that we can - // attach the comment to the tag decl. - if (SourceMgr.isMacroArgExpansion(DeclLoc) && - TD->isCompleteDefinition()) - return SourceMgr.getExpansionLoc(DeclLoc); - } + + const SourceLocation DeclLoc = D->getLocation(); + if (DeclLoc.isMacroID()) { + if (isa<TypedefDecl>(D)) { + // If location of the typedef name is in a macro, it is because being + // declared via a macro. Try using declaration's starting location as + // the "declaration location". + return D->getBeginLoc(); + } + + if (const auto *TD = dyn_cast<TagDecl>(D)) { + // If location of the tag decl is inside a macro, but the spelling of + // the tag name comes from a macro argument, it looks like a special + // macro like NS_ENUM is being used to define the tag decl. In that + // case, adjust the source location to the expansion loc so that we can + // attach the comment to the tag decl. + if (SourceMgr.isMacroArgExpansion(DeclLoc) && TD->isCompleteDefinition()) + return SourceMgr.getExpansionLoc(DeclLoc); } - return DeclLoc; } - return {}; + return DeclLoc; } RawComment *ASTContext::getRawCommentForDeclNoCacheImpl( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits