diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-03-30 13:22:29 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-30 13:22:29 +0000 |
commit | b7df0eb9a6e30e16d112384e9e9890ea5388e8a0 (patch) | |
tree | 5eaa708cef3b5a217f79005d8c3a7f9fe1b42fed /tools/stats_log_api_gen/Collation.cpp | |
parent | 924069c2aa1d3fa64969868ccdf6dc8bf54fc670 (diff) | |
parent | 23daf2656c4a1ce5871195fe51782093732b9187 (diff) |
Merge changes I6f6b4d78,I874696cf into rvc-dev
* changes:
Only send reset state annotation when needed
Group annotations for the same atom id
Diffstat (limited to 'tools/stats_log_api_gen/Collation.cpp')
-rw-r--r-- | tools/stats_log_api_gen/Collation.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/tools/stats_log_api_gen/Collation.cpp b/tools/stats_log_api_gen/Collation.cpp index bf390935455a..1387bb5f7bc6 100644 --- a/tools/stats_log_api_gen/Collation.cpp +++ b/tools/stats_log_api_gen/Collation.cpp @@ -454,16 +454,12 @@ bool get_non_chained_node(const Descriptor* atom, AtomDecl* atomDecl, return has_attribution_node; } -static void populateFieldNumberToAnnotations(const AtomDecl& atomDecl, - FieldNumberToAnnotations* fieldNumberToAnnotations) { - for (FieldNumberToAnnotations::const_iterator it = atomDecl.fieldNumberToAnnotations.begin(); - it != atomDecl.fieldNumberToAnnotations.end(); it++) { +static void populateFieldNumberToAtomDeclSet(const shared_ptr<AtomDecl>& atomDecl, + FieldNumberToAtomDeclSet* fieldNumberToAtomDeclSet) { + for (FieldNumberToAnnotations::const_iterator it = atomDecl->fieldNumberToAnnotations.begin(); + it != atomDecl->fieldNumberToAnnotations.end(); it++) { const int fieldNumber = it->first; - const set<shared_ptr<Annotation>>& insertAnnotationsSource = it->second; - set<shared_ptr<Annotation>>& insertAnnotationsTarget = - (*fieldNumberToAnnotations)[fieldNumber]; - insertAnnotationsTarget.insert(insertAnnotationsSource.begin(), - insertAnnotationsSource.end()); + (*fieldNumberToAtomDeclSet)[fieldNumber].insert(atomDecl); } } @@ -513,18 +509,19 @@ int collate_atoms(const Descriptor* descriptor, const string& moduleName, Atoms* } const Descriptor* atom = atomField->message_type(); - AtomDecl atomDecl(atomField->number(), atomField->name(), atom->name()); + shared_ptr<AtomDecl> atomDecl = + make_shared<AtomDecl>(atomField->number(), atomField->name(), atom->name()); if (atomField->options().GetExtension(os::statsd::allow_from_any_uid) == true) { - atomDecl.whitelisted = true; + atomDecl->whitelisted = true; if (dbg) { printf("%s is whitelisted\n", atomField->name().c_str()); } } - if (atomDecl.code < PULL_ATOM_START_ID && + if (atomDecl->code < PULL_ATOM_START_ID && atomField->options().GetExtension(os::statsd::truncate_timestamp)) { - addAnnotationToAtomDecl(&atomDecl, ATOM_ID_FIELD_NUMBER, + addAnnotationToAtomDecl(atomDecl.get(), ATOM_ID_FIELD_NUMBER, ANNOTATION_ID_TRUNCATE_TIMESTAMP, ANNOTATION_TYPE_BOOL, AnnotationValue(true)); if (dbg) { @@ -533,29 +530,33 @@ int collate_atoms(const Descriptor* descriptor, const string& moduleName, Atoms* } vector<java_type_t> signature; - errorCount += collate_atom(atom, &atomDecl, &signature); - if (atomDecl.primaryFields.size() != 0 && atomDecl.exclusiveField == 0) { + errorCount += collate_atom(atom, atomDecl.get(), &signature); + if (atomDecl->primaryFields.size() != 0 && atomDecl->exclusiveField == 0) { print_error(atomField, "Cannot have a primary field without an exclusive field: %s\n", atomField->name().c_str()); errorCount++; continue; } + FieldNumberToAtomDeclSet& fieldNumberToAtomDeclSet = atoms->signatureInfoMap[signature]; + populateFieldNumberToAtomDeclSet(atomDecl, &fieldNumberToAtomDeclSet); + atoms->decls.insert(atomDecl); - FieldNumberToAnnotations& fieldNumberToAnnotations = atoms->signatureInfoMap[signature]; - populateFieldNumberToAnnotations(atomDecl, &fieldNumberToAnnotations); - AtomDecl nonChainedAtomDecl(atomField->number(), atomField->name(), atom->name()); + shared_ptr<AtomDecl> nonChainedAtomDecl = + make_shared<AtomDecl>(atomField->number(), atomField->name(), atom->name()); vector<java_type_t> nonChainedSignature; - if (get_non_chained_node(atom, &nonChainedAtomDecl, &nonChainedSignature)) { - atoms->non_chained_decls.insert(nonChainedAtomDecl); - FieldNumberToAnnotations& fieldNumberToAnnotations = + if (get_non_chained_node(atom, nonChainedAtomDecl.get(), &nonChainedSignature)) { + FieldNumberToAtomDeclSet& nonChainedFieldNumberToAtomDeclSet = atoms->nonChainedSignatureInfoMap[nonChainedSignature]; - populateFieldNumberToAnnotations(atomDecl, &fieldNumberToAnnotations); + populateFieldNumberToAtomDeclSet(nonChainedAtomDecl, + &nonChainedFieldNumberToAtomDeclSet); + + atoms->non_chained_decls.insert(nonChainedAtomDecl); } - if (atomDecl.code < PULL_ATOM_START_ID && atomDecl.code > maxPushedAtomId) { - maxPushedAtomId = atomDecl.code; + if (atomDecl->code < PULL_ATOM_START_ID && atomDecl->code > maxPushedAtomId) { + maxPushedAtomId = atomDecl->code; } } @@ -563,8 +564,7 @@ int collate_atoms(const Descriptor* descriptor, const string& moduleName, Atoms* if (dbg) { printf("signatures = [\n"); - for (map<vector<java_type_t>, FieldNumberToAnnotations>::const_iterator it = - atoms->signatureInfoMap.begin(); + for (SignatureInfoMap::const_iterator it = atoms->signatureInfoMap.begin(); it != atoms->signatureInfoMap.end(); it++) { printf(" "); for (vector<java_type_t>::const_iterator jt = it->first.begin(); jt != it->first.end(); |