Skip to content

Commit

Permalink
[analyzer][NFC] CallDescription should own the qualified name parts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Balazs Benics committed Nov 19, 2021
1 parent 9ad0a90 commit de9d7e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/StaticAnalyzer/Core/CallDescription.cpp
Expand Up @@ -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;
Expand All @@ -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.
Expand Down

0 comments on commit de9d7e4

Please sign in to comment.