Run clang-tidy modernize-use-nullptr on //courgette
This was done on Windows. Non-Windows platform-specific code hasn't been converted. This is a mechanical change. See bugs for justification and details. Bug: 776257, 778942 Change-Id: Iad35c3a9911e5a1c8ae3ce77c5b5c9e8481a9c05 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1536067 Reviewed-by: Will Harris <wfh@chromium.org> Commit-Queue: Raul Tambre <raul@tambre.ee> Cr-Commit-Position: refs/heads/master@{#645197}
This commit is contained in:
@ -61,10 +61,13 @@ class LabelInfo {
|
||||
// Just a no-argument constructor and copy constructor. Actual LabelInfo
|
||||
// objects are allocated in std::pair structs in a std::map.
|
||||
LabelInfo()
|
||||
: label_(NULL), is_model_(false), debug_index_(0), refs_(0),
|
||||
assignment_(NULL),
|
||||
next_addr_(NULL),
|
||||
prev_addr_(NULL) {}
|
||||
: label_(nullptr),
|
||||
is_model_(false),
|
||||
debug_index_(0),
|
||||
refs_(0),
|
||||
assignment_(nullptr),
|
||||
next_addr_(nullptr),
|
||||
prev_addr_(nullptr) {}
|
||||
|
||||
private:
|
||||
void operator=(const LabelInfo*); // Disallow assignment only.
|
||||
@ -205,13 +208,11 @@ typedef std::set<Node*, OrderNodeByWeightDecreasing> NodeQueue;
|
||||
|
||||
class AssignmentProblem {
|
||||
public:
|
||||
AssignmentProblem(const Trace& model,
|
||||
const Trace& problem)
|
||||
AssignmentProblem(const Trace& model, const Trace& problem)
|
||||
: m_trace_(model),
|
||||
p_trace_(problem),
|
||||
m_root_(NULL),
|
||||
p_root_(NULL) {
|
||||
}
|
||||
m_root_(nullptr),
|
||||
p_root_(nullptr) {}
|
||||
|
||||
~AssignmentProblem() {
|
||||
for (size_t i = 0; i < all_nodes_.size(); ++i)
|
||||
@ -279,7 +280,7 @@ class AssignmentProblem {
|
||||
|
||||
Node* m_node = FindModelNode(p_node);
|
||||
|
||||
if (m_node == NULL) {
|
||||
if (m_node == nullptr) {
|
||||
VLOG(2) << "Can't find model node";
|
||||
unsolved_.insert(p_node);
|
||||
return;
|
||||
@ -431,7 +432,7 @@ class AssignmentProblem {
|
||||
LabelInfo* m_info = m_trace_[m_pos];
|
||||
|
||||
// To match, either (1) both are assigned or (2) both are unassigned.
|
||||
if ((p_info->assignment_ == NULL) != (m_info->assignment_ == NULL))
|
||||
if ((p_info->assignment_ == nullptr) != (m_info->assignment_ == nullptr))
|
||||
break;
|
||||
|
||||
// If they are assigned, it needs to be consistent (same index).
|
||||
@ -469,7 +470,7 @@ class AssignmentProblem {
|
||||
LabelInfo* p_info = p_trace_[p_pos];
|
||||
LabelInfo* m_info = m_trace_[m_pos];
|
||||
|
||||
if ((p_info->assignment_ == NULL) != (m_info->assignment_ == NULL))
|
||||
if ((p_info->assignment_ == nullptr) != (m_info->assignment_ == nullptr))
|
||||
break;
|
||||
|
||||
if (p_info->assignment_ && m_info->assignment_) {
|
||||
@ -495,34 +496,34 @@ class AssignmentProblem {
|
||||
}
|
||||
|
||||
Node* FindModelNode(Node* node) {
|
||||
if (node->prev_ == NULL)
|
||||
if (node->prev_ == nullptr)
|
||||
return m_root_;
|
||||
|
||||
Node* m_parent = FindModelNode(node->prev_);
|
||||
if (m_parent == NULL) {
|
||||
return NULL;
|
||||
if (m_parent == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ExtendNode(m_parent, m_trace_);
|
||||
|
||||
LabelInfo* p_label = node->in_edge_;
|
||||
LabelInfo* m_label = p_label->assignment_;
|
||||
if (m_label == NULL) {
|
||||
if (m_label == nullptr) {
|
||||
VLOG(2) << "Expected assigned prefix";
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Node::Edges::iterator e = m_parent->edges_.find(m_label);
|
||||
if (e == m_parent->edges_.end()) {
|
||||
VLOG(3) << "Expected defined edge in parent";
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return e->second;
|
||||
}
|
||||
|
||||
Node* MakeRootNode(const Trace& trace) {
|
||||
Node* node = new Node(NULL, NULL);
|
||||
Node* node = new Node(nullptr, nullptr);
|
||||
all_nodes_.push_back(node);
|
||||
for (uint32_t i = 0; i < trace.size(); ++i) {
|
||||
++node->count_;
|
||||
@ -540,7 +541,7 @@ class AssignmentProblem {
|
||||
if (index < trace.size()) {
|
||||
LabelInfo* item = trace.at(index);
|
||||
Node*& slot = node->edges_[item];
|
||||
if (slot == NULL) {
|
||||
if (slot == nullptr) {
|
||||
slot = new Node(item, node);
|
||||
all_nodes_.push_back(slot);
|
||||
node->edges_in_frequency_order.push_back(slot);
|
||||
@ -568,9 +569,7 @@ class AssignmentProblem {
|
||||
class GraphAdjuster : public AdjustmentMethod {
|
||||
public:
|
||||
GraphAdjuster()
|
||||
: prog_(NULL),
|
||||
model_(NULL),
|
||||
debug_label_index_gen_(0) {}
|
||||
: prog_(nullptr), model_(nullptr), debug_label_index_gen_(0) {}
|
||||
~GraphAdjuster() = default;
|
||||
|
||||
bool Adjust(const AssemblyProgram& model, AssemblyProgram* program) {
|
||||
@ -618,7 +617,7 @@ class GraphAdjuster : public AdjustmentMethod {
|
||||
Ordered ordered;
|
||||
for (Trace::const_iterator p = trace.begin(); p != trace.end(); ++p)
|
||||
ordered.insert(*p);
|
||||
LabelInfo* prev = NULL;
|
||||
LabelInfo* prev = nullptr;
|
||||
for (Ordered::iterator p = ordered.begin(); p != ordered.end(); ++p) {
|
||||
LabelInfo* curr = *p;
|
||||
if (prev) prev->next_addr_ = curr;
|
||||
@ -637,7 +636,7 @@ class GraphAdjuster : public AdjustmentMethod {
|
||||
|
||||
LabelInfo* MakeLabelInfo(Label* label, bool is_model, uint32_t position) {
|
||||
LabelInfo& slot = label_infos_[label];
|
||||
if (slot.label_ == NULL) {
|
||||
if (slot.label_ == nullptr) {
|
||||
slot.label_ = label;
|
||||
slot.is_model_ = is_model;
|
||||
slot.debug_index_ = ++debug_label_index_gen_;
|
||||
|
@ -169,9 +169,12 @@ class LabelInfo {
|
||||
// Just a no-argument constructor and copy constructor. Actual LabelInfo
|
||||
// objects are allocated in std::pair structs in a std::map.
|
||||
LabelInfo()
|
||||
: label_(NULL), is_model_(false), debug_index_(0), refs_(0),
|
||||
assignment_(NULL), candidates_(NULL)
|
||||
{}
|
||||
: label_(nullptr),
|
||||
is_model_(false),
|
||||
debug_index_(0),
|
||||
refs_(0),
|
||||
assignment_(nullptr),
|
||||
candidates_(nullptr) {}
|
||||
|
||||
~LabelInfo();
|
||||
|
||||
@ -218,7 +221,7 @@ class LabelInfoMaker {
|
||||
|
||||
LabelInfo* MakeLabelInfo(Label* label, bool is_model, uint32_t position) {
|
||||
LabelInfo& slot = label_infos_[label];
|
||||
if (slot.label_ == NULL) {
|
||||
if (slot.label_ == nullptr) {
|
||||
slot.label_ = label;
|
||||
slot.is_model_ = is_model;
|
||||
slot.debug_index_ = ++debug_label_index_gen_;
|
||||
@ -353,7 +356,7 @@ class AssignmentCandidates {
|
||||
};
|
||||
|
||||
AssignmentCandidates* LabelInfo::candidates() {
|
||||
if (candidates_ == NULL)
|
||||
if (candidates_ == nullptr)
|
||||
candidates_ = new AssignmentCandidates(this);
|
||||
return candidates_;
|
||||
}
|
||||
@ -412,8 +415,7 @@ class Shingle {
|
||||
Shingle(const Trace& trace, size_t exemplar_position)
|
||||
: trace_(trace),
|
||||
exemplar_position_(exemplar_position),
|
||||
pattern_(NULL) {
|
||||
}
|
||||
pattern_(nullptr) {}
|
||||
|
||||
const Trace& trace_; // The shingle lives inside trace_.
|
||||
size_t exemplar_position_; // At this position (and other positions).
|
||||
@ -513,7 +515,8 @@ class ShinglePattern {
|
||||
|
||||
typedef std::set<FreqView, FreqView::Greater> Histogram;
|
||||
|
||||
ShinglePattern() : index_(NULL), model_coverage_(0), program_coverage_(0) {}
|
||||
ShinglePattern()
|
||||
: index_(nullptr), model_coverage_(0), program_coverage_(0) {}
|
||||
|
||||
const Index* index_; // Points to the key in the owning map value_type.
|
||||
Histogram model_histogram_;
|
||||
@ -524,7 +527,7 @@ class ShinglePattern {
|
||||
|
||||
std::string ToString(const ShinglePattern::Index* index) {
|
||||
std::string s;
|
||||
if (index == NULL) {
|
||||
if (index == nullptr) {
|
||||
s = "<null>";
|
||||
} else {
|
||||
base::StringAppendF(&s, "<%d: ", index->variables_);
|
||||
@ -586,7 +589,7 @@ std::string HistogramToStringFull(const ShinglePattern::Histogram& histogram,
|
||||
|
||||
std::string ToString(const ShinglePattern* pattern, size_t snippet_max = 3) {
|
||||
std::string s;
|
||||
if (pattern == NULL) {
|
||||
if (pattern == nullptr) {
|
||||
s = "<null>";
|
||||
} else {
|
||||
s = "{";
|
||||
@ -815,7 +818,7 @@ class AssignmentProblem {
|
||||
// Nothing much we can do with such a short problem.
|
||||
return true;
|
||||
}
|
||||
instances_.resize(trace_.size() - Shingle::kWidth + 1, NULL);
|
||||
instances_.resize(trace_.size() - Shingle::kWidth + 1, nullptr);
|
||||
AddShingles(0, model_end_);
|
||||
AddShingles(model_end_, trace_.size());
|
||||
InitialClassify();
|
||||
@ -906,12 +909,12 @@ class AssignmentProblem {
|
||||
pattern->program_histogram_.erase(ShinglePattern::FreqView(shingle));
|
||||
pattern->program_coverage_ -= shingle->position_count();
|
||||
}
|
||||
shingle->set_pattern(NULL);
|
||||
shingle->set_pattern(nullptr);
|
||||
}
|
||||
|
||||
void Reclassify(Shingle* shingle) {
|
||||
ShinglePattern* pattern = shingle->pattern();
|
||||
LOG_ASSERT(pattern == NULL);
|
||||
LOG_ASSERT(pattern == nullptr);
|
||||
|
||||
ShinglePattern::Index index(shingle);
|
||||
if (index.variables_ == 0)
|
||||
@ -1065,8 +1068,8 @@ class AssignmentProblem {
|
||||
for (uint8_t i = 0; i < Shingle::kWidth; ++i) {
|
||||
LabelInfo* program_info = program_instance->at(i);
|
||||
LabelInfo* model_info = model_instance->at(i);
|
||||
if ((model_info->assignment_ == NULL) !=
|
||||
(program_info->assignment_ == NULL)) {
|
||||
if ((model_info->assignment_ == nullptr) !=
|
||||
(program_info->assignment_ == nullptr)) {
|
||||
VLOG(2) << "ERROR " << i
|
||||
<< "\n\t" << ToString(pattern, 10)
|
||||
<< "\n\t" << ToString(program_instance)
|
||||
@ -1224,7 +1227,7 @@ class AssignmentProblem {
|
||||
|
||||
class Adjuster : public AdjustmentMethod {
|
||||
public:
|
||||
Adjuster() : prog_(NULL), model_(NULL) {}
|
||||
Adjuster() : prog_(nullptr), model_(nullptr) {}
|
||||
~Adjuster() = default;
|
||||
|
||||
bool Adjust(const AssemblyProgram& model, AssemblyProgram* program) {
|
||||
|
@ -246,7 +246,7 @@ void DisassembleAdjustDiff(const base::FilePath& old_file,
|
||||
for (int i = 0;; ++i) {
|
||||
courgette::SinkStream* old_stream = flow.data(flow.OLD)->sinks.stream(i);
|
||||
courgette::SinkStream* new_stream = flow.data(flow.NEW)->sinks.stream(i);
|
||||
if (old_stream == NULL && new_stream == NULL)
|
||||
if (old_stream == nullptr && new_stream == nullptr)
|
||||
break;
|
||||
|
||||
courgette::SourceStream old_source;
|
||||
|
@ -629,12 +629,12 @@ std::string DisassemblerWin32::DescribeRVA(RVA rva) const {
|
||||
|
||||
const Section* DisassemblerWin32::FindNextSection(
|
||||
FileOffset file_offset) const {
|
||||
const Section* best = 0;
|
||||
const Section* best = nullptr;
|
||||
for (int i = 0; i < number_of_sections_; ++i) {
|
||||
const Section* section = §ions_[i];
|
||||
if (section->size_of_raw_data > 0) { // i.e. has data in file.
|
||||
if (file_offset <= section->file_offset_of_raw_data) {
|
||||
if (best == 0 ||
|
||||
if (best == nullptr ||
|
||||
section->file_offset_of_raw_data < best->file_offset_of_raw_data) {
|
||||
best = section;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ TransformationPatchGenerator* MakeGenerator(Element* old_element,
|
||||
}
|
||||
|
||||
LOG(WARNING) << "Unexpected Element::Kind " << old_element->kind();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Checks to see if the proposed comparison is 'unsafe'. Sometimes one element
|
||||
@ -180,7 +180,7 @@ Status FindGenerators(Ensemble* old_ensemble, Ensemble* new_ensemble,
|
||||
// prioritize elements that are of a similar size or similar position in the
|
||||
// sequence of elements.
|
||||
//
|
||||
Element* best_old_element = NULL;
|
||||
Element* best_old_element = nullptr;
|
||||
size_t best_difference = std::numeric_limits<size_t>::max();
|
||||
for (size_t old_index = 0; old_index < old_elements.size(); ++old_index) {
|
||||
Element* old_element = old_elements[old_index];
|
||||
@ -204,7 +204,7 @@ Status FindGenerators(Ensemble* old_ensemble, Ensemble* new_ensemble,
|
||||
VLOG(1) << "Skip " << new_element->Name()
|
||||
<< " - identical to " << old_element->Name();
|
||||
best_difference = 0;
|
||||
best_old_element = NULL;
|
||||
best_old_element = nullptr;
|
||||
break;
|
||||
}
|
||||
if (difference < best_difference) {
|
||||
|
@ -38,16 +38,15 @@ namespace courgette {
|
||||
|
||||
// FileMapping
|
||||
|
||||
FileMapping::FileMapping() : mapping_(NULL), view_(NULL) {
|
||||
}
|
||||
FileMapping::FileMapping() : mapping_(nullptr), view_(nullptr) {}
|
||||
|
||||
FileMapping::~FileMapping() {
|
||||
Close();
|
||||
}
|
||||
|
||||
bool FileMapping::InitializeView(size_t size) {
|
||||
DCHECK(view_ == NULL);
|
||||
DCHECK(mapping_ != NULL);
|
||||
DCHECK(view_ == nullptr);
|
||||
DCHECK(mapping_ != nullptr);
|
||||
view_ = ::MapViewOfFile(mapping_, FILE_MAP_WRITE, 0, 0, size);
|
||||
if (!view_) {
|
||||
Close();
|
||||
@ -59,7 +58,7 @@ bool FileMapping::InitializeView(size_t size) {
|
||||
bool FileMapping::Create(HANDLE file, size_t size) {
|
||||
DCHECK(file != INVALID_HANDLE_VALUE);
|
||||
DCHECK(!valid());
|
||||
mapping_ = ::CreateFileMapping(file, NULL, PAGE_READWRITE, 0, 0, NULL);
|
||||
mapping_ = ::CreateFileMapping(file, nullptr, PAGE_READWRITE, 0, 0, nullptr);
|
||||
if (!mapping_)
|
||||
return false;
|
||||
|
||||
@ -71,12 +70,12 @@ void FileMapping::Close() {
|
||||
::UnmapViewOfFile(view_);
|
||||
if (mapping_)
|
||||
::CloseHandle(mapping_);
|
||||
mapping_ = NULL;
|
||||
view_ = NULL;
|
||||
mapping_ = nullptr;
|
||||
view_ = nullptr;
|
||||
}
|
||||
|
||||
bool FileMapping::valid() const {
|
||||
return view_ != NULL;
|
||||
return view_ != nullptr;
|
||||
}
|
||||
|
||||
void* FileMapping::view() const {
|
||||
@ -128,7 +127,7 @@ bool TempMapping::valid() const {
|
||||
|
||||
// static
|
||||
TempMapping* TempMapping::GetMappingFromPtr(void* mem) {
|
||||
TempMapping* ret = NULL;
|
||||
TempMapping* ret = nullptr;
|
||||
if (mem) {
|
||||
ret = reinterpret_cast<TempMapping**>(mem)[-1];
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ const uint8_t* Varint::Parse32WithLimit(const uint8_t* source,
|
||||
uint32_t* output) {
|
||||
uint32_t digit, result;
|
||||
if (source >= limit)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
digit = *(source++);
|
||||
result = digit & 127;
|
||||
if (digit < 128) {
|
||||
@ -75,7 +75,7 @@ const uint8_t* Varint::Parse32WithLimit(const uint8_t* source,
|
||||
}
|
||||
|
||||
if (source >= limit)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
digit = *(source++);
|
||||
result |= (digit & 127) << 7;
|
||||
if (digit < 128) {
|
||||
@ -84,7 +84,7 @@ const uint8_t* Varint::Parse32WithLimit(const uint8_t* source,
|
||||
}
|
||||
|
||||
if (source >= limit)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
digit = *(source++);
|
||||
result |= (digit & 127) << 14;
|
||||
if (digit < 128) {
|
||||
@ -93,7 +93,7 @@ const uint8_t* Varint::Parse32WithLimit(const uint8_t* source,
|
||||
}
|
||||
|
||||
if (source >= limit)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
digit = *(source++);
|
||||
result |= (digit & 127) << 21;
|
||||
if (digit < 128) {
|
||||
@ -102,7 +102,7 @@ const uint8_t* Varint::Parse32WithLimit(const uint8_t* source,
|
||||
}
|
||||
|
||||
if (source >= limit)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
digit = *(source++);
|
||||
result |= (digit & 127) << 28;
|
||||
if (digit < 128) {
|
||||
@ -110,7 +110,7 @@ const uint8_t* Varint::Parse32WithLimit(const uint8_t* source,
|
||||
return source;
|
||||
}
|
||||
|
||||
return NULL; // Value is too long to be a Varint32.
|
||||
return nullptr; // Value is too long to be a Varint32.
|
||||
}
|
||||
|
||||
// Write the base-128 digits in little-endian order. All except the last digit
|
||||
@ -244,14 +244,14 @@ bool SourceStreamSet::Init(const void* source, size_t byte_count) {
|
||||
|
||||
unsigned int version;
|
||||
const uint8_t* finger = Varint::Parse32WithLimit(start, end, &version);
|
||||
if (finger == NULL)
|
||||
if (finger == nullptr)
|
||||
return false;
|
||||
if (version != kStreamsSerializationFormatVersion)
|
||||
return false;
|
||||
|
||||
unsigned int count;
|
||||
finger = Varint::Parse32WithLimit(finger, end, &count);
|
||||
if (finger == NULL)
|
||||
if (finger == nullptr)
|
||||
return false;
|
||||
if (count > kMaxStreams)
|
||||
return false;
|
||||
@ -263,7 +263,7 @@ bool SourceStreamSet::Init(const void* source, size_t byte_count) {
|
||||
|
||||
for (size_t i = 0; i < count_; ++i) {
|
||||
finger = Varint::Parse32WithLimit(finger, end, &lengths[i]);
|
||||
if (finger == NULL)
|
||||
if (finger == nullptr)
|
||||
return false;
|
||||
accumulated_length += lengths[i];
|
||||
}
|
||||
|
25
courgette/third_party/divsufsort/divsufsort.cc
vendored
25
courgette/third_party/divsufsort/divsufsort.cc
vendored
@ -178,10 +178,9 @@ construct_SA(const sauchar_t *T, saidx_it SA,
|
||||
the sorted order of type B* suffixes. */
|
||||
for(c1 = ALPHABET_SIZE - 2; 0 <= c1; --c1) {
|
||||
/* Scan the suffix array from right to left. */
|
||||
for(i = SA + BUCKET_BSTAR(c1, c1 + 1),
|
||||
j = SA + BUCKET_A(c1 + 1) - 1, k = NULL, c2 = -1;
|
||||
i <= j;
|
||||
--j) {
|
||||
for (i = SA + BUCKET_BSTAR(c1, c1 + 1), j = SA + BUCKET_A(c1 + 1) - 1,
|
||||
k = nullptr, c2 = -1;
|
||||
i <= j; --j) {
|
||||
if(0 < (s = *j)) {
|
||||
assert(T[s] == c1);
|
||||
assert(((s + 1) < n) && (T[s] <= T[s + 1]));
|
||||
@ -239,16 +238,24 @@ divsufsort(const sauchar_t *T, saidx_it SA, saidx_t n) {
|
||||
saint_t err = 0;
|
||||
|
||||
/* Check arguments. */
|
||||
if((T == NULL) || (SA == NULL) || (n < 0)) { return -1; }
|
||||
else if(n == 0) { return 0; }
|
||||
else if(n == 1) { SA[0] = 0; return 0; }
|
||||
else if(n == 2) { m = (T[0] < T[1]); SA[m ^ 1] = 0, SA[m] = 1; return 0; }
|
||||
if ((T == nullptr) || (SA == nullptr) || (n < 0)) {
|
||||
return -1;
|
||||
} else if (n == 0) {
|
||||
return 0;
|
||||
} else if (n == 1) {
|
||||
SA[0] = 0;
|
||||
return 0;
|
||||
} else if (n == 2) {
|
||||
m = (T[0] < T[1]);
|
||||
SA[m ^ 1] = 0, SA[m] = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bucket_A = (saidx_t *)malloc(BUCKET_A_SIZE * sizeof(saidx_t));
|
||||
bucket_B = (saidx_t *)malloc(BUCKET_B_SIZE * sizeof(saidx_t));
|
||||
|
||||
/* Suffixsort. */
|
||||
if((bucket_A != NULL) && (bucket_B != NULL)) {
|
||||
if ((bucket_A != nullptr) && (bucket_B != nullptr)) {
|
||||
m = sort_typeBstar(T, SA, bucket_A, bucket_B, n);
|
||||
construct_SA(T, SA, bucket_A, bucket_B, n, m);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user