343 Commits

Author SHA1 Message Date
Philippe Canal
1b8795f0c3 In findFunction*, add template instantiation if needed.
Update the test accordingly.
2013-11-04 14:35:07 +01:00
Philippe Canal
66d3abc12c Add instantiation (if needed) to findAnyFunction 2013-11-04 14:35:06 +01:00
Philippe Canal
0adde75bd2 In findAnyFunction, properly handle the template case.
As the other findFunction*, findAnyFunction does not
(yet?) instantiate the function template if has not
yet been instantiated.

Also add test for findAnyFunction.
2013-11-04 14:35:06 +01:00
Philippe Canal
b96f1409ac In GetPartiallyDesugaredType add support for expression as template parameter.
For example:
namespace edm {
  template <int I> class Hash {};
  const int typeN =1;
  typedef Hash<typeN> ParentageID;
}

edm::ParentageID should be desugared to edm::Hash<1>.
2013-10-30 13:44:58 +01:00
Vassil Vassilev
a08152d576 Enhance the support for removing global values from the module with JIT lock.
When the machine code was generated the JIT retains a lock to the global values
so they don't go out of sync. In the cases of circular references like:
int g();
int f() {g();}
int g() {f();}
we cannot count on the removal order to get rid of the uses. We need to use the
replaceAllUsesWith. This is however tricky because the JIT already generated the
code for f and g and it doesn't make sense to replace anything with anything else.

Thus in order to support that we need to hack one of the JIT callbacks which
prevents the replace of values of already emitted code.
2013-10-29 20:19:24 +01:00
Vassil Vassilev
bf03ba5040 Fail the test because of the dead constant leftover. 2013-10-29 20:19:24 +01:00
Vassil Vassilev
5765fb83f5 Add test for unloading classes. 2013-10-29 20:19:23 +01:00
Vassil Vassilev
64b1a77356 Fix the case when the decl doesn't need mangling, adapt the test to the new impl. 2013-10-29 20:19:23 +01:00
Vassil Vassilev
9b352aa828 Use store/compare state for detailed verification. 2013-10-29 20:19:17 +01:00
Vassil Vassilev
846aac852c Assert that the reference came from the static initializers and upgrade the test.
The compiled code is unloaded by iterating the AST out of which the compiled code
came. The problem is that C++ supports static initialization. For example:
int a = 5; on the global scope means set the value of a to 5 before the program
starts. To support that clang implicitly generates functions that enforce the
expected initialization order. That can become easily very complex. Let's see
a more "real-life" example:

int f() { printf("I am f()"); return 0; }
int a = f();

Besides the code for a and f clang will emit:
define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" {
entry:
  %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%"struct.cling::runtime::internal::__trigger__cxa_atexit"*)* @_ZN5cling7runtime8internal21__trigger__cxa_atexitD1Ev to void (i8*)*), i8* getelementptr inbounds (%"struct.cling::runtime::internal::__trigger__cxa_atexit"* @_ZN5cling7runtime8internal1SE, i32 0, i32 0), i8* @__dso_handle) #1
  ret void
}
define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
entry:
  call void @__cxx_global_var_init()
  ret void
}

and more importantly:

define internal void @__cxx_global_var_init1() section "__TEXT,__StaticInit,regular,pure_instructions" {
entry:
  %call = call i32 @_Z1fv() ; THAT IS A REFERENCE TO f()
  store i32 %call, i32* undef, align 4
  ret void
}

