164 Commits

Author SHA1 Message Date
Axel Naumann
f507a8da1b Rename public value printer function to cling::printValue. 2013-05-15 11:43:12 +02:00
Vassil Vassilev
782d2568ea Factor our common functionality and replace CreateTypeSourceInfo with getTrivialTypeSourceInfo.
git-svn-id: http://root.cern.ch/svn/root/trunk@49347 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-25 12:48:15 +00:00
Axel Naumann
70695fe2be Update to clang/llvm r179269 (llvm vendor branch r49215):
Parser::Scope versus Sema::DeclContext are now checked for cross-vailidity.
Emit the TU-transaction explicitly instead of relying on a first transaction.
The typename extraction now takes a stream instead of a string to write to.
The llvm::Linker has much reduced functionality; use llvm::sys::Path instead to find dynamic libraries.


git-svn-id: http://root.cern.ch/svn/root/trunk@49325 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 16:28:08 +00:00
Vassil Vassilev
343a649e42 Reorder enum. Add enum constant for the size, fix a wrong condition in an assert.
git-svn-id: http://root.cern.ch/svn/root/trunk@49320 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 15:04:09 +00:00
Vassil Vassilev
5e47631c1c Check whether the begun transaction is the one being committed.
git-svn-id: http://root.cern.ch/svn/root/trunk@49315 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 12:53:08 +00:00
Vassil Vassilev
a02f334f7f Don't be too harsh if somebody asks for the last nested transaction.
git-svn-id: http://root.cern.ch/svn/root/trunk@49314 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 12:52:07 +00:00
Vassil Vassilev
852606b028 Reuse the empty nested transactions too.
git-svn-id: http://root.cern.ch/svn/root/trunk@49307 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 09:57:30 +00:00
Vassil Vassilev
2d770ce24c Move resetting of the transaction in the transaction itself.
git-svn-id: http://root.cern.ch/svn/root/trunk@49303 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 09:06:58 +00:00
Vassil Vassilev
0fac9d5de3 Empty is a transaction with no decls and no nested transactions.
git-svn-id: http://root.cern.ch/svn/root/trunk@49302 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 08:51:27 +00:00
Vassil Vassilev
8817cef9ca Reduce the creation of empty top-most transactions. Instead if the last
transaction was empty just reuse it.


git-svn-id: http://root.cern.ch/svn/root/trunk@49301 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-24 06:55:38 +00:00
Vassil Vassilev
ec7bc1e519 Move the set of llvm::Module from the Transaction ctor to commitTransaction.
git-svn-id: http://root.cern.ch/svn/root/trunk@49295 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-23 21:36:41 +00:00
Axel Naumann
48b4a4e934 For Decls coming from a parsed file that describes the content of a library:
the callbacks must be triggered for those, too.
As they are not part of a transaction (think "module") they are now sent to the deserialization listener.
This can be removed once the modules work.

Set the state of the transaction to Committing before the static init - which might trigger more decls even though CodeGen has been run over the decls.

Forward DeclCollector::HandleInterestingDecl() to DeclCollector::HandleTopLevelDecl() for decls from the AST reader / from headers describing libraries.

Empty transactions must be passed to TCling; they trigger the sending of deserialized decls to ROOT/Meta.

Don't start TCling's artificial TU Transaction if the transaction coming in is empty - we need a decl to get the ASTContext.

Swap the deserialized decls before handling them in TCling, such that nested calls don't see the same decls again.


git-svn-id: http://root.cern.ch/svn/root/trunk@49197 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-10 15:15:49 +00:00
Vassil Vassilev
3ce238085f Reorder: put the nested transaction container right after the decl container.
git-svn-id: http://root.cern.ch/svn/root/trunk@49140 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-09 08:55:54 +00:00
Vassil Vassilev
4760be34eb Remove redundant method. Improve style.
git-svn-id: http://root.cern.ch/svn/root/trunk@49138 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-09 08:44:51 +00:00
Vassil Vassilev
564659c170 Fix a misnomer.
git-svn-id: http://root.cern.ch/svn/root/trunk@49125 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-08 14:35:35 +00:00
Vassil Vassilev
df0dc16c07 Make cling::Transaction cheaper to construct. Lazy-create the container of the
nested transactions. 

Now sizeof(cling::Transaction()) == 56.


git-svn-id: http://root.cern.ch/svn/root/trunk@49124 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-08 14:27:57 +00:00
Axel Naumann
a91112365b Add documentation!
git-svn-id: http://root.cern.ch/svn/root/trunk@49105 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-05 21:55:12 +00:00
Axel Naumann
2e153295ff Make the default compilation options compatible with a compiler.
Add comparison ops: I needed them for a dead end and now I have them and the compiler won't generate its own.


