1 //===--- CommandLineArgs.cpp ----------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "clang/Testing/CommandLineArgs.h"
10 #include "llvm/MC/TargetRegistry.h"
11 #include "llvm/Support/ErrorHandling.h"
15 std::vector
<std::string
> getCommandLineArgsForTesting(TestLanguage Lang
) {
16 std::vector
<std::string
> Args
;
17 // Test with basic arguments.
20 Args
= {"-x", "c", "-std=c89"};
23 Args
= {"-x", "c", "-std=c99"};
26 Args
= {"-std=c++03", "-frtti"};
29 Args
= {"-std=c++11", "-frtti"};
32 Args
= {"-std=c++14", "-frtti"};
35 Args
= {"-std=c++17", "-frtti"};
38 Args
= {"-std=c++20", "-frtti"};
41 Args
= {"-x", "objective-c", "-frtti", "-fobjc-nonfragile-abi"};
44 Args
= {"-x", "objective-c++", "-frtti"};
47 llvm_unreachable("Not implemented yet!");
52 std::vector
<std::string
> getCC1ArgsForTesting(TestLanguage Lang
) {
53 std::vector
<std::string
> Args
;
56 Args
= {"-xc", "-std=c89"};
59 Args
= {"-xc", "-std=c99"};
62 Args
= {"-std=c++03"};
65 Args
= {"-std=c++11"};
68 Args
= {"-std=c++14"};
71 Args
= {"-std=c++17"};
74 Args
= {"-std=c++20"};
77 Args
= {"-xobjective-c"};
80 Args
= {"-xobjective-c++"};
83 llvm_unreachable("Not implemented yet!");
88 StringRef
getFilenameForTesting(TestLanguage Lang
) {
110 llvm_unreachable("Unhandled TestLanguage enum");
113 std::string
getAnyTargetForTesting() {
114 for (const auto &Target
: llvm::TargetRegistry::targets()) {
116 StringRef
TargetName(Target
.getName());
117 if (TargetName
== "x86-64")
118 TargetName
= "x86_64";
119 if (llvm::TargetRegistry::lookupTarget(std::string(TargetName
), Error
) ==
121 return std::string(TargetName
);
127 } // end namespace clang