[LLVMdev] Does llvm-lit support type substitution (macro)?

Reid Kleckner rnk at google.com
Wed Sep 10 09:15:13 PDT 2014


You can use the C preprocessor:

// RUN: %clang_cc1 -DTYPE=char %s -fsyntax-only
// RUN: %clang_cc1 -DTYPE=short %s -fsyntax-only
// RUN: %clang_cc1 -DTYPE=unsigned %s -fsyntax-only

void func(TYPE a) {
  a = 3;
}

But, as David suggests, this kind of data-driven testing usually isn't
useful.

On Wed, Sep 10, 2014 at 8:39 AM, David Blaikie <dblaikie at gmail.com> wrote:

> Nope, lit doesn't have anything like that.
>
> Best to keep the tests simple, sometimes to the point of being repetitious.
>
> Do you actually have different codepaths to test for each type?
> On Sep 10, 2014 8:05 AM, "lyh.kernel" <lyh.kernel at gmail.com> wrote:
>
>> Hello all,
>>
>> I am writing test cases which are dedicated to be executed by llvm-lit.
>> Most of my test cases have the same logic but different types. For example:
>>
>> // RUN: %clang_cc1 -fsyntax-only
>> func (int a) {
>>   a = 3;
>> }
>>
>> // RUN: %clang_cc1 -fsyntax-only
>> func (char a) {
>>   a = 3;
>> }
>>
>> // RUN: %clang_cc1 -fsyntax-only
>> func (unsigned a) {
>>   a = 3;
>> }
>>
>> Now I put them in three different test cases but it is hard to maintain.
>> I am wondering whether llvm-lit support writing test cases with macro
>> parameter and a parameter config file:
>>
>> // RUN: %clang_cc1 -fsyntax-only
>> func (TYPE a) {
>>   a = 3;
>> }
>>
>> // TYPE config
>> TYPE = {int, char, unsigned}
>>
>> Many thanks
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
> _______________________________________________
> 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/20140910/4659ef9d/attachment.html>


More information about the llvm-dev mailing list