clang  16.0.0git
CommandLineArgs.cpp
Go to the documentation of this file.
1 //===--- CommandLineArgs.cpp ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/Support/ErrorHandling.h"
11 
12 namespace clang {
13 
14 std::vector<std::string> getCommandLineArgsForTesting(TestLanguage Lang) {
15  std::vector<std::string> Args;
16  // Test with basic arguments.
17  switch (Lang) {
18  case Lang_C89:
19  Args = {"-x", "c", "-std=c89"};
20  break;
21  case Lang_C99:
22  Args = {"-x", "c", "-std=c99"};
23  break;
24  case Lang_CXX03:
25  Args = {"-std=c++03", "-frtti"};
26  break;
27  case Lang_CXX11:
28  Args = {"-std=c++11", "-frtti"};
29  break;
30  case Lang_CXX14:
31  Args = {"-std=c++14", "-frtti"};
32  break;
33  case Lang_CXX17:
34  Args = {"-std=c++17", "-frtti"};
35  break;
36  case Lang_CXX20:
37  Args = {"-std=c++20", "-frtti"};
38  break;
39  case Lang_OBJC:
40  Args = {"-x", "objective-c", "-frtti", "-fobjc-nonfragile-abi"};
41  break;
42  case Lang_OBJCXX:
43  Args = {"-x", "objective-c++", "-frtti"};
44  break;
45  case Lang_OpenCL:
46  llvm_unreachable("Not implemented yet!");
47  }
48  return Args;
49 }
50 
51 std::vector<std::string> getCC1ArgsForTesting(TestLanguage Lang) {
52  std::vector<std::string> Args;
53  switch (Lang) {
54  case Lang_C89:
55  Args = {"-xc", "-std=c89"};
56  break;
57  case Lang_C99:
58  Args = {"-xc", "-std=c99"};
59  break;
60  case Lang_CXX03:
61  Args = {"-std=c++03"};
62  break;
63  case Lang_CXX11:
64  Args = {"-std=c++11"};
65  break;
66  case Lang_CXX14:
67  Args = {"-std=c++14"};
68  break;
69  case Lang_CXX17:
70  Args = {"-std=c++17"};
71  break;
72  case Lang_CXX20:
73  Args = {"-std=c++20"};
74  break;
75  case Lang_OBJC:
76  Args = {"-xobjective-c"};
77  break;
78  case Lang_OBJCXX:
79  Args = {"-xobjective-c++"};
80  break;
81  case Lang_OpenCL:
82  llvm_unreachable("Not implemented yet!");
83  }
84  return Args;
85 }
86 
88  switch (Lang) {
89  case Lang_C89:
90  case Lang_C99:
91  return "input.c";
92 
93  case Lang_CXX03:
94  case Lang_CXX11:
95  case Lang_CXX14:
96  case Lang_CXX17:
97  case Lang_CXX20:
98  return "input.cc";
99 
100  case Lang_OpenCL:
101  return "input.cl";
102 
103  case Lang_OBJC:
104  return "input.m";
105 
106  case Lang_OBJCXX:
107  return "input.mm";
108  }
109  llvm_unreachable("Unhandled TestLanguage enum");
110 }
111 
112 } // end namespace clang
clang::Lang_CXX14
@ Lang_CXX14
Definition: CommandLineArgs.h:28
clang::Lang_CXX20
@ Lang_CXX20
Definition: CommandLineArgs.h:30
clang::getCC1ArgsForTesting
std::vector< std::string > getCC1ArgsForTesting(TestLanguage Lang)
Definition: CommandLineArgs.cpp:51
clang::Lang_OBJC
@ Lang_OBJC
Definition: CommandLineArgs.h:32
clang::getFilenameForTesting
StringRef getFilenameForTesting(TestLanguage Lang)
Definition: CommandLineArgs.cpp:87
clang::TestLanguage
TestLanguage
Definition: CommandLineArgs.h:23
clang::Lang_OBJCXX
@ Lang_OBJCXX
Definition: CommandLineArgs.h:33
clang::Lang_OpenCL
@ Lang_OpenCL
Definition: CommandLineArgs.h:31
clang::getCommandLineArgsForTesting
std::vector< std::string > getCommandLineArgsForTesting(TestLanguage Lang)
Definition: CommandLineArgs.cpp:14
clang::Lang_CXX11
@ Lang_CXX11
Definition: CommandLineArgs.h:27
clang::Lang_C89
@ Lang_C89
Definition: CommandLineArgs.h:24
clang::Lang_CXX17
@ Lang_CXX17
Definition: CommandLineArgs.h:29
clang::Lang_C99
@ Lang_C99
Definition: CommandLineArgs.h:25
clang
Definition: CalledOnceCheck.h:17
CommandLineArgs.h
clang::Lang_CXX03
@ Lang_CXX03
Definition: CommandLineArgs.h:26