ChromiumCheckModel.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- ChromiumCheckModel.h ------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines a dataflow model for Chromium's family of CHECK functions.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef CLANG_ANALYSIS_FLOWSENSITIVE_MODELS_CHROMIUMCHECKMODEL_H
  18. #define CLANG_ANALYSIS_FLOWSENSITIVE_MODELS_CHROMIUMCHECKMODEL_H
  19. #include "clang/AST/DeclCXX.h"
  20. #include "clang/AST/Stmt.h"
  21. #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
  22. #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
  23. #include "llvm/ADT/DenseSet.h"
  24. namespace clang {
  25. namespace dataflow {
  26. /// Models the behavior of Chromium's CHECK, DCHECK, etc. macros, so that code
  27. /// after a call to `*CHECK` can rely on the condition being true.
  28. class ChromiumCheckModel : public DataflowModel {
  29. public:
  30. ChromiumCheckModel() = default;
  31. bool transfer(const CFGElement *Element, Environment &Env) override;
  32. private:
  33. /// Declarations for `::logging::CheckError::.*Check`, lazily initialized.
  34. llvm::SmallDenseSet<const CXXMethodDecl *> CheckDecls;
  35. };
  36. } // namespace dataflow
  37. } // namespace clang
  38. #endif // CLANG_ANALYSIS_FLOWSENSITIVE_MODELS_CHROMIUMCHECKMODEL_H
  39. #ifdef __GNUC__
  40. #pragma GCC diagnostic pop
  41. #endif