xref: /freebsd/contrib/llvm-project/clang/lib/Testing/CommandLineArgs.cpp (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
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 
9 #include "clang/Testing/CommandLineArgs.h"
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_OBJCXX:
40     Args = {"-x", "objective-c++", "-frtti"};
41     break;
42   case Lang_OpenCL:
43     llvm_unreachable("Not implemented yet!");
44   }
45   return Args;
46 }
47 
48 StringRef getFilenameForTesting(TestLanguage Lang) {
49   switch (Lang) {
50   case Lang_C89:
51   case Lang_C99:
52     return "input.c";
53 
54   case Lang_CXX03:
55   case Lang_CXX11:
56   case Lang_CXX14:
57   case Lang_CXX17:
58   case Lang_CXX20:
59     return "input.cc";
60 
61   case Lang_OpenCL:
62     return "input.cl";
63 
64   case Lang_OBJCXX:
65     return "input.mm";
66   }
67   llvm_unreachable("Unhandled TestLanguage enum");
68 }
69 
70 } // end namespace clang
71