@@ -90,9 +90,10 @@ void BugReporterContext::anchor() {}
90
90
91
91
namespace {
92
92
93
- using StackDiagPair =
93
+ // / A (CallPiece, node assiciated with its CallEnter) pair.
94
+ using CallWithEntry =
94
95
std::pair<PathDiagnosticCallPiece *, const ExplodedNode *>;
95
- using StackDiagVector = SmallVector<StackDiagPair , 6 >;
96
+ using CallWithEntryStack = SmallVector<CallWithEntry , 6 >;
96
97
97
98
// / Map from each node to the diagnostic pieces visitors emit for them.
98
99
using VisitorsDiagnosticsTy =
@@ -108,7 +109,7 @@ using LocationContextMap =
108
109
// / A helper class that contains everything needed to construct a
109
110
// / PathDiagnostic object. It does no much more then providing convenient
110
111
// / getters and some well placed asserts for extra security.
111
- class BugReportConstruct {
112
+ class PathDiagnosticConstruct {
112
113
// / The consumer we're constructing the bug report for.
113
114
const PathDiagnosticConsumer *Consumer;
114
115
// / Our current position in the bug path, which is owned by
@@ -124,16 +125,16 @@ class BugReportConstruct {
124
125
// / We keep stack of calls to functions as we're ascending the bug path.
125
126
// / TODO: PathDiagnostic has a stack doing the same thing, shouldn't we use
126
127
// / that instead?
127
- StackDiagVector CallStack;
128
+ CallWithEntryStack CallStack;
128
129
InterestingExprs IE;
129
130
// / The bug report we're constructing. For ease of use, this field is kept
130
131
// / public, though some "shortcut" getters are provided for commonly used
131
132
// / methods of PathDiagnostic.
132
133
std::unique_ptr<PathDiagnostic> PD;
133
134
134
135
public:
135
- BugReportConstruct (const PathDiagnosticConsumer *PDC,
136
- const ExplodedNode *ErrorNode, const BugReport *R);
136
+ PathDiagnosticConstruct (const PathDiagnosticConsumer *PDC,
137
+ const ExplodedNode *ErrorNode, const BugReport *R);
137
138
138
139
// / \returns the location context associated with the current position in the
139
140
// / bug path.
@@ -234,29 +235,30 @@ class PathDiagnosticBuilder : public BugReporterContext {
234
235
generate (const PathDiagnosticConsumer *PDC) const ;
235
236
236
237
private:
237
- void generatePathDiagnosticsForNode (BugReportConstruct &C,
238
+ void generatePathDiagnosticsForNode (PathDiagnosticConstruct &C,
238
239
PathDiagnosticLocation &PrevLoc) const ;
239
240
240
- void generateMinimalDiagForBlockEdge (BugReportConstruct &C,
241
+ void generateMinimalDiagForBlockEdge (PathDiagnosticConstruct &C,
241
242
BlockEdge BE) const ;
242
243
243
244
PathDiagnosticPieceRef
244
- generateDiagForGotoOP (const BugReportConstruct &C, const Stmt *S,
245
+ generateDiagForGotoOP (const PathDiagnosticConstruct &C, const Stmt *S,
245
246
PathDiagnosticLocation &Start) const ;
246
247
247
248
PathDiagnosticPieceRef
248
- generateDiagForSwitchOP (const BugReportConstruct &C, const CFGBlock *Dst,
249
+ generateDiagForSwitchOP (const PathDiagnosticConstruct &C, const CFGBlock *Dst,
249
250
PathDiagnosticLocation &Start) const ;
250
251
251
- PathDiagnosticPieceRef generateDiagForBinaryOP (const BugReportConstruct &C,
252
- const Stmt *T,
253
- const CFGBlock *Src,
254
- const CFGBlock *DstC) const ;
252
+ PathDiagnosticPieceRef
253
+ generateDiagForBinaryOP (const PathDiagnosticConstruct &C, const Stmt *T,
254
+ const CFGBlock *Src, const CFGBlock *DstC) const ;
255
255
256
- PathDiagnosticLocation ExecutionContinues (const BugReportConstruct &C) const ;
256
+ PathDiagnosticLocation
257
+ ExecutionContinues (const PathDiagnosticConstruct &C) const ;
257
258
258
- PathDiagnosticLocation ExecutionContinues (llvm::raw_string_ostream &os,
259
- const BugReportConstruct &C) const ;
259
+ PathDiagnosticLocation
260
+ ExecutionContinues (llvm::raw_string_ostream &os,
261
+ const PathDiagnosticConstruct &C) const ;
260
262
261
263
BugReport *getBugReport () const { return R; }
262
264
};
@@ -364,8 +366,8 @@ static void removeRedundantMsgs(PathPieces &path) {
364
366
// / Recursively scan through a path and prune out calls and macros pieces
365
367
// / that aren't needed. Return true if afterwards the path contains
366
368
// / "interesting stuff" which means it shouldn't be pruned from the parent path.
367
- static bool removeUnneededCalls (const BugReportConstruct &C, PathPieces &pieces ,
368
- const BugReport *R,
369
+ static bool removeUnneededCalls (const PathDiagnosticConstruct &C,
370
+ PathPieces &pieces, const BugReport *R,
369
371
bool IsInteresting = false ) {
370
372
bool containsSomethingInteresting = IsInteresting;
371
373
const unsigned N = pieces.size ();
@@ -519,8 +521,8 @@ static void removePiecesWithInvalidLocations(PathPieces &Pieces) {
519
521
}
520
522
}
521
523
522
- PathDiagnosticLocation
523
- PathDiagnosticBuilder::ExecutionContinues ( const BugReportConstruct &C) const {
524
+ PathDiagnosticLocation PathDiagnosticBuilder::ExecutionContinues (
525
+ const PathDiagnosticConstruct &C) const {
524
526
if (const Stmt *S = PathDiagnosticLocation::getNextStmt (C.getCurrentNode ()))
525
527
return PathDiagnosticLocation (S, getSourceManager (),
526
528
C.getCurrLocationContext ());
@@ -529,9 +531,8 @@ PathDiagnosticBuilder::ExecutionContinues(const BugReportConstruct &C) const {
529
531
getSourceManager ());
530
532
}
531
533
532
- PathDiagnosticLocation
533
- PathDiagnosticBuilder::ExecutionContinues (llvm::raw_string_ostream &os,
534
- const BugReportConstruct &C) const {
534
+ PathDiagnosticLocation PathDiagnosticBuilder::ExecutionContinues (
535
+ llvm::raw_string_ostream &os, const PathDiagnosticConstruct &C) const {
535
536
// Slow, but probably doesn't matter.
536
537
if (os.str ().empty ())
537
538
os << ' ' ;
@@ -665,7 +666,7 @@ getEnclosingStmtLocation(const Stmt *S, const LocationContext *LC,
665
666
// / void *ptr = my_malloc(); // returned allocated memory
666
667
// / } // leak
667
668
static void updateStackPiecesWithMessage (PathDiagnosticPiece &P,
668
- const StackDiagVector &CallStack) {
669
+ const CallWithEntryStack &CallStack) {
669
670
if (auto *ep = dyn_cast<PathDiagnosticEventPiece>(&P)) {
670
671
if (ep->hasCallStackHint ())
671
672
for (const auto &I : CallStack) {
@@ -686,7 +687,7 @@ static void CompactMacroExpandedPieces(PathPieces &path,
686
687
const SourceManager& SM);
687
688
688
689
PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForSwitchOP (
689
- const BugReportConstruct &C, const CFGBlock *Dst,
690
+ const PathDiagnosticConstruct &C, const CFGBlock *Dst,
690
691
PathDiagnosticLocation &Start) const {
691
692
692
693
const SourceManager &SM = getSourceManager ();
@@ -744,7 +745,7 @@ PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForSwitchOP(
744
745
}
745
746
746
747
PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForGotoOP (
747
- const BugReportConstruct &C, const Stmt *S,
748
+ const PathDiagnosticConstruct &C, const Stmt *S,
748
749
PathDiagnosticLocation &Start) const {
749
750
std::string sbuf;
750
751
llvm::raw_string_ostream os (sbuf);
@@ -755,7 +756,7 @@ PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForGotoOP(
755
756
}
756
757
757
758
PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForBinaryOP (
758
- const BugReportConstruct &C, const Stmt *T, const CFGBlock *Src,
759
+ const PathDiagnosticConstruct &C, const Stmt *T, const CFGBlock *Src,
759
760
const CFGBlock *Dst) const {
760
761
761
762
const SourceManager &SM = getSourceManager ();
@@ -803,7 +804,7 @@ PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForBinaryOP(
803
804
}
804
805
805
806
void PathDiagnosticBuilder::generateMinimalDiagForBlockEdge (
806
- BugReportConstruct &C, BlockEdge BE) const {
807
+ PathDiagnosticConstruct &C, BlockEdge BE) const {
807
808
const SourceManager &SM = getSourceManager ();
808
809
const LocationContext *LC = C.getCurrLocationContext ();
809
810
const CFGBlock *Src = BE.getSrc ();
@@ -1135,7 +1136,7 @@ static std::unique_ptr<FilesToLineNumsMap>
1135
1136
findExecutedLines (const SourceManager &SM, const ExplodedNode *N);
1136
1137
1137
1138
void PathDiagnosticBuilder::generatePathDiagnosticsForNode (
1138
- BugReportConstruct &C, PathDiagnosticLocation &PrevLoc) const {
1139
+ PathDiagnosticConstruct &C, PathDiagnosticLocation &PrevLoc) const {
1139
1140
ProgramPoint P = C.getCurrentNode ()->getLocation ();
1140
1141
const SourceManager &SM = getSourceManager ();
1141
1142
@@ -1235,7 +1236,7 @@ void PathDiagnosticBuilder::generatePathDiagnosticsForNode(
1235
1236
1236
1237
// Make the contents of the call the active path for now.
1237
1238
C.PD ->pushActivePath (&P->path );
1238
- C.CallStack .push_back (StackDiagPair (P, C.getCurrentNode ()));
1239
+ C.CallStack .push_back (CallWithEntry (P, C.getCurrentNode ()));
1239
1240
return ;
1240
1241
}
1241
1242
@@ -1784,7 +1785,7 @@ static void removeIdenticalEvents(PathPieces &path) {
1784
1785
}
1785
1786
}
1786
1787
1787
- static bool optimizeEdges (const BugReportConstruct &C, PathPieces &path,
1788
+ static bool optimizeEdges (const PathDiagnosticConstruct &C, PathPieces &path,
1788
1789
OptimizedCallsSet &OCS) {
1789
1790
bool hasChanges = false ;
1790
1791
const LocationContext *LC = C.getLocationContextFor (&path);
@@ -1966,7 +1967,7 @@ static bool optimizeEdges(const BugReportConstruct &C, PathPieces &path,
1966
1967
// / statement had an invalid source location), this function does nothing.
1967
1968
// FIXME: We should just generate invalid edges anyway and have the optimizer
1968
1969
// deal with them.
1969
- static void dropFunctionEntryEdge (const BugReportConstruct &C,
1970
+ static void dropFunctionEntryEdge (const PathDiagnosticConstruct &C,
1970
1971
PathPieces &Path) {
1971
1972
const auto *FirstEdge =
1972
1973
dyn_cast<PathDiagnosticControlFlowPiece>(Path.front ().get ());
@@ -1997,9 +1998,9 @@ static void updateExecutedLinesWithDiagnosticPieces(PathDiagnostic &PD) {
1997
1998
}
1998
1999
}
1999
2000
2000
- BugReportConstruct::BugReportConstruct ( const PathDiagnosticConsumer *PDC,
2001
- const ExplodedNode *ErrorNode,
2002
- const BugReport *R)
2001
+ PathDiagnosticConstruct::PathDiagnosticConstruct (
2002
+ const PathDiagnosticConsumer *PDC, const ExplodedNode *ErrorNode,
2003
+ const BugReport *R)
2003
2004
: Consumer(PDC), CurrentNode(ErrorNode),
2004
2005
SM(CurrentNode->getCodeDecl ().getASTContext().getSourceManager()),
2005
2006
PD(generateEmptyDiagnosticForReport(R, getSourceManager())) {
@@ -2020,7 +2021,7 @@ PathDiagnosticBuilder::generate(const PathDiagnosticConsumer *PDC) const {
2020
2021
if (!PDC->shouldGenerateDiagnostics ())
2021
2022
return generateEmptyDiagnosticForReport (R, getSourceManager ());
2022
2023
2023
- BugReportConstruct Construct (PDC, ErrorNode, R);
2024
+ PathDiagnosticConstruct Construct (PDC, ErrorNode, R);
2024
2025
2025
2026
const SourceManager &SM = getSourceManager ();
2026
2027
const BugReport *R = getBugReport ();
0 commit comments