<div dir="ltr"><div>On Thu, Feb 12, 2015 at 6:50 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Rui,<br>
<br>
Unfortunately types are visible only within the class.<br>
<br>
Example :-<br>
<br>
class A {<br>
public:<br>
  typedef int MyType;<br>
  MyType foo();<br>
};<br>
<br>
MyType A::foo() {<br>
  return 0;<br>
}<br>
<br>
int main() {<br>
  A a;<br>
  a.foo();<br>
}<br>
<br>
1.cpp:7:1: error: unknown type name 'MyType'; did you mean 'A::MyType'?<br>
MyType A::foo() {<br>
<br>
I wanted to only return a range than giving full access to the data structure outside the class.<br></blockquote><div><br></div><div>You are not going to give a full access. I suggested returning a const reference.</div><div><br></div><div>Actually I think returning a range for a set is bad. The whole point of using set here is because it's a set -- you want to check whether a symbol is a member of the set or not. Because you return only the iterator, you cannot call count() on it. You made O(1) to O(n).</div><div><br></div><div>I don't think we need something tricky here. Let's just return a const reference to the field.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Shankar Easwaran<div><div><br>
<br>
On 2/12/2015 5:55 PM, Rui Ueyama wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Feb 12, 2015 at 2:37 PM, Shankar Easwaran <<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: shankare<br>
Date: Thu Feb 12 16:37:27 2015<br>
New Revision: 228968<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228968&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=228968&view=rev</a><br>
Log:<br>
[ELF] Insert wrap symbols into a set.<br>
<br>
Symbols specified by --wrap was being inserted into a vector, change this<br>
to<br>
insert into a set, so that we have unique entries.<br>
<br>
Modified:<br>
     lld/trunk/include/lld/<u></u>ReaderWriter/<u></u>ELFLinkingContext.h<br>
     lld/trunk/lib/ReaderWriter/<u></u>ELF/ELFLinkingContext.cpp<br>
     lld/trunk/test/elf/wrap.test<br>
<br>
Modified: lld/trunk/include/lld/<u></u>ReaderWriter/<u></u>ELFLinkingContext.h<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=228968&r1=228967&r2=228968&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/include/lld/<u></u>ReaderWriter/<u></u>ELFLinkingContext.h?rev=<u></u>228968&r1=228967&r2=228968&<u></u>view=diff</a><br>
<br>
==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/include/lld/<u></u>ReaderWriter/<u></u>ELFLinkingContext.h (original)<br>
+++ lld/trunk/include/lld/<u></u>ReaderWriter/<u></u>ELFLinkingContext.h Thu Feb 12<br>
16:37:27 2015<br>
@@ -24,6 +24,7 @@<br>
  #include "llvm/Support/ELF.h"<br>
  #include <map><br>
  #include <memory><br>
+#include <set><br>
<br>
  namespace lld {<br>
  class DefinedAtom;<br>
@@ -47,6 +48,7 @@ public:<br>
<br>
  class ELFLinkingContext : public LinkingContext {<br>
  public:<br>
+  typedef std::set<StringRef>::iterator StringRefSetIterT;<br>
<br>
</blockquote>
You defined StringSetIterT and<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    /// \brief The type of ELF executable that the linker<br>
    /// creates.<br>
@@ -305,7 +307,7 @@ public:<br>
    // --wrap option.<br>
    void addWrapForSymbol(StringRef);<br>
<br>
-  StringRefVector wrapCalls() const;<br>
+  range<std::set<StringRef>::<u></u>iterator> wrapCalls() const;<br>
<br>
  private:<br>
    ELFLinkingContext() LLVM_DELETED_FUNCTION;<br>
@@ -346,7 +348,7 @@ protected:<br>
    StringRef _soname;<br>
    StringRefVector _rpathList;<br>
    StringRefVector _rpathLinkList;<br>
-  StringRefVector _wrapCalls;<br>
+  std::set<StringRef> _wrapCalls;<br>
    std::map<std::string, uint64_t> _absoluteSymbols;<br>
    llvm::StringSet<> _dynamicallyExportedSymbols;<br>
    std::vector<std::unique_ptr<<u></u>script::Parser>> _scripts;<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/<u></u>ELF/ELFLinkingContext.cpp<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=228968&r1=228967&r2=228968&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/lib/<u></u>ReaderWriter/ELF/<u></u>ELFLinkingContext.cpp?rev=<u></u>228968&r1=228967&r2=228968&<u></u>view=diff</a><br>
<br>
==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/lib/ReaderWriter/<u></u>ELF/ELFLinkingContext.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/<u></u>ELF/ELFLinkingContext.cpp Thu Feb 12<br>
16:37:27 2015<br>
@@ -258,10 +258,11 @@ std::string ELFLinkingContext::demangle(<br>
<br>
  // Support --wrap option.<br>
  void ELFLinkingContext::<u></u>addWrapForSymbol(StringRef symbol) {<br>
-  _wrapCalls.push_back(symbol);<br>
+  _wrapCalls.insert(symbol);<br>
  }<br>
<br>
-ELFLinkingContext::<u></u>StringRefVector ELFLinkingContext::wrapCalls() const {<br>
+range<ELFLinkingContext::<u></u>StringRefSetIterT><br>
<br>
</blockquote>
use that here with range<>. Is this needed? Why don't you just return const<br>
std::set<StringRef> & from this function?<br>
<br>
+ELFLinkingContext::wrapCalls(<u></u>) const {<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    return _wrapCalls;<br>
  }<br>
<br>
<br>
Modified: lld/trunk/test/elf/wrap.test<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/wrap.test?rev=228968&r1=228967&r2=228968&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lld/trunk/test/elf/<u></u>wrap.test?rev=228968&r1=<u></u>228967&r2=228968&view=diff</a><br>
<br>
==============================<u></u>==============================<u></u>==================<br>
--- lld/trunk/test/elf/wrap.test (original)<br>
+++ lld/trunk/test/elf/wrap.test Thu Feb 12 16:37:27 2015<br>
@@ -26,9 +26,9 @@<br>
  #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.wrapfoo.o<br>
  #RUN: yaml2obj -format=elf -docnum 3 %s -o %t.realfoo.o<br>
  #RUN: lld -flavor gnu -target x86_64 %t.main.o %t.wrapfoo.o %t.realfoo.o \<br>
-#RUN: --wrap foo --noinhibit-exec --output-filetype=yaml -o %t2.out<br>
+#RUN: --wrap foo --wrap foo --noinhibit-exec --output-filetype=yaml -o<br>
%t2.out<br>
  #RUN: lld -flavor gnu -target x86_64 %t.main.o %t.wrapfoo.o  \<br>
-#RUN: --wrap foo --noinhibit-exec --output-filetype=yaml -o %t2.out.undef<br>
2>&1 |  \<br>
+#RUN: --wrap foo --wrap foo --noinhibit-exec --output-filetype=yaml -o<br>
%t2.out.undef 2>&1 |  \<br>
  #RUN: FileCheck %s -check-prefix=CHECKUNDEF<br>
  #CHECKWRAP:  - name:            main<br>
  #CHECKWRAP:    references:<br>
<br>
<br>
______________________________<u></u>_________________<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/<u></u>mailman/listinfo/llvm-commits</a><br>
<br>
</blockquote></blockquote>
<br>
<br></div></div><span><font color="#888888">
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</font></span></blockquote></div><br></div></div>