[clang] de9d7e4 - [analyzer][NFC] CallDescription should own the qualified name parts
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 19 09:32:56 PST 2021
Author: Balazs Benics
Date: 2021-11-19T18:32:13+01:00
New Revision: de9d7e42aca29920e9918ecaed4ad9c45fa673f1
URL: https://github.com/llvm/llvm-project/commit/de9d7e42aca29920e9918ecaed4ad9c45fa673f1
DIFF: https://github.com/llvm/llvm-project/commit/de9d7e42aca29920e9918ecaed4ad9c45fa673f1.diff
LOG: [analyzer][NFC] CallDescription should own the qualified name parts
Previously, CallDescription simply referred to the qualified name parts
by `const char*` pointers.
In the future we might want to dynamically load and populate
`CallDescriptionMaps`, hence we will need the `CallDescriptions` to
actually **own** their qualified name parts.
Reviewed By: martong, xazax.hun
Differential Revision: https://reviews.llvm.org/D113593
Added:
Modified:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
clang/lib/StaticAnalyzer/Core/CallDescription.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
index a35a5fb912eb..abc2b93e32fe 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
@@ -43,7 +43,7 @@ class CallDescription {
mutable Optional<const IdentifierInfo *> II;
// The list of the qualified names used to identify the specified CallEvent,
// e.g. "{a, b}" represent the qualified names, like "a::b".
- std::vector<const char *> QualifiedName;
+ std::vector<std::string> QualifiedName;
Optional<unsigned> RequiredArgs;
Optional<size_t> RequiredParams;
int Flags;
diff --git a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp
index 3ab54de96f3f..af541bdcfd59 100644
--- a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp
@@ -17,6 +17,7 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
+#include <iterator>
using namespace llvm;
using namespace clang;
@@ -35,10 +36,12 @@ ento::CallDescription::CallDescription(
int Flags, ArrayRef<const char *> QualifiedName,
Optional<unsigned> RequiredArgs /*= None*/,
Optional<size_t> RequiredParams /*= None*/)
- : QualifiedName(QualifiedName), RequiredArgs(RequiredArgs),
+ : RequiredArgs(RequiredArgs),
RequiredParams(readRequiredParams(RequiredArgs, RequiredParams)),
Flags(Flags) {
assert(!QualifiedName.empty());
+ this->QualifiedName.reserve(QualifiedName.size());
+ llvm::copy(QualifiedName, std::back_inserter(this->QualifiedName));
}
/// Construct a CallDescription with default flags.
More information about the cfe-commits
mailing list