headersearch.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Test reading of PCH with changed location of original input files,
  2. // i.e. invoking header search.
  3. // Generate the original files:
  4. // RUN: rm -rf %t_orig %t_moved
  5. // RUN: mkdir -p %t_orig/sub %t_orig/sub2
  6. // RUN: echo 'struct orig_sub{char c; int i; };' > %t_orig/sub/orig_sub.h
  7. // RUN: echo 'void orig_sub2_1();' > %t_orig/sub2/orig_sub2_1.h
  8. // RUN: echo '#include "orig_sub2_1.h"' > %t_orig/sub2/orig_sub2.h
  9. // RUN: echo 'template <typename T> void tf() { orig_sub2_1(); T::foo(); }' >> %t_orig/sub2/orig_sub2.h
  10. // RUN: echo 'void foo() {}' > %t_orig/tmp2.h
  11. // RUN: echo '#include "tmp2.h"' > %t_orig/all.h
  12. // RUN: echo '#include "sub/orig_sub.h"' >> %t_orig/all.h
  13. // RUN: echo '#include "orig_sub2.h"' >> %t_orig/all.h
  14. // RUN: echo 'int all();' >> %t_orig/all.h
  15. // This test relies on -Wpadded, which is only implemented for Itanium record
  16. // layout.
  17. // Generate the PCH:
  18. // RUN: cd %t_orig && %clang_cc1 -triple %itanium_abi_triple -x c++ -emit-pch -o all.h.pch -Isub2 all.h
  19. // RUN: cp -R %t_orig %t_moved
  20. // Check diagnostic with location in original source:
  21. // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -Wpadded -emit-llvm-only %s 2> %t.stderr
  22. // RUN: grep 'struct orig_sub' %t.stderr
  23. // Check diagnostic with 2nd location in original source:
  24. // RUN: not %clang_cc1 -triple %itanium_abi_triple -DREDECL -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-llvm-only %s 2> %t.stderr
  25. // RUN: grep 'void foo' %t.stderr
  26. // Check diagnostic with instantiation location in original source:
  27. // RUN: not %clang_cc1 -triple %itanium_abi_triple -DINSTANTIATION -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-llvm-only %s 2> %t.stderr
  28. // RUN: grep 'orig_sub2_1' %t.stderr
  29. void qq(orig_sub*) {all();}
  30. #ifdef REDECL
  31. float foo() {return 0;}
  32. #endif
  33. #ifdef INSTANTIATION
  34. void f() {
  35. tf<int>();
  36. }
  37. #endif