tra created this revision. tra added a reviewer: Hahnfeld. Herald added subscribers: bixia, jlebar, sanjoy.
This keeps predefined macros for CUDA to work as they were before and lets OpenMP control the set of macros it needs. https://reviews.llvm.org/D51501 Files: clang/lib/Frontend/InitPreprocessor.cpp Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -1158,8 +1158,16 @@ // Install things like __POWERPC__, __GNUC__, etc into the macro table. if (InitOpts.UsePredefines) { + // CUDA and OpenMP handle preprocessing differently. CUDA wants to see + // identical preprocessed output (as close to it as possible), so it + // provides full set of predefined macros for both sides of compilation. + if (LangOpts.CUDA && PP.getAuxTargetInfo()) + InitializePredefinedMacros(*PP.getAuxTargetInfo(), LangOpts, FEOpts, + Builder); InitializePredefinedMacros(PP.getTargetInfo(), LangOpts, FEOpts, Builder); - if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice) && PP.getAuxTargetInfo()) + // OpenMP relies on selectively picking predefined macros to work around the + // bits of host includes it can't compile during device-side compilation. + if (LangOpts.OpenMPIsDevice && PP.getAuxTargetInfo()) InitializePredefinedAuxMacros(*PP.getAuxTargetInfo(), LangOpts, Builder); // Install definitions to make Objective-C++ ARC work well with various
Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -1158,8 +1158,16 @@ // Install things like __POWERPC__, __GNUC__, etc into the macro table. if (InitOpts.UsePredefines) { + // CUDA and OpenMP handle preprocessing differently. CUDA wants to see + // identical preprocessed output (as close to it as possible), so it + // provides full set of predefined macros for both sides of compilation. + if (LangOpts.CUDA && PP.getAuxTargetInfo()) + InitializePredefinedMacros(*PP.getAuxTargetInfo(), LangOpts, FEOpts, + Builder); InitializePredefinedMacros(PP.getTargetInfo(), LangOpts, FEOpts, Builder); - if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice) && PP.getAuxTargetInfo()) + // OpenMP relies on selectively picking predefined macros to work around the + // bits of host includes it can't compile during device-side compilation. + if (LangOpts.OpenMPIsDevice && PP.getAuxTargetInfo()) InitializePredefinedAuxMacros(*PP.getAuxTargetInfo(), LangOpts, Builder); // Install definitions to make Objective-C++ ARC work well with various
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits