[HIPIFY][#207][fix] Translate all preprocessor's conditional blocks

+ Start to translate preprocessor's false conditional blocks too:
  based on clang's https://reviews.llvm.org/D66597;
  available only starting from LLVM 10.0 or trunk.
+ Option -skip-excluded-preprocessor-conditional-blocks for skipping excluded conditional blocks:
  the default behavior for hipify-clang built with LLVM < 10.0;
  false by default for hipify-clang built with LLVM 10 or trunk.
+ Add 4 preprocessor unit tests, 2 of which are LLVM 10.0 only
+ Update couple of existing tests by setting -skip-excluded-preprocessor-conditional-blocks option:
  update lit testing accordingly


[ROCm/clr commit: 32f22a0117]
Bu işleme şunda yer alıyor:
Evgeny Mankov
2019-08-28 21:17:35 +03:00
ebeveyn bd631e815b
işleme 65ba03dd4c
15 değiştirilmiş dosya ile 223 ekleme ve 12 silme
+21
Dosyayı Görüntüle
@@ -20,8 +20,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "ArgParse.h"
#include "LLVMCompat.h"
#include "llvm/Support/Path.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Frontend/CompilerInstance.h"
const std::string sHipify = "[HIPIFY] ", sConflict = "conflict: ", sError = "error: ", sWarning = "warning: ";
namespace llcompat {
@@ -122,4 +127,20 @@ bool pragma_once_outside_header() {
#endif
}
void RetainExcludedConditionalBlocks(clang::CompilerInstance &CI) {
#if LLVM_VERSION_MAJOR > 9
clang::PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
PPOpts.RetainExcludedConditionalBlocks = !SkipExcludedPPConditionalBlocks;
#endif
}
bool CheckCompatibility() {
#if LLVM_VERSION_MAJOR < 10
if (SkipExcludedPPConditionalBlocks) {
llvm::errs() << "\n" << sHipify << sWarning << "Option '" << SkipExcludedPPConditionalBlocks.ArgStr.str() << "' is supported starting from LLVM version 10.0\n";
}
#endif
return true;
}
} // namespace llcompat