Commit Graph

291 Commits

Author SHA1 Message Date
Axel Naumann
4dde17ab8e Functions are extern "C".
(cherry picked from commit c7caadda0902a0b5cf7194c584ffd3cc328827a1)
2013-12-06 15:36:00 +01:00
Axel Naumann
b4dea2cde6 Interpreter::compileFunction(): compile this function and give me its address.
(cherry picked from commit 04de3a90cddb2718dc263ee104854b5395bfd869)
2013-12-06 15:36:00 +01:00
Axel Naumann
67f5e5bf64 Add option to disable rollback. Handle missing ExecEngine. 2013-12-02 13:53:30 +01:00
CristinaCristescu
46f07198b0 Add comments and fix trailing spaces. 2013-11-25 13:56:01 +01:00
CristinaCristescu
85b4232729 Revert macro def for error recovery. 2013-11-25 13:56:01 +01:00
CristinaCristescu
0490caaa99 Macro recovery 2013-11-25 13:56:00 +01:00
Philippe Canal
0476b4d4dc Move '-Wno-ambiguous-member-template' from cling to CallFunc 2013-11-20 21:40:00 +01:00
Philippe Canal
ca1b4775d4 Disable Wambiguous-member-template.
In CallFunc we currently always (intentionally and somewhat necessarily)
always fully specify member function template, however this can lead to
an ambiguity with a class template.  For example in
roottest/cling/functionTemplate we get:

  input_line_171:3:15: warning: lookup of 'set' in member access expression is ambiguous; using member of 't'
        ((t*)obj)->set<int>(*(int*)args[0]);
                   ^
  /local2/pcanal/cint_working/rootcling/root/roottest/cling/functionTemplate/t.h:19:9: note: lookup in the object type 't' refers here
        void set(T targ) {
             ^
  /usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../include/c++/4.4.5/bits/stl_set.h:87:11: note: lookup from the current scope refers here
         class set
               ^
  This is an intention warning implemented in clang, see
  http://llvm.org/viewvc/llvm-project?view=revision&revision=105518

This fixes a failure in pythoncintrun in roottest/cling/functionTemplate.
2013-11-20 15:07:57 +01:00
Vassil Vassilev
7a4fcf39ed Make sure we call the dtor for the state object. 2013-11-14 15:24:02 +01:00
Axel Naumann
bd3c03cc17 80cols. 2013-10-31 14:43:56 +01:00
Vassil Vassilev
e6b54ae93a Remap only if not in -fsyntax-only. 2013-10-31 14:43:56 +01:00
Vassil Vassilev
4294b35b0c Remap the cxa_at_exit earlier.
The problem was that the remapping happened on the first executeFunction, which
was fine. Now that we have the Transaction's empty wrapper functions removed it's
not enough.

NOTE: that any decls coming within the RuntimeUniverse.h which need 'managed'
storage will still trigger the same problem.
2013-10-31 14:43:56 +01:00
Vassil Vassilev
ceb7eaf1fc Remove useless code. 2013-10-31 14:43:56 +01:00
Axel Naumann
4ec5d9380f Report if an absolute filename cannot be found. 2013-10-31 11:30:54 +01:00
Vassil Vassilev
0f6901e8b8 The transaction may not contain a wrapper. This may be due to the fact that if the wrapper was empty it is removed. Of course this should be asserted properly in future. 2013-10-29 20:19:27 +01:00
Vassil Vassilev
91c54bda2e Add more handy interface that takes a number of transactions to be rolled back. 2013-10-29 20:19:25 +01:00
Vassil Vassilev
dc410b73b8 Even in cases where the transaction was empty return success. 2013-10-29 20:19:20 +01:00
Vassil Vassilev
69eb1a59a6 Enforce integrity of getGlobalAddress, too. 2013-10-29 20:19:19 +01:00
Vassil Vassilev
5c3b327acc Compile might return empty transaction, i.e transaction with no decls.
Then we should cut off interpreting early.
2013-10-29 20:19:15 +01:00
Vassil Vassilev
f531e3d196 Add TODO. 2013-10-29 20:19:14 +01:00
Vassil Vassilev
aa5ae69f10 Make the function static. 2013-10-29 20:19:13 +01:00
Vassil Vassilev
f1e156daa4 Construct the mangle context upon each call. It is cheap to construct. And makes the call independent and static-ready :) 2013-10-29 20:19:12 +01:00
Vassil Vassilev
f0152f8772 Remove code duplication. 2013-10-29 20:19:10 +01:00
Vassil Vassilev
2872bc06d4 From me and Cristina: Fix removal of out-of-line definitions.
If we had:
struct MyClass {
  void f() {}
}
MyClass::f(){} // expected error redefinition of f.

