Hi Eli, Let's say I have a file ClassA.h, that pairs with a file ClassA.cpp to product a library libClassA.a. ClassA.h contains the single declaration. class A {...}; I want to transform it to: #include "ClassB.h" class A : public class B {...}; ClassB.h is the header file for a library libClassB.a built from ClassB.cpp and ClassB.h. I can clearly link libClassB with libClassA. But how can I bring in the header file so that it's declarations will be known in ClassA.h. Remember this is happening during a pass. Thanks, David On Mon, Jul 6, 2009 at 12:48 AM, Eli Friedman <eli.friedman at gmail.com>wrote:> On Sun, Jul 5, 2009 at 1:16 PM, David Minor<dahvid.minor at gmail.com> wrote: > > I'm writing a code transformation that involves adding an include to > > existing code, adding a base class > > to and existing class and then linking with a previously compiled > library. > > The main problem for me > > seems to be how can I add the include? Can I compile the include alone > to > > byte code and pre-pend it? > > Should I compile the library, which includes the include and parse out > the > > include and pre-pend it? > > Am I missing something fundamental here? > > If you want to add additional bitcode to an existing bitcode file, you > can link them together with llvm-link (or the equivalent C++ API > calls). Beyond that, I'm not following what you're trying to do. > > -Eli > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090707/86892a6b/attachment.html>
On Tue, Jul 7, 2009 at 1:42 AM, David Minor<dahvid.minor at gmail.com> wrote:> Hi Eli, > Let's say I have a file ClassA.h, that pairs with a file ClassA.cpp > to product a library libClassA.a. > ClassA.h contains the single declaration. > > class A {...}; > > I want to transform it to: > > #include "ClassB.h" > > class A : public class B {...}; > > ClassB.h is the header file for a library libClassB.a built from ClassB.cpp > and ClassB.h. > I can clearly link libClassB with libClassA. But how can I bring in the > header file so that it's declarations will be known in ClassA.h. Remember > this is happening during a pass.You have to rebuild libClassA.a from scratch; the generation of bitcode makes too many hard-coded assumptions about the layout of classes to manipulate the bitcode accurately. -Eli
I see, Adding includes is trivial even w/o llvm, but the real problem here is manipulation of classes, if I understand you correctly adding an inheritee wouldn't be possible. David On Tue, Jul 7, 2009 at 12:43 PM, Eli Friedman <eli.friedman at gmail.com>wrote:> On Tue, Jul 7, 2009 at 1:42 AM, David Minor<dahvid.minor at gmail.com> wrote: > > Hi Eli, > > Let's say I have a file ClassA.h, that pairs with a file ClassA.cpp > > to product a library libClassA.a. > > ClassA.h contains the single declaration. > > > > class A {...}; > > > > I want to transform it to: > > > > #include "ClassB.h" > > > > class A : public class B {...}; > > > > ClassB.h is the header file for a library libClassB.a built from > ClassB.cpp > > and ClassB.h. > > I can clearly link libClassB with libClassA. But how can I bring in the > > header file so that it's declarations will be known in ClassA.h. > Remember > > this is happening during a pass. > > You have to rebuild libClassA.a from scratch; the generation of > bitcode makes too many hard-coded assumptions about the layout of > classes to manipulate the bitcode accurately. > > -Eli > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090708/c6df31a8/attachment.html>