[llvm-bcanalyzer] Don't dump the contents if -dump is not passed
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Wed, 13 Nov 2019 18:37:14 +0000 (10:37 -0800)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Wed, 13 Nov 2019 18:38:57 +0000 (10:38 -0800)
With all the previous refactorings this slipped through and now we
always dump the contents of the bitcode files, even if -dump is not
passed.

llvm/test/Other/bcanalyzer-dump-option.txt [new file with mode: 0644]
llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp

diff --git a/llvm/test/Other/bcanalyzer-dump-option.txt b/llvm/test/Other/bcanalyzer-dump-option.txt
new file mode 100644 (file)
index 0000000..1da2a03
--- /dev/null
@@ -0,0 +1,11 @@
+RUN: llvm-bcanalyzer -dump %S/Inputs/has-block-info.bc | FileCheck -check-prefix=WITH-DUMP %s
+RUN: llvm-bcanalyzer %S/Inputs/has-block-info.bc | FileCheck -check-prefix=WITHOUT-DUMP %s
+
+WITH-DUMP: <ABC
+WITHOUT-DUMP-NOT: <ABC
+WITH-DUMP: </ABC>
+WITHOUT-DUMP-NOT: </ABC>
+WITH-DUMP: <XYZ
+WITHOUT-DUMP-NOT: <XYZ
+WITH-DUMP: </XYZ>
+WITHOUT-DUMP-NOT: </XYZ>
index 01cba1f6e3c96d39d6f5772d7a9af7128099a026..639a6d1ec02cd3acbf23b516a87464f6a5539eb9 100644 (file)
@@ -102,8 +102,9 @@ int main(int argc, char **argv) {
   O.Symbolic = !NonSymbolic;
   O.ShowBinaryBlobs = ShowBinaryBlobs;
 
-  ExitOnErr(
-      BA.analyze(O, CheckHash.empty() ? None : Optional<StringRef>(CheckHash)));
+  ExitOnErr(BA.analyze(
+      Dump ? Optional<BCDumpOptions>(O) : Optional<BCDumpOptions>(None),
+      CheckHash.empty() ? None : Optional<StringRef>(CheckHash)));
 
   if (Dump)
     outs() << "\n\n";