Skip to content

Commit edb7885

Browse files
committed
[analyzer][NFC] Address inlines of D65484
llvm-svn: 368745
1 parent a8c624a commit edb7885

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

clang/lib/StaticAnalyzer/Core/BugReporter.cpp

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ void BugReporterContext::anchor() {}
9090

9191
namespace {
9292

93-
using StackDiagPair =
93+
/// A (CallPiece, node assiciated with its CallEnter) pair.
94+
using CallWithEntry =
9495
std::pair<PathDiagnosticCallPiece *, const ExplodedNode *>;
95-
using StackDiagVector = SmallVector<StackDiagPair, 6>;
96+
using CallWithEntryStack = SmallVector<CallWithEntry, 6>;
9697

9798
/// Map from each node to the diagnostic pieces visitors emit for them.
9899
using VisitorsDiagnosticsTy =
@@ -108,7 +109,7 @@ using LocationContextMap =
108109
/// A helper class that contains everything needed to construct a
109110
/// PathDiagnostic object. It does no much more then providing convenient
110111
/// getters and some well placed asserts for extra security.
111-
class BugReportConstruct {
112+
class PathDiagnosticConstruct {
112113
/// The consumer we're constructing the bug report for.
113114
const PathDiagnosticConsumer *Consumer;
114115
/// Our current position in the bug path, which is owned by
@@ -124,16 +125,16 @@ class BugReportConstruct {
124125
/// We keep stack of calls to functions as we're ascending the bug path.
125126
/// TODO: PathDiagnostic has a stack doing the same thing, shouldn't we use
126127
/// that instead?
127-
StackDiagVector CallStack;
128+
CallWithEntryStack CallStack;
128129
InterestingExprs IE;
129130
/// The bug report we're constructing. For ease of use, this field is kept
130131
/// public, though some "shortcut" getters are provided for commonly used
131132
/// methods of PathDiagnostic.
132133
std::unique_ptr<PathDiagnostic> PD;
133134

134135
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);
137138

138139
/// \returns the location context associated with the current position in the
139140
/// bug path.
@@ -234,29 +235,30 @@ class PathDiagnosticBuilder : public BugReporterContext {
234235
generate(const PathDiagnosticConsumer *PDC) const;
235236

236237
private:
237-
void generatePathDiagnosticsForNode(BugReportConstruct &C,
238+
void generatePathDiagnosticsForNode(PathDiagnosticConstruct &C,
238239
PathDiagnosticLocation &PrevLoc) const;
239240

240-
void generateMinimalDiagForBlockEdge(BugReportConstruct &C,
241+
void generateMinimalDiagForBlockEdge(PathDiagnosticConstruct &C,
241242
BlockEdge BE) const;
242243

243244
PathDiagnosticPieceRef
244-
generateDiagForGotoOP(const BugReportConstruct &C, const Stmt *S,
245+
generateDiagForGotoOP(const PathDiagnosticConstruct &C, const Stmt *S,
245246
PathDiagnosticLocation &Start) const;
246247

247248
PathDiagnosticPieceRef
248-
generateDiagForSwitchOP(const BugReportConstruct &C, const CFGBlock *Dst,
249+
generateDiagForSwitchOP(const PathDiagnosticConstruct &C, const CFGBlock *Dst,
249250
PathDiagnosticLocation &Start) const;
250251

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;
255255

256-
PathDiagnosticLocation ExecutionContinues(const BugReportConstruct &C) const;
256+
PathDiagnosticLocation
257+
ExecutionContinues(const PathDiagnosticConstruct &C) const;
257258

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;
260262

261263
BugReport *getBugReport() const { return R; }
262264
};
@@ -364,8 +366,8 @@ static void removeRedundantMsgs(PathPieces &path) {
364366
/// Recursively scan through a path and prune out calls and macros pieces
365367
/// that aren't needed. Return true if afterwards the path contains
366368
/// "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,
369371
bool IsInteresting = false) {
370372
bool containsSomethingInteresting = IsInteresting;
371373
const unsigned N = pieces.size();
@@ -519,8 +521,8 @@ static void removePiecesWithInvalidLocations(PathPieces &Pieces) {
519521
}
520522
}
521523

522-
PathDiagnosticLocation
523-
PathDiagnosticBuilder::ExecutionContinues(const BugReportConstruct &C) const {
524+
PathDiagnosticLocation PathDiagnosticBuilder::ExecutionContinues(
525+
const PathDiagnosticConstruct &C) const {
524526
if (const Stmt *S = PathDiagnosticLocation::getNextStmt(C.getCurrentNode()))
525527
return PathDiagnosticLocation(S, getSourceManager(),
526528
C.getCurrLocationContext());
@@ -529,9 +531,8 @@ PathDiagnosticBuilder::ExecutionContinues(const BugReportConstruct &C) const {
529531
getSourceManager());
530532
}
531533

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 {
535536
// Slow, but probably doesn't matter.
536537
if (os.str().empty())
537538
os << ' ';
@@ -665,7 +666,7 @@ getEnclosingStmtLocation(const Stmt *S, const LocationContext *LC,
665666
/// void *ptr = my_malloc(); // returned allocated memory
666667
/// } // leak
667668
static void updateStackPiecesWithMessage(PathDiagnosticPiece &P,
668-
const StackDiagVector &CallStack) {
669+
const CallWithEntryStack &CallStack) {
669670
if (auto *ep = dyn_cast<PathDiagnosticEventPiece>(&P)) {
670671
if (ep->hasCallStackHint())
671672
for (const auto &I : CallStack) {
@@ -686,7 +687,7 @@ static void CompactMacroExpandedPieces(PathPieces &path,
686687
const SourceManager& SM);
687688

688689
PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForSwitchOP(
689-
const BugReportConstruct &C, const CFGBlock *Dst,
690+
const PathDiagnosticConstruct &C, const CFGBlock *Dst,
690691
PathDiagnosticLocation &Start) const {
691692

692693
const SourceManager &SM = getSourceManager();
@@ -744,7 +745,7 @@ PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForSwitchOP(
744745
}
745746

746747
PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForGotoOP(
747-
const BugReportConstruct &C, const Stmt *S,
748+
const PathDiagnosticConstruct &C, const Stmt *S,
748749
PathDiagnosticLocation &Start) const {
749750
std::string sbuf;
750751
llvm::raw_string_ostream os(sbuf);
@@ -755,7 +756,7 @@ PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForGotoOP(
755756
}
756757

757758
PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForBinaryOP(
758-
const BugReportConstruct &C, const Stmt *T, const CFGBlock *Src,
759+
const PathDiagnosticConstruct &C, const Stmt *T, const CFGBlock *Src,
759760
const CFGBlock *Dst) const {
760761

761762
const SourceManager &SM = getSourceManager();
@@ -803,7 +804,7 @@ PathDiagnosticPieceRef PathDiagnosticBuilder::generateDiagForBinaryOP(
803804
}
804805

805806
void PathDiagnosticBuilder::generateMinimalDiagForBlockEdge(
806-
BugReportConstruct &C, BlockEdge BE) const {
807+
PathDiagnosticConstruct &C, BlockEdge BE) const {
807808
const SourceManager &SM = getSourceManager();
808809
const LocationContext *LC = C.getCurrLocationContext();
809810
const CFGBlock *Src = BE.getSrc();
@@ -1135,7 +1136,7 @@ static std::unique_ptr<FilesToLineNumsMap>
11351136
findExecutedLines(const SourceManager &SM, const ExplodedNode *N);
11361137

11371138
void PathDiagnosticBuilder::generatePathDiagnosticsForNode(
1138-
BugReportConstruct &C, PathDiagnosticLocation &PrevLoc) const {
1139+
PathDiagnosticConstruct &C, PathDiagnosticLocation &PrevLoc) const {
11391140
ProgramPoint P = C.getCurrentNode()->getLocation();
11401141
const SourceManager &SM = getSourceManager();
11411142

@@ -1235,7 +1236,7 @@ void PathDiagnosticBuilder::generatePathDiagnosticsForNode(
12351236

12361237
// Make the contents of the call the active path for now.
12371238
C.PD->pushActivePath(&P->path);
1238-
C.CallStack.push_back(StackDiagPair(P, C.getCurrentNode()));
1239+
C.CallStack.push_back(CallWithEntry(P, C.getCurrentNode()));
12391240
return;
12401241
}
12411242

@@ -1784,7 +1785,7 @@ static void removeIdenticalEvents(PathPieces &path) {
17841785
}
17851786
}
17861787

1787-
static bool optimizeEdges(const BugReportConstruct &C, PathPieces &path,
1788+
static bool optimizeEdges(const PathDiagnosticConstruct &C, PathPieces &path,
17881789
OptimizedCallsSet &OCS) {
17891790
bool hasChanges = false;
17901791
const LocationContext *LC = C.getLocationContextFor(&path);
@@ -1966,7 +1967,7 @@ static bool optimizeEdges(const BugReportConstruct &C, PathPieces &path,
19661967
/// statement had an invalid source location), this function does nothing.
19671968
// FIXME: We should just generate invalid edges anyway and have the optimizer
19681969
// deal with them.
1969-
static void dropFunctionEntryEdge(const BugReportConstruct &C,
1970+
static void dropFunctionEntryEdge(const PathDiagnosticConstruct &C,
19701971
PathPieces &Path) {
19711972
const auto *FirstEdge =
19721973
dyn_cast<PathDiagnosticControlFlowPiece>(Path.front().get());
@@ -1997,9 +1998,9 @@ static void updateExecutedLinesWithDiagnosticPieces(PathDiagnostic &PD) {
19971998
}
19981999
}
19992000

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)
20032004
: Consumer(PDC), CurrentNode(ErrorNode),
20042005
SM(CurrentNode->getCodeDecl().getASTContext().getSourceManager()),
20052006
PD(generateEmptyDiagnosticForReport(R, getSourceManager())) {
@@ -2020,7 +2021,7 @@ PathDiagnosticBuilder::generate(const PathDiagnosticConsumer *PDC) const {
20202021
if (!PDC->shouldGenerateDiagnostics())
20212022
return generateEmptyDiagnosticForReport(R, getSourceManager());
20222023

2023-
BugReportConstruct Construct(PDC, ErrorNode, R);
2024+
PathDiagnosticConstruct Construct(PDC, ErrorNode, R);
20242025

20252026
const SourceManager &SM = getSourceManager();
20262027
const BugReport *R = getBugReport();

0 commit comments

Comments
 (0)