clang.c 923 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "tests.h"
  2. #include "debug.h"
  3. #include "util.h"
  4. #include "c++/clang-c.h"
  5. #include <linux/kernel.h>
  6. static struct {
  7. int (*func)(void);
  8. const char *desc;
  9. } clang_testcase_table[] = {
  10. #ifdef HAVE_LIBCLANGLLVM_SUPPORT
  11. {
  12. .func = test__clang_to_IR,
  13. .desc = "builtin clang compile C source to IR",
  14. },
  15. {
  16. .func = test__clang_to_obj,
  17. .desc = "builtin clang compile C source to ELF object",
  18. },
  19. #endif
  20. };
  21. int test__clang_subtest_get_nr(void)
  22. {
  23. return (int)ARRAY_SIZE(clang_testcase_table);
  24. }
  25. const char *test__clang_subtest_get_desc(int i)
  26. {
  27. if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
  28. return NULL;
  29. return clang_testcase_table[i].desc;
  30. }
  31. #ifndef HAVE_LIBCLANGLLVM_SUPPORT
  32. int test__clang(int i __maybe_unused)
  33. {
  34. return TEST_SKIP;
  35. }
  36. #else
  37. int test__clang(int i)
  38. {
  39. if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
  40. return TEST_FAIL;
  41. return clang_testcase_table[i].func();
  42. }
  43. #endif