summaryrefslogtreecommitdiff
path: root/tools/incident_section_gen/main.cpp
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2020-04-23 14:39:18 -0700
committerChih-Hung Hsieh <chh@google.com>2020-04-23 14:52:58 -0700
commit788703574368a83eaecd689883a1e9bed32fb21d (patch)
tree022f5211375c1c511e5dcda5e5c8e7826072f19d /tools/incident_section_gen/main.cpp
parentf5ed9171e63223f5b6d501cec5664f76bb971161 (diff)
Fix clang-analyzer-core.uninitialized.Branch warnings
Bug: 154760495 Test: make with WITH_TIDY=1 and DEFAULT_GLOBAL_TIDY_CHECKS=clang-analyzer-core.uninitialized.Branch Change-Id: I569749166177c25e63b32fb468dccd13797acc05
Diffstat (limited to 'tools/incident_section_gen/main.cpp')
-rw-r--r--tools/incident_section_gen/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/incident_section_gen/main.cpp b/tools/incident_section_gen/main.cpp
index 91f875ed9918..ba1267b28fbb 100644
--- a/tools/incident_section_gen/main.cpp
+++ b/tools/incident_section_gen/main.cpp
@@ -368,10 +368,13 @@ static bool generatePrivacyFlags(const Descriptor* descriptor, const Destination
// Don't generate a variable twice
if (!hasDefaultFlags[i]) variableNames[fieldName] = false;
}
+ // hasDefaultFlags[i] has been initialized in the above for-loop,
+ // but clang-tidy analyzer still report uninitized values.
+ // So we use NOLINT to suppress those false positives.
bool allDefaults = true;
for (size_t i=0; i<fieldsInOrder.size(); i++) {
- allDefaults &= hasDefaultFlags[i];
+ allDefaults &= hasDefaultFlags[i]; // NOLINT(clang-analyzer-core.uninitialized.Assign)
}
parents->erase(messageName); // erase the message type name when exit the message.
@@ -384,7 +387,7 @@ static bool generatePrivacyFlags(const Descriptor* descriptor, const Destination
printf("Privacy* %s[] = {\n", messageName.c_str());
for (size_t i=0; i<fieldsInOrder.size(); i++) {
const FieldDescriptor* field = fieldsInOrder[i];
- if (hasDefaultFlags[i]) continue;
+ if (hasDefaultFlags[i]) continue; // NOLINT(clang-analyzer-core.uninitialized.Branch)
printf(" &%s,\n", getFieldName(field).c_str());
policyCount++;
}