[clang] 35ff3a0 - [analyzer][NFC] Make the API of CallDescription safer slightly
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 17 06:56:21 PST 2021
Author: Balazs Benics
Date: 2021-11-17T15:55:35+01:00
New Revision: 35ff3a0095d5b2dafa2fc8dd762377342aef9c50
URL: https://github.com/llvm/llvm-project/commit/35ff3a0095d5b2dafa2fc8dd762377342aef9c50
DIFF: https://github.com/llvm/llvm-project/commit/35ff3a0095d5b2dafa2fc8dd762377342aef9c50.diff
LOG: [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()`
Added:
Modified:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
Removed:
################################################################################
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
index 9148dcaa87544..bbf58d753b1f6 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
@@ -18,6 +18,7 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/Support/Compiler.h"
#include <vector>
namespace clang {
@@ -67,6 +68,8 @@ class CallDescription {
Optional<unsigned> RequiredArgs = None,
Optional<size_t> RequiredParams = None);
+ CallDescription(std::nullptr_t) = delete;
+
/// Get the name of the function that this object matches.
StringRef getFunctionName() const { return QualifiedName.back(); }
@@ -104,7 +107,7 @@ template <typename T> class CallDescriptionMap {
CallDescriptionMap(const CallDescriptionMap &) = delete;
CallDescriptionMap &operator=(const CallDescription &) = delete;
- const T *lookup(const CallEvent &Call) const {
+ LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
// Slow path: linear lookup.
// TODO: Implement some sort of fast path.
for (const std::pair<CallDescription, T> &I : LinearMap)
More information about the cfe-commits
mailing list