Closed Bug 1681464 Opened 5 years ago Closed 3 years ago

[Automated review] clang-tidy wants parens around definitions in macros, but the hazard build errors on them

Categories

(Developer Infrastructure :: Source Code Analysis, defect, P3)

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: mozbugz, Unassigned)

Details

Phabricator URL: https://phabricator.services.mozilla.com/D98890?vs=on&id=375312#toc

Code and clang-tidy warning:

#define GET_JSON(VARIABLE, GETTER, TYPE) \
  ASSERT_HAS_JSON(GETTER, TYPE);         \
  const Json::Value& VARIABLE = (GETTER)

Lint: clang-tidy

WARNING: macro argument should be enclosed in parentheses

Note that this is a variable declaration, they usually don't have parentheses around them. But C++ allows them -- I didn't know that!

However the Linux "hazard" build errors on them:
https://treeherder.mozilla.org/logviewer?job_id=324018295&repo=autoland&lineNumber=16247

 /builds/worker/checkouts/gecko/tools/profiler/tests/gtest/GeckoProfiler.cpp:110:21: error: unnecessary parentheses in declaration of 'meta' [-Werror=parentheses]
   110 |   const Json::Value&(VARIABLE) = (GETTER)
       |                     ^

Now, I doubt there's a way to make clang-tidy more clever about this(?)

Priority: -- → P3
Product: Firefox Build System → Developer Infrastructure

This is static-analysis and in the end it's reliability it's marked as medium and there isn't a cheap way to make clang-tidy smarter about this checker.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.