Skip to content

Commit 35ff3a0

Browse files
author
Balazs Benics
committed
[analyzer][NFC] Make the API of CallDescription safer slightly
The new //deleted// constructor overload makes sure that no implicit conversion from `0` would happen to `ArrayRef<const char*>`. Also adds nodiscard to the `CallDescriptionMap::lookup()`
1 parent 8924ba3 commit 35ff3a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
1919
#include "llvm/ADT/ArrayRef.h"
2020
#include "llvm/ADT/Optional.h"
21+
#include "llvm/Support/Compiler.h"
2122
#include <vector>
2223

2324
namespace clang {
@@ -67,6 +68,8 @@ class CallDescription {
6768
Optional<unsigned> RequiredArgs = None,
6869
Optional<size_t> RequiredParams = None);
6970

71+
CallDescription(std::nullptr_t) = delete;
72+
7073
/// Get the name of the function that this object matches.
7174
StringRef getFunctionName() const { return QualifiedName.back(); }
7275

@@ -104,7 +107,7 @@ template <typename T> class CallDescriptionMap {
104107
CallDescriptionMap(const CallDescriptionMap &) = delete;
105108
CallDescriptionMap &operator=(const CallDescription &) = delete;
106109

107-
const T *lookup(const CallEvent &Call) const {
110+
LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
108111
// Slow path: linear lookup.
109112
// TODO: Implement some sort of fast path.
110113
for (const std::pair<CallDescription, T> &I : LinearMap)

0 commit comments

Comments
 (0)