Adjust BUILD.gn files for path-based unsafe buffer warnings.

Prepare for using the clang plugin-based filtering mechanism for
unsafe buffer warnings. This is enabled automatically as appropriate in
build/config/clang/BUILD.gn (sync'ed from outside of pdfium repository
along with other tools). It is enabled on a directory-by-directory basis
based on some paths.txt file (location to be specified via a GN variable
following a build/ roll past https://crrev.com/c/5369835.

Change-Id: I030dc5d15b2b9ea0541af146bcce5d61df13ffee
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117510
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 9ae3656..193024a 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -343,13 +343,6 @@
   ]
 }
 
-config("pdfium_nounsafe_buffer_usage_config") {
-  cflags = []
-  if (is_clang) {
-    cflags += [ "-Wunsafe-buffer-usage" ]
-  }
-}
-
 config("pdfium_noshorten_config") {
   cflags = []
   if (is_clang) {
diff --git a/core/fxcrt/BUILD.gn b/core/fxcrt/BUILD.gn
index b7b8578..bd5d617 100644
--- a/core/fxcrt/BUILD.gn
+++ b/core/fxcrt/BUILD.gn
@@ -144,7 +144,6 @@
   configs += [
     "../../:pdfium_strict_config",
     "../../:pdfium_noshorten_config",
-    "../../:pdfium_nounsafe_buffer_usage_config",
   ]
   public_deps = [
     "../../:freetype_common",
diff --git a/core/fxcrt/compiler_specific.h b/core/fxcrt/compiler_specific.h
index 00b84af..a2d0b68 100644
--- a/core/fxcrt/compiler_specific.h
+++ b/core/fxcrt/compiler_specific.h
@@ -83,21 +83,17 @@
 #define UNSAFE_BUFFER_USAGE
 #endif
 
-#if defined(__clang__)
 // clang-format off
 // Formatting is off so that we can put each _Pragma on its own line, as
 // recommended by the gcc docs.
+#if defined(__clang__)
 #define UNSAFE_BUFFERS(...)                  \
   _Pragma("clang unsafe_buffer_usage begin") \
   __VA_ARGS__                                \
   _Pragma("clang unsafe_buffer_usage end")
-// clang-format on
-#define UNSAFE_BUFFERS_INCLUDE_BEGIN _Pragma("clang unsafe_buffer_usage begin")
-#define UNSAFE_BUFFERS_INCLUDE_END _Pragma("clang unsafe_buffer_usage end")
 #else
 #define UNSAFE_BUFFERS(...) __VA_ARGS__
-#define UNSAFE_BUFFERS_INCLUDE_BEGIN
-#define UNSAFE_BUFFERS_INCLUDE_END
 #endif
+// clang-format on
 
 #endif  // CORE_FXCRT_COMPILER_SPECIFIC_H_
diff --git a/core/fxcrt/css/BUILD.gn b/core/fxcrt/css/BUILD.gn
index 3482f71..cd138b6 100644
--- a/core/fxcrt/css/BUILD.gn
+++ b/core/fxcrt/css/BUILD.gn
@@ -54,7 +54,6 @@
   configs += [
     "../../../:pdfium_strict_config",
     "../../../:pdfium_noshorten_config",
-    "../../../:pdfium_nounsafe_buffer_usage_config",
   ]
   deps = [
     "../",
diff --git a/core/fxcrt/fx_memory_pa.cpp b/core/fxcrt/fx_memory_pa.cpp
index 6241f83..d7a1e72 100644
--- a/core/fxcrt/fx_memory_pa.cpp
+++ b/core/fxcrt/fx_memory_pa.cpp
@@ -10,9 +10,7 @@
 #include "core/fxcrt/fx_safe_types.h"
 
 #if defined(PDF_USE_PARTITION_ALLOC)
-UNSAFE_BUFFERS_INCLUDE_BEGIN
 #include "partition_alloc/partition_alloc.h"
-UNSAFE_BUFFERS_INCLUDE_END
 #else
 #error "File compiled under wrong build option."
 #endif
diff --git a/core/fxcrt/raw_span.h b/core/fxcrt/raw_span.h
index ff570e3..7f2eb37 100644
--- a/core/fxcrt/raw_span.h
+++ b/core/fxcrt/raw_span.h
@@ -9,9 +9,7 @@
 #include "core/fxcrt/span.h"
 
 #if defined(PDF_USE_PARTITION_ALLOC)
-UNSAFE_BUFFERS_INCLUDE_BEGIN
 #include "partition_alloc/pointers/raw_ptr.h"
-UNSAFE_BUFFERS_INCLUDE_END
 #else
 #include "core/fxcrt/unowned_ptr_exclusion.h"
 #endif
diff --git a/core/fxcrt/unowned_ptr.h b/core/fxcrt/unowned_ptr.h
index 4e77c5f..264c2d0 100644
--- a/core/fxcrt/unowned_ptr.h
+++ b/core/fxcrt/unowned_ptr.h
@@ -42,10 +42,8 @@
 #include "core/fxcrt/compiler_specific.h"
 
 #if defined(PDF_USE_PARTITION_ALLOC)
-UNSAFE_BUFFERS_INCLUDE_BEGIN
 #include "partition_alloc/partition_alloc_buildflags.h"
 #include "partition_alloc/pointers/raw_ptr.h"
-UNSAFE_BUFFERS_INCLUDE_END
 
 #if !BUILDFLAG(USE_PARTITION_ALLOC)
 #error "pdf_use_partition_alloc=true requires use_partition_alloc=true"