<div dir="ltr">Yes, but a bug that has already been fixed already ..<div><br></div><div>However, I think we are now messing up that lambda ..</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Sep 7, 2013 at 9:14 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:13px;font-family:arial,sans-serif">-    // Sort symbols by position.</span><br style="font-size:13px;font-family:arial,sans-serif">
<span style="font-size:13px;font-family:arial,sans-serif">-    std::stable_sort(symbols.</span><span style="font-size:13px;font-family:arial,sans-serif">begin(), symbols.end(),</span><br style="font-size:13px;font-family:arial,sans-serif">

<span style="font-size:13px;font-family:arial,sans-serif">-      // For some reason MSVC fails to allow the lambda in this context with a</span><br style="font-size:13px;font-family:arial,sans-serif">
<span style="font-size:13px;font-family:arial,sans-serif">-      // "illegal use of local type in type instantiation". MSVC is clearly</span><br style="font-size:13px;font-family:arial,sans-serif">
<span style="font-size:13px;font-family:arial,sans-serif">-      // wrong here. Force a conversion to function pointer to work around.</span><br style="font-size:13px;font-family:arial,sans-serif">
<span style="font-size:13px;font-family:arial,sans-serif">-      static_cast<bool(*)(const coff_symbol*, const coff_symbol*)>(</span><br style="font-size:13px;font-family:arial,sans-serif">
<span style="font-size:13px;font-family:arial,sans-serif">-        [](const coff_symbol *a, const coff_symbol *b) -> bool {</span><br style="font-size:13px;font-family:arial,sans-serif">
<span style="font-size:13px;font-family:arial,sans-serif">+      // Sort symbols by position.</span><br style="font-size:13px;font-family:arial,sans-serif"><span style="font-size:13px;font-family:arial,sans-serif">+    std::stable_sort(</span><div>

<span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">I wonder why this comment ("// Sort symbols...") got indented? clang-format bug?</span></div>

<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">-- Sean Silva</span></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Sep 7, 2013 at 1:56 PM, Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@bec.de" target="_blank">joerg@bec.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Author: joerg<br>
Date: Sat Sep  7 12:56:23 2013<br>
New Revision: 190254<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=190254&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=190254&view=rev</a><br>
Log:<br>
Run clang-format.<br>
<br>
Modified:<br>
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=190254&r1=190253&r2=190254&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=190254&r1=190253&r2=190254&view=diff</a><br>


==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Sat Sep  7 12:56:23 2013<br>
@@ -51,11 +51,11 @@ namespace {<br>
 // Converts the COFF symbol attribute to the LLD's atom attribute.<br>
 Atom::Scope getScope(const coff_symbol *symbol) {<br>
   switch (symbol->StorageClass) {<br>
-    case llvm::COFF::IMAGE_SYM_CLASS_EXTERNAL:<br>
-      return Atom::scopeGlobal;<br>
-    case llvm::COFF::IMAGE_SYM_CLASS_STATIC:<br>
-    case llvm::COFF::IMAGE_SYM_CLASS_LABEL:<br>
-      return Atom::scopeTranslationUnit;<br>
+  case llvm::COFF::IMAGE_SYM_CLASS_EXTERNAL:<br>
+    return Atom::scopeGlobal;<br>
+  case llvm::COFF::IMAGE_SYM_CLASS_STATIC:<br>
+  case llvm::COFF::IMAGE_SYM_CLASS_LABEL:<br>
+    return Atom::scopeTranslationUnit;<br>
   }<br>
   llvm_unreachable("Unknown scope");<br>
 }<br>
@@ -96,22 +96,22 @@ DefinedAtom::Alignment getAlignment(cons<br>
<br>
 DefinedAtom::Merge getMerge(const coff_aux_section_definition *auxsym) {<br>
   switch (auxsym->Selection) {<br>
-    case llvm::COFF::IMAGE_COMDAT_SELECT_NODUPLICATES:<br>
-      return DefinedAtom::mergeNo;<br>
-    case llvm::COFF::IMAGE_COMDAT_SELECT_ANY:<br>
-      return DefinedAtom::mergeAsWeakAndAddressUsed;<br>
-    case llvm::COFF::IMAGE_COMDAT_SELECT_SAME_SIZE:<br>
-    case llvm::COFF::IMAGE_COMDAT_SELECT_EXACT_MATCH:<br>
-    case llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE:<br>
-    case llvm::COFF::IMAGE_COMDAT_SELECT_LARGEST:<br>
-    case llvm::COFF::IMAGE_COMDAT_SELECT_NEWEST:<br>
-      // FIXME: These attributes has more complicated semantics than the regular<br>
-      // weak symbol. These are mapped to mergeAsWeakAndAddressUsed for now<br>
-      // because the core linker does not support them yet. We eventually have<br>
-      // to implement them for full COFF support.<br>
-      return DefinedAtom::mergeAsWeakAndAddressUsed;<br>
-    default:<br>
-      llvm_unreachable("Unknown merge type");<br>
+  case llvm::COFF::IMAGE_COMDAT_SELECT_NODUPLICATES:<br>
+    return DefinedAtom::mergeNo;<br>
+  case llvm::COFF::IMAGE_COMDAT_SELECT_ANY:<br>
+    return DefinedAtom::mergeAsWeakAndAddressUsed;<br>
+  case llvm::COFF::IMAGE_COMDAT_SELECT_SAME_SIZE:<br>
+  case llvm::COFF::IMAGE_COMDAT_SELECT_EXACT_MATCH:<br>
+  case llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE:<br>
+  case llvm::COFF::IMAGE_COMDAT_SELECT_LARGEST:<br>
+  case llvm::COFF::IMAGE_COMDAT_SELECT_NEWEST:<br>
+    // FIXME: These attributes has more complicated semantics than the regular<br>
+    // weak symbol. These are mapped to mergeAsWeakAndAddressUsed for now<br>
+    // because the core linker does not support them yet. We eventually have<br>
+    // to implement them for full COFF support.<br>
+    return DefinedAtom::mergeAsWeakAndAddressUsed;<br>
+  default:<br>
+    llvm_unreachable("Unknown merge type");<br>
   }<br>
 }<br>
<br>
@@ -120,7 +120,7 @@ private:<br>
   typedef vector<const coff_symbol *> SymbolVectorT;<br>
   typedef std::map<const coff_section *, SymbolVectorT> SectionToSymbolsT;<br>
   typedef std::map<const StringRef, Atom *> SymbolNameToAtomT;<br>
-  typedef std::map<const coff_section *, vector<COFFDefinedFileAtom *>><br>
+  typedef std::map<const coff_section *, vector<COFFDefinedFileAtom *> ><br>
   SectionToAtomsT;<br>
<br>
 public:<br>
@@ -222,8 +222,8 @@ private:<br>
     for (const coff_symbol *sym : symbols) {<br>
       if (sym->SectionNumber != llvm::COFF::IMAGE_SYM_ABSOLUTE)<br>
         continue;<br>
-      auto *atom = new (_alloc) COFFAbsoluteAtom(<br>
-          *this, _symbolName[sym], getScope(sym), sym->Value);<br>
+      auto *atom = new (_alloc)<br>
+          COFFAbsoluteAtom(*this, _symbolName[sym], getScope(sym), sym->Value);<br>
<br>
       result.push_back(atom);<br>
       _symbolAtom[sym] = atom;<br>
@@ -277,9 +277,9 @@ private:<br>
           sym->Value > 0) {<br>
         StringRef name = _symbolName[sym];<br>
         uint32_t size = sym->Value;<br>
-        auto *atom = new (_alloc) COFFBSSAtom(<br>
-            *this, name, getScope(sym), DefinedAtom::permRW_,<br>
-            DefinedAtom::mergeAsWeakAndAddressUsed, size, 0);<br>
+        auto *atom = new (_alloc)<br>
+            COFFBSSAtom(*this, name, getScope(sym), DefinedAtom::permRW_,<br>
+                        DefinedAtom::mergeAsWeakAndAddressUsed, size, 0);<br>
         result.push_back(atom);<br>
         continue;<br>
       }<br>
@@ -349,8 +349,8 @@ private:<br>
<br>
       if (sym->NumberOfAuxSymbols == 0)<br>
         return llvm::object::object_error::parse_failed;<br>
-      const coff_aux_section_definition *aux = reinterpret_cast<<br>
-          const coff_aux_section_definition *>(i.second);<br>
+      const coff_aux_section_definition *aux =<br>
+          reinterpret_cast<const coff_aux_section_definition *>(i.second);<br>
       _merge[sec] = getMerge(aux);<br>
     }<br>
<br>
@@ -372,13 +372,14 @@ private:<br>
   AtomizeDefinedSymbolsInSection(const coff_section *section,<br>
                                  vector<const coff_symbol *> &symbols,<br>
                                  vector<COFFDefinedFileAtom *> &atoms) {<br>
-    // Sort symbols by position.<br>
-    std::stable_sort(symbols.begin(), symbols.end(),<br>
-      // For some reason MSVC fails to allow the lambda in this context with a<br>
-      // "illegal use of local type in type instantiation". MSVC is clearly<br>
-      // wrong here. Force a conversion to function pointer to work around.<br>
-      static_cast<bool(*)(const coff_symbol*, const coff_symbol*)>(<br>
-        [](const coff_symbol *a, const coff_symbol *b) -> bool {<br>
+      // Sort symbols by position.<br>
+    std::stable_sort(<br>
+        symbols.begin(), symbols.end(),<br>
+        // For some reason MSVC fails to allow the lambda in this context with a<br>
+        // "illegal use of local type in type instantiation". MSVC is clearly<br>
+        // wrong here. Force a conversion to function pointer to work around.<br>
+        static_cast<bool (*)(const coff_symbol *, const coff_symbol *)>(<br>
+                [](const coff_symbol * a, const coff_symbol * b)->bool {<br>
       return a->Value < b->Value;<br>
     }));<br>
<br>
@@ -393,9 +394,8 @@ private:<br>
         llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) {<br>
       for (auto si = symbols.begin(), se = symbols.end(); si != se; ++si) {<br>
         const coff_symbol *sym = *si;<br>
-        uint32_t size = (si + 1 == se)<br>
-            ? section->SizeOfRawData - sym->Value<br>
-            : si[1]->Value - sym->Value;<br>
+        uint32_t size = (si + 1 == se) ? section->SizeOfRawData - sym->Value<br>
+                                       : si[1]->Value - sym->Value;<br>
         auto *atom = new (_alloc) COFFBSSAtom(<br>
             *this, _symbolName[sym], getScope(sym), getPermissions(section),<br>
             DefinedAtom::mergeAsWeakAndAddressUsed, size, ++ordinal);<br>
@@ -427,9 +427,9 @@ private:<br>
     // Create an atom for the entire section.<br>
     if (symbols.empty()) {<br>
       ArrayRef<uint8_t> data(secData.data(), secData.size());<br>
-      auto *atom = new (_alloc) COFFDefinedAtom(<br>
-          *this, "", sectionName, Atom::scopeTranslationUnit, type, perms,<br>
-          _merge[section], data, 0);<br>
+      auto *atom = new (_alloc)<br>
+          COFFDefinedAtom(*this, "", sectionName, Atom::scopeTranslationUnit,<br>
+                          type, perms, _merge[section], data, 0);<br>
       atoms.push_back(atom);<br>
       _definedAtomLocations[section][0] = atom;<br>
       return error_code::success();<br>
@@ -440,9 +440,9 @@ private:<br>
     if (symbols[0]->Value != 0) {<br>
       uint64_t size = symbols[0]->Value;<br>
       ArrayRef<uint8_t> data(secData.data(), size);<br>
-      auto *atom = new (_alloc) COFFDefinedAtom(<br>
-          *this, "", sectionName, Atom::scopeTranslationUnit, type, perms,<br>
-          _merge[section], data, ++ordinal);<br>
+      auto *atom = new (_alloc)<br>
+          COFFDefinedAtom(*this, "", sectionName, Atom::scopeTranslationUnit,<br>
+                          type, perms, _merge[section], data, ++ordinal);<br>
       atoms.push_back(atom);<br>
       _definedAtomLocations[section][0] = atom;<br>
     }<br>
@@ -450,13 +450,12 @@ private:<br>
     for (auto si = symbols.begin(), se = symbols.end(); si != se; ++si) {<br>
       const uint8_t *start = secData.data() + (*si)->Value;<br>
       // if this is the last symbol, take up the remaining data.<br>
-      const uint8_t *end = (si + 1 == se)<br>
-          ? secData.data() + secData.size()<br>
-          : secData.data() + (*(si + 1))->Value;<br>
+      const uint8_t *end = (si + 1 == se) ? secData.data() + secData.size()<br>
+                                          : secData.data() + (*(si + 1))->Value;<br>
       ArrayRef<uint8_t> data(start, end);<br>
-      auto *atom = new (_alloc) COFFDefinedAtom(<br>
-          *this, _symbolName[*si], sectionName, getScope(*si), type, perms,<br>
-          _merge[section], data, ++ordinal);<br>
+      auto *atom = new (_alloc)<br>
+          COFFDefinedAtom(*this, _symbolName[*si], sectionName, getScope(*si),<br>
+                          type, perms, _merge[section], data, ++ordinal);<br>
       atoms.push_back(atom);<br>
       _symbolAtom[*si] = atom;<br>
       _definedAtomLocations[section][(*si)->Value] = atom;<br>
@@ -583,7 +582,8 @@ private:<br>
         return error_code::success();<br>
       }<br>
     }<br>
-    // Section was not found, but it's not an error. This method returns an error<br>
+    // Section was not found, but it's not an error. This method returns an<br>
+    // error<br>
     // only when there's a read error.<br>
     return error_code::success();<br>
   }<br>
@@ -643,15 +643,15 @@ private:<br>
   std::map<const coff_symbol *, const coff_symbol *> _auxSymbol;<br>
<br>
   // A map from section to its atoms.<br>
-  std::map<const coff_section *, vector<COFFDefinedFileAtom *>> _sectionAtoms;<br>
+  std::map<const coff_section *, vector<COFFDefinedFileAtom *> > _sectionAtoms;<br>
<br>
   // A map to get whether the section allows its contents to be merged or not.<br>
   std::map<const coff_section *, DefinedAtom::Merge> _merge;<br>
<br>
   // A sorted map to find an atom from a section and an offset within<br>
   // the section.<br>
-  std::map<const coff_section *,<br>
-           std::map<uint32_t, COFFDefinedAtom *>> _definedAtomLocations;<br>
+  std::map<const coff_section *, std::map<uint32_t, COFFDefinedAtom *> ><br>
+  _definedAtomLocations;<br>
<br>
   mutable llvm::BumpPtrAllocator _alloc;<br>
   const PECOFFLinkingContext &_context;<br>
@@ -677,8 +677,9 @@ public:<br>
         _PECOFFLinkingContext(context) {}<br>
<br>
   error_code parseFile(LinkerInput &input,<br>
-                       std::vector<std::unique_ptr<File>> &result) const {<br>
-    StringRef magic(input.getBuffer().getBufferStart(), input.getBuffer().getBufferSize());<br>
+                       std::vector<std::unique_ptr<File> > &result) const {<br>
+    StringRef magic(input.getBuffer().getBufferStart(),<br>
+                    input.getBuffer().getBufferSize());<br>
     llvm::sys::fs::file_magic fileType = llvm::sys::fs::identify_magic(magic);<br>
     if (fileType == llvm::sys::fs::file_magic::archive)<br>
       return _readerArchive.parseFile(input, result);<br>
@@ -702,7 +703,7 @@ private:<br>
<br>
     // Split the string into tokens, as the shell would do for argv.<br>
     SmallVector<const char *, 16> tokens;<br>
-    tokens.push_back("link");  // argv[0] is the command name. Will be ignored.<br>
+    tokens.push_back("link"); // argv[0] is the command name. Will be ignored.<br>
     llvm::cl::TokenizeWindowsCommandLine(directives, _stringSaver, tokens);<br>
     tokens.push_back(nullptr);<br>
<br>
@@ -712,14 +713,14 @@ private:<br>
     const char **argv = &tokens[0];<br>
     std::string errorMessage;<br>
     llvm::raw_string_ostream stream(errorMessage);<br>
-    bool parseFailed = WinLinkDriver::parse(<br>
-        argc, argv, _PECOFFLinkingContext, stream, /*isDirective*/true);<br>
+    bool parseFailed = WinLinkDriver::parse(argc, argv, _PECOFFLinkingContext,<br>
+                                            stream, /*isDirective*/ true);<br>
     stream.flush();<br>
<br>
     // Print error message if error.<br>
     if (parseFailed) {<br>
-      auto msg = Twine("Failed to parse '") + directives + "': "<br>
-          + errorMessage + "\n";<br>
+      auto msg =<br>
+          Twine("Failed to parse '") + directives + "': " + errorMessage + "\n";<br>
       llvm::report_fatal_error(msg);<br>
     }<br>
     if (!errorMessage.empty()) {<br>
@@ -728,7 +729,7 @@ private:<br>
   }<br>
<br>
   error_code parseCOFFFile(std::unique_ptr<MemoryBuffer> &mb,<br>
-                           std::vector<std::unique_ptr<File>> &result) const {<br>
+                           std::vector<std::unique_ptr<File> > &result) const {<br>
     // Parse the memory buffer as PECOFF file.<br>
     error_code ec;<br>
     std::unique_ptr<FileCOFF> file(<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</blockquote></div><br></div>