Use range-based for loops. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205953 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Atanasyan 2014-04-10 06:02:49 +00:00
parent f2eed86ea5
commit fb52dba011

View File

@ -158,10 +158,9 @@ void Input::endMapping() {
MapHNode *MN = dyn_cast_or_null<MapHNode>(CurrentNode); MapHNode *MN = dyn_cast_or_null<MapHNode>(CurrentNode);
if (!MN) if (!MN)
return; return;
for (MapHNode::NameToNode::iterator i = MN->Mapping.begin(), for (const auto &NN : MN->Mapping) {
End = MN->Mapping.end(); i != End; ++i) { if (!MN->isValidKey(NN.first())) {
if (!MN->isValidKey(i->first())) { setError(NN.second, Twine("unknown key '") + NN.first() + "'");
setError(i->second, Twine("unknown key '") + i->first() + "'");
break; break;
} }
} }
@ -255,9 +254,8 @@ bool Input::bitSetMatch(const char *Str, bool) {
return false; return false;
if (SequenceHNode *SQ = dyn_cast<SequenceHNode>(CurrentNode)) { if (SequenceHNode *SQ = dyn_cast<SequenceHNode>(CurrentNode)) {
unsigned Index = 0; unsigned Index = 0;
for (std::vector<HNode *>::iterator i = SQ->Entries.begin(), for (HNode *N : SQ->Entries) {
End = SQ->Entries.end(); i != End; ++i) { if (ScalarHNode *SN = dyn_cast<ScalarHNode>(N)) {
if (ScalarHNode *SN = dyn_cast<ScalarHNode>(*i)) {
if (SN->value().equals(Str)) { if (SN->value().equals(Str)) {
BitValuesUsed[Index] = true; BitValuesUsed[Index] = true;
return true; return true;
@ -319,9 +317,8 @@ Input::HNode *Input::createHNodes(Node *N) {
return new ScalarHNode(N, KeyStr); return new ScalarHNode(N, KeyStr);
} else if (SequenceNode *SQ = dyn_cast<SequenceNode>(N)) { } else if (SequenceNode *SQ = dyn_cast<SequenceNode>(N)) {
SequenceHNode *SQHNode = new SequenceHNode(N); SequenceHNode *SQHNode = new SequenceHNode(N);
for (SequenceNode::iterator i = SQ->begin(), End = SQ->end(); i != End; for (Node &SN : *SQ) {
++i) { HNode *Entry = this->createHNodes(&SN);
HNode *Entry = this->createHNodes(i);
if (EC) if (EC)
break; break;
SQHNode->Entries.push_back(Entry); SQHNode->Entries.push_back(Entry);
@ -329,9 +326,8 @@ Input::HNode *Input::createHNodes(Node *N) {
return SQHNode; return SQHNode;
} else if (MappingNode *Map = dyn_cast<MappingNode>(N)) { } else if (MappingNode *Map = dyn_cast<MappingNode>(N)) {
MapHNode *mapHNode = new MapHNode(N); MapHNode *mapHNode = new MapHNode(N);
for (MappingNode::iterator i = Map->begin(), End = Map->end(); i != End; for (KeyValueNode &KVN : *Map) {
++i) { ScalarNode *KeyScalar = dyn_cast<ScalarNode>(KVN.getKey());
ScalarNode *KeyScalar = dyn_cast<ScalarNode>(i->getKey());
StringStorage.clear(); StringStorage.clear();
StringRef KeyStr = KeyScalar->getValue(StringStorage); StringRef KeyStr = KeyScalar->getValue(StringStorage);
if (!StringStorage.empty()) { if (!StringStorage.empty()) {
@ -341,7 +337,7 @@ Input::HNode *Input::createHNodes(Node *N) {
memcpy(Buf, &StringStorage[0], Len); memcpy(Buf, &StringStorage[0], Len);
KeyStr = StringRef(Buf, Len); KeyStr = StringRef(Buf, Len);
} }
HNode *ValueHNode = this->createHNodes(i->getValue()); HNode *ValueHNode = this->createHNodes(KVN.getValue());
if (EC) if (EC)
break; break;
mapHNode->Mapping[KeyStr] = ValueHNode; mapHNode->Mapping[KeyStr] = ValueHNode;
@ -356,9 +352,8 @@ Input::HNode *Input::createHNodes(Node *N) {
} }
bool Input::MapHNode::isValidKey(StringRef Key) { bool Input::MapHNode::isValidKey(StringRef Key) {
for (SmallVectorImpl<const char *>::iterator i = ValidKeys.begin(), for (const char *K : ValidKeys) {
End = ValidKeys.end(); i != End; ++i) { if (Key.equals(K))
if (Key.equals(*i))
return true; return true;
} }
return false; return false;
@ -373,17 +368,13 @@ bool Input::canElideEmptySequence() {
} }
Input::MapHNode::~MapHNode() { Input::MapHNode::~MapHNode() {
for (MapHNode::NameToNode::iterator i = Mapping.begin(), End = Mapping.end(); for (auto &N : Mapping)
i != End; ++i) { delete N.second;
delete i->second;
}
} }
Input::SequenceHNode::~SequenceHNode() { Input::SequenceHNode::~SequenceHNode() {
for (std::vector<HNode*>::iterator i = Entries.begin(), End = Entries.end(); for (HNode *N : Entries)
i != End; ++i) { delete N;
delete *i;
}
} }