[HIPIFY][fix][#211] Taking into account include guard controlling macro

...while including HIP main header file, which is inserted now after #indef controlling macro, or after #pragma once, if it's occurred earlier.

+ Add a couple of unit tests.
ToDo: Check backward compatibility on older clang versions.
This commit is contained in:
Evgeny Mankov
2019-08-02 16:46:45 +03:00
parent f52245d440
commit 25075729f9
4 changed files with 73 additions and 6 deletions
@@ -0,0 +1,14 @@
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
// Checks that HIP header file is included after #pragma once,
// which goes before include guard controlling macro.
// CHECK: #pragma once
// CHECK-NEXT: #include <hip/hip_runtime.h>
#pragma once
#ifndef HEADERS_TEST_10_H
// CHECK: #ifndef HEADERS_TEST_10_H
// CHECK-NOT: #include <hip/hip_runtime.h>
#define HEADERS_TEST_10_H
#include <stdio.h>
static int counter = 0;
#endif // HEADERS_TEST_10_H
@@ -0,0 +1,14 @@
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args
// Checks that HIP header file is included after include guard controlling macro,
// which goes before #pragma once.
// CHECK: #ifndef HEADERS_TEST_10_H
// CHECK-NEXT: #include <hip/hip_runtime.h>
#ifndef HEADERS_TEST_10_H
// CHECK: #pragma once
#pragma once
// CHECK-NOT: #include <hip/hip_runtime.h>
#define HEADERS_TEST_10_H
#include <stdio.h>
static int counter = 0;
#endif // HEADERS_TEST_10_H