In that case we would have tried to remove the lookup entry for the decl from
the primary decl context of the lexical decl context, which entry doesn't exist.
It is registered in the semantic decl context of the decl itself.
2013-10-16 16:37:58 +02:00
Vassil Vassilev
082f3feab4 Dump the llvm::Module too. 2013-10-14 09:11:40 +02:00
Vassil Vassilev
308de089be Compare the reverse so that the newer changes appear with + in the diff. 2013-10-14 09:11:40 +02:00
Vassil Vassilev
98c6a9d5bc The compare/store state can trigger deserialization. 2013-10-14 09:11:40 +02:00
Vassil Vassilev
f4fc65893c Send shutdown signal only when the ExecutionContext exists.
ExecutionContext doesn't exist in '-fsyntax-only' mode.
2013-10-14 09:11:40 +02:00
Vassil Vassilev
409324ef76 Implement shutdown action for the ExecutionContext.
When we tear down, the ExecutionContext must destroy all 'managed' addresses.
For example the LifetimeHandlers that came from the DynamicLookup. This needs
the interpreter to be in a 'sane' state, because they might call back the
Interpreter. For example gCling->execute("delete ...");
2013-10-14 09:11:39 +02:00
Axel Naumann
5706d4bdef Workaround broken JIT exceptions, use longjmp instead. 2013-10-03 09:54:00 +02:00
Axel Naumann
b62b5d7937 Combine include path -D; pass src and obj for LLVMDEV/ROOT; remove unused -Ds 2013-09-30 18:09:03 +02:00
Axel Naumann
68c8bb74e8 By Vassil: update to current llvm. 2013-09-26 17:54:19 +02:00
Axel Naumann
954b089b2f More Path fixes, remove dupe headers. 2013-09-26 17:54:19 +02:00
Axel Naumann
f4f518ba9c Remove more Paths. 2013-09-26 17:54:18 +02:00
Vassil Vassilev
f1a128f825 Reduce the amount of #included files. 2013-09-24 12:07:07 +02:00
Vassil Vassilev
9d87f9b56e Move dynamic library handling in separate class. 2013-09-24 12:07:05 +02:00
Vassil Vassilev
4f7a63f93d Lookup might trigger deserialization. 2013-09-20 10:12:57 +02:00
Vassil Vassilev
19181a1392 Move the ExecutionContext-specific parts from the Interpreter. 2013-09-20 10:12:57 +02:00
Vassil Vassilev
b4f912f8c5 We don't need to keep track of the .L-ed files. The implementation of TCling is very raw and I bet we can improve it a lot. 2013-09-18 20:33:06 +02:00
Vassil Vassilev
156e74b8dd Update references to the file. 2013-09-18 20:33:06 +02:00
Vassil Vassilev
6f569a1aaa Move the implementation in an interpreter-independent object.
We don't need the intepreter to store clang's state. We can use a separate object
for that which allows to be reused.

