mirror of https://gitee.com/bigwinds/arangodb
Suppress false positives about "potential null pointer dereference" (#8501)
This commit is contained in:
parent
44810a1218
commit
ff06c5244f
|
@ -100,9 +100,30 @@ bool ShortestPathExecutorInfos::usesOutputRegister(OutputName type) const {
|
|||
return _registerMapping.find(type) != _registerMapping.end();
|
||||
}
|
||||
|
||||
static std::string typeToString(ShortestPathExecutorInfos::OutputName type) {
|
||||
switch(type) {
|
||||
case ShortestPathExecutorInfos::VERTEX:
|
||||
return std::string{"VERTEX"};
|
||||
case ShortestPathExecutorInfos::EDGE:
|
||||
return std::string{"EDGE"};
|
||||
default:
|
||||
return std::string{"<INVALID("} + std::to_string(type) + ")>";
|
||||
}
|
||||
}
|
||||
|
||||
RegisterId ShortestPathExecutorInfos::findRegisterChecked(OutputName type) const {
|
||||
auto const& it = _registerMapping.find(type);
|
||||
if (ADB_UNLIKELY(it == _registerMapping.end())) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||
TRI_ERROR_INTERNAL,
|
||||
"Logic error: requested unused register type " + typeToString(type));
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
RegisterId ShortestPathExecutorInfos::getOutputRegister(OutputName type) const {
|
||||
TRI_ASSERT(usesOutputRegister(type));
|
||||
return _registerMapping.find(type)->second;
|
||||
return findRegisterChecked(type);
|
||||
}
|
||||
|
||||
graph::TraverserCache* ShortestPathExecutorInfos::cache() const {
|
||||
|
|
|
@ -122,6 +122,9 @@ class ShortestPathExecutorInfos : public ExecutorInfos {
|
|||
|
||||
graph::TraverserCache* cache() const;
|
||||
|
||||
private:
|
||||
RegisterId findRegisterChecked(OutputName type) const;
|
||||
|
||||
private:
|
||||
/// @brief the shortest path finder.
|
||||
std::unique_ptr<arangodb::graph::ShortestPathFinder> _finder;
|
||||
|
|
|
@ -64,31 +64,60 @@ Traverser& TraversalExecutorInfos::traverser() {
|
|||
return *_traverser.get();
|
||||
}
|
||||
|
||||
bool TraversalExecutorInfos::useVertexOutput() const {
|
||||
return _registerMapping.find(OutputName::VERTEX) != _registerMapping.end();
|
||||
bool TraversalExecutorInfos::usesOutputRegister(OutputName type) const {
|
||||
return _registerMapping.find(type) != _registerMapping.end();
|
||||
}
|
||||
|
||||
RegisterId TraversalExecutorInfos::vertexRegister() const {
|
||||
TRI_ASSERT(useVertexOutput());
|
||||
return _registerMapping.find(OutputName::VERTEX)->second;
|
||||
bool TraversalExecutorInfos::useVertexOutput() const {
|
||||
return usesOutputRegister(OutputName::VERTEX);
|
||||
}
|
||||
|
||||
bool TraversalExecutorInfos::useEdgeOutput() const {
|
||||
return _registerMapping.find(OutputName::EDGE) != _registerMapping.end();
|
||||
}
|
||||
|
||||
RegisterId TraversalExecutorInfos::edgeRegister() const {
|
||||
TRI_ASSERT(useEdgeOutput());
|
||||
return _registerMapping.find(OutputName::EDGE)->second;
|
||||
return usesOutputRegister(OutputName::EDGE);
|
||||
}
|
||||
|
||||
bool TraversalExecutorInfos::usePathOutput() const {
|
||||
return _registerMapping.find(OutputName::PATH) != _registerMapping.end();
|
||||
return usesOutputRegister(OutputName::PATH);
|
||||
}
|
||||
|
||||
static std::string typeToString(TraversalExecutorInfos::OutputName type) {
|
||||
switch(type) {
|
||||
case TraversalExecutorInfos::VERTEX:
|
||||
return std::string{"VERTEX"};
|
||||
case TraversalExecutorInfos::EDGE:
|
||||
return std::string{"EDGE"};
|
||||
case TraversalExecutorInfos::PATH:
|
||||
return std::string{"PATH"};
|
||||
default:
|
||||
return std::string{"<INVALID("} + std::to_string(type) + ")>";
|
||||
}
|
||||
}
|
||||
|
||||
RegisterId TraversalExecutorInfos::findRegisterChecked(OutputName type) const {
|
||||
auto const& it = _registerMapping.find(type);
|
||||
if (ADB_UNLIKELY(it == _registerMapping.end())) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||
TRI_ERROR_INTERNAL,
|
||||
"Logic error: requested unused register type " + typeToString(type));
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
RegisterId TraversalExecutorInfos::getOutputRegister(OutputName type) const {
|
||||
TRI_ASSERT(usesOutputRegister(type));
|
||||
return findRegisterChecked(type);
|
||||
}
|
||||
|
||||
RegisterId TraversalExecutorInfos::vertexRegister() const {
|
||||
return getOutputRegister(OutputName::VERTEX);
|
||||
}
|
||||
|
||||
RegisterId TraversalExecutorInfos::edgeRegister() const {
|
||||
return getOutputRegister(OutputName::EDGE);
|
||||
}
|
||||
|
||||
RegisterId TraversalExecutorInfos::pathRegister() const {
|
||||
TRI_ASSERT(usePathOutput());
|
||||
return _registerMapping.find(OutputName::PATH)->second;
|
||||
return getOutputRegister(OutputName::PATH);
|
||||
}
|
||||
|
||||
bool TraversalExecutorInfos::usesFixedSource() const {
|
||||
|
|
|
@ -67,6 +67,10 @@ class TraversalExecutorInfos : public ExecutorInfos {
|
|||
|
||||
traverser::Traverser& traverser();
|
||||
|
||||
bool usesOutputRegister(OutputName type) const;
|
||||
|
||||
RegisterId getOutputRegister(OutputName type) const;
|
||||
|
||||
bool useVertexOutput() const;
|
||||
|
||||
RegisterId vertexRegister() const;
|
||||
|
@ -87,6 +91,9 @@ class TraversalExecutorInfos : public ExecutorInfos {
|
|||
|
||||
std::vector<std::pair<Variable const*, RegisterId>> const& filterConditionVariables() const;
|
||||
|
||||
private:
|
||||
RegisterId findRegisterChecked(OutputName type) const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<traverser::Traverser> _traverser;
|
||||
std::unordered_map<OutputName, RegisterId, OutputNameHash> _registerMapping;
|
||||
|
|
Loading…
Reference in New Issue