[PATCH] D51669: [analyzer] [NFC] Prefer passing raw reference to value instead of a reference to unique_ptr
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 6 17:46:04 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC341620: [analyzer] [NFC] Prefer passing around reference to std::unique_ptr& (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D51669?vs=163959&id=164338#toc
Repository:
rC Clang
https://reviews.llvm.org/D51669
Files:
lib/StaticAnalyzer/Core/BugReporter.cpp
Index: lib/StaticAnalyzer/Core/BugReporter.cpp
===================================================================
--- lib/StaticAnalyzer/Core/BugReporter.cpp
+++ lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3010,7 +3010,7 @@
/// into \p ExecutedLines.
static void populateExecutedLinesWithFunctionSignature(
const Decl *Signature, SourceManager &SM,
- std::unique_ptr<FilesToLineNumsMap> &ExecutedLines) {
+ FilesToLineNumsMap &ExecutedLines) {
SourceRange SignatureSourceRange;
const Stmt* Body = Signature->getBody();
if (const auto FD = dyn_cast<FunctionDecl>(Signature)) {
@@ -3030,19 +3030,19 @@
FileID FID = SM.getFileID(SM.getExpansionLoc(Start));
for (unsigned Line = StartLine; Line <= EndLine; Line++)
- ExecutedLines->operator[](FID).insert(Line);
+ ExecutedLines[FID].insert(Line);
}
static void populateExecutedLinesWithStmt(
const Stmt *S, SourceManager &SM,
- std::unique_ptr<FilesToLineNumsMap> &ExecutedLines) {
+ FilesToLineNumsMap &ExecutedLines) {
SourceLocation Loc = S->getSourceRange().getBegin();
if (!Loc.isValid())
return;
SourceLocation ExpansionLoc = SM.getExpansionLoc(Loc);
FileID FID = SM.getFileID(ExpansionLoc);
unsigned LineNo = SM.getExpansionLineNumber(ExpansionLoc);
- ExecutedLines->operator[](FID).insert(LineNo);
+ ExecutedLines[FID].insert(LineNo);
}
/// \return all executed lines including function signatures on the path
@@ -3055,27 +3055,27 @@
if (N->getFirstPred() == nullptr) {
// First node: show signature of the entrance point.
const Decl *D = N->getLocationContext()->getDecl();
- populateExecutedLinesWithFunctionSignature(D, SM, ExecutedLines);
+ populateExecutedLinesWithFunctionSignature(D, SM, *ExecutedLines);
} else if (auto CE = N->getLocationAs<CallEnter>()) {
// Inlined function: show signature.
const Decl* D = CE->getCalleeContext()->getDecl();
- populateExecutedLinesWithFunctionSignature(D, SM, ExecutedLines);
+ populateExecutedLinesWithFunctionSignature(D, SM, *ExecutedLines);
} else if (const Stmt *S = PathDiagnosticLocation::getStmt(N)) {
- populateExecutedLinesWithStmt(S, SM, ExecutedLines);
+ populateExecutedLinesWithStmt(S, SM, *ExecutedLines);
// Show extra context for some parent kinds.
const Stmt *P = N->getParentMap().getParent(S);
// The path exploration can die before the node with the associated
// return statement is generated, but we do want to show the whole
// return.
if (const auto *RS = dyn_cast_or_null<ReturnStmt>(P)) {
- populateExecutedLinesWithStmt(RS, SM, ExecutedLines);
+ populateExecutedLinesWithStmt(RS, SM, *ExecutedLines);
P = N->getParentMap().getParent(RS);
}
if (P && (isa<SwitchCase>(P) || isa<LabelStmt>(P)))
- populateExecutedLinesWithStmt(P, SM, ExecutedLines);
+ populateExecutedLinesWithStmt(P, SM, *ExecutedLines);
}
N = N->getFirstPred();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51669.164338.patch
Type: text/x-patch
Size: 3018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180907/86964264/attachment.bin>
More information about the cfe-commits
mailing list