diff options
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/StreamChecker.cpp')
| -rw-r--r-- | lib/StaticAnalyzer/Checkers/StreamChecker.cpp | 22 | 
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index 92647f0327305..1ea5e07695133 100644 --- a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -1,9 +1,8 @@  //===-- StreamChecker.cpp -----------------------------------------*- C++ -*--//  // -//                     The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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  //  //===----------------------------------------------------------------------===//  // @@ -15,6 +14,7 @@  #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"  #include "clang/StaticAnalyzer/Core/Checker.h"  #include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"  #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"  #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"  #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" @@ -72,7 +72,7 @@ public:        II_fsetpos(nullptr), II_clearerr(nullptr), II_feof(nullptr),        II_ferror(nullptr), II_fileno(nullptr) {} -  bool evalCall(const CallExpr *CE, CheckerContext &C) const; +  bool evalCall(const CallEvent &Call, CheckerContext &C) const;    void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;  private: @@ -104,11 +104,15 @@ private:  REGISTER_MAP_WITH_PROGRAMSTATE(StreamMap, SymbolRef, StreamState) -bool StreamChecker::evalCall(const CallExpr *CE, CheckerContext &C) const { -  const FunctionDecl *FD = C.getCalleeDecl(CE); +bool StreamChecker::evalCall(const CallEvent &Call, CheckerContext &C) const { +  const auto *FD = dyn_cast_or_null<FunctionDecl>(Call.getDecl());    if (!FD || FD->getKind() != Decl::Function)      return false; +  const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); +  if (!CE) +    return false; +    ASTContext &Ctx = C.getASTContext();    if (!II_fopen)      II_fopen = &Ctx.Idents.get("fopen"); @@ -409,3 +413,7 @@ void StreamChecker::checkDeadSymbols(SymbolReaper &SymReaper,  void ento::registerStreamChecker(CheckerManager &mgr) {    mgr.registerChecker<StreamChecker>();  } + +bool ento::shouldRegisterStreamChecker(const LangOptions &LO) { +  return true; +}  | 
