Browse files

Generate warnings properly for multi-file compiles.

BUG=5367019

Slang (llvm-rs-cc) was clobbering warnings during multi-file compilation
because they are not part of the error count. When the diagnostics get reset,
we should be dumping whichever non-error (i.e. warning) diagnostics we have
accumulated. During investigation, I also found then that our dependency
generation path can cause duplicate warnings to be added to the diagnostic
client. Thus, to fix this bug, the change need dumps relevant diagnostics, but
then suppresses warnings if we are compiling the same file multiple times
(once for code generation and once for dependencies).

Change-Id: I4b94e962f93b96f31ff7e7d6cce45418fe39e1d1
  • Loading branch information...
1 parent 3f175af commit c632be206ac4fe49a5db05cfa54942d774329dbe @stephenhines stephenhines committed Sep 23, 2011
View
2 llvm-rs-cc.cpp
@@ -444,7 +444,7 @@ int main(int argc, const char **argv) {
Opts.mTargetAPI,
Opts.mJavaReflectionPathBase,
Opts.mJavaReflectionPackageName);
- llvm::errs() << Compiler->getErrorMessage();
+ Compiler->reset();
return CompileFailed;
}
View
1 slang.cpp
@@ -457,6 +457,7 @@ int Slang::compile() {
}
void Slang::reset() {
+ llvm::errs() << mDiagClient->str();
mDiagnostics->Reset();
mDiagClient->reset();
return;
View
10 slang_rs.cpp
@@ -295,6 +295,10 @@ bool SlangRS::compile(
return false;
}
+ // Skip generation of warnings a second time if we are doing more than just
+ // a single pass over the input file.
+ bool SuppressAllWarnings = (OutputType != Slang::OT_Dependency);
+
for (unsigned i = 0, e = IOFiles.size(); i != e; i++) {
InputFile = IOFileIter->first;
OutputFile = IOFileIter->second;
@@ -342,8 +346,14 @@ bool SlangRS::compile(
if (!setDepOutput(DepOutputFile))
return false;
+ if (SuppressAllWarnings) {
+ getDiagnostics().setSuppressAllDiagnostics(true);
+ }
if (generateDepFile() > 0)
return false;
+ if (SuppressAllWarnings) {
+ getDiagnostics().setSuppressAllDiagnostics(false);
+ }
DepFileIter++;
}
View
1 tests/P_unknown_function/stderr.txt.expect
@@ -0,0 +1 @@
+unknown_function.rs:6:5: warning: implicit declaration of function 'rsgProgramStoreGetDepthFunc' is invalid in C99
View
2 tests/P_unknown_function/stdout.txt.expect
@@ -0,0 +1,2 @@
+Generating ScriptC_unknown_function.java ...
+Generating ScriptC_zzz.java ...
View
8 tests/P_unknown_function/unknown_function.rs
@@ -0,0 +1,8 @@
+#pragma version(1)
+#pragma rs java_package_name(foo)
+
+void foo() {
+ rs_program_store ps;
+ rsgProgramStoreGetDepthFunc(ps);
+}
+
View
5 tests/P_unknown_function/zzz.rs
@@ -0,0 +1,5 @@
+#pragma version(1)
+#pragma rs java_package_name(foo)
+
+int i;
+
View
1 tests/test.py
@@ -65,6 +65,7 @@ def ExecTest(dirname):
cmd_string = ('../../../../../out/host/linux-x86/bin/llvm-rs-cc '
'-o tmp/ -p tmp/ '
+ '-MD '
'-I ../../../../../frameworks/base/libs/rs/scriptc/ '
'-I ../../../../../external/clang/lib/Headers/')
base_args = cmd_string.split()

0 comments on commit c632be2

Please sign in to comment.