diff options
author | Xusong Wang <xusongw@google.com> | 2021-04-23 01:41:34 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-04-23 01:41:34 +0000 |
commit | c18239d6f4107dc46003e62358e84e5ffd4e40a2 (patch) | |
tree | 9d0f3b222b928760723ac8abafe0067b9fdc60b5 | |
parent | 1c41f89ff006ba09936f40b967ccd9a9f6136b1a (diff) | |
parent | 2326fcb8e4e7a4a3a298400b2d677c85ad6f629a (diff) | |
download | slang-c18239d6f4107dc46003e62358e84e5ffd4e40a2.tar.gz |
Merge "Have slang emit a warning on renderscript deprecation." am: 2326fcb8e4
Original change: https://android-review.googlesource.com/c/platform/frameworks/compile/slang/+/1685186
Change-Id: I88342580bca3a5b4195ca8374172f485d63ecebb
-rw-r--r-- | llvm-rs-cc.cpp | 10 | ||||
-rw-r--r-- | rs_cc_options.cpp | 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 |
5 files changed, 18 insertions, 2 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..ad1dc13 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; 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() |