Enable raw_ptr usage enforcement for PDFium.

Reduce the scope of the files over which the plugin is run to
avoid false positives and save some cycles. Do not enable on
Windows yet to make incremental progress.

Change-Id: Idf65aa9c4015bb2f30b70043ac47f402aad72714
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107370
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 62a57c9..14c123b 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -221,56 +221,6 @@
 
     # May flag some issues when converting int to size_t.
     cflags += [ "-Wtautological-unsigned-zero-compare" ]
-
-    if (clang_use_chrome_plugins) {
-      # Catch misuse of C-style pointers.
-      cflags += [
-        # TODO(tsepez): enable these tests.
-        #"-Xclang",
-        #"-plugin-arg-find-bad-constructs",
-        #"-Xclang",
-        #"check-raw-ptr-fields",
-
-        #"-Xclang",
-        #"-plugin-arg-find-bad-constructs",
-        #"-Xclang",
-        #"raw-ptr-exclude-path=public",
-
-        #"-Xclang",
-        #"-plugin-arg-find-bad-constructs",
-        #"-Xclang",
-        #"raw-ptr-exclude-path=testing",
-
-        #"-Xclang",
-        #"-plugin-arg-find-bad-constructs",
-        #"-Xclang",
-        #"raw-ptr-exclude-path=unittest",
-
-        #"-Xclang",
-        #"-plugin-arg-find-bad-constructs",
-        #"-Xclang",
-        #"raw-ptr-exclude-path=embeddertest",
-
-        # TODO(tsepez): enforce raw_ref<> as well.
-        # "-Xclang",
-        # "-plugin-arg-find-bad-constructs",
-        # "-Xclang",
-        # "check-raw-ref-fields",
-      ]
-      defines += [
-        #"PDF_ENABLE_UNOWNED_PTR_EXCLUSION",
-      ]
-
-      # Catch misuse of cppgc in XFA.
-      if (pdf_enable_xfa) {
-        cflags += [
-          "-Xclang",
-          "-add-plugin",
-          "-Xclang",
-          "blink-gc-plugin",
-        ]
-      }
-    }
   }
 
   if (!is_win && !is_clang) {
@@ -333,9 +283,54 @@
   }
 }
 
+config("pdfium_plugin_config") {
+  cflags = []
+  defines = []
+  if (clang_use_chrome_plugins) {
+    # Catch misuse of C-style pointers.
+    # TODO(tsepez): enable for windows, too.
+    if (!is_win) {
+      cflags += [
+        "-Xclang",
+        "-plugin-arg-find-bad-constructs",
+        "-Xclang",
+        "check-raw-ptr-fields",
+
+        "-Xclang",
+        "-plugin-arg-find-bad-constructs",
+        "-Xclang",
+        "raw-ptr-exclude-path=public",
+
+        "-Xclang",
+        "-plugin-arg-find-bad-constructs",
+        "-Xclang",
+        "raw-ptr-exclude-path=test",
+
+        # TODO(tsepez): enforce raw_ref<> as well.
+        # "-Xclang",
+        # "-plugin-arg-find-bad-constructs",
+        # "-Xclang",
+        # "check-raw-ref-fields",
+      ]
+      defines += [ "PDF_ENABLE_UNOWNED_PTR_EXCLUSION" ]
+    }
+
+    # Catch misuse of cppgc in XFA.
+    if (pdf_enable_xfa) {
+      cflags += [
+        "-Xclang",
+        "-add-plugin",
+        "-Xclang",
+        "blink-gc-plugin",
+      ]
+    }
+  }
+}
+
 config("pdfium_strict_config") {
   configs = [
     ":pdfium_core_config",
+    ":pdfium_plugin_config",
     "//build/config/compiler:wexit_time_destructors",
     "//build/config/compiler:wglobal_constructors",
   ]