So when iterating the AST and trying to remove f(), we cannot because it is still
referenced by __cxx_global_var_init1. However we know this is not an issue,
because that __cxx_global_var_init1 was meant to be executed only once and that
already happened. So in first approximation we could drop the references of f
in __cxx_global_var_init1 and remove the rest.
2013-10-29 20:19:12 +01:00
Axel Naumann
4de45c1b85 Add include path. 2013-10-17 12:38:55 +02:00
Axel Naumann
3c7481a11c Not using exceptions anymore thus these now work on 32bit. 2013-10-14 17:10:55 +02:00
Vassil Vassilev
694a0e4c3f Update the CHECK-NOT clause. 2013-10-14 11:48:55 +02:00
Vassil Vassilev
3d7b328517 Add future tests for implicit auto, when it gets fully adopted in cling.
The adoption should be done soon.
2013-10-14 09:11:40 +02:00
Vassil Vassilev
e43a6a6816 Fix broken by construction test. 2013-10-14 09:11:39 +02:00
Vassil Vassilev
2ce823fbef We don't need -verify. 2013-10-14 09:11:39 +02:00
Vassil Vassilev
eade01b61f Check against the new message printed out if there were differences. 2013-10-14 09:11:39 +02:00
Vassil Vassilev
a1395d0401 Revert the right cached files even when there are macros involved.
Fix the semantic of the test.
2013-10-14 09:11:39 +02:00
Vassil Vassilev
a0df2fac1d Add the -I so that Redeclarables.h can be found. 2013-10-14 09:11:39 +02:00
Vassil Vassilev
41b0539819 Don't forget to add FileCheck. 2013-10-14 09:11:39 +02:00
Vassil Vassilev
559b978279 Fix test semantics. 2013-10-14 09:11:39 +02:00
Vassil Vassilev
26eec6ab21 Now expected errors are printed out and filecheck cannot skip them. This is actually an improvement in newest llvm. In that case we don't need to run the test twice. 2013-10-14 09:11:38 +02:00
Vassil Vassilev
ffa77e6521 We cannot forward declare a function inside a function. 2013-10-14 09:11:38 +02:00
Axel Naumann
84b49183f3 Adapt to new diag format. 2013-10-03 09:54:00 +02:00
Vassil Vassilev
069a9d76c1 Remove unnecessary files that used to 'steer' the testsuite. 2013-09-27 14:33:05 +02:00
Vassil Vassilev
c31d15a1a1 Update cling's testsuite to use the newest llvm lit. 2013-09-27 14:33:04 +02:00
Baozeng Ding
fc98551c43 Add more tests testing derefs in BinOps and Casts. 2013-09-25 10:07:06 +02:00
Vassil Vassilev
c512b9abf4 No need of cleanup in the testsuite - we use temporary uniquely named files. 2013-09-18 20:33:05 +02:00
Vassil Vassilev
bcb3aaa6ae Disable tests on SLC6 32 bit. 2013-09-13 15:25:01 +02:00
Vassil Vassilev
1ddf4093b9 Extend the AST null deref checher and disable the IR checker.
This resulted in one change of warning kind, which is expected. I disabled the
test MetdhoCalls, Baozeng will look at it once he gets the code.
2013-09-11 13:50:57 +02:00
Baozeng Ding
a62759105c Add support for int *p = 0; *p; at AST level. 2013-09-10 11:43:57 +02:00
Baozeng Ding
a46498e831 Adapt the test suite to the new warnings produced.
Disable the indirect calls. We don't support them yet on AST level.
2013-09-09 15:38:51 +02:00
Vassil Vassilev
342918a4b9 Adapt to _Bool -> bool Use reg expr, because when building cling standalone we should still get _Bool. 2013-09-05 19:08:56 +02:00
Philippe Canal
7b7e237d81 adapt to new interface 2013-09-03 15:26:56 +02:00
Philippe Canal
f13c81470a We must have a function implementation to take its address 2013-08-31 20:49:07 +02:00
Philippe Canal
fc90db23ba In ReturnSynthesizer add better support for RecordType.
When we dectect that the last expression is a record type and is not
a temporary, we now return it by reference, hence avoiding an unnecessary
and sometimes impossible (cout) copy.   If it is a temporary we still
return a 'copy'.
2013-08-31 20:49:07 +02:00
Philippe Canal
52da28145b Fix ROOT-5442, wrong normalization of std::vector<myNamespace::myClass1*>::const_iterator
GetPartiallyDesugaredType was 'forgetting' to add full qualification of the
template parameters in some case (where the template paramter in the
QualType was not yet an elaborated type).  Extend the internal interface to
distinguish when we need to add full qualification to the type itself or its
template parameters.
2013-08-29 08:59:59 +02:00
Philippe Canal
467cb93b3e Add support for lookup function from QualType(s).
Add new overload for findFunctionProto and matchFunctionProto which rather than
taking the list of argument types as a StringRef, take it as a
const llvm::SmallVector<clang::QualType, 4>.  This avoids the (permanent)
allocations inside clang due to the Parsing of types.
2013-08-26 00:10:54 +02:00
Jerome Beclin
162101dd9d Instrument the error recovery testsuite with .store- and .compare- State.
Add a special lit substitution giving us the executed test folder, so that
before next run we could cleanup.
2013-08-21 14:29:57 +02:00
Baozeng Ding
715e222957 Add support for null deref checks in indirect calls. 2013-08-21 11:34:51 +02:00
Baozeng Ding
cc877954ae Add support for mangling: How we can check regular C++ functions.
Indirect calls are still an issue.
2013-08-21 11:14:55 +02:00
Philippe Canal
39d8a3e8a6 Add matchFunctionProto returning the decl only in case of exact match.
The new call is:

const clang::FunctionDecl* matchFunctionProto(const clang::Decl* scopeDecl,
                                              llvm::StringRef funcName,
                                              llvm::StringRef funcProto,
                                              bool objectIsConst
                                              ) const;

and the function must match in name and prototype (including constness).
The only thing not checked is the actual declaration context.
2013-08-17 01:45:56 +02:00
Philippe Canal
31b60e0ab5 Add support for restricting the function search to const functions.
Add an optional argument objectIsConst to findFunctionArgs and
findFunctionProto:

   const clang::FunctionDecl* findFunctionProto(const clang::Decl* scopeDecl,
                                                llvm::StringRef funcName,
                                                llvm::StringRef funcProto,
                                                bool objectIsConst) const;

   const clang::FunctionDecl* findFunctionArgs(const clang::Decl* scopeDecl,
                                               llvm::StringRef funcName,
                                               llvm::StringRef funcArgs,
                                               bool objectIsConst) const;
2013-08-17 01:45:55 +02:00
Vassil Vassilev
f3ccb10135 Spell correctly expected-warning and not warning expected. Call a function with non null and check the expected result. 2013-08-16 22:52:52 +02:00
Baozeng Ding
eca58d0ffc Add support for the cases where the pointer is not char*. 2013-08-16 19:50:53 +02:00
Vassil Vassilev
76c598f0ff Uncomment commented lines, that fail on Mac. 2013-08-15 23:17:51 +02:00
Vassil Vassilev
452e98bf46 Add a reproducer in the test of a current issue for Baozeng to look into.
This happens probably because we don't iterate over the redecl chains and thus
we don't pickup the attribute.
2013-08-15 23:17:51 +02:00
Vassil Vassilev
eeb99d7030 Add failing test for Baozeng to fine tune the NullDeref impl. 2013-08-15 22:26:57 +02:00
Vassil Vassilev
694eb20c36 Mark back as non-failing. There is still some issue on Mac that need to be investigated. 2013-08-15 10:15:55 +02:00
Vassil Vassilev
914c09228e Mark test as XFAIL. Follow the cling naming convention. 2013-08-15 09:49:59 +02:00