Provide *much* shorter and cleaner implementation.
2013-09-18 20:33:05 +02:00
Vassil Vassilev
408742eb71 80 Cols. 2013-09-13 15:18:56 +02:00
Vassil Vassilev
5c7a283759 Synthesizing if(DeclRefExpr) throw requires cling to be run with rtti.
Fix that problem by introducing an indirection - a compiled function that throws.
2013-09-11 23:11:57 +02:00
Vassil Vassilev
b4e0eca21f Add trampoline that will help avoid running without -no-rtti. 2013-09-11 23:11:57 +02:00
Vassil Vassilev
a204e40a01 Silence warnings for unused fields. 2013-09-10 17:04:55 +02:00
Vassil Vassilev
90a59ff3bc Comment out that unused variable until the new llvm import. 2013-09-10 17:04:55 +02:00
Vassil Vassilev
d057535f0a Add tmp prefix. 2013-09-10 11:43:57 +02:00
Vassil Vassilev
a779afdcc1 Don't use local type as template argument. 2013-09-07 12:26:52 +02:00
Jerome Beclin
afcd8a7cca Commit of storeState/compareState that now print lookup table and included files
Implementation of .files moved in the Interpreter.cpp

storeState now calls three functions: dumpAST(), dumpLookup(), printIncludedFiles().
compareState now calls three functions: compareAST(), compareLookup(), compareIncludedFiles().
It's working for the included files and the AST, and it needs a new patch for
being able to dump the lookup tables (we cannot use dumpLookups() for the moment).
2013-09-07 10:41:01 +02:00
Jerome Beclin
624354cfb4 Commit Interpreter.cpp with dumpLookupTable() function not working yet.
This will be fully operational after the LLVM/Clang update.
2013-09-07 10:41:00 +02:00
Vassil Vassilev
92ffc7afd7 Check if there were errors and only if there were not - run. 2013-09-01 16:52:53 +02:00
Vassil Vassilev
110fa5a460 Iterating over the AST might trigger deserialization. 2013-08-28 16:43:59 +02:00
Vassil Vassilev
f043c36192 Constify. 2013-08-28 16:43:59 +02:00
Vassil Vassilev
8c168320f0 Hide the callback adaptor classes in the implementation. 2013-08-22 13:50:56 +02:00
Jerome Beclin
ead0f8d091 Implement cling (clang) internal state verification.
There are cases where cling needs to 'rollback' its state to a previous one.
Examples for that are cling's error recovery and code unloading. This can become
easily tricky to implement. One step reducing the complexity is the verification
of the 'interesting' data structures.

Implement .storeState and .compareState commands, which dump the internal compiler
data structures like AST (implemented), included files (in progress) and lookup
tables (unimplemented yet). The information is dumped into a file and then that
file is diff-ed to the one taken with .compareState. If they were identical all
files are deleted otherwise a .diff file with the differences remains for debug.
2013-08-21 14:29:57 +02:00
Axel Naumann
3b64a6b98a Nobody but I sees dlsym handles const :-) Give in. 2013-08-21 14:06:58 +02:00
Axel Naumann
05f7752740 Make static; ROOT must call it before cling::Interpreter is created. 2013-08-21 14:06:57 +02:00
Axel Naumann
6cf9eba1d9 Add an interface for the ExecutionEngine to look at a RTLD_LOCAL library. 2013-08-21 14:06:57 +02:00
Axel Naumann
9b019990ea Keep a set of .so handles without creating a llvm::sys::DynamicLibarary for each
Symbol lookup happens through dlsym(0).
Handle 0, i.e. the program image, is the only DynamicLibrary that is created.
2013-08-21 14:06:55 +02:00
Vassil Vassilev
88cc4a1ed2 Implement autoloading of entities in unknown namespaces. Eg. MyNamespace::MyClass. The implementation is far from ideal, but for the timeline we have it is good enough. On a second iteration it could be improved a lot. 2013-08-21 10:54:51 +02:00
Philippe Canal
357182f857 To be consistent we need to mangle the destructor as the complete one.
This is what we already do with constructor and when we lookup and search
for destructor we want the actually destructor implementation not the
one which also does the delete.
2013-08-12 21:38:56 +02:00
Vassil Vassilev
aea73f5beb Simplify. 2013-08-07 17:58:56 +02:00
Vassil Vassilev
b202f00c12 We now keep track of the deserialized declarations in the transaction, because ROOT needs the callbacks to be fired on deserialized bunch of declarations.
Track down (almost) all places that might trigger deserialization of declarations
and wrap it with cling::PushTransactionRAII. I could solve it much more elegantly
by putting that RAII in the callback of the ExternalASTSource, but I wanted to be
verbose and denote all the places that trigger deserializations in ROOT. This
will help us in future optimize this code, because we want to deserialize as
rare as possible.

