add -W<warning>/-Werror CLI options

-Weverything: enable all diagnotics
-Wfoo: enable "foo"
-Wno-foo: disable "foo"

-Werror: turn diagnostic warnings into errors
-Wno-error=foo: turn "foo" into a warning

For now, only -Winterface-name is available, which checks if interface
names start with "I".

Bug: 168028537
Test: aidl_unittests
Change-Id: I31516b337dd80b9833205bf769af40e49f88d15d
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 30b6abc..b829f6b 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -4312,6 +4312,26 @@
   EXPECT_NE(nullptr, Parse("IFoo.aidl", contents, typenames_, GetLanguage()));
 }
 
+TEST_P(AidlTest, WarningInterfaceName) {
+  io_delegate_.SetFileContents("p/Foo.aidl", "interface Foo {}");
+  auto options = Options::From("aidl --lang " + Options::LanguageToString(GetLanguage()) +
+                               " -Weverything -o out -h out p/Foo.aidl");
+  CaptureStderr();
+  EXPECT_EQ(0, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("WARNING: p/Foo.aidl:1.1-10: Interface names should start with I.\n",
+            GetCapturedStderr());
+}
+
+TEST_P(AidlTest, ErrorInterfaceName) {
+  io_delegate_.SetFileContents("p/Foo.aidl", "interface Foo {}");
+  auto options = Options::From("aidl --lang " + Options::LanguageToString(GetLanguage()) +
+                               " -Weverything -Werror -o out -h out p/Foo.aidl");
+  CaptureStderr();
+  EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+  EXPECT_EQ("ERROR: p/Foo.aidl:1.1-10: Interface names should start with I.\n",
+            GetCapturedStderr());
+}
+
 struct TypeParam {
   string kind;
   string literal;