#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
#include "clang/AST/TypeLoc.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Tooling/Tooling.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cctype>
namespace clang {
usingnamespaceclang::ast_matchers;
ElementsAre;
ResultOf;
Values;
namespace {
ExprMatcher;
StmtMatcher;
std::unique_ptr<ASTUnit>
buildASTFromCodeWithArgs(const Twine &Code,
const std::vector<std::string> &Args) { … }
std::unique_ptr<ASTUnit> buildASTFromCode(const Twine &Code) { … }
ExprMatcher declRefTo(StringRef Name) { … }
StmtMatcher withEnclosingCompound(ExprMatcher Matcher) { … }
bool isMutated(const SmallVectorImpl<BoundNodes> &Results, ASTUnit *AST) { … }
bool isDeclMutated(const SmallVectorImpl<BoundNodes> &Results, ASTUnit *AST) { … }
SmallVector<std::string, 1>
mutatedBy(const SmallVectorImpl<BoundNodes> &Results, ASTUnit *AST) { … }
std::string removeSpace(std::string s) { … }
const std::string StdRemoveReference = …;
const std::string StdMove = …;
const std::string StdForward = …;
}
TEST(ExprMutationAnalyzerTest, Trivial) { … }
class AssignmentTest : public ::testing::TestWithParam<std::string> { … };
TEST_P(AssignmentTest, AssignmentModifies) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(ExprMutationAnalyzerTest, AssignmentConditionalWithInheritance) { … }
class IncDecTest : public ::testing::TestWithParam<std::string> { … };
TEST_P(IncDecTest, IncDecModifies) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) { … }
TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) { … }
TEST(ExprMutationAnalyzerTest, ConstMemberFunc) { … }
TEST(ExprMutationAnalyzerTest, TypeDependentMemberCall) { … }
TEST(ExprMutationAnalyzerTest, MemberPointerMemberCall) { … }
TEST(ExprMutationAnalyzerTest, NonConstOperator) { … }
TEST(ExprMutationAnalyzerTest, ConstOperator) { … }
TEST(ExprMutationAnalyzerTest, UnresolvedOperator) { … }
TEST(ExprMutationAnalyzerTest, DependentOperatorWithNonDependentOperand) { … }
TEST(ExprMutationAnalyzerTest, FoldExpression) { … }
TEST(ExprMutationAnalyzerTest, ByValueArgument) { … }
TEST(ExprMutationAnalyzerTest, ByConstValueArgument) { … }
TEST(ExprMutationAnalyzerTest, ByNonConstRefArgument) { … }
TEST(ExprMutationAnalyzerTest, ByNonConstRefArgumentFunctionTypeDependent) { … }
TEST(ExprMutationAnalyzerTest, ByConstRefArgument) { … }
TEST(ExprMutationAnalyzerTest, ByNonConstRRefArgument) { … }
TEST(ExprMutationAnalyzerTest, ByConstRRefArgument) { … }
TEST(ExprMutationAnalyzerTest, BindingModifies) { … }
TEST(ExprMutationAnalyzerTest, BindingDoesNotModify) { … }
TEST(ExprMutationAnalyzerTest, Move) { … }
TEST(ExprMutationAnalyzerTest, Forward) { … }
TEST(ExprMutationAnalyzerTest, CallUnresolved) { … }
TEST(ExprMutationAnalyzerTest, ReturnAsValue) { … }
TEST(ExprMutationAnalyzerTest, ReturnAsNonConstRef) { … }
TEST(ExprMutationAnalyzerTest, ReturnAsConstRef) { … }
TEST(ExprMutationAnalyzerTest, ReturnAsNonConstRRef) { … }
TEST(ExprMutationAnalyzerTest, ReturnAsConstRRef) { … }
TEST(ExprMutationAnalyzerTest, TakeAddress) { … }
TEST(ExprMutationAnalyzerTest, ArrayToPointerDecay) { … }
TEST(ExprMutationAnalyzerTest, TemplateWithArrayToPointerDecay) { … }
TEST(ExprMutationAnalyzerTest, FollowRefModified) { … }
TEST(ExprMutationAnalyzerTest, FollowRefNotModified) { … }
TEST(ExprMutationAnalyzerTest, FollowConditionalRefModified) { … }
TEST(ExprMutationAnalyzerTest, FollowConditionalRefNotModified) { … }
TEST(ExprMutationAnalyzerTest, FollowFuncArgModified) { … }
TEST(ExprMutationAnalyzerTest, FollowFuncArgNotModified) { … }
TEST(ExprMutationAnalyzerTest, ArrayElementModified) { … }
TEST(ExprMutationAnalyzerTest, ArrayElementNotModified) { … }
TEST(ExprMutationAnalyzerTest, NestedMemberModified) { … }
TEST(ExprMutationAnalyzerTest, NestedMemberNotModified) { … }
TEST(ExprMutationAnalyzerTest, CastToValue) { … }
TEST(ExprMutationAnalyzerTest, CastToRefModified) { … }
TEST(ExprMutationAnalyzerTest, CastToRefNotModified) { … }
TEST(ExprMutationAnalyzerTest, CastToConstRef) { … }
TEST(ExprMutationAnalyzerTest, CommaExprWithAnAssignment) { … }
TEST(ExprMutationAnalyzerTest, CommaExprWithDecOp) { … }
TEST(ExprMutationAnalyzerTest, CommaExprWithNonConstMemberCall) { … }
TEST(ExprMutationAnalyzerTest, CommaExprWithConstMemberCall) { … }
TEST(ExprMutationAnalyzerTest, CommaExprWithCallExpr) { … }
TEST(ExprMutationAnalyzerTest, CommaExprWithCallUnresolved) { … }
TEST(ExprMutationAnalyzerTest, CommaExprParmRef) { … }
TEST(ExprMutationAnalyzerTest, CommaExprWithAmpersandOp) { … }
TEST(ExprMutationAnalyzerTest, CommaExprAsReturnAsValue) { … }
TEST(ExprMutationAnalyzerTest, CommaExprAsReturnAsNonConstRef) { … }
TEST(ExprMutationAnalyzerTest, CommaExprAsArrayToPointerDecay) { … }
TEST(ExprMutationAnalyzerTest, CommaExprAsUniquePtr) { … }
TEST(ExprMutationAnalyzerTest, CommaNestedConditional) { … }
TEST(ExprMutationAnalyzerTest, LambdaDefaultCaptureByValue) { … }
TEST(ExprMutationAnalyzerTest, LambdaExplicitCaptureByValue) { … }
TEST(ExprMutationAnalyzerTest, LambdaDefaultCaptureByRef) { … }
TEST(ExprMutationAnalyzerTest, LambdaExplicitCaptureByRef) { … }
TEST(ExprMutationAnalyzerTest, RangeForArrayByRefModified) { … }
TEST(ExprMutationAnalyzerTest, RangeForArrayByRefModifiedByImplicitInit) { … }
TEST(ExprMutationAnalyzerTest, RangeForArrayByValue) { … }
TEST(ExprMutationAnalyzerTest, RangeForArrayByConstRef) { … }
TEST(ExprMutationAnalyzerTest, RangeForNonArrayByRefModified) { … }
TEST(ExprMutationAnalyzerTest, RangeForNonArrayByRefNotModified) { … }
TEST(ExprMutationAnalyzerTest, RangeForNonArrayByValue) { … }
TEST(ExprMutationAnalyzerTest, RangeForNonArrayByConstRef) { … }
TEST(ExprMutationAnalyzerTest, UnevaluatedExpressions) { … }
TEST(ExprMutationAnalyzerTest, NotUnevaluatedExpressions) { … }
TEST(ExprMutationAnalyzerTest, UniquePtr) { … }
TEST(ExprMutationAnalyzerTest, SelfRef) { … }
TEST(ExprMutationAnalyzerTest, UnevaluatedContext) { … }
TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) { … }
}