diff --git a/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp index 8d380ed1b93dec83dc9fbfc2f9b3d8a8c56983a3..0e269201a2ef84b56698afd3ede3f2f219c28141 100644 --- a/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp @@ -20,9 +20,16 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include +#include + +#include "Yaml.h" +#include "llvm/Support/YAMLTraits.h" using namespace clang; using namespace ento; +using llvm::yaml::MappingTraits; +using llvm::yaml::IO; +using llvm::yaml::Input; namespace { typedef SmallVector SymbolVector; @@ -82,8 +89,25 @@ public: PointerEscapeKind Kind) const; }; +struct lhjPattern { + std::string type; + std::vector list; +}; } // end anonymous namespace +namespace llvm { +namespace yaml { + +template <> struct MappingTraits { + static void mapping(IO &io, lhjPattern &info) { + io.mapRequired("type", info.type); + io.mapOptional("value", info.list); + } +}; + +} +} + /// The state of the checker is a map from tracked stream symbols to their /// state. Let's store it in the ProgramState. REGISTER_MAP_WITH_PROGRAMSTATE(StreamMap, SymbolRef, StreamState) @@ -135,6 +159,20 @@ void SimpleStreamChecker::checkPostCall(const CallEvent &Call, void SimpleStreamChecker::checkPreCall(const CallEvent &Call, CheckerContext &C) const { + /*lhj demo*/ + std::vector obj; + CheckerManager *Mgr = C.getAnalysisManager().getCheckerManager(); + std::string Option{"Config"}; + StringRef ConfigFile = + Mgr->getAnalyzerOptions().getCheckerStringOption(this, Option); + llvm::Optional Config = + getConfiguration(*Mgr, this, Option, ConfigFile); + for (lhjPattern &lp : obj) { + std::cout << "type=" << lp.type; + } + + /*lhj demo end*/ + if (!Call.isGlobalCFunction()) return;