2016-08-08 16:29:06 -04:00
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
2020-10-28 17:28:36 +01:00
// RUN: cat %s | %cling -Xclang -verify 2>&1 | FileCheck %s
2016-08-08 16:29:06 -04:00
// Make sure we are correctly parsing the arguments for CIFactory::createCI
# include "cling/Interpreter/InvocationOptions.h"
const char * argv [ ] = {
" progname " ,
" - " ,
" -xobjective-c " ,
" FileToExecuteA " ,
" -isysroot " ,
" APAth " ,
2016-08-16 18:05:45 -04:00
" -nobuiltininc " ,
2016-08-08 16:29:06 -04:00
" -v " ,
" FileToExecuteB " ,
" -L/Path/To/Libs " ,
" -lTest "
} ;
const int argc = sizeof ( argv ) / sizeof ( argv [ 0 ] ) ;
cling : : CompilerOptions COpts ( argc , argv ) ;
COpts . Language
2017-02-22 14:17:22 -05:00
// CHECK: (unsigned int) 1
2016-08-08 16:29:06 -04:00
COpts . SysRoot
2017-02-22 14:17:22 -05:00
// CHECK-NEXT: (unsigned int) 1
2016-08-16 18:05:45 -04:00
COpts . NoBuiltinInc
2017-02-22 14:17:22 -05:00
// CHECK-NEXT: (unsigned int) 1
2016-08-08 16:29:06 -04:00
COpts . NoCXXInc
2017-02-22 14:17:22 -05:00
// CHECK-NEXT: (unsigned int) 0
2019-01-15 12:21:51 +01:00
COpts . CUDAHost
// CHECK-NEXT: (unsigned int) 0
COpts . CUDADevice
2018-03-14 13:41:11 +01:00
// CHECK-NEXT: (unsigned int) 0
COpts . DefaultLanguage ( )
// CHECK-NEXT: false
2016-08-08 16:29:06 -04:00
// library caller options: arguments passed as is
COpts . Remaining
2017-02-14 16:34:59 -05:00
// CHECK-NEXT: {{.*}} { "progname", "-", "-xobjective-c", "FileToExecuteA", "-isysroot", "APAth", "-nobuiltininc", "-v", "FileToExecuteB", "-L/Path/To/Libs", "-lTest" }
2016-08-08 16:29:06 -04:00
2018-03-14 13:41:11 +01:00
argv [ 2 ] = " -xcuda " ;
2016-08-08 16:29:06 -04:00
argv [ 6 ] = " -nostdinc++ " ;
2018-03-14 13:41:11 +01:00
2016-08-08 16:29:06 -04:00
cling : : InvocationOptions IOpts ( argc , argv ) ;
IOpts . Inputs
2017-02-14 16:34:59 -05:00
// CHECK-NEXT: {{.*}} { "-", "FileToExecuteA", "FileToExecuteB" }
2016-08-08 16:29:06 -04:00
IOpts . LibSearchPath
2017-02-14 16:34:59 -05:00
// CHECK-NEXT: {{.*}} { "/Path/To/Libs" }
2016-08-08 16:29:06 -04:00
IOpts . LibsToLoad
2017-02-14 16:34:59 -05:00
// CHECK-NEXT: {{.*}} { "Test" }
2016-08-08 16:29:06 -04:00
IOpts . CompilerOpts . Language
2017-02-22 14:17:22 -05:00
// CHECK-NEXT: (unsigned int) 1
2016-08-08 16:29:06 -04:00
IOpts . CompilerOpts . SysRoot
2017-02-22 14:17:22 -05:00
// CHECK-NEXT: (unsigned int) 1
2016-08-16 18:05:45 -04:00
IOpts . CompilerOpts . NoBuiltinInc
2017-02-22 14:17:22 -05:00
// CHECK-NEXT: (unsigned int) 0
2016-08-08 16:29:06 -04:00
IOpts . CompilerOpts . NoCXXInc
2017-02-22 14:17:22 -05:00
// CHECK-NEXT: (unsigned int) 1
2019-01-15 12:21:51 +01:00
IOpts . CompilerOpts . CUDAHost
2018-03-14 13:41:11 +01:00
// CHECK-NEXT: (unsigned int) 1
2019-01-15 12:21:51 +01:00
IOpts . CompilerOpts . CUDADevice
// CHECK-NEXT: (unsigned int) 0
2018-03-14 13:41:11 +01:00
// if the language is cuda, it should set automatically the c++ standard
IOpts . CompilerOpts . DefaultLanguage ( )
// CHECK-NEXT: true
2016-08-08 16:29:06 -04:00
// user options from main: filtered by cling (no '-')
IOpts . CompilerOpts . Remaining
2017-02-14 16:34:59 -05:00
// Windows translates -nostdinc++ to -nostdinc++. Ignore that fact for the test.
2018-03-14 13:41:11 +01:00
// CHECK-NEXT: {{.*}} { "progname", "-xcuda", "FileToExecuteA", "-isysroot", "APAth", {{.*}}, "-v", "FileToExecuteB" }
2016-08-08 16:29:06 -04:00
2019-01-15 12:21:51 +01:00
// this flag allows to compile ptx code with the interpreter instance
// CUDAHost and CUDADevice must not be true at the same time
2019-02-12 10:30:28 +01:00
// --cuda-device-only implies -xcuda
2019-01-15 12:21:51 +01:00
argv [ 10 ] = " --cuda-device-only " ;
cling : : InvocationOptions IOpts2 ( argc , argv ) ;
IOpts2 . CompilerOpts . CUDAHost
// CHECK-NEXT: (unsigned int) 0
IOpts2 . CompilerOpts . CUDADevice
// CHECK-NEXT: (unsigned int) 1
2016-08-08 16:29:06 -04:00
// expected-no-diagnostics
. q