njames93 created this revision. njames93 added reviewers: aaron.ballman, alexfh, JonasToth, hokein, gribozavr2. Herald added subscribers: cfe-commits, xazax.hun. Herald added a project: clang.
Fixes noexcept operator misinterpreted as being evaluated <https://bugs.llvm.org/show_bug.cgi?id=44667>. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D73441 Files: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp @@ -1271,3 +1271,14 @@ } }; } + +namespace PR44667 { +#define REQUIRE(expr) (void)(expr); +struct S {}; + +void foo() { + S s; + REQUIRE(noexcept(S{std::move(s)})); + S other{std::move(s)}; +} +} // namespace PR44667 Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp @@ -8,6 +8,7 @@ #include "UseAfterMoveCheck.h" +#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Analysis/CFG.h" #include "clang/Lex/Lexer.h" @@ -382,7 +383,8 @@ hasArgument(0, declRefExpr().bind("arg")), anyOf(hasAncestor(lambdaExpr().bind("containing-lambda")), hasAncestor(functionDecl().bind("containing-func"))), - unless(inDecltypeOrTemplateArg())) + unless(inDecltypeOrTemplateArg()), + unless(hasAncestor(cxxNoexceptExpr()))) .bind("call-move"); Finder->addMatcher(
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp @@ -1271,3 +1271,14 @@ } }; } + +namespace PR44667 { +#define REQUIRE(expr) (void)(expr); +struct S {}; + +void foo() { + S s; + REQUIRE(noexcept(S{std::move(s)})); + S other{std::move(s)}; +} +} // namespace PR44667 Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp @@ -8,6 +8,7 @@ #include "UseAfterMoveCheck.h" +#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Analysis/CFG.h" #include "clang/Lex/Lexer.h" @@ -382,7 +383,8 @@ hasArgument(0, declRefExpr().bind("arg")), anyOf(hasAncestor(lambdaExpr().bind("containing-lambda")), hasAncestor(functionDecl().bind("containing-func"))), - unless(inDecltypeOrTemplateArg())) + unless(inDecltypeOrTemplateArg()), + unless(hasAncestor(cxxNoexceptExpr()))) .bind("call-move"); Finder->addMatcher(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits