diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-05-20 21:01:19 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-05-20 21:01:19 +0000 |
commit | 868c46bea44e068e2b90bd4a959c7272b9c873e0 (patch) | |
tree | b77bdf0926442a5b1c72f42c10ae68f67f57afa8 | |
parent | a4b31ad90a34232c3786450f62e9913362168448 (diff) | |
parent | 12ec298d1df69797209ebec3844900f34899097e (diff) | |
download | slang-868c46bea44e068e2b90bd4a959c7272b9c873e0.tar.gz |
Snap for 7384448 from 12ec298d1df69797209ebec3844900f34899097e to simpleperf-release
Change-Id: Ib85032b43eaf9c5b3631ba7a01ec0e79a1622816
-rw-r--r-- | llvm-rs-cc.cpp | 10 | ||||
-rw-r--r-- | rs_cc_options.cpp | 15 | ||||
-rw-r--r-- | slang_version.h | 5 | ||||
-rw-r--r-- | tests/P_warnings_deprecated/deprecated.rscript | 2 | ||||
-rw-r--r-- | tests/P_warnings_deprecated/stderr.txt.expect | 1 | ||||
-rwxr-xr-x | tests/slang_test.py | 2 |
6 files changed, 27 insertions, 8 deletions
diff --git a/llvm-rs-cc.cpp b/llvm-rs-cc.cpp index a51e672..0c1143d 100644 --- a/llvm-rs-cc.cpp +++ b/llvm-rs-cc.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "clang/Basic/AllDiagnostics.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" @@ -223,6 +224,14 @@ extern "C" const char *__asan_default_options() { return "detect_leaks=0"; } +static void emitDeprecationWarning(clang::DiagnosticsEngine *DiagEngine) { + DiagEngine->Report(clang::diag::warn_deprecated_message) + << "Renderscript" + << "Please refer to the migration guide " + "(https://developer.android.com/guide/topics/renderscript/migration-guide) " + "for the proposed alternatives."; +} + int main(int argc, const char **argv) { llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. LLVMInitializeARMTargetInfo(); @@ -263,6 +272,7 @@ int main(int argc, const char **argv) { (void)DiagEngine.setSeverityForGroup(clang::diag::Flavor::WarningOrError, "implicit-function-declaration", clang::diag::Severity::Error); + emitDeprecationWarning(&DiagEngine); // Report error if no input file if (Inputs.empty()) { diff --git a/rs_cc_options.cpp b/rs_cc_options.cpp index f84294b..89720a3 100644 --- a/rs_cc_options.cpp +++ b/rs_cc_options.cpp @@ -133,6 +133,11 @@ bool ParseArguments(const llvm::ArrayRef<const char *> &ArgsIn, // employ/encourage this extension for zero-initialization of structures. DiagOpts.Warnings.push_back("no-gnu-empty-initializer"); + // Always turn deprecation warning into a warning even if -Werror is specified. + // This is because we will always emit RenderScript deprecation warning, and turning + // it into an error will make the compilation always fail. + DiagOpts.Warnings.push_back("no-error=deprecated-declarations"); + for (llvm::opt::ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) { const llvm::opt::Arg *A = *it; @@ -290,13 +295,11 @@ bool ParseArguments(const llvm::ArrayRef<const char *> &ArgsIn, if (Opts.mTargetAPI == 0) { Opts.mTargetAPI = UINT_MAX; - } else if (Opts.mTargetAPI == SLANG_N_MR1_TARGET_API || - Opts.mTargetAPI == SLANG_O_TARGET_API || - Opts.mTargetAPI == SLANG_O_MR1_TARGET_API || - Opts.mTargetAPI == SLANG_P_TARGET_API) { + } else if (Opts.mTargetAPI > SLANG_MAXIMUM_TARGET_API && + Opts.mTargetAPI <= SLANG_MAXIMUM_CMDLINE_TARGET_API) { // Bug: http://b/35767071 - // No new APIs for N_MR1, O, O_MR1 and P, convert to N. - Opts.mTargetAPI = SLANG_N_TARGET_API; + // No new APIs after N, convert to N. + Opts.mTargetAPI = SLANG_MAXIMUM_TARGET_API; } if ((Opts.mTargetAPI < 21) || (Opts.mBitcodeStorage == BCST_CPP_CODE)) diff --git a/slang_version.h b/slang_version.h index 7ca6230..e6e47a3 100644 --- a/slang_version.h +++ b/slang_version.h @@ -46,7 +46,12 @@ enum SlangTargetAPI { SLANG_O_TARGET_API = 26, SLANG_O_MR1_TARGET_API = 27, SLANG_P_TARGET_API = 28, + SLANG_Q_TARGET_API = 29, + SLANG_R_TARGET_API = 30, + SLANG_S_TARGET_API = 31, SLANG_MAXIMUM_TARGET_API = RS_VERSION, + // The maximum API level that is acceptable for the "-target-api" commandline option. + SLANG_MAXIMUM_CMDLINE_TARGET_API = SLANG_S_TARGET_API, SLANG_DEVELOPMENT_TARGET_API = RS_DEVELOPMENT_API }; // Note that RS_VERSION is defined at build time (see Android.mk for details). diff --git a/tests/P_warnings_deprecated/deprecated.rscript b/tests/P_warnings_deprecated/deprecated.rscript index 4e5f5af..03f0185 100644 --- a/tests/P_warnings_deprecated/deprecated.rscript +++ b/tests/P_warnings_deprecated/deprecated.rscript @@ -1,4 +1,4 @@ -// -target-api 22 +// -target-api 22 -Wdeprecated-declarations #pragma version(1) #pragma rs java_package_name(foo) diff --git a/tests/P_warnings_deprecated/stderr.txt.expect b/tests/P_warnings_deprecated/stderr.txt.expect index ca4afee..4241202 100644 --- a/tests/P_warnings_deprecated/stderr.txt.expect +++ b/tests/P_warnings_deprecated/stderr.txt.expect @@ -1,3 +1,4 @@ +warning: Renderscript is deprecated: Please refer to the migration guide (https://developer.android.com/guide/topics/renderscript/migration-guide) for the proposed alternatives. deprecated.rscript:9:9: warning: 'rsClamp' is deprecated: Use clamp() instead. ../../../../../frameworks/rs/script_api/include/rs_math.rsh:6482:5: note: 'rsClamp' has been explicitly marked deprecated here deprecated.rscript:10:8: warning: 'rsGetAllocation' is deprecated: This function is deprecated and will be removed from the SDK in a future release. diff --git a/tests/slang_test.py b/tests/slang_test.py index 82593cc..628ec7f 100755 --- a/tests/slang_test.py +++ b/tests/slang_test.py @@ -163,7 +163,7 @@ GetOutDir.cache = None def CreateCmd(): """Creates the test command to run for the current test.""" - cmd_string = ('%s/bin/llvm-rs-cc -o tmp/ -p tmp/ -MD ' + cmd_string = ('%s/bin/llvm-rs-cc -o tmp/ -p tmp/ -MD -Wno-deprecated-declarations ' '-I ../../../../../frameworks/rs/script_api/include/ ' '-I ../../../../../external/clang/lib/Headers/') % GetOutDir() base_args = cmd_string.split() |