aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core')
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h34
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h5
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/IssueHash.h50
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h7
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h16
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h56
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h20
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h17
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h22
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h3
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h18
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h2
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h14
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h3
-rw-r--r--contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h12
15 files changed, 135 insertions, 144 deletions
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index d2df24a6e21b..ccf35e0a81ec 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H
#define LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H
+#include "clang/Analysis/PathDiagnostic.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/Optional.h"
@@ -177,23 +178,23 @@ public:
/// description in a formatted manner. If \p MinLineWidth is set to 0, no line
/// breaks are introduced for the description.
///
- /// Format, depending whether the option name's length is less then
- /// \p OptionWidth:
+ /// Format, depending whether the option name's length is less than
+ /// \p EntryWidth:
///
/// <padding>EntryName<padding>Description
/// <---------padding--------->Description
/// <---------padding--------->Description
///
- /// <padding>VeryVeryLongOptionName
+ /// <padding>VeryVeryLongEntryName
/// <---------padding--------->Description
/// <---------padding--------->Description
- /// ^~~~~~~~ InitialPad
- /// ^~~~~~~~~~~~~~~~~~~~~~~~~~ EntryWidth
+ /// ^~~~~~~~~InitialPad
+ /// ^~~~~~~~~~~~~~~~~~EntryWidth
/// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~MinLineWidth
- static void printFormattedEntry(
- llvm::raw_ostream &Out,
- std::pair<StringRef, StringRef> EntryDescPair,
- size_t EntryWidth, size_t InitialPad, size_t MinLineWidth = 0);
+ static void printFormattedEntry(llvm::raw_ostream &Out,
+ std::pair<StringRef, StringRef> EntryDescPair,
+ size_t InitialPad, size_t EntryWidth,
+ size_t MinLineWidth = 0);
/// Pairs of checker/package name and enable/disable.
std::vector<std::pair<std::string, bool>> CheckersAndPackages;
@@ -255,11 +256,10 @@ public:
unsigned NoRetryExhausted : 1;
/// Emit analyzer warnings as errors.
- unsigned AnalyzerWerror : 1;
+ bool AnalyzerWerror : 1;
/// The inlining stack depth limit.
- // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls).
- unsigned InlineMaxStackDepth = 5;
+ unsigned InlineMaxStackDepth;
/// The mode of function selection used during inlining.
AnalysisInliningMode InliningMode = NoRedundancy;
@@ -390,6 +390,16 @@ public:
///
/// \sa CXXMemberInliningMode
bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const;
+
+ ento::PathDiagnosticConsumerOptions getDiagOpts() const {
+ return {FullCompilerInvocation,
+ ShouldDisplayMacroExpansions,
+ ShouldSerializeStats,
+ ShouldWriteStableReportFilename,
+ AnalyzerWerror,
+ ShouldApplyFixIts,
+ ShouldDisplayCheckerNameForText};
+ }
};
using AnalyzerOptionsRef = IntrusiveRefCntPtr<AnalyzerOptions>;
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 365b1ff1bfe3..58a88f452ed9 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -53,7 +53,7 @@ public:
/// Note that this function does *not* get run on the very last node
/// of the report, as the PathDiagnosticPiece associated with the
/// last node should be unique.
- /// Use {@code getEndPath} to customize the note associated with the report
+ /// Use \ref getEndPath to customize the note associated with the report
/// end instead.
///
/// The last parameter can be used to register a new visitor with the given
@@ -373,7 +373,7 @@ public:
class FalsePositiveRefutationBRVisitor final : public BugReporterVisitor {
private:
/// Holds the constraints in a given path
- ConstraintRangeTy Constraints;
+ ConstraintMap Constraints;
public:
FalsePositiveRefutationBRVisitor();
@@ -390,7 +390,6 @@ public:
bool OverwriteConstraintsOnExistingSyms);
};
-
/// The visitor detects NoteTags and displays the event notes they contain.
class TagVisitor : public BugReporterVisitor {
public:
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/IssueHash.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/IssueHash.h
deleted file mode 100644
index 38d5f847fc29..000000000000
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/IssueHash.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//===---------- IssueHash.h - Generate identification hashes ----*- C++ -*-===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_STATICANALYZER_CORE_ISSUE_HASH_H
-#define LLVM_CLANG_STATICANALYZER_CORE_ISSUE_HASH_H
-
-#include "llvm/ADT/SmallString.h"
-
-namespace clang {
-class Decl;
-class SourceManager;
-class FullSourceLoc;
-class LangOptions;
-
-/// Get an MD5 hash to help identify bugs.
-///
-/// This function returns a hash that helps identify bugs within a source file.
-/// This identification can be utilized to diff diagnostic results on different
-/// snapshots of a projects, or maintain a database of suppressed diagnotics.
-///
-/// The hash contains the normalized text of the location associated with the
-/// diagnostic. Normalization means removing the whitespaces. The associated
-/// location is the either the last location of a diagnostic path or a uniqueing
-/// location. The bugtype and the name of the checker is also part of the hash.
-/// The last component is the string representation of the enclosing declaration
-/// of the associated location.
-///
-/// In case a new hash is introduced, the old one should still be maintained for
-/// a while. One should not introduce a new hash for every change, it is
-/// possible to introduce experimental hashes that may change in the future.
-/// Such hashes should be marked as experimental using a comment in the plist
-/// files.
-llvm::SmallString<32> GetIssueHash(const SourceManager &SM,
- FullSourceLoc &IssueLoc,
- llvm::StringRef CheckerName,
- llvm::StringRef BugType, const Decl *D,
- const LangOptions &LangOpts);
-
-/// Get the string representation of issue hash. See GetIssueHash() for
-/// more information.
-std::string GetIssueString(const SourceManager &SM, FullSourceLoc &IssueLoc,
- llvm::StringRef CheckerName, llvm::StringRef BugType,
- const Decl *D, const LangOptions &LangOpts);
-} // namespace clang
-
-#endif
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
index 8601966c91e5..f40f88eb32ff 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
@@ -13,6 +13,8 @@
#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHDIAGNOSTICCONSUMERS_H
#define LLVM_CLANG_STATICANALYZER_CORE_PATHDIAGNOSTICCONSUMERS_H
+#include "clang/Analysis/PathDiagnostic.h"
+
#include <string>
#include <vector>
@@ -30,8 +32,9 @@ class PathDiagnosticConsumer;
typedef std::vector<PathDiagnosticConsumer*> PathDiagnosticConsumers;
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN) \
- void CREATEFN(AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C, \
- const std::string &Prefix, const Preprocessor &PP, \
+ void CREATEFN(PathDiagnosticConsumerOptions Diagopts, \
+ PathDiagnosticConsumers &C, const std::string &Prefix, \
+ const Preprocessor &PP, \
const cross_tu::CrossTranslationUnitContext &CTU);
#include "clang/StaticAnalyzer/Core/Analyses.def"
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
index a001c0dc7030..142b1ab11750 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -79,11 +79,11 @@ public:
};
class PointerToMemberData : public llvm::FoldingSetNode {
- const DeclaratorDecl *D;
+ const NamedDecl *D;
llvm::ImmutableList<const CXXBaseSpecifier *> L;
public:
- PointerToMemberData(const DeclaratorDecl *D,
+ PointerToMemberData(const NamedDecl *D,
llvm::ImmutableList<const CXXBaseSpecifier *> L)
: D(D), L(L) {}
@@ -92,11 +92,11 @@ public:
iterator begin() const { return L.begin(); }
iterator end() const { return L.end(); }
- static void Profile(llvm::FoldingSetNodeID& ID, const DeclaratorDecl *D,
+ static void Profile(llvm::FoldingSetNodeID &ID, const NamedDecl *D,
llvm::ImmutableList<const CXXBaseSpecifier *> L);
- void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, D, L); }
- const DeclaratorDecl *getDeclaratorDecl() const {return D;}
+ void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, D, L); }
+ const NamedDecl *getDeclaratorDecl() const { return D; }
llvm::ImmutableList<const CXXBaseSpecifier *> getCXXBaseList() const {
return L;
@@ -236,9 +236,9 @@ public:
const LazyCompoundValData *getLazyCompoundValData(const StoreRef &store,
const TypedValueRegion *region);
- const PointerToMemberData *getPointerToMemberData(
- const DeclaratorDecl *DD,
- llvm::ImmutableList<const CXXBaseSpecifier *> L);
+ const PointerToMemberData *
+ getPointerToMemberData(const NamedDecl *ND,
+ llvm::ImmutableList<const CXXBaseSpecifier *> L);
llvm::ImmutableList<SVal> getEmptySValList() {
return SValListFactory.getEmptyList();
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
index a2a98c558a4b..060fff1a7407 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -225,7 +225,7 @@ public:
/// Returns the expression whose value will be the result of this call.
/// May be null.
- const Expr *getOriginExpr() const {
+ virtual const Expr *getOriginExpr() const {
return Origin.dyn_cast<const Expr *>();
}
@@ -530,7 +530,7 @@ protected:
}
public:
- virtual const CallExpr *getOriginExpr() const {
+ const CallExpr *getOriginExpr() const override {
return cast<CallExpr>(AnyFunctionCall::getOriginExpr());
}
@@ -543,9 +543,7 @@ public:
}
Kind getKind() const override { return CE_Function; }
- virtual StringRef getKindAsString() const override {
- return "SimpleFunctionCall";
- }
+ StringRef getKindAsString() const override { return "SimpleFunctionCall"; }
static bool classof(const CallEvent *CA) {
return CA->getKind() == CE_Function;
@@ -570,7 +568,7 @@ protected:
RegionAndSymbolInvalidationTraits *ETraits) const override;
public:
- virtual const CallExpr *getOriginExpr() const {
+ const CallExpr *getOriginExpr() const override {
return cast<CallExpr>(CallEvent::getOriginExpr());
}
@@ -653,7 +651,7 @@ public:
ArrayRef<ParmVarDecl *> parameters() const override;
Kind getKind() const override { return CE_Block; }
- virtual StringRef getKindAsString() const override { return "BlockCall"; }
+ StringRef getKindAsString() const override { return "BlockCall"; }
static bool classof(const CallEvent *CA) { return CA->getKind() == CE_Block; }
};
@@ -708,7 +706,7 @@ protected:
void cloneTo(void *Dest) const override { new (Dest) CXXMemberCall(*this); }
public:
- virtual const CXXMemberCallExpr *getOriginExpr() const {
+ const CXXMemberCallExpr *getOriginExpr() const override {
return cast<CXXMemberCallExpr>(CXXInstanceCall::getOriginExpr());
}
@@ -727,7 +725,7 @@ public:
RuntimeDefinition getRuntimeDefinition() const override;
Kind getKind() const override { return CE_CXXMember; }
- virtual StringRef getKindAsString() const override { return "CXXMemberCall"; }
+ StringRef getKindAsString() const override { return "CXXMemberCall"; }
static bool classof(const CallEvent *CA) {
return CA->getKind() == CE_CXXMember;
@@ -752,7 +750,7 @@ protected:
}
public:
- virtual const CXXOperatorCallExpr *getOriginExpr() const {
+ const CXXOperatorCallExpr *getOriginExpr() const override {
return cast<CXXOperatorCallExpr>(CXXInstanceCall::getOriginExpr());
}
@@ -767,9 +765,7 @@ public:
const Expr *getCXXThisExpr() const override;
Kind getKind() const override { return CE_CXXMemberOperator; }
- virtual StringRef getKindAsString() const override {
- return "CXXMemberOperatorCall";
- }
+ StringRef getKindAsString() const override { return "CXXMemberOperatorCall"; }
static bool classof(const CallEvent *CA) {
return CA->getKind() == CE_CXXMemberOperator;
@@ -838,9 +834,7 @@ public:
}
Kind getKind() const override { return CE_CXXDestructor; }
- virtual StringRef getKindAsString() const override {
- return "CXXDestructorCall";
- }
+ StringRef getKindAsString() const override { return "CXXDestructorCall"; }
static bool classof(const CallEvent *CA) {
return CA->getKind() == CE_CXXDestructor;
@@ -898,7 +892,7 @@ protected:
void cloneTo(void *Dest) const override { new (Dest) CXXConstructorCall(*this); }
public:
- virtual const CXXConstructExpr *getOriginExpr() const {
+ const CXXConstructExpr *getOriginExpr() const override {
return cast<CXXConstructExpr>(AnyFunctionCall::getOriginExpr());
}
@@ -913,9 +907,7 @@ public:
}
Kind getKind() const override { return CE_CXXConstructor; }
- virtual StringRef getKindAsString() const override {
- return "CXXConstructorCall";
- }
+ StringRef getKindAsString() const override { return "CXXConstructorCall"; }
static bool classof(const CallEvent *CA) {
return CA->getKind() == CE_CXXConstructor;
@@ -959,7 +951,7 @@ protected:
}
public:
- virtual const CXXInheritedCtorInitExpr *getOriginExpr() const {
+ const CXXInheritedCtorInitExpr *getOriginExpr() const override {
return cast<CXXInheritedCtorInitExpr>(AnyFunctionCall::getOriginExpr());
}
@@ -986,14 +978,14 @@ public:
return getInheritingConstructor()->getArg(Index);
}
- virtual SVal getArgSVal(unsigned Index) const override {
+ SVal getArgSVal(unsigned Index) const override {
return getState()->getSVal(
getArgExpr(Index),
getInheritingStackFrame()->getParent()->getStackFrame());
}
Kind getKind() const override { return CE_CXXInheritedConstructor; }
- virtual StringRef getKindAsString() const override {
+ StringRef getKindAsString() const override {
return "CXXInheritedConstructorCall";
}
@@ -1017,7 +1009,7 @@ protected:
void cloneTo(void *Dest) const override { new (Dest) CXXAllocatorCall(*this); }
public:
- virtual const CXXNewExpr *getOriginExpr() const {
+ const CXXNewExpr *getOriginExpr() const override {
return cast<CXXNewExpr>(AnyFunctionCall::getOriginExpr());
}
@@ -1058,9 +1050,7 @@ public:
}
Kind getKind() const override { return CE_CXXAllocator; }
- virtual StringRef getKindAsString() const override {
- return "CXXAllocatorCall";
- }
+ StringRef getKindAsString() const override { return "CXXAllocatorCall"; }
static bool classof(const CallEvent *CE) {
return CE->getKind() == CE_CXXAllocator;
@@ -1091,7 +1081,7 @@ protected:
}
public:
- virtual const CXXDeleteExpr *getOriginExpr() const {
+ const CXXDeleteExpr *getOriginExpr() const override {
return cast<CXXDeleteExpr>(AnyFunctionCall::getOriginExpr());
}
@@ -1107,9 +1097,7 @@ public:
}
Kind getKind() const override { return CE_CXXDeallocator; }
- virtual StringRef getKindAsString() const override {
- return "CXXDeallocatorCall";
- }
+ StringRef getKindAsString() const override { return "CXXDeallocatorCall"; }
static bool classof(const CallEvent *CE) {
return CE->getKind() == CE_CXXDeallocator;
@@ -1153,7 +1141,7 @@ protected:
Selector Sel) const;
public:
- virtual const ObjCMessageExpr *getOriginExpr() const {
+ const ObjCMessageExpr *getOriginExpr() const override {
return cast<ObjCMessageExpr>(CallEvent::getOriginExpr());
}
@@ -1230,9 +1218,7 @@ public:
ArrayRef<ParmVarDecl*> parameters() const override;
Kind getKind() const override { return CE_ObjCMessage; }
- virtual StringRef getKindAsString() const override {
- return "ObjCMethodCall";
- }
+ StringRef getKindAsString() const override { return "ObjCMethodCall"; }
static bool classof(const CallEvent *CA) {
return CA->getKind() == CE_ObjCMessage;
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index 8fd7f52585b8..54572bd81f20 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -301,6 +301,26 @@ public:
IsPrunable);
}
+ /// A shorthand version of getNoteTag that accepts a lambda with stream for
+ /// note.
+ ///
+ /// @param Cb Callback with 'BugReport &' and 'llvm::raw_ostream &'.
+ /// @param IsPrunable Whether the note is prunable. It allows BugReporter
+ /// to omit the note from the report if it would make the displayed
+ /// bug path significantly shorter.
+ const NoteTag *getNoteTag(
+ std::function<void(PathSensitiveBugReport &BR, llvm::raw_ostream &OS)> &&Cb,
+ bool IsPrunable = false) {
+ return getNoteTag(
+ [Cb](PathSensitiveBugReport &BR) -> std::string {
+ llvm::SmallString<128> Str;
+ llvm::raw_svector_ostream OS(Str);
+ Cb(BR, OS);
+ return std::string(OS.str());
+ },
+ IsPrunable);
+ }
+
/// Returns the word that should be used to refer to the declaration
/// in the report.
StringRef getDeclDescription(const Decl *D);
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
index cdfe986355c5..582a56cbee1e 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -869,6 +869,23 @@ private:
void handleConstructor(const Expr *E, ExplodedNode *Pred,
ExplodedNodeSet &Dst);
+public:
+ /// Note whether this loop has any more iteratios to model. These methods are
+ /// essentially an interface for a GDM trait. Further reading in
+ /// ExprEngine::VisitObjCForCollectionStmt().
+ LLVM_NODISCARD static ProgramStateRef
+ setWhetherHasMoreIteration(ProgramStateRef State,
+ const ObjCForCollectionStmt *O,
+ const LocationContext *LC, bool HasMoreIteraton);
+
+ LLVM_NODISCARD static ProgramStateRef
+ removeIterationState(ProgramStateRef State, const ObjCForCollectionStmt *O,
+ const LocationContext *LC);
+
+ LLVM_NODISCARD static bool hasMoreIteration(ProgramStateRef State,
+ const ObjCForCollectionStmt *O,
+ const LocationContext *LC);
+private:
/// Store the location of a C++ object corresponding to a statement
/// until the statement is actually encountered. For example, if a DeclStmt
/// has CXXConstructExpr as its initializer, the object would be considered
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
index a42eebd7d4e8..bc5d5f57cd68 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -126,6 +126,8 @@ public:
RangeSet Intersect(BasicValueFactory &BV, Factory &F,
const RangeSet &Other) const;
RangeSet Negate(BasicValueFactory &BV, Factory &F) const;
+ RangeSet Delete(BasicValueFactory &BV, Factory &F,
+ const llvm::APSInt &Point) const;
void print(raw_ostream &os) const;
@@ -134,15 +136,8 @@ public:
}
};
-class ConstraintRange {};
-using ConstraintRangeTy = llvm::ImmutableMap<SymbolRef, RangeSet>;
-
-template <>
-struct ProgramStateTrait<ConstraintRange>
- : public ProgramStatePartialTrait<ConstraintRangeTy> {
- static void *GDMIndex();
-};
-
+using ConstraintMap = llvm::ImmutableMap<SymbolRef, RangeSet>;
+ConstraintMap getConstraintMap(ProgramStateRef State);
class RangedConstraintManager : public SimpleConstraintManager {
public:
@@ -169,8 +164,8 @@ public:
protected:
/// Assume a constraint between a symbolic expression and a concrete integer.
virtual ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym,
- BinaryOperator::Opcode op,
- const llvm::APSInt &Int);
+ BinaryOperator::Opcode op,
+ const llvm::APSInt &Int);
//===------------------------------------------------------------------===//
// Interface that subclasses must implement.
@@ -218,8 +213,9 @@ private:
static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment);
};
-} // end GR namespace
+} // namespace ento
+} // namespace clang
-} // end clang namespace
+REGISTER_FACTORY_WITH_PROGRAMSTATE(ConstraintMap)
#endif
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
index 6a0f5f10874e..07fc73a670f3 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -122,8 +122,7 @@ public:
// this method tries to get the interpretation (the actual value) from
// the solver, which is currently not cached.
- llvm::SMTExprRef Exp =
- SMTConv::fromData(Solver, SD->getSymbolID(), Ty, Ctx.getTypeSize(Ty));
+ llvm::SMTExprRef Exp = SMTConv::fromData(Solver, Ctx, SD);
Solver->reset();
addStateConstraints(State);
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
index bdebe238829e..2d0f169260a4 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
@@ -319,11 +319,16 @@ public:
}
/// Construct an SMTSolverRef from a SymbolData.
- static inline llvm::SMTExprRef fromData(llvm::SMTSolverRef &Solver,
- const SymbolID ID, const QualType &Ty,
- uint64_t BitWidth) {
- llvm::Twine Name = "$" + llvm::Twine(ID);
- return Solver->mkSymbol(Name.str().c_str(), mkSort(Solver, Ty, BitWidth));
+ static inline llvm::SMTExprRef
+ fromData(llvm::SMTSolverRef &Solver, ASTContext &Ctx, const SymbolData *Sym) {
+ const SymbolID ID = Sym->getSymbolID();
+ const QualType Ty = Sym->getType();
+ const uint64_t BitWidth = Ctx.getTypeSize(Ty);
+
+ llvm::SmallString<16> Str;
+ llvm::raw_svector_ostream OS(Str);
+ OS << Sym->getKindStr() << ID;
+ return Solver->mkSymbol(Str.c_str(), mkSort(Solver, Ty, BitWidth));
}
// Wrapper to generate SMTSolverRef from SymbolCast data.
@@ -422,8 +427,7 @@ public:
if (RetTy)
*RetTy = Sym->getType();
- return fromData(Solver, SD->getSymbolID(), Sym->getType(),
- Ctx.getTypeSize(Sym->getType()));
+ return fromData(Solver, Ctx, SD);
}
if (const SymbolCast *SC = dyn_cast<SymbolCast>(Sym)) {
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
index 35ebefdc00d6..4ea85f9730bb 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -233,7 +233,7 @@ public:
const LocationContext *LCtx,
unsigned count);
- DefinedSVal getMemberPointer(const DeclaratorDecl *DD);
+ DefinedSVal getMemberPointer(const NamedDecl *ND);
DefinedSVal getFunctionPointer(const FunctionDecl *func);
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index 1abe29782088..bb295ab591d4 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -80,7 +80,7 @@ public:
#define ABSTRACT_SVAL_WITH_KIND(Id, Parent) Id ## Kind,
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
};
- enum { BaseBits = 2, BaseMask = 0x3 };
+ enum { BaseBits = 2, BaseMask = 0b11 };
protected:
const void *Data = nullptr;
@@ -116,7 +116,7 @@ public:
unsigned getRawKind() const { return Kind; }
BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
- unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+ unsigned getSubKind() const { return Kind >> BaseBits; }
// This method is required for using SVal in a FoldingSetNode. It
// extracts a unique signature for this SVal object.
@@ -182,12 +182,6 @@ public:
/// should continue to the base regions if the region is not symbolic.
SymbolRef getAsSymbol(bool IncludeBaseRegions = false) const;
- /// getAsSymbolicExpression - If this Sval wraps a symbolic expression then
- /// return that expression. Otherwise return NULL.
- const SymExpr *getAsSymbolicExpression() const;
-
- const SymExpr *getAsSymExpr() const;
-
const MemRegion *getAsRegion() const;
/// printJson - Pretty-prints in JSON format.
@@ -526,7 +520,7 @@ class PointerToMember : public NonLoc {
public:
using PTMDataType =
- llvm::PointerUnion<const DeclaratorDecl *, const PointerToMemberData *>;
+ llvm::PointerUnion<const NamedDecl *, const PointerToMemberData *>;
const PTMDataType getPTMData() const {
return PTMDataType::getFromOpaqueValue(const_cast<void *>(Data));
@@ -534,7 +528,7 @@ public:
bool isNullMemberPointer() const;
- const DeclaratorDecl *getDecl() const;
+ const NamedDecl *getDecl() const;
template<typename AdjustedDecl>
const AdjustedDecl *getDeclAs() const {
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
index abfcd1d80faa..2f4ac6ba5f97 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
@@ -126,6 +126,9 @@ protected:
public:
~SymbolData() override = default;
+ /// Get a string representation of the kind of the region.
+ virtual StringRef getKindStr() const = 0;
+
SymbolID getSymbolID() const { return Sym; }
unsigned computeComplexity() const override {
diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
index 390ced8c29f8..c71cb88f5574 100644
--- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -59,6 +59,8 @@ public:
Profile(profile, R);
}
+ StringRef getKindStr() const override;
+
void dumpToStream(raw_ostream &os) const override;
const MemRegion *getOriginRegion() const override { return getRegion(); }
@@ -99,6 +101,8 @@ public:
QualType getType() const override;
+ StringRef getKindStr() const override;
+
void dumpToStream(raw_ostream &os) const override;
static void Profile(llvm::FoldingSetNodeID& profile, const Stmt *S,
@@ -141,6 +145,8 @@ public:
QualType getType() const override;
+ StringRef getKindStr() const override;
+
void dumpToStream(raw_ostream &os) const override;
const MemRegion *getOriginRegion() const override { return getRegion(); }
@@ -177,6 +183,8 @@ public:
QualType getType() const override;
+ StringRef getKindStr() const override;
+
void dumpToStream(raw_ostream &os) const override;
static void Profile(llvm::FoldingSetNodeID& profile, const SubRegion *R) {
@@ -226,6 +234,8 @@ public:
QualType getType() const override;
+ StringRef getKindStr() const override;
+
void dumpToStream(raw_ostream &os) const override;
static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion *R,
@@ -529,7 +539,7 @@ public:
bool isLive(SymbolRef sym);
bool isLiveRegion(const MemRegion *region);
- bool isLive(const Stmt *ExprVal, const LocationContext *LCtx) const;
+ bool isLive(const Expr *ExprVal, const LocationContext *LCtx) const;
bool isLive(const VarRegion *VR, bool includeStoreBindings = false) const;
/// Unconditionally marks a symbol as live.