git-svn-id: http://root.cern.ch/svn/root/trunk@49101 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-05 15:10:05 +00:00
Axel Naumann
8c680be610 Implement hasFunction().
Rephrase !(a==b).

This file still needs major refactoring to remove code duplication.


git-svn-id: http://root.cern.ch/svn/root/trunk@49099 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-05 13:50:01 +00:00
Axel Naumann
89d418feb6 Remove Completed flag; integrated it into state:
collecting->completed->committing->committed
Make m_DeclQueue lazily allocated to reduce sizeof(Transaction) in an effort to make the TransactionRAII cheaper - second part is coming up.
Remove unused thus unneeded and annoying (non-const) iterator interfaces; they clash with the constness of the EmptyQueue.


git-svn-id: http://root.cern.ch/svn/root/trunk@49097 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-05 13:43:01 +00:00
Axel Naumann
ce0752f698 Rename state kUnknown to kCollecting.
Implement Transaction::printStructure().
Remove unnecessary non-const overload of getWrapperFD().


git-svn-id: http://root.cern.ch/svn/root/trunk@49095 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-05 13:12:57 +00:00
Vassil Vassilev
1e8aee2da4 Resurrect the trunk:
The issue is that sometimes we don't have a begun transaction. This can happen
mostly in cases when the code doesn't come from text representation but:
  * From lookup, where template is being instantiated
  * From a PCH/PCM, where a decl was deserialized.

This patch solves the first case: When we do findScope we have to instantiate
the declaration if needed.
Every time there is a chance that generated code's declarations can be orphaned,
we have to explicitly push a transaction so that we can keep the integrity.


git-svn-id: http://root.cern.ch/svn/root/trunk@49070 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-03 16:25:08 +00:00
Vassil Vassilev
2b054ac81d Remove files from cling's trunk. They are in clang's mainline and our vendor drop.
git-svn-id: http://root.cern.ch/svn/root/trunk@49069 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-03 14:55:23 +00:00
Axel Naumann
8389c5b1e1 Merge development from branches/dev/root6-pch into the trunk: enable PCH for ROOT.
git-svn-id: http://root.cern.ch/svn/root/trunk@48958 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-27 18:07:03 +00:00
Axel Naumann
4a0c1c6e1f Merge with trunk, r48857 - r48937.
git-svn-id: http://root.cern.ch/svn/root/branches/dev/root6-pch@48938 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-26 15:23:24 +00:00
Vassil Vassilev
25e1924b5f *Lay the foundation of return by-value support.
Some functions return temporary objects. Eg:

  std::string getName() {
    return "ROOT";
  }

  In that case the lifetime of the temporary variable is defined by the caller. 
  Such function called by TClingCallFunc would cause undefined behaviour, because
  there is no actual caller and the compiler cannot define any lifetime. 

  In order to provide such concept we have implemented cling::StoredValueRef, which
  is a reference counted cling::Value. As long as somebody "has" a copy of it, the
  boxed value (and the occupied memory) will live.

  However cling::Value and cling::StoredValueRef expose LLVM/clang/cling internals
  to ROOT. We want to avoid for now exposing LLVM/clang/cling internals, so we have
  TInterpreterValue, which makes cling::StoredValueRef opaque.

*New interface taking TInterpreterValue is added to the TInterpreter to allow the
users to manage the lifetime of the returned temporaries.

*Replace the occurrances of cling::Value with cling::StoredValueRef to avoid 
any lifetime management issues.

*Minor optimizations of the existing implementation

*Tweaks to the build system so that TInterpreterValue.cxx could 
#include cling/Interpreter/StoredValueRef.h

PLEASE NOTE: This is not the final implementation it needs polishing. Eg. there
is a bug that should be fixed soon, which doesn't allow to get the actual result
out of the TInterpreterValue.


git-svn-id: http://root.cern.ch/svn/root/trunk@48895 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-18 21:30:00 +00:00
Fons Rademakers
a3cb06c5e6 Fixes for compiling with C++11 and libcxx on OSX.
git-svn-id: http://root.cern.ch/svn/root/trunk@48886 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-17 13:31:45 +00:00
Axel Naumann
0de0164c3f Add a deserialization listener: we do not receive all decls through the ASTConsumer interface.
git-svn-id: http://root.cern.ch/svn/root/branches/dev/root6-pch@48864 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-13 09:26:55 +00:00
Axel Naumann
77ba6929b0 v5 of patches.
Remaining:
* callfunc issues finding functions
* vtable issues (likely related)
* in stressHistogram: Test  3: Projection with Range for Histograms and Profiles................OK
  Error in <TStreamerInfo::Build>: TProfile, unknown type: EErrorType fErrorMode


git-svn-id: http://root.cern.ch/svn/root/branches/dev/root6-pch@48858 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-11 13:11:15 +00:00
Axel Naumann
5408532f3b Don't expose DynamicLookupRuntimeUniverse.h to G__Meta.o (missing symbol gCling).
Reshuffle gCling; definition is now provided by the Interpreter internally, not in any header.
This will cause missing symbols in libraries instead of silently creating dumplicated (JIT / library).
Still requires Vassil to add a parameter to LifetimeHandler() - but this will cause a cling test failure as a reminder.


git-svn-id: http://root.cern.ch/svn/root/trunk@48817 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-05 17:03:49 +00:00
Vassil Vassilev
e6a53da83d Add documentation and silence doxygen warning.
git-svn-id: http://root.cern.ch/svn/root/trunk@48812 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-05 11:18:59 +00:00
Vassil Vassilev
12a6b029e3 Typo.
git-svn-id: http://root.cern.ch/svn/root/trunk@48762 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-28 10:03:29 +00:00
Axel Naumann
1acbc2d486 GenericValue::op= is smart; it takes *this into account.
That won't work for construction; so replace with placement new.
Also need default c'tor for Value() to initialize m_GV correctly.


git-svn-id: http://root.cern.ch/svn/root/trunk@48709 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-26 11:14:05 +00:00
Axel Naumann
46bd172859 Add proper include guard.
This header gets included by enabling dynamic lookup, and by RegisterModule() of G__Meta.
We need the latter for the many-pcm case.


git-svn-id: http://root.cern.ch/svn/root/trunk@48703 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-26 09:46:50 +00:00
Axel Naumann
b364112d1d Don't expose SmallVector (which needs DataTypes.h).
Use vector instead.


git-svn-id: http://root.cern.ch/svn/root/trunk@48691 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-25 15:54:36 +00:00
Axel Naumann
5279835d41 Add explicit copy c'tor + assign op so no uninit memory gets copied.
git-svn-id: http://root.cern.ch/svn/root/trunk@48689 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-25 15:20:49 +00:00
Axel Naumann
9d69f41211 Move llvm::sys::DynamicLibrary out of the Interpreter header.
git-svn-id: http://root.cern.ch/svn/root/trunk@48685 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-25 13:38:54 +00:00
Axel Naumann
c835d37455 Don't store Paths but strings. Reduces dependencies.
git-svn-id: http://root.cern.ch/svn/root/trunk@48683 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-25 13:14:24 +00:00
Axel Naumann
664e8b22ac Reduce the amount of headers needed by the dynamic scopes at runtime:
* Make GenericValue, clang::QualType opaque in Value
* Move LifetimeHandler implementation into source; requires separate header
* 

Also:
* Value: replace CPP macros by overloads


git-svn-id: http://root.cern.ch/svn/root/trunk@48675 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-22 15:59:54 +00:00
Axel Naumann
e0397a6d4c Be specific about which gCling we are talking about (ROOT has its own...)
git-svn-id: http://root.cern.ch/svn/root/trunk@48667 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-21 17:34:59 +00:00
Vassil Vassilev
3bcfc8b25e Prepare dynamic scopes for integration in ROOT;
* Merge the DynamicIDHandler into InterpreterCallbacks. The DynamicIDHandler was
used to define the failed lookup names as dependent, so that later on they could
be "healed" by the EvaluateTSynthesizer - by generating a call to gCling->EvaluateT...

* Add a flag in the InterpreterCallbacks giving a hint when the failed lookup is
performed - during compilation time or during evaluation type, maybe its name is
misnomer. Maybe I should rename it to IsInRuntimeEvalMode or smth like that...

* Simplify the evaluation routine. The idea is to be merged with one of the 
existing - either echo or evaluate

* Implement proper mock object as test dynamic symbol resolver callback. Now it
fully relies on InterpreterCallbacks.

* Implement dynamic expression node marking. Every node that needs runtime 
resolution is marked as dependent. However, clang marks other nodes as dependent,
too (eg. templates). Until now it was very difficult to distinguish between both.
Now every "artificially" (marked by us) node's declaration is annotated so that 
it could be found back easily by using a simple RecursiveASTVisitor.

Generally we have two issues when using dynamic scopes - filtering the failed 
lookups that need to be evaluated at runtime, and filtering the "artificially"
marked as dependent dynamic nodes/decls. Whereas the second issue is solved by
using the annotations, the first one is more tricky to solve because clang doesn't
give us enough information to conclude what should be done. For now I have 
narrowed down the cases so that dynamic nodes can appear only in function decls.


git-svn-id: http://root.cern.ch/svn/root/trunk@48575 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-14 17:29:30 +00:00
Vassil Vassilev
ca634731e2 Tabs.
git-svn-id: http://root.cern.ch/svn/root/trunk@48569 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-14 11:36:41 +00:00
Vassil Vassilev
729b170788 Enrich the implementaion of Interpreter::mangleName, make it public and rename it
to maybeMangleDeclName (which is more talkative).
Use Interpreter::maybeMangleDeclName instead of duplicating code.


git-svn-id: http://root.cern.ch/svn/root/trunk@48545 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-12 15:38:44 +00:00
Vassil Vassilev
7abc2a8334 Add support in TClingCallFunc for calling virtual functions: when we have a
CallFunc representation of a member function, we have its concrete address, and
if there is derived class there is no way how to evaluate the vtable and call the
correct virtual.

In order to evaluate the member's vtable, we either have to calculate it (which
is platform/implementation dependent) or create a trampoline function which calls
the target function. Thus codegen will generate code for vtable evaluation. The
trampolines are created for functions that could be possibly virtual - non-static
member functions, declared as virutal. A trampoline looks like this:

void unique_name(Base* This, MyClass2* a, MyClass3* b, double c, MyClass* ret) {
  if (ret) 
    *ret = This->function(*a, *b, c);
  else 
    This->function(*a, *b, c);
}

where we pass in explicitly the address that CallFunc is given (This), followed
by set of arguments (possibly needing conversion) and if the target is non-void
a last argument that is used to provide a storage for the return result.

The given arguments and the required by *LLVM* IR may differ - in that case 
simple argument conversions are done. For now primary pointers and builtins, which
covers pretty much entire LLVM type system.

Note that the first implementation is very rough and suboptimal, however it is 
very good starting point (milestone):
* Common code is extracted out in its separate routines (here a lot of refactoring more
could be done).
* cling::Value now stores besides clang::QualType, describing (soft-of inaccurately)
the llvm::GenericValue, LLVM-type which is the actual description of the generic value.
* cling::Value naming conventions improved;
* cling::Interpreter::getLLVMType is added temporarily and soon will be removed.

* TClingCallFunc now preallocates space for the this ptr and the return result.
(instead of multiple array copies)
* TClingCallFunc now stores not llvm::GenericValues but cling::StoredValueRefs
because the type conversions need llvm::GenericValue's description (which 
essentially is the type).
* Does better default argument evaluation: it could be even *more betterer* if
we query Sema to fold for us the constant expressions instead of decompiling them
to source and using cling for evaluation.
* Return storage implemented.


And, yes that is the longest commit message in my life...
Implementation of argument conversion is revised.


git-svn-id: http://root.cern.ch/svn/root/trunk@48537 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-11 17:30:03 +00:00
Vassil Vassilev
d14cab524a Add TODO.
git-svn-id: http://root.cern.ch/svn/root/trunk@48536 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-11 17:03:50 +00:00
Vassil Vassilev
7832135a63 * Move the check whether a symbol is dynamic from the testsuite to the "mainline".
* Add the dynamic ID handler, responsible for the dynamic scopes, as ExternalSemaSoruce
for the TClingCallbacks. 

From here on we don't know how many tests will fail due to that.
I might end up reverting it if they are too many.


git-svn-id: http://root.cern.ch/svn/root/trunk@48529 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-11 13:19:55 +00:00
Vassil Vassilev
8c2ccd177f Move the DynamicIDHandler into separate source file so that it could be used while
implementing custom interpreter callbacks.


git-svn-id: http://root.cern.ch/svn/root/trunk@48527 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-11 12:55:01 +00:00
Paul Russo
1737ff69c7 Change TCling::ResetGlobals() to invoke the global destructors.
This fixes roottest workaround ClingWorkAroundIncorrectTearDownOrder.


git-svn-id: http://root.cern.ch/svn/root/trunk@48514 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-08 18:11:36 +00:00
Vassil Vassilev
5bbb8c2aba Implement the autoloading for ROOT_MODULES.
git-svn-id: http://root.cern.ch/svn/root/trunk@48385 27541ba8-7e3a-0410-8455-c3a389f83636
2013-01-23 14:41:15 +00:00
Vassil Vassilev
1ae610b211 Fix savannah #99234.
The issue we experienced is that we couldn't pipe the output in the terminal.
The reason is that we were using llvm::outs() which closes explicitly the file
descriptor (thanks Axel for the help debugging).
We introduce our custom stream, which keeps the file descriptor open so that
we can use it in pipes. For debugging purposes, however we use/should use llvm::errs()

The lesson learned:
DONT USE LLVM::OUTS() ANYMORE!


git-svn-id: http://root.cern.ch/svn/root/trunk@48316 27541ba8-7e3a-0410-8455-c3a389f83636
2013-01-17 15:27:14 +00:00