#include "clang/Tooling/Transformer/SourceCodeBuilders.h"
#include "clang/AST/Type.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Testing/Support/SupportHelpers.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <optional>
usingnamespaceclang;
usingnamespacetooling;
usingnamespaceast_matchers;
namespace {
MatchResult;
ValueIs;
static std::string wrapSnippet(StringRef StatementCode) { … }
static DeclarationMatcher wrapMatcher(const StatementMatcher &Matcher) { … }
struct TestMatch { … };
static std::optional<TestMatch> matchStmt(StringRef StatementCode,
StatementMatcher Matcher) { … }
static void testPredicate(bool (*Pred)(const Expr &), StringRef Snippet,
bool Expected) { … }
static void testPredicateOnArg(bool (*Pred)(const Expr &), StringRef Snippet,
bool Expected) { … }
TEST(SourceCodeBuildersTest, needParensAfterUnaryOperator) { … }
TEST(SourceCodeBuildersTest, needParensAfterUnaryOperatorInImplicitConversion) { … }
TEST(SourceCodeBuildersTest, mayEverNeedParens) { … }
TEST(SourceCodeBuildersTest, mayEverNeedParensInImplictConversion) { … }
TEST(SourceCodeBuildersTest, isKnownPointerLikeTypeUniquePtr) { … }
TEST(SourceCodeBuildersTest, isKnownPointerLikeTypeSharedPtr) { … }
TEST(SourceCodeBuildersTest, isKnownPointerLikeTypeUnknownTypeFalse) { … }
TEST(SourceCodeBuildersTest, isKnownPointerLikeTypeNormalTypeFalse) { … }
static void testBuilder(
std::optional<std::string> (*Builder)(const Expr &, const ASTContext &),
StringRef Snippet, StringRef Expected) { … }
static void testBuildAccess(StringRef Snippet, StringRef Expected,
PLTClass C = PLTClass::Pointer) { … }
TEST(SourceCodeBuildersTest, BuildParensUnaryOp) { … }
TEST(SourceCodeBuildersTest, BuildParensBinOp) { … }
TEST(SourceCodeBuildersTest, BuildParensValue) { … }
TEST(SourceCodeBuildersTest, BuildParensSubscript) { … }
TEST(SourceCodeBuildersTest, BuildParensCall) { … }
TEST(SourceCodeBuildersTest, BuildAddressOfValue) { … }
TEST(SourceCodeBuildersTest, BuildAddressOfPointerDereference) { … }
TEST(SourceCodeBuildersTest, BuildAddressOfPointerDereferenceIgnoresParens) { … }
TEST(SourceCodeBuildersTest, BuildAddressOfBinaryOperation) { … }
TEST(SourceCodeBuildersTest, BuildAddressOfImplicitThis) { … }
TEST(SourceCodeBuildersTest, BuildDereferencePointer) { … }
TEST(SourceCodeBuildersTest, BuildDereferenceValueAddress) { … }
TEST(SourceCodeBuildersTest, BuildDereferenceValueAddressIgnoresParens) { … }
TEST(SourceCodeBuildersTest, BuildDereferenceBinaryOperation) { … }
TEST(SourceCodeBuildersTest, BuildDotValue) { … }
TEST(SourceCodeBuildersTest, BuildDotPointerDereference) { … }
TEST(SourceCodeBuildersTest, BuildDotPointerDereferenceIgnoresParens) { … }
TEST(SourceCodeBuildersTest, BuildDotBinaryOperation) { … }
TEST(SourceCodeBuildersTest, BuildDotPointerDereferenceExprWithParens) { … }
TEST(SourceCodeBuildersTest, BuildArrowPointer) { … }
TEST(SourceCodeBuildersTest, BuildArrowValueAddress) { … }
TEST(SourceCodeBuildersTest, BuildArrowValueAddressIgnoresParens) { … }
TEST(SourceCodeBuildersTest, BuildArrowBinaryOperation) { … }
TEST(SourceCodeBuildersTest, BuildArrowValueAddressWithParens) { … }
TEST(SourceCodeBuildersTest, BuildAccessValue) { … }
TEST(SourceCodeBuildersTest, BuildAccessPointerDereference) { … }
TEST(SourceCodeBuildersTest, BuildAccessPointerDereferenceIgnoresParens) { … }
TEST(SourceCodeBuildersTest, BuildAccessValueBinaryOperation) { … }
TEST(SourceCodeBuildersTest, BuildAccessPointerDereferenceExprWithParens) { … }
TEST(SourceCodeBuildersTest, BuildAccessPointer) { … }
TEST(SourceCodeBuildersTest, BuildAccessValueAddress) { … }
TEST(SourceCodeBuildersTest, BuildAccessValueAddressIgnoresParens) { … }
TEST(SourceCodeBuildersTest, BuildAccessPointerBinaryOperation) { … }
TEST(SourceCodeBuildersTest, BuildAccessValueAddressWithParens) { … }
TEST(SourceCodeBuildersTest, BuildAccessSmartPointer) { … }
TEST(SourceCodeBuildersTest, BuildAccessSmartPointerAsValue) { … }
TEST(SourceCodeBuildersTest, BuildAccessSmartPointerDeref) { … }
TEST(SourceCodeBuildersTest, BuildAccessSmartPointerDerefAsValue) { … }
TEST(SourceCodeBuildersTest, BuildAccessSmartPointerMemberCall) { … }
TEST(SourceCodeBuildersTest, BuildAccessIgnoreImplicit) { … }
TEST(SourceCodeBuildersTest, BuildAccessImplicitThis) { … }
TEST(SourceCodeBuildersTest, BuildAccessImplicitThisIgnoreImplicitCasts) { … }
}