[gjs: 2/5] maint: Bring headers in line with IWYU 0.18




commit ef14a8a445cb5c596144309795c37436cb653b90
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Jul 24 23:51:02 2022 -0700

    maint: Bring headers in line with IWYU 0.18
    
    As with every release, IWYU's algorithms have slightly changed, and some
    bugs have been fixed meaning we can remove some workarounds from the
    postprocessing script; unfortunately other bugs have appeared as well.

 gi/boxed.h                 |  4 +---
 gi/closure.h               |  1 -
 gi/function.h              |  2 +-
 gi/object.h                |  4 +---
 gi/union.cpp               |  1 -
 gi/utils-inl.h             |  2 --
 gjs/byteArray.cpp          |  1 -
 gjs/context-private.h      |  5 ++---
 gjs/gjs_pch.hh             |  2 ++
 gjs/jsapi-util-error.cpp   |  5 +----
 gjs/jsapi-util-string.cpp  |  1 +
 gjs/jsapi-util.cpp         |  5 +----
 gjs/profiler.cpp           |  1 -
 test/gjs-test-rooting.cpp  |  1 -
 test/gjs-test-utils.h      |  3 +--
 tools/gjs-private-iwyu.imp |  1 +
 tools/process_iwyu.py      | 31 ++++++++++++++-----------------
 17 files changed, 26 insertions(+), 44 deletions(-)
---
diff --git a/gi/boxed.h b/gi/boxed.h
index 29a0d9d6a..ef2404a6f 100644
--- a/gi/boxed.h
+++ b/gi/boxed.h
@@ -15,6 +15,7 @@
 #include <glib-object.h>
 #include <glib.h>
 
+#include <js/AllocPolicy.h>
 #include <js/GCHashTable.h>  // for GCHashMap
 #include <js/HashTable.h>    // for DefaultHasher
 #include <js/Id.h>
@@ -33,9 +34,6 @@ class JSTracer;
 namespace JS {
 class CallArgs;
 }