This should make roottest a bit happier.
2013-08-04 18:44:55 +02:00
Vassil Vassilev
3556a6cc13 Indents. 2013-08-02 17:34:56 +02:00
Vassil Vassilev
2bab03fa58 Use the transaction pool to reduce the number of transaction allocations. Add extra assertions. Simplify *a lot* the implementation. 2013-08-02 17:34:56 +02:00
Vassil Vassilev
f9fc521b89 Use the function that exists in the Interpreter class itself. 2013-08-02 17:34:56 +02:00
Vassil Vassilev
48984bc835 Simplify commitTransaction by moving the running of inits in the caller.
Temporarily we create a nested transaction instead of delegating that to the
caller to decide. This should be fixed soon.
2013-08-02 17:34:54 +02:00
Vassil Vassilev
32f1010977 Make if-checks asserts, because those cases are not expected anymore. 2013-08-02 17:34:54 +02:00
Vassil Vassilev
059b031f4d Simplify the code and enforce stricter rules. 2013-08-02 17:34:54 +02:00
Vassil Vassilev
fc7d1879da Replace Decl** with the more accurate Transaction**.
Add output Transaction parameter to Interpreter::parse.
2013-07-15 12:58:54 +02:00
Axel Naumann
0c74a310d8 Rebase to master/HEAD; split commitTransaction(); select needed parts in emitAllDecls(). 2013-06-28 00:33:17 +02:00
Axel Naumann
07ee17e09b Use new interface 2013-06-28 00:33:17 +02:00
Axel Naumann
a2bb0b2b46 codegen() really does emitAllDecls(); use new IncrementalParser interfaces. 2013-06-28 00:33:17 +02:00
Vassil Vassilev
0ff9231adc Don't set the module in Interpreter::codegen. This is leftover from the cherrypick. 2013-06-25 09:30:35 +02:00
Vassil Vassilev
0fbca300d4 When codegenning a transaction we must set the active module in codegen to the given one.
Add an assertion checking if there is codegen.
2013-06-25 09:30:32 +02:00
Vassil Vassilev
52c25a3f40 Construct execution context only if there is codegen enabled. 2013-06-25 09:30:32 +02:00
Axel Naumann
502afb5e91 Move codegen forcing to IncrementalParser, skip transformers and callbacks. 2013-06-21 09:27:56 +02:00
Vassil Vassilev
87a4b6bd63 From Baozeng: Add .printIR meta command, printing the llvm::Module. 2013-06-17 21:00:58 +02:00
Vassil Vassilev
e74e7655d0 Revert "Progress on the llvm multi-module support."
This reverts commit 9d78faef6a45cb16c05fe7a96d9e2eb9fb2c1298.
2013-06-05 16:26:51 +02:00
Vassil Vassilev
b1d11c2987 Progress on the llvm multi-module support.
Now we build a llvm::Module per cling::Transaction and link them in on commit.
2013-06-05 16:26:51 +02:00
Vassil Vassilev
312a24266e Ignore some diagnostics, even when we declare. 2013-05-24 10:41:03 +02:00
Vassil Vassilev
7476ebe7df They say merging was easy, then I am stupid. 2013-05-24 10:37:34 +02:00
Vassil Vassilev
052976bf88 endTransaction should take a transaction to be ended.
Parsing code in ROOT can lead to lookups which open a nested transactions. Ending
the current transaction in these cases is misleading because usually the
transaction that is expected to be ended is different.

