-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[NFC] [analyzer] Factor out SymbolManager::get<*> #121781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
08b838a
5213d1b
cd94ced
605ee80
883a6e3
dd41465
71d05bb
8dc8cfd
207ff9b
8246491
3ed3a34
83b9302
3a6b5d8
fb5b3ad
ecb06cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,10 +113,10 @@ class SymbolConjured : public SymbolData { | |
|
|
||
| void dumpToStream(raw_ostream &os) const override; | ||
|
|
||
| static void Profile(llvm::FoldingSetNodeID& profile, const Stmt *S, | ||
| QualType T, unsigned Count, const LocationContext *LCtx, | ||
| static void Profile(llvm::FoldingSetNodeID &profile, const Stmt *S, | ||
| const LocationContext *LCtx, QualType T, unsigned Count, | ||
| const void *SymbolTag) { | ||
| profile.AddInteger((unsigned) SymbolConjuredKind); | ||
| profile.AddInteger((unsigned)SymbolConjuredKind); | ||
| profile.AddPointer(S); | ||
| profile.AddPointer(LCtx); | ||
| profile.Add(T); | ||
|
|
@@ -125,7 +125,7 @@ class SymbolConjured : public SymbolData { | |
| } | ||
|
|
||
| void Profile(llvm::FoldingSetNodeID& profile) override { | ||
| Profile(profile, S, T, Count, LCtx, SymbolTag); | ||
| Profile(profile, S, LCtx, T, Count, SymbolTag); | ||
| } | ||
|
|
||
| // Implement isa<T> support. | ||
|
|
@@ -224,6 +224,8 @@ class SymbolMetadata : public SymbolData { | |
| const Stmt *S; | ||
| QualType T; | ||
| const LocationContext *LCtx; | ||
| /// Count can be used to differentiate regions corresponding to | ||
| /// different loop iterations, thus, making the symbol path-dependent. | ||
| unsigned Count; | ||
| const void *Tag; | ||
|
|
||
|
|
@@ -525,14 +527,14 @@ class SymbolManager { | |
|
|
||
| static bool canSymbolicate(QualType T); | ||
|
|
||
| /// Make a unique symbol for MemRegion R according to its kind. | ||
| const SymbolRegionValue* getRegionValueSymbol(const TypedValueRegion* R); | ||
| template <typename T, typename... Args> const T *get(Args &&...args); | ||
|
||
|
|
||
| const SymbolConjured* conjureSymbol(const Stmt *E, | ||
| const LocationContext *LCtx, | ||
| QualType T, | ||
| const SymbolConjured *conjureSymbol(const Stmt *E, | ||
| const LocationContext *LCtx, QualType T, | ||
| unsigned VisitCount, | ||
| const void *SymbolTag = nullptr); | ||
| const void *SymbolTag = nullptr) { | ||
| return get<SymbolConjured>(E, LCtx, T, VisitCount, SymbolTag); | ||
| } | ||
|
|
||
| const SymbolConjured* conjureSymbol(const Expr *E, | ||
| const LocationContext *LCtx, | ||
|
|
@@ -541,41 +543,6 @@ class SymbolManager { | |
| return conjureSymbol(E, LCtx, E->getType(), VisitCount, SymbolTag); | ||
| } | ||
|
|
||
| const SymbolDerived *getDerivedSymbol(SymbolRef parentSymbol, | ||
| const TypedValueRegion *R); | ||
|
|
||
| const SymbolExtent *getExtentSymbol(const SubRegion *R); | ||
|
|
||
| /// Creates a metadata symbol associated with a specific region. | ||
| /// | ||
| /// VisitCount can be used to differentiate regions corresponding to | ||
| /// different loop iterations, thus, making the symbol path-dependent. | ||
| const SymbolMetadata *getMetadataSymbol(const MemRegion *R, const Stmt *S, | ||
| QualType T, | ||
| const LocationContext *LCtx, | ||
| unsigned VisitCount, | ||
| const void *SymbolTag = nullptr); | ||
|
|
||
| const SymbolCast* getCastSymbol(const SymExpr *Operand, | ||
| QualType From, QualType To); | ||
|
|
||
| const SymIntExpr *getSymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op, | ||
| APSIntPtr rhs, QualType t); | ||
|
|
||
| const SymIntExpr *getSymIntExpr(const SymExpr &lhs, BinaryOperator::Opcode op, | ||
| APSIntPtr rhs, QualType t) { | ||
| return getSymIntExpr(&lhs, op, rhs, t); | ||
| } | ||
|
|
||
| const IntSymExpr *getIntSymExpr(APSIntPtr lhs, BinaryOperator::Opcode op, | ||
| const SymExpr *rhs, QualType t); | ||
|
|
||
| const SymSymExpr *getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, | ||
| const SymExpr *rhs, QualType t); | ||
|
|
||
| const UnarySymExpr *getUnarySymExpr(const SymExpr *operand, | ||
| UnaryOperator::Opcode op, QualType t); | ||
|
|
||
| QualType getType(const SymExpr *SE) const { | ||
| return SE->getType(); | ||
| } | ||
|
|
@@ -707,6 +674,19 @@ class SymbolVisitor { | |
| virtual bool VisitMemRegion(const MemRegion *) { return true; } | ||
| }; | ||
|
|
||
| template <typename T, typename... Args> | ||
| const T *SymbolManager::get(Args &&...args) { | ||
| llvm::FoldingSetNodeID profile; | ||
| T::Profile(profile, std::forward<Args>(args)...); | ||
steakhal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| void *InsertPos; | ||
| SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos); | ||
| if (!SD) { | ||
| SD = Alloc.make<T>(std::forward<Args>(args)...); | ||
| DataSet.InsertNode(SD, InsertPos); | ||
| } | ||
| return cast<T>(SD); | ||
| } | ||
|
|
||
| } // namespace ento | ||
|
|
||
| } // namespace clang | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.