Thrift: Fix fingerprinting bug.
Summary:
Fingerprints were'nt being initialized properly because I forgot to move
the initialization from t_struct to t_type. Fixed that.
Also, typedefs weren't generating fingerprints for their true types.
Reviewed By: mcslee
Test Plan:
This didn't work before with -cpp -dense. Now it does.
typedef list<i32> ilist
struct foo { 1: ilist l }
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665268 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_struct.h b/compiler/cpp/src/parse/t_struct.h
index 05cd216..39da110 100644
--- a/compiler/cpp/src/parse/t_struct.h
+++ b/compiler/cpp/src/parse/t_struct.h
@@ -9,7 +9,6 @@
#include <vector>
#include <string>
-#include <cstring>
#include "t_type.h"
#include "t_field.h"
@@ -28,18 +27,12 @@
t_struct(t_program* program) :
t_type(program),
is_xception_(false),
- xsd_all_(false)
- {
- memset(fingerprint_, 0, sizeof(fingerprint_));
- }
+ xsd_all_(false) {}
t_struct(t_program* program, const std::string& name) :
t_type(program, name),
is_xception_(false),
- xsd_all_(false)
- {
- memset(fingerprint_, 0, sizeof(fingerprint_));
- }
+ xsd_all_(false) {}
void set_name(const std::string& name) {
name_ = name;
diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h
index 61975d5..3144356 100644
--- a/compiler/cpp/src/parse/t_type.h
+++ b/compiler/cpp/src/parse/t_type.h
@@ -8,6 +8,7 @@
#define T_TYPE_H
#include <string>
+#include <cstring>
#include "t_doc.h"
// What's worse? This, or making a src/parse/non_inlined.cc?
@@ -114,17 +115,28 @@
protected:
- t_type() {}
+ t_type() {
+ memset(fingerprint_, 0, sizeof(fingerprint_));
+ }
t_type(t_program* program) :
- program_(program) {}
+ program_(program)
+ {
+ memset(fingerprint_, 0, sizeof(fingerprint_));
+ }
t_type(t_program* program, std::string name) :
program_(program),
- name_(name) {}
+ name_(name)
+ {
+ memset(fingerprint_, 0, sizeof(fingerprint_));
+ }
t_type(std::string name) :
- name_(name) {}
+ name_(name)
+ {
+ memset(fingerprint_, 0, sizeof(fingerprint_));
+ }
t_program* program_;
std::string name_;
diff --git a/compiler/cpp/src/parse/t_typedef.h b/compiler/cpp/src/parse/t_typedef.h
index 341a6ff..f2c9713 100644
--- a/compiler/cpp/src/parse/t_typedef.h
+++ b/compiler/cpp/src/parse/t_typedef.h
@@ -43,6 +43,13 @@
return type_->get_fingerprint_material();
}
+ virtual void generate_fingerprint() {
+ t_type::generate_fingerprint();
+ if (!type_->has_fingerprint()) {
+ type_->generate_fingerprint();
+ }
+ }
+
private:
t_type* type_;
std::string symbolic_;