Skip to content

Commit

Permalink
fix(build): (NFC) Fix some compiler warnings emitted when compiling w…
Browse files Browse the repository at this point in the history
…ith Clang 13.0

 - `-Wc++11-narrowing`
 - `-Wrange-loop-construct`
  • Loading branch information
whisperity committed Apr 4, 2022
1 parent 83a6a9a commit fd15caa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions plugins/cpp/parser/include/cppparser/cppparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ class CppParser : public AbstractParser
bool isNonSourceFlag(const std::string& arg_) const;
bool parseByJson(const std::string& jsonFile_, std::size_t threadNum_);
int parseWorker(const clang::tooling::CompileCommand& command_);

void initBuildActions();
void markByInclusion(model::FilePtr file_);
void markByInclusion(const model::FilePtr& file_);
std::vector<std::vector<std::string>> createCleanupOrder();
bool cleanupWorker(const std::string& path_);

std::unordered_set<std::uint64_t> _parsedCommandHashes;

};

} // parser
} // cc

Expand Down
4 changes: 2 additions & 2 deletions plugins/cpp/parser/src/cppparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void CppParser::markModifiedFiles()
// Detect changed files through C++ header inclusions.
util::OdbTransaction {_ctx.db} ([&]
{
for (const model::FilePtr file : filePtrs)
for (const model::FilePtr& file : filePtrs)
{
if(file)
{
Expand Down Expand Up @@ -711,7 +711,7 @@ void CppParser::initBuildActions()
});
}

void CppParser::markByInclusion(model::FilePtr file_)
void CppParser::markByInclusion(const model::FilePtr& file_)
{
auto inclusions = _ctx.db->query<model::CppHeaderInclusion>(
odb::query<model::CppHeaderInclusion>::included == file_->id);
Expand Down
8 changes: 6 additions & 2 deletions plugins/cpp/test/src/cppparsertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,10 @@ TEST_F(CppParserTest, Record)
{
EXPECT_EQ(n.symbolType, model::CppAstNode::SymbolType::Type);

using LineType = decltype(n.location.range.start.line);
switch (n.location.range.start.line)
{
case -1:
case static_cast<LineType>(-1):
EXPECT_TRUE(
// TODO: investigate the type of this. It is possibly the parameter
// of a compiler generated copy constructor or assignment operator.
Expand Down Expand Up @@ -653,10 +654,13 @@ TEST_F(CppParserTest, Variable)
astNodes = _db->query<model::CppAstNode>(
QCppAstNode::entityHash == memberVariable.entityHash);

using LineType =
decltype(std::declval<model::CppAstNode>().location.range.start.line);
for (const model::CppAstNode& n : astNodes)
switch (n.location.range.start.line)
{
case -1: // Access by compiler generated constructors.
case static_cast<LineType>(-1):
// Access by compiler generated constructors.
case 44: // Simple access for read.
EXPECT_EQ(n.astType, model::CppAstNode::AstType::Read);
break;
Expand Down
4 changes: 2 additions & 2 deletions webserver/src/mainrequesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace webserver
class Session;
class SessionManager;

struct MainRequestHandler
class MainRequestHandler
{
public:
SessionManager* sessionManager;
Expand All @@ -30,7 +30,7 @@ struct MainRequestHandler
template <typename F>
auto executeWithSessionContext(cc::webserver::Session* sess_, F func);
};

} // webserver
} // cc

Expand Down

0 comments on commit fd15caa

Please sign in to comment.