njames93 created this revision. njames93 added reviewers: aaron.ballman, alexfh, gribozavr2. Herald added subscribers: cfe-commits, xazax.hun. Herald added a project: clang.
Fix a potential assert in use-noexcept check if there is an issue getting the `TypeSourceInfo` as well as a small clean up. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D80371 Files: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h =================================================================== --- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h +++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h @@ -41,7 +41,7 @@ private: const std::string NoexceptMacro; - bool UseNoexceptFalse; + const bool UseNoexceptFalse; }; } // namespace modernize Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp @@ -27,22 +27,13 @@ } void UseNoexceptCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher( - functionDecl( - cxxMethodDecl( - hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSpec()))), - anyOf(hasOverloadedOperatorName("delete[]"), - hasOverloadedOperatorName("delete"), cxxDestructorDecl())) - .bind("del-dtor")) - .bind("funcDecl"), - this); - Finder->addMatcher( functionDecl( hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSpec()))), - unless(anyOf(hasOverloadedOperatorName("delete[]"), - hasOverloadedOperatorName("delete"), - cxxDestructorDecl()))) + optionally(cxxMethodDecl(anyOf(hasAnyOverloadedOperatorName( + "delete[]", "delete"), + cxxDestructorDecl())) + .bind("del-dtor"))) .bind("funcDecl"), this); @@ -80,6 +71,10 @@ .castAs<FunctionProtoTypeLoc>() .getExceptionSpecRange(); } + + if (Range.isInvalid()) + return; + CharSourceRange CRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(Range), *Result.SourceManager, Result.Context->getLangOpts());
Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h =================================================================== --- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h +++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h @@ -41,7 +41,7 @@ private: const std::string NoexceptMacro; - bool UseNoexceptFalse; + const bool UseNoexceptFalse; }; } // namespace modernize Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp @@ -27,22 +27,13 @@ } void UseNoexceptCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher( - functionDecl( - cxxMethodDecl( - hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSpec()))), - anyOf(hasOverloadedOperatorName("delete[]"), - hasOverloadedOperatorName("delete"), cxxDestructorDecl())) - .bind("del-dtor")) - .bind("funcDecl"), - this); - Finder->addMatcher( functionDecl( hasTypeLoc(loc(functionProtoType(hasDynamicExceptionSpec()))), - unless(anyOf(hasOverloadedOperatorName("delete[]"), - hasOverloadedOperatorName("delete"), - cxxDestructorDecl()))) + optionally(cxxMethodDecl(anyOf(hasAnyOverloadedOperatorName( + "delete[]", "delete"), + cxxDestructorDecl())) + .bind("del-dtor"))) .bind("funcDecl"), this); @@ -80,6 +71,10 @@ .castAs<FunctionProtoTypeLoc>() .getExceptionSpecRange(); } + + if (Range.isInvalid()) + return; + CharSourceRange CRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(Range), *Result.SourceManager, Result.Context->getLangOpts());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits