[gjs: 1/12] CI: Fix bug in IWYU mapping file




commit 792a9d944fa3d2408481debccc0bec2d523d22c1
Author: Philip Chimento <philip chimento gmail com>
Date:   Mon Nov 23 21:55:58 2020 -0800

    CI: Fix bug in IWYU mapping file
    
    Oops, we accidentally made the IWYU mapping file invalid, so the IWYU job
    was not functioning correctly. Move the workaround into the postprocessing
    script, and fix all the include fixes that have been missed in the
    meantime while this was broken.
    
    New code has also exposed some false positives in IWYU, so add those
    exceptions to the false positive list.

 gi/arg-cache.cpp           |  3 +++
 gi/arg-cache.h             |  1 +
 gi/arg.cpp                 |  2 +-
 gi/arg.h                   |  2 +-
 gi/boxed.cpp               |  1 +
 gi/fundamental.cpp         |  1 +
 gi/gerror.h                |  1 +
 gi/interface.cpp           |  1 +
 gi/repo.cpp                |  1 -
 gi/union.cpp               |  1 +
 gi/wrapperutils.h          |  1 -
 modules/cairo-context.cpp  |  1 +
 modules/cairo-region.cpp   |  1 +
 modules/cairo-surface.cpp  |  1 +
 tools/gjs-private-iwyu.imp |  3 ---
 tools/process_iwyu.py      | 26 ++++++++++++++++++++++++++
 16 files changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index a4289cc8..53ca5b5b 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -7,7 +7,9 @@
 #include <inttypes.h>
 #include <stdint.h>
 #include <string.h>
+
 #include <limits>
+#include <unordered_set>  // for unordered_set::erase(), insert()
 
 #include <ffi.h>
 #include <girepository.h>
@@ -37,6 +39,7 @@
 #include "gi/param.h"
 #include "gi/union.h"
 #include "gi/value.h"
+#include "gi/wrapperutils.h"  // for GjsTypecheckNoThrow
 #include "gjs/byteArray.h"
 #include "gjs/jsapi-util.h"
 #include "util/log.h"
diff --git a/gi/arg-cache.h b/gi/arg-cache.h
index 0d553443..6b19e6d8 100644
--- a/gi/arg-cache.h
+++ b/gi/arg-cache.h
@@ -18,6 +18,7 @@
 #include <js/TypeDecls.h>
 
 #include "gi/arg.h"
+#include "gjs/enum-utils.h"
 #include "gjs/macros.h"
 
 struct GjsFunctionCallState;
diff --git a/gi/arg.cpp b/gi/arg.cpp
index e565437c..59d231b4 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -7,7 +7,6 @@
 
 #include <string.h>  // for strcmp, strlen, memcpy
 
-#include <memory>  // for operator!=, unique_ptr
 #include <string>
 
 #include <girepository.h>
@@ -45,6 +44,7 @@
 #include "gjs/atoms.h"
 #include "gjs/byteArray.h"
 #include "gjs/context-private.h"
+#include "gjs/enum-utils.h"
 #include "gjs/jsapi-util.h"
 #include "util/log.h"
 
diff --git a/gi/arg.h b/gi/arg.h
index 6c91f0b8..90ea60fb 100644
--- a/gi/arg.h
+++ b/gi/arg.h
@@ -13,9 +13,9 @@
 #include <girepository.h>
 #include <glib-object.h>
 
+#include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
 
-#include "gjs/enum-utils.h"
 #include "gjs/macros.h"
 
 // Different roles for a GIArgument; currently used only in exception and debug
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 96fdc89d..d349e3d2 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -20,6 +20,7 @@
 #include <js/GCVector.h>     // for MutableWrappedPtrOperations
 #include <js/TracingAPI.h>
 #include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
 #include <js/Value.h>
 #include <js/ValueArray.h>
 #include <jsapi.h>  // for IdVector, JS_AtomizeAndPinJSString
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index d5103d1b..c60d18f8 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -13,6 +13,7 @@
 #include <js/GCHashTable.h>  // for WeakCache
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
 #include <jsapi.h>  // for InformalValueTypeName, JS_GetClass
 #include <mozilla/HashTable.h>
 
diff --git a/gi/gerror.h b/gi/gerror.h
index 9968d4e8..104bc765 100644
--- a/gi/gerror.h
+++ b/gi/gerror.h
@@ -15,6 +15,7 @@
 #include <js/TypeDecls.h>
 
 #include "gi/wrapperutils.h"
+#include "gjs/jsapi-util.h"  // for GjsAutoPointer operators
 #include "gjs/macros.h"
 #include "util/log.h"
 
diff --git a/gi/interface.cpp b/gi/interface.cpp
index 4c309f50..23b64fab 100644
--- a/gi/interface.cpp
+++ b/gi/interface.cpp
@@ -9,6 +9,7 @@
 
 #include <js/Class.h>
 #include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
 
 #include "gi/function.h"
 #include "gi/interface.h"
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 1f76d847..446addc1 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -15,7 +15,6 @@
 #include <js/ComparisonOperators.h>
 #include <js/Id.h>                  // for JSID_IS_STRING, JSID_VOID
 #include <js/PropertyDescriptor.h>  // for JSPROP_PERMANENT, JSPROP_RESOLVING
-#include <js/PropertySpec.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
 #include <js/Utility.h>  // for UniqueChars
diff --git a/gi/union.cpp b/gi/union.cpp
index 6a01833d..1387ceb0 100644
--- a/gi/union.cpp
+++ b/gi/union.cpp
@@ -10,6 +10,7 @@
 #include <js/Class.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
+#include <js/Utility.h>  // for UniqueChars
 #include <js/Warnings.h>
 
 #include "gi/arg-inl.h"
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 4b38cb2f..bb583853 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -22,7 +22,6 @@
 #include <js/MemoryFunctions.h>
 #include <js/RootingAPI.h>
 #include <js/TypeDecls.h>
-#include <js/Utility.h>  // for UniqueChars
 #include <jsapi.h>       // for JS_GetPrivate, JS_SetPrivate, JS_Ge...
 #include <jspubtd.h>     // for JSProto_TypeError
 
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index 398f8b4f..3654cae4 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -27,6 +27,7 @@
 #include "gi/arg-inl.h"
 #include "gi/arg.h"
 #include "gi/foreign.h"
+#include "gjs/enum-utils.h"
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
 #include "gjs/jsapi-util.h"
diff --git a/modules/cairo-region.cpp b/modules/cairo-region.cpp
index 72b592f7..e731fb4f 100644
--- a/modules/cairo-region.cpp
+++ b/modules/cairo-region.cpp
@@ -24,6 +24,7 @@
 #include "gi/foreign.h"
 #include "gjs/atoms.h"
 #include "gjs/context-private.h"
+#include "gjs/enum-utils.h"
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
 #include "gjs/jsapi-util.h"
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index bd21ddf0..3d4067fb 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -21,6 +21,7 @@
 #include "gi/arg-inl.h"
 #include "gi/arg.h"
 #include "gi/foreign.h"
+#include "gjs/enum-utils.h"
 #include "gjs/jsapi-class.h"
 #include "gjs/jsapi-util-args.h"
 #include "gjs/jsapi-util.h"
diff --git a/tools/gjs-private-iwyu.imp b/tools/gjs-private-iwyu.imp
index c6a8eeae..0234ef55 100644
--- a/tools/gjs-private-iwyu.imp
+++ b/tools/gjs-private-iwyu.imp
@@ -23,7 +23,4 @@
   {"include": ["@\"sysprof-capture-.*\"", "private", "<sysprof-capture.h>", "public"]},
   {"include": ["@<sysprof-capture-.*>", "private", "<sysprof-capture.h>", "public"]},
   {"include": ["<X11/Xlib.h>", "private", "<cairo-xlib.h>", "public"]},
-
-  # Workaround for https://github.com/include-what-you-use/include-what-you-use/issues/226
-  {"include": ["<cstdint>", "private", "<stdint.h>", "public"]},
 ]
diff --git a/tools/process_iwyu.py b/tools/process_iwyu.py
index 1bd764bb..f8f237a3 100755
--- a/tools/process_iwyu.py
+++ b/tools/process_iwyu.py
@@ -57,6 +57,9 @@ FWD_DECLS_IN_HEADER = (
 )
 add_fwd_header = False
 
+CSTDINT = '#include <cstdint>'
+STDINTH = '#include <stdint.h>'
+
 FALSE_POSITIVES = (
     # The bodies of these structs already come before their usage,
     # we don't need to have forward declarations of them as well
@@ -70,6 +73,20 @@ FALSE_POSITIVES = (
     ('gjs/importer.cpp', '#include <algorithm>', 'for max'),
     ('modules/cairo-context.cpp', '#include <algorithm>', 'for max'),
 
+    # False positive when using EnumType operators
+    ('gi/arg-cache.cpp', '#include <type_traits>', 'for enable_if_t'),
+
+    # False positive when using GjsAutoPointer
+    ('gi/private.cpp', '#include <type_traits>',
+     'for remove_reference<>::type'),
+    ('gi/value.cpp', '#include <type_traits>', 'for remove_reference<>::type'),
+    ('gjs/debugger.cpp', '#include <type_traits>',
+     'for remove_reference<>::type'),
+    ('gjs/importer.cpp', '#include <type_traits>',
+     'for remove_reference<>::type'),
+    ('gjs/profiler.cpp', '#include <type_traits>',
+     'for remove_reference<>::type'),
+
     # Weird false positive on some versions of IWYU
     ('gi/arg.cpp', 'struct _GHashTable;', ''),
     ('gi/arg.cpp', 'struct _GVariant;', ''),
@@ -79,6 +96,15 @@ FALSE_POSITIVES = (
 def output():
     global file, state, add_fwd_header, there_were_errors
 
+    # Workaround for
+    # https://github.com/include-what-you-use/include-what-you-use/issues/226
+    if CSTDINT in add:
+        why = add.pop(CSTDINT, None)
+        if STDINTH in remove:
+            remove.pop(STDINTH, None)
+        else:
+            add[STDINTH] = why
+
     if add_fwd_header:
         if FWD_HEADER not in all_includes:
             if FWD_HEADER in remove:


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