llvm/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp

//===- unittests/StaticAnalyzer/CallDescriptionTest.cpp -------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "CheckerRegistration.h"
#include "Reusables.h"

#include "clang/AST/ExprCXX.h"
#include "clang/Analysis/PathDiagnostic.h"
#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
#include "clang/Tooling/Tooling.h"
#include "gtest/gtest.h"
#include <type_traits>

namespace clang {
namespace ento {
namespace {

// A wrapper around CallDescriptionMap<bool> that allows verifying that
// all functions have been found. This is needed because CallDescriptionMap
// isn't supposed to support iteration.
class ResultMap {};

// Scan the code body for call expressions and see if we find all calls that
// we were supposed to find ("true" in the provided ResultMap) and that we
// don't find the ones that we weren't supposed to find
// ("false" in the ResultMap).
template <typename MatchedExprT>
class CallDescriptionConsumer : public ExprEngineConsumer {};

template <typename MatchedExprT = CallExpr>
class CallDescriptionAction : public ASTFrontendAction {};

TEST(CallDescription, SimpleNameMatching) {}

TEST(CallDescription, RequiredArguments) {}

TEST(CallDescription, LackOfRequiredArguments) {}

constexpr StringRef MockStdStringHeader =;

TEST(CallDescription, QualifiedNames) {}

TEST(CallDescription, MatchConstructor) {}

// FIXME: Test matching destructors: {"std", "basic_string", "~basic_string"}
//        This feature is actually implemented, but the test infra is not yet
//        sophisticated enough for testing this. To do that, we will need to
//        implement a much more advanced dispatching mechanism using the CFG for
//        the implicit destructor events.

TEST(CallDescription, MatchConversionOperator) {}

TEST(CallDescription, RejectOverQualifiedNames) {}

TEST(CallDescription, DontSkipNonInlineNamespaces) {}

TEST(CallDescription, SkipTopInlineNamespaces) {}

TEST(CallDescription, SkipAnonimousNamespaces) {}

TEST(CallDescription, AliasNames) {}

TEST(CallDescription, AliasSingleNamespace) {}

TEST(CallDescription, AliasMultipleNamespaces) {}

TEST(CallDescription, NegativeMatchQualifiedNames) {}

TEST(CallDescription, MatchBuiltins) {}

//===----------------------------------------------------------------------===//
// Testing through a checker interface.
//
// Above, the static analyzer isn't run properly, only the bare minimum to
// create CallEvents. This causes CallEvents through function pointers to not
// refer to the pointee function, but this works fine if we run
// AnalysisASTConsumer.
//===----------------------------------------------------------------------===//

class CallDescChecker
    : public Checker<check::PreCall, check::PreStmt<CallExpr>> {};

void addCallDescChecker(AnalysisASTConsumer &AnalysisConsumer,
                        AnalyzerOptions &AnOpts) {}

TEST(CallDescription, CheckCallExprMatching) {}

} // namespace
} // namespace ento
} // namespace clang