summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-04-30 18:15:34 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-04-30 18:15:34 +0000
commite0f0c0e247b29b9ec57dbd710608fa7132f5b504 (patch)
treea6b928c674891275ae74bc61236dbed25a731897 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parente012ede137af48a0ad0e384fa44f0df2e6a687d8 (diff)
downloadbcm5719-llvm-e0f0c0e247b29b9ec57dbd710608fa7132f5b504.tar.gz
bcm5719-llvm-e0f0c0e247b29b9ec57dbd710608fa7132f5b504.zip
CodeGen: convert to range based loops
Convert to using some range based loops, avoid unnecessary variables for unchecked casts. NFC. llvm-svn: 268165
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp56
1 files changed, 20 insertions, 36 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index a4626556878..d540ea7d06f 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -490,10 +490,7 @@ emitModuleFlags(MCStreamer &Streamer,
MDNode *LinkerOptions = nullptr;
StringRef SectionVal;
- for (ArrayRef<Module::ModuleFlagEntry>::iterator
- i = ModuleFlags.begin(), e = ModuleFlags.end(); i != e; ++i) {
- const Module::ModuleFlagEntry &MFE = *i;
-
+ for (const auto &MFE : ModuleFlags) {
// Ignore flags with 'Require' behavior.
if (MFE.Behavior == Module::Require)
continue;
@@ -518,16 +515,10 @@ emitModuleFlags(MCStreamer &Streamer,
// Emit the linker options if present.
if (LinkerOptions) {
- for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i != e; ++i) {
- MDNode *MDOptions = cast<MDNode>(LinkerOptions->getOperand(i));
+ for (const auto &Option : LinkerOptions->operands()) {
SmallVector<std::string, 4> StrOptions;
-
- // Convert to strings.
- for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) {
- MDString *MDOption = cast<MDString>(MDOptions->getOperand(ii));
- StrOptions.push_back(MDOption->getString());
- }
-
+ for (const auto &Piece : cast<MDNode>(Option)->operands())
+ StrOptions.push_back(cast<MDString>(Piece)->getString());
Streamer.EmitLinkerOptions(StrOptions);
}
}
@@ -1051,32 +1042,25 @@ emitModuleFlags(MCStreamer &Streamer,
Mangler &Mang, const TargetMachine &TM) const {
MDNode *LinkerOptions = nullptr;
- // Look for the "Linker Options" flag, since it's the only one we support.
- for (ArrayRef<Module::ModuleFlagEntry>::iterator
- i = ModuleFlags.begin(), e = ModuleFlags.end(); i != e; ++i) {
- const Module::ModuleFlagEntry &MFE = *i;
+ for (const auto &MFE : ModuleFlags) {
StringRef Key = MFE.Key->getString();
- Metadata *Val = MFE.Val;
- if (Key == "Linker Options") {
- LinkerOptions = cast<MDNode>(Val);
- break;
- }
+ if (Key == "Linker Options")
+ LinkerOptions = cast<MDNode>(MFE.Val);
}
- if (!LinkerOptions)
- return;
- // Emit the linker options to the linker .drectve section. According to the
- // spec, this section is a space-separated string containing flags for linker.
- MCSection *Sec = getDrectveSection();
- Streamer.SwitchSection(Sec);
- for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i != e; ++i) {
- MDNode *MDOptions = cast<MDNode>(LinkerOptions->getOperand(i));
- for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) {
- MDString *MDOption = cast<MDString>(MDOptions->getOperand(ii));
- // Lead with a space for consistency with our dllexport implementation.
- std::string Directive(" ");
- Directive.append(MDOption->getString());
- Streamer.EmitBytes(Directive);
+ if (LinkerOptions) {
+ // Emit the linker options to the linker .drectve section. According to the
+ // spec, this section is a space-separated string containing flags for
+ // linker.
+ MCSection *Sec = getDrectveSection();
+ Streamer.SwitchSection(Sec);
+ for (const auto &Option : LinkerOptions->operands()) {
+ for (const auto &Piece : cast<MDNode>(Option)->operands()) {
+ // Lead with a space for consistency with our dllexport implementation.
+ std::string Directive(" ");
+ Directive.append(cast<MDString>(Piece)->getString());
+ Streamer.EmitBytes(Directive);
+ }
}
}
}
OpenPOWER on IntegriCloud