-namespace js {
-class SystemAllocPolicy;
-}
 
 /* To conserve memory, we have two different kinds of private data for GBoxed
  * JS wrappers: BoxedInstance, and BoxedPrototype. Both inherit from BoxedBase
diff --git a/gi/closure.h b/gi/closure.h
index a9110fc57..a13e040aa 100644
--- a/gi/closure.h
+++ b/gi/closure.h
@@ -12,7 +12,6 @@
 #include <glib-object.h>
 #include <stddef.h>
 
-#include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
 
 #include "gi/utils-inl.h"
diff --git a/gi/function.h b/gi/function.h
index b70c7e297..5db20ec8b 100644
--- a/gi/function.h
+++ b/gi/function.h
@@ -14,13 +14,13 @@
 
 #include <ffi.h>
 #include <girepository.h>
+#include <girffi.h>  // for g_callable_info_get_closure_native_address
 #include <glib-object.h>
 #include <glib.h>
 
 #include <js/GCVector.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
-#include <js/Value.h>  // IWYU pragma: keep
 
 #include "gi/closure.h"
 #include "gjs/jsapi-util.h"
diff --git a/gi/object.h b/gi/object.h
index f73e73585..0985845e9 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -17,6 +17,7 @@
 #include <glib-object.h>
 #include <glib.h>
 
+#include <js/AllocPolicy.h>
 #include <js/GCHashTable.h>  // for GCHashMap
 #include <js/HashTable.h>    // for DefaultHasher
 #include <js/Id.h>
@@ -38,9 +39,6 @@ class JSTracer;
 namespace JS {
 class CallArgs;
 }
-namespace js {
-class SystemAllocPolicy;
-}
 namespace Gjs {
 namespace Test {
 struct ObjectInstance;
diff --git a/gi/union.cpp b/gi/union.cpp
index 0b310ed18..5096f7a56 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -5,7 +5,6 @@
 #include <config.h>
 
 #include <girepository.h>
-#include <glib.h>  // for g_atomic_rc_box_acquire, ...
 
 #include <js/CallArgs.h>
 #include <js/Class.h>
diff --git a/gi/utils-inl.h b/gi/utils-inl.h
index 96a17da35..e7b6c734b 100644
--- a/gi/utils-inl.h
+++ b/gi/utils-inl.h
@@ -8,8 +8,6 @@
 
 #include <stdint.h>
 
-#include <algorithm>    // IWYU pragma: keep (for find)
-#include <type_traits>  // IWYU pragma: keep
 #include <utility>      // IWYU pragma: keep (for swap)
 #include <vector>
 
diff --git a/gjs/byteArray.cpp b/gjs/byteArray.cpp
index 9380c3d3d..455075fa7 100644
--- a/gjs/byteArray.cpp
+++ b/gjs/byteArray.cpp
@@ -6,7 +6,6 @@
 
 #include <stdint.h>
 
-#include <girepository.h>
 #include <glib-object.h>
 #include <glib.h>
 
diff --git a/gjs/context-private.h b/gjs/context-private.h
index 3bc7d50fa..a109f579a 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -21,6 +21,7 @@
 #include <glib-object.h>
 #include <glib.h>
 
+#include <js/AllocPolicy.h>
 #include <js/Context.h>
 #include <js/GCAPI.h>
 #include <js/GCHashTable.h>
@@ -32,6 +33,7 @@
 #include <js/UniquePtr.h>
 #include <js/ValueArray.h>
 #include <jsfriendapi.h>  // for ScriptEnvironmentPreparer
+#include <mozilla/Vector.h>
 
 #include "gi/closure.h"
 #include "gjs/context.h"
@@ -41,9 +43,6 @@
 #include "gjs/profiler.h"
 #include "gjs/promise.h"
 
-namespace js {
-class SystemAllocPolicy;
-}
 class GjsAtoms;
 class JSTracer;
 
diff --git a/gjs/gjs_pch.hh b/gjs/gjs_pch.hh
index 337e585f5..ff91229bf 100644
--- a/gjs/gjs_pch.hh
+++ b/gjs/gjs_pch.hh
@@ -108,8 +108,10 @@
 #include <mozilla/HashTable.h>
 #include <mozilla/Likely.h>
 #include <mozilla/Maybe.h>
+#include <mozilla/Span.h>
 #include <mozilla/UniquePtr.h>
 #include <mozilla/Unused.h>
+#include <mozilla/Vector.h>
 #ifdef HAVE_READLINE_READLINE_H
 #include <readline/history.h>
 #include <readline/readline.h>
diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp
index cefaba363..c003904b9 100644
--- a/gjs/jsapi-util-error.cpp
+++ b/gjs/jsapi-util-error.cpp
@@ -8,6 +8,7 @@
 
 #include <glib.h>
 
+#include <js/AllocPolicy.h>
 #include <js/CharacterEncoding.h>
 #include <js/ErrorReport.h>
 #include <js/Exception.h>
@@ -28,10 +29,6 @@
 #include "util/log.h"
 #include "util/misc.h"
 
-namespace js {
-class SystemAllocPolicy;
-}
-
 using CauseSet = JS::GCHashSet<JSObject*, js::DefaultHasher<JSObject*>,
                                js::SystemAllocPolicy>;
 
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index a39a0c055..29e56c9e2 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -32,6 +32,7 @@
 #include <jsapi.h>        // for JS_GetFunctionDisplayId
 #include <jsfriendapi.h>  // for IdToValue, IsFunctionObject, ...
 #include <mozilla/CheckedInt.h>
+#include <mozilla/Span.h>
 
 #include "gjs/jsapi-util.h"
 #include "gjs/macros.h"
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 4dc442705..3acb66421 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -17,6 +17,7 @@
 #include <utility>  // for move
 #include <vector>
 
+#include <js/AllocPolicy.h>
 #include <js/Array.h>
 #include <js/CallArgs.h>
 #include <js/CharacterEncoding.h>
@@ -43,10 +44,6 @@
 #include "gjs/jsapi-util.h"
 #include "gjs/macros.h"
 
-namespace js {
-class SystemAllocPolicy;
-}
-
 static void
 throw_property_lookup_error(JSContext       *cx,
                             JS::HandleObject obj,
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index 095f7a63f..db020e025 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -16,7 +16,6 @@
 #    include <stdint.h>
 #    include <stdio.h>      // for sscanf
 #    include <string.h>     // for memcpy, strlen
-#    include <sys/types.h>  // for timer_t
 #    include <syscall.h>    // for __NR_gettid
 #    include <time.h>       // for size_t, CLOCK_MONOTONIC, itimerspec, ...
 #    ifdef HAVE_UNISTD_H
diff --git a/test/gjs-test-rooting.cpp b/test/gjs-test-rooting.cpp
index 7a82f70df..edf8656ba 100644
--- a/test/gjs-test-rooting.cpp
+++ b/test/gjs-test-rooting.cpp
@@ -8,7 +8,6 @@
 #include <js/Class.h>
 #include <js/GCAPI.h>  // for JS_GC, JS_SetGCCallback, JSGCStatus
 #include <js/Object.h>
-#include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
 #include <js/Value.h>
 #include <jsapi.h>  // for JS_NewObject
diff --git a/test/gjs-test-utils.h b/test/gjs-test-utils.h
index b641e8cd8..ebb5e8850 100644
--- a/test/gjs-test-utils.h
+++ b/test/gjs-test-utils.h
@@ -10,11 +10,10 @@
 
 #include <glib.h>    // for g_assert_...
 #include <stdint.h>  // for uintptr_t
-#include <iterator>  // for pair
 #include <limits>    // for numeric_limits
 #include <string>
 #include <type_traits>  // for is_same
-#include <utility>  // IWYU pragma: keep
+#include <utility>
 
 #include "gjs/context.h"
 
diff --git a/tools/gjs-private-iwyu.imp b/tools/gjs-private-iwyu.imp
index a5695102e..ce86e59e8 100644
--- a/tools/gjs-private-iwyu.imp
+++ b/tools/gjs-private-iwyu.imp
@@ -3,6 +3,7 @@
 
 # IWYU mapping file for files that are part of libgjs
 [
+  {"include": ["<bits/chrono.h>", "private", "<chrono>", "public"]},
   {"include": ["<bits/this_thread_sleep.h>", "private", "<thread>", "public"]},
   {"include": ["<bits/sigevent-consts.h>", "private", "<signal.h>", "public"]},
   {"include": ["<bits/siginfo-consts.h>", "private", "<signal.h>", "public"]},
diff --git a/tools/process_iwyu.py b/tools/process_iwyu.py
index 4d5288ecb..05865560d 100755
--- a/tools/process_iwyu.py
+++ b/tools/process_iwyu.py
@@ -70,22 +70,14 @@ FALSE_POSITIVES = (
     # std::vector::push_back()
     # https://github.com/include-what-you-use/include-what-you-use/issues/908
     ('gi/function.cpp', '#include <algorithm>', 'for max'),
+    ('gi/function.cpp', '#include <algorithm>', 'for fill_n, max'),  # also!
     ('gi/private.cpp', '#include <algorithm>', 'for max'),
-    ('gjs/importer.cpp', '#include <algorithm>', 'for max'),
+    ('gjs/context.cpp', '#include <algorithm>', 'for copy, max, find'),
+    ('gjs/importer.cpp', '#include <algorithm>', 'for max, copy'),
     ('modules/cairo-context.cpp', '#include <algorithm>', 'for max'),
 
-    # False positive when using Mozilla vectors' append() and
-    # infallibleAppend()
-    # https://github.com/include-what-you-use/include-what-you-use/issues/926
-    # https://bugzilla.mozilla.org/show_bug.cgi?id=1713550
-    ('gi/function.cpp', '#include <utility>', 'for forward'),
-    ('gi/ns.cpp', '#include <utility>', 'for forward'),
-    ('gjs/module.cpp', '#include <utility>', 'for forward'),
-    ('gjs/objectbox.cpp', '#include <utility>', 'for forward'),
-
     # False positive when using EnumType operators
     # https://github.com/include-what-you-use/include-what-you-use/issues/927
-    ('gi/arg-cache.h', '#include <type_traits>', 'for enable_if_t'),
     ('modules/cairo-context.cpp', '#include <type_traits>', 'for enable_if_t'),
     ('modules/cairo-region.cpp', '#include <type_traits>', 'for enable_if_t'),
     ('modules/cairo-surface.cpp', '#include <type_traits>', 'for enable_if_t'),
@@ -95,8 +87,6 @@ FALSE_POSITIVES = (
     ('gi/boxed.cpp', '#include <type_traits>', 'for remove_reference<>::type'),
     ('gi/interface.cpp', '#include <type_traits>',
      'for remove_reference<>::type'),
-    ('gi/object.cpp', '#include <type_traits>',
-     'for remove_reference<>::type'),
     ('gi/private.cpp', '#include <type_traits>',
      'for remove_reference<>::type'),
     ('gi/value.cpp', '#include <type_traits>', 'for remove_reference<>::type'),
@@ -108,13 +98,20 @@ FALSE_POSITIVES = (
      'for remove_reference<>::type'),
     ('gjs/profiler.cpp', '#include <type_traits>',
      'for remove_reference<>::type'),
-    ('gjs/promise.cpp', '#include <type_traits>',
-     'for remove_reference<>::type'),
     ('test/gjs-test-jsapi-utils.cpp', '#include <type_traits>',
      'for remove_reference<>::type'),
 
-    # Weird false positive on some versions of IWYU
-    ('gi/arg.cpp', 'struct _GVariant;', ''),
+    # False positive when constructing JS::GCHashMap
+    ('gi/boxed.h', '#include <utility>', 'for move'),
+    ('gi/object.h', '#include <utility>', 'for move'),
+    ('gjs/jsapi-util-error.cpp', '#include <utility>', 'for move'),
+    ('gjs/jsapi-util-error.h', '#include <utility>', 'for move'),
+
+    # Haven't managed to diagnose this one. It's triggered by replacing log.cpp
+    # with the following code, but not by that code in a standalone file.
+    # #include <vector>
+    # static std::vector<bool> v;
+    # void f() { v = std::vector<bool>(1, true); }
     ('util/log.cpp', '#include <algorithm>', 'for copy'),
 
     # For some reason IWYU wants these with angle brackets when they are


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]