Add an argument to endTransaction to disambiguate. Please note that this fixes
the regular cases of ROOT autoloading.

One of the remaining issues is autoloading of classes, which are passed in as
template arguments. The second remaining is autoloading of classes residing in
unnamed namespaces. Eg. MyNamespace::MyClass, where the diagnostic is issued upon
seeing that MyNamespace is unknown.
2013-04-27 01:52:55 +02:00
Axel Naumann
14c6595959 Update cling's patches to be relative to its LastKnownGood.
Simplify some of the patches by reverting some of the changed llvm / clang files to the original ones.


git-svn-id: http://root.cern.ch/svn/root/trunk@49363 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-26 11:45:17 +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
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
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
Axel Naumann
376aecc88b Remove stray include (that I didn't notice because my llvm install area still have the old files...)
git-svn-id: http://root.cern.ch/svn/root/trunk@49194 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-10 12:47:53 +00:00
Axel Naumann
5ce1193a62 Revert type_loweing patch, remove it.
Instead publish the single interface we actually need: ConvertType().
Add the corresponding patch.
This brings cling's clang much closer to the original, making the update a lot easier.


git-svn-id: http://root.cern.ch/svn/root/trunk@49192 27541ba8-7e3a-0410-8455-c3a389f83636
2013-04-10 11:52:26 +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
Axel Naumann
4daa80085f Simplify.
git-svn-id: http://root.cern.ch/svn/root/trunk@48985 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-28 14:34:42 +00:00
Axel Naumann
dc4f8a89e2 Process the trailing nested transaction of decls that were collected during the commit of the current transaction even if there are no callbacks.
Move CodeGenModule::Reset() to where the initializers are run to enforce the survival of the global inits until they are run.


git-svn-id: http://root.cern.ch/svn/root/trunk@48979 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-28 14:12: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
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
Vassil Vassilev
9bad1a3d72 Do not set the callbacks to 0 when the dynamic scopes are disabled.
git-svn-id: http://root.cern.ch/svn/root/trunk@48851 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-07 23:46:57 +00:00
Axel Naumann
1cbc4971a2 80 cols
git-svn-id: http://root.cern.ch/svn/root/trunk@48825 27541ba8-7e3a-0410-8455-c3a389f83636
2013-03-06 11:19: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
Axel Naumann
96b10954c4 Don't crash when emitting diagnostics during startup, but set up diag client before doing the runtime includes.
git-svn-id: http://root.cern.ch/svn/root/trunk@48732 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-27 15:05:21 +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
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
87356648fb Indentation, use using directive.
git-svn-id: http://root.cern.ch/svn/root/trunk@48684 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-25 13:15:35 +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
40ef9800f6 Try to load the header from a module, if that fails: include the header.
Fixes cling test suite.


git-svn-id: http://root.cern.ch/svn/root/trunk@48676 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-22 16:35:15 +00:00
Axel Naumann
fd45ec84c1 Don't create a variable of type __trigger__cxa_atexit; that's only needed for the header to convince the JIT to codegen its d'tor (it will create dupe symbols when compiling the dictionary otherwise).
Use loadModuleForHeader() for DynamicLookupRuntimeUniverse.h - we need to find a way to determine whether CodeGen needs to run on an include (i.e. whether it's from a PCM) or not.


git-svn-id: http://root.cern.ch/svn/root/trunk@48665 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-21 17:31:30 +00:00
Vassil Vassilev
a526b217e0 Explicit template instantiations should end up on the global scope.
Fixes: http://savannah.cern.ch/bugs/?100449


git-svn-id: http://root.cern.ch/svn/root/trunk@48618 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-18 13:22:39 +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
Philippe Canal
578fbe2a93 Disable the warning about uninitialized field when parsing a header from a module ... this avoid complaining about a (real) bug in QT headers
git-svn-id: http://root.cern.ch/svn/root/trunk@48572 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-14 17:10:38 +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
Philippe Canal
5895324cbb Add missing return statement
git-svn-id: http://root.cern.ch/svn/root/trunk@48520 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-08 20:46:52 +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
Axel Naumann
98960f8bb1 Add comment explaining read size of 512 bytes for file magic determination.
git-svn-id: http://root.cern.ch/svn/root/trunk@48501 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-07 13:14:26 +00:00
Axel Naumann
8bdaaf26a7 From Bertrand: fixes for cygwin.
* The PE magic is not within the first 64 bytes (only the DOS "MK" is); need to read more to identify DLLs.
* Use Windows's EnumProcessModules() even on cygwin to enumerate the loaded libraries; needs a Windows library (psapi) to be linked in.
* Filter system libraries on Windows: ignore it if contains "/usr/bin/cyg" or the Windows install path.
* Don't export any symbols from clang and llvm, we don't need them outside libCore. Before, all symbols were exported leading to a symbol table overflow.


git-svn-id: http://root.cern.ch/svn/root/trunk@48500 27541ba8-7e3a-0410-8455-c3a389f83636
2013-02-07 13:11:08 +00:00
Vassil Vassilev
a8c69889d7 Call Sema::ActOnEndOfTranslationUnit in order to complete the module import.
For example, if the module contained virtual classes Sema has to generate/update
the virtual tables and so on, exactly as we do after each incremental parse 
(IncrementalParser::ParseInternal)

Now we have the code generated for the inlines coming from a module, but due to
a bug in the current state of the modules it generates some declaration of
a function (declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32) nounwind),
which causes the jit to choke with "LLVM ERROR: Cannot select: intrinsic %llvm.ptr.annotation"


git-svn-id: http://root.cern.ch/svn/root/trunk@48406 27541ba8-7e3a-0410-8455-c3a389f83636
2013-01-24 10:54:57 +00:00
Vassil Vassilev
d604bcff01 Fix unused var warning.
git-svn-id: http://root.cern.ch/svn/root/trunk@48392 27541ba8-7e3a-0410-8455-c3a389f83636
2013-01-23 16:05:23 +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
Philippe Canal
90d940fbb8 Introduce (and use in TCling) Interpreter::parseForModule that codegen just
inline functions (and should codegen anything that is not directly provide
by a library 'described' by a module).


git-svn-id: http://root.cern.ch/svn/root/trunk@48197 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-25 04:57:07 +00:00
Vassil Vassilev
d107bd91ea Remove newline.
git-svn-id: http://root.cern.ch/svn/root/trunk@48042 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-14 11:40:52 +00:00
Vassil Vassilev
d8d127664d Until we have the full implementation of the preprocessor directives just act
on #include. This makes sure that we don't do any extra work causing roottest
failures.


git-svn-id: http://root.cern.ch/svn/root/trunk@47972 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-11 14:43:40 +00:00
Vassil Vassilev
b117bb49de Implement simple preparse of input lines. In many cases this helps to take
quickly decisions what to do with the input. Partially fixes savannah #99294


git-svn-id: http://root.cern.ch/svn/root/trunk@47941 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-10 11:17:43 +00:00
Vassil Vassilev
e846d218bb Initialize the newly introduced flag.
git-svn-id: http://root.cern.ch/svn/root/trunk@47888 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-06 11:36:29 +00:00
Vassil Vassilev
b4ae9af6f1 RawInput mode has proven itself to be very helpful. We should have support for it
on Interpreter level and not at MetaProcessor level.


git-svn-id: http://root.cern.ch/svn/root/trunk@47881 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-06 10:38:56 +00:00
Philippe Canal
498f1d913b Revert -r47806 which had negative consequences (failing to handle properly #ifdef at the beginning of an unnamed script and making it much harder to update roottest to work around missing feature in cling)
git-svn-id: http://root.cern.ch/svn/root/trunk@47869 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-06 04:43:49 +00:00
Vassil Vassilev
8dc005bc10 Ignore warning for use of auto keyword.
git-svn-id: http://root.cern.ch/svn/root/trunk@47845 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-05 10:04:42 +00:00
Vassil Vassilev
8a46f33881 80.
git-svn-id: http://root.cern.ch/svn/root/trunk@47826 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-04 16:23:30 +00:00
Axel Naumann
5b92bda924 Skip white space when determining whether input can be wrapped or not.
Fixes Savannah #99246


git-svn-id: http://root.cern.ch/svn/root/trunk@47806 27541ba8-7e3a-0410-8455-c3a389f83636
2012-12-04 08:54:16 +00:00
Vassil Vassilev
512d1bbf21 Add interface in cling::Interpreter that avoids lexing, parsing and sematic
analysis. It just takes the transaction runs all the transformers on it 
(depending on the compilation options residing in the transaction itself) and
generate code for it.


git-svn-id: http://root.cern.ch/svn/root/trunk@47518 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-21 02:28:31 +00:00
Axel Naumann
2da8caecff Handle unresolved symbols in static initialization.
Now that it's used twice, extract the conversion from ExeContext::ExeResult to Interp::ExeResult.
IncrementalParser will try to roll the transaction back for unresolved initializers.


git-svn-id: http://root.cern.ch/svn/root/trunk@47484 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-20 16:24:02 +00:00
Axel Naumann
c197c04fb6 DiagConsumer::Begin/EndSourceFile() are used to switch from "parsing command line flags" to "parsing source files" more; not to signal a new source file to the diag client.
Switch BeginSourceFile() on after having parsed Interpreter internals.
Switch it off (EndSourceFile()) in ~Interpreter.
Indentation.

Now that we handle diags appropriately, test/ErrorRecovery/MetaProcessor.C fails; repair it.


git-svn-id: http://root.cern.ch/svn/root/trunk@47476 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-20 13:21:00 +00:00
Axel Naumann
afcf1105c9 Having warnings does not mean failure.
git-svn-id: http://root.cern.ch/svn/root/trunk@47469 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-20 09:43:17 +00:00
Vassil Vassilev
009338beb7 Since cling::Transaction is public and the fact that on commit of transaction a
new transaction could be triggered, every compile should return the transaction
that it actually compiled. I.e. the cling::IncrementalParser::getLastTransaction
in many cases might not be the transaction we expect. For example in ROOT's case
plugin manager is triggered for some reason and the last transaction is not the
one that I'd personally expect.
This should be fix roottest/.../runMemory.C


git-svn-id: http://root.cern.ch/svn/root/trunk@47465 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-20 03:26:52 +00:00
Axel Naumann
6e29edaafa Add getAddressOfGlobal() taking a const char symbol name.
git-svn-id: http://root.cern.ch/svn/root/trunk@47358 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-16 15:32:43 +00:00
Axel Naumann
ee70e6bee3 tryCode only makes sense if a shared library is tried.
Fixes "cond jump dep on uninit var" / cling test failure.


git-svn-id: http://root.cern.ch/svn/root/trunk@47345 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-16 13:39:09 +00:00
Axel Naumann
5491fc88b6 Use the full path name to the shared library when registering it, not just "libGPad".
git-svn-id: http://root.cern.ch/svn/root/trunk@47342 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-16 11:30:31 +00:00
Vassil Vassilev
20180ac047 Temporarily!? publish the parser.
git-svn-id: http://root.cern.ch/svn/root/trunk@47340 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 23:51:52 +00:00
Axel Naumann
28dc13c51e Don't try to #include a file for which we know it's a dynamic library (that just failed to load) or a bitcode file.
Fixes bug #98798.
Print error message from loader ("cling::Interpreter::tryLinker(): .../libFoo.so: undefined symbol: bar") on dlopen failure.


git-svn-id: http://root.cern.ch/svn/root/trunk@47339 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 21:36:41 +00:00
Axel Naumann
7d5ed9e511 Define result of ExecutionContext::executeFunction().
Return it all the way through Interpreter.
Fixes bug #98837.


git-svn-id: http://root.cern.ch/svn/root/trunk@47337 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 20:55:43 +00:00
Axel Naumann
226b360b15 Rename LoadLibResult constants to start with 'k'.
Enable kLoadLibExists case in TCintWithCling.

Collect statistics about loaded files.
Give access to that through .file; rename SourceManager dump to fileEx.

Documentation.

(Sorry, should have been three patches.)


git-svn-id: http://root.cern.ch/svn/root/trunk@47330 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 18:23:11 +00:00
Axel Naumann
e8d7963b97 Split dumping and extraction of IncludePaths (aka HeaderSearchOpts).
Call it like this:
SmallVector<std::string, 100> inclPaths;
interp->GetIncludePaths(inclPaths, false, true);
to get the include paths prefixed with -I, but no system onclude paths.

Mark include paths supplied via AddIncludePath() as IsUserSupplied.


git-svn-id: http://root.cern.ch/svn/root/trunk@47325 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 17:07:44 +00:00
Axel Naumann
d5f237f819 Move "library load result" enum to the other enum.
Make tryLinker a member function now that it uses the collection of loaded libraries.
Implement "was alreday loaded" as possible loadLibrary() result.


git-svn-id: http://root.cern.ch/svn/root/trunk@47324 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 16:41:30 +00:00
Axel Naumann
8616cc7bea Split loadFile() into two and we have a new interface loadLibrary()!
Prepare new result "library was alreday loaded" - will be implemented if we actually need it.


git-svn-id: http://root.cern.ch/svn/root/trunk@47319 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 14:50:59 +00:00
Vassil Vassilev
c3c5d1e11a Use separate parser for our string-based lookup. This in general is safer because
we don't need pin-point precision while we recover the lookup parser from lookup.


git-svn-id: http://root.cern.ch/svn/root/trunk@47298 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-15 00:11:14 +00:00
Vassil Vassilev
76975bf2da Improve cling's transaction model. For now a bit hackish because it doesn't
actually support proper nesting of transactions.
(begin|end)Transaction return the transaction began or ended, which simplifies
interaction in case of nested transactions (coming from the autoloading)

Implement new function which transforms the single-linked list into a vector of
transactions for debugging purposes only.


git-svn-id: http://root.cern.ch/svn/root/trunk@47290 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-14 22:06:58 +00:00
Paul Russo
afe62b76cb Use CodeGen to lower an AST type to a LLVM type.
git-svn-id: http://root.cern.ch/svn/root/trunk@47285 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-14 21:23:31 +00:00
Axel Naumann
d0e7ca647f Determine the resType from the function decl.
git-svn-id: http://root.cern.ch/svn/root/trunk@47174 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-11 17:06:00 +00:00
Axel Naumann
d1112e3ce5 Get the result type directly from the wrapper function's return type.
Do that *after* the tranformers have done their work; they change the result type.
Silence a "return 12" inside a (not yet transformed) void wrapper().
The return type will later be repaired by the ReturnSynthesizer if needed.


git-svn-id: http://root.cern.ch/svn/root/trunk@47165 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-11 12:53:21 +00:00
Axel Naumann
32852bd800 Missing curly!
git-svn-id: http://root.cern.ch/svn/root/trunk@47001 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-02 12:56:40 +00:00
Axel Naumann
c68930cc52 Make the cxa_atexit replacements more C-like (e.g. don't put them into namespaces).
git-svn-id: http://root.cern.ch/svn/root/trunk@46997 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-02 11:51:05 +00:00