[前][次][番号順一覧][スレッド一覧]

ruby-changes:60760

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 13 Apr 2020 16:06:25 +0900 (JST)
Subject: [ruby-changes:60760] c37a357c13 (master): include what you use.

https://git.ruby-lang.org/ruby.git/commit/?id=c37a357c13

From c37a357c13b399b79fb1ef197738f60cae472dbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Sun, 12 Apr 2020 15:42:45 +0900
Subject: include what you use.

This reverts commit 443389effc37308ce1a3c3a840082a344fc6af56.
This reverts commit d94960f22ec2de3a3855305cb51343806d2b46c7.

Inclusion of header files must be explicit.  Every file shall directly
include what is necessary.

https://github.com/include-what-you-use/include-what-you-use says:

> When every file includes what it uses, then it is possible to edit any
> file and remove unused headers, without fear of accidentally breaking
> the upwards dependencies of that file. It also becomes easy to
> automatically track and update dependencies in the source code.

Though we don't use iwyu itself, the principle quoted above is a good
thing that we can agree.

Now that include guards were added to every and all of the headers
inside of our project this changeset does not increase compile time, at
least on my machine.

diff --git a/common.mk b/common.mk
index 4b9e029..edfe110 100644
--- a/common.mk
+++ b/common.mk
@@ -3878,6 +3878,7 @@ dir.$(OBJEXT): {$(VPATH)}3/variable.h https://github.com/ruby/ruby/blob/trunk/common.mk#L3878
 dir.$(OBJEXT): {$(VPATH)}3/warning_push.h
 dir.$(OBJEXT): {$(VPATH)}3/xmalloc.h
 dir.$(OBJEXT): {$(VPATH)}assert.h
+dir.$(OBJEXT): {$(VPATH)}builtin.h
 dir.$(OBJEXT): {$(VPATH)}backward/2/assume.h
 dir.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
 dir.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -3890,7 +3891,6 @@ dir.$(OBJEXT): {$(VPATH)}backward/2/r_cast.h https://github.com/ruby/ruby/blob/trunk/common.mk#L3891
 dir.$(OBJEXT): {$(VPATH)}backward/2/rmodule.h
 dir.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
 dir.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-dir.$(OBJEXT): {$(VPATH)}builtin.h
 dir.$(OBJEXT): {$(VPATH)}config.h
 dir.$(OBJEXT): {$(VPATH)}defines.h
 dir.$(OBJEXT): {$(VPATH)}dir.c
@@ -5416,10 +5416,6 @@ explicit_bzero.$(OBJEXT): {$(VPATH)}3/compiler_is/sunpro.h https://github.com/ruby/ruby/blob/trunk/common.mk#L5416
 explicit_bzero.$(OBJEXT): {$(VPATH)}3/compiler_since.h
 explicit_bzero.$(OBJEXT): {$(VPATH)}3/config.h
 explicit_bzero.$(OBJEXT): {$(VPATH)}3/dllexport.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}3/has/attribute.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}3/has/warning.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}3/token_paste.h
-explicit_bzero.$(OBJEXT): {$(VPATH)}3/warning_push.h
 explicit_bzero.$(OBJEXT): {$(VPATH)}config.h
 explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
 explicit_bzero.$(OBJEXT): {$(VPATH)}missing.h
@@ -11782,10 +11778,6 @@ ruby-runner.$(OBJEXT): {$(VPATH)}3/compiler_is/msvc.h https://github.com/ruby/ruby/blob/trunk/common.mk#L11778
 ruby-runner.$(OBJEXT): {$(VPATH)}3/compiler_is/sunpro.h
 ruby-runner.$(OBJEXT): {$(VPATH)}3/compiler_since.h
 ruby-runner.$(OBJEXT): {$(VPATH)}3/config.h
-ruby-runner.$(OBJEXT): {$(VPATH)}3/has/attribute.h
-ruby-runner.$(OBJEXT): {$(VPATH)}3/has/warning.h
-ruby-runner.$(OBJEXT): {$(VPATH)}3/token_paste.h
-ruby-runner.$(OBJEXT): {$(VPATH)}3/warning_push.h
 ruby-runner.$(OBJEXT): {$(VPATH)}config.h
 ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.c
 ruby-runner.$(OBJEXT): {$(VPATH)}ruby-runner.h
@@ -13089,10 +13081,6 @@ strlcat.$(OBJEXT): {$(VPATH)}3/compiler_is/sunpro.h https://github.com/ruby/ruby/blob/trunk/common.mk#L13081
 strlcat.$(OBJEXT): {$(VPATH)}3/compiler_since.h
 strlcat.$(OBJEXT): {$(VPATH)}3/config.h
 strlcat.$(OBJEXT): {$(VPATH)}3/dllexport.h
-strlcat.$(OBJEXT): {$(VPATH)}3/has/attribute.h
-strlcat.$(OBJEXT): {$(VPATH)}3/has/warning.h
-strlcat.$(OBJEXT): {$(VPATH)}3/token_paste.h
-strlcat.$(OBJEXT): {$(VPATH)}3/warning_push.h
 strlcat.$(OBJEXT): {$(VPATH)}config.h
 strlcat.$(OBJEXT): {$(VPATH)}missing.h
 strlcat.$(OBJEXT): {$(VPATH)}strlcat.c
@@ -13106,10 +13094,6 @@ strlcpy.$(OBJEXT): {$(VPATH)}3/compiler_is/sunpro.h https://github.com/ruby/ruby/blob/trunk/common.mk#L13094
 strlcpy.$(OBJEXT): {$(VPATH)}3/compiler_since.h
 strlcpy.$(OBJEXT): {$(VPATH)}3/config.h
 strlcpy.$(OBJEXT): {$(VPATH)}3/dllexport.h
-strlcpy.$(OBJEXT): {$(VPATH)}3/has/attribute.h
-strlcpy.$(OBJEXT): {$(VPATH)}3/has/warning.h
-strlcpy.$(OBJEXT): {$(VPATH)}3/token_paste.h
-strlcpy.$(OBJEXT): {$(VPATH)}3/warning_push.h
 strlcpy.$(OBJEXT): {$(VPATH)}config.h
 strlcpy.$(OBJEXT): {$(VPATH)}missing.h
 strlcpy.$(OBJEXT): {$(VPATH)}strlcpy.c
diff --git a/include/ruby/3/anyargs.h b/include/ruby/3/anyargs.h
index 7eff1b2..d85a49b 100644
--- a/include/ruby/3/anyargs.h
+++ b/include/ruby/3/anyargs.h
@@ -72,6 +72,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/anyargs.h#L72
 #include "ruby/3/attr/weakref.h"
 #include "ruby/3/cast.h"
 #include "ruby/3/config.h"
+#include "ruby/3/has/attribute.h"
 #include "ruby/3/intern/class.h"
 #include "ruby/3/intern/vm.h"
 #include "ruby/3/method.h"
diff --git a/include/ruby/3/arithmetic/int.h b/include/ruby/3/arithmetic/int.h
index 8c2e9f2..2ebf808 100644
--- a/include/ruby/3/arithmetic/int.h
+++ b/include/ruby/3/arithmetic/int.h
@@ -31,6 +31,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/arithmetic/int.h#L31
 #include "ruby/3/dllexport.h"
 #include "ruby/3/special_consts.h"
 #include "ruby/3/value.h"
+#include "ruby/3/warning_push.h"
 #include "ruby/assert.h"
 
 #define RB_INT2NUM  rb_int2num_inline
diff --git a/include/ruby/3/assume.h b/include/ruby/3/assume.h
index 13928db..9664f56 100644
--- a/include/ruby/3/assume.h
+++ b/include/ruby/3/assume.h
@@ -27,6 +27,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/assume.h#L27
  */
 #include "ruby/3/config.h"
 #include "ruby/3/cast.h"
+#include "ruby/3/compiler_since.h"
 #include "ruby/3/has/builtin.h"
 #include "ruby/3/warning_push.h"
 
diff --git a/include/ruby/3/attr/alloc_size.h b/include/ruby/3/attr/alloc_size.h
index 251a19f..5d4ece0 100644
--- a/include/ruby/3/attr/alloc_size.h
+++ b/include/ruby/3/attr/alloc_size.h
@@ -20,6 +20,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/alloc_size.h#L20
  *             extension libraries. They could be written in C++98.
  * @brief      Defines #RUBY3_ATTR_ALLOC_SIZE.
  */
+#include "ruby/3/has/attribute.h"
 
 /** Wraps (or simulates) `__attribute__((alloc_size))` */
 #if RUBY3_HAS_ATTRIBUTE(alloc_size)
diff --git a/include/ruby/3/attr/artificial.h b/include/ruby/3/attr/artificial.h
index a9f305d..f5450e3 100644
--- a/include/ruby/3/attr/artificial.h
+++ b/include/ruby/3/attr/artificial.h
@@ -34,6 +34,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/artificial.h#L34
  *      case it gets  vital to know where the inlining  happened in the callee.
  *      See also https://stackoverflow.com/a/21936099
  */
+#include "ruby/3/has/attribute.h"
 
 /** Wraps (or simulates) `__attribute__((artificial))` */
 #if RUBY3_HAS_ATTRIBUTE(artificial)
diff --git a/include/ruby/3/attr/cold.h b/include/ruby/3/attr/cold.h
index 5b5263f..3822f0a 100644
--- a/include/ruby/3/attr/cold.h
+++ b/include/ruby/3/attr/cold.h
@@ -21,6 +21,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/cold.h#L21
  * @brief      Defines #RUBY3_ATTR_COLD.
  */
 #include "ruby/3/compiler_is.h"
+#include "ruby/3/has/attribute.h"
 
 /** Wraps (or simulates) `__attribute__((cold))` */
 #if RUBY3_COMPILER_IS(SunPro)
diff --git a/include/ruby/3/attr/const.h b/include/ruby/3/attr/const.h
index d97495c..6c36e9a 100644
--- a/include/ruby/3/attr/const.h
+++ b/include/ruby/3/attr/const.h
@@ -20,6 +20,8 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/const.h#L20
  *             extension libraries. They could be written in C++98.
  * @brief      Defines #RUBY3_ATTR_CONST.
  */
+#include "ruby/3/compiler_since.h"
+#include "ruby/3/has/attribute.h"
 #include "ruby/3/has/declspec_attribute.h"
 
 /** Wraps (or simulates) `__attribute__((const))` */
diff --git a/include/ruby/3/attr/constexpr.h b/include/ruby/3/attr/constexpr.h
index 582d9fd..576ec7f 100644
--- a/include/ruby/3/attr/constexpr.h
+++ b/include/ruby/3/attr/constexpr.h
@@ -22,6 +22,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/constexpr.h#L22
  */
 #include "ruby/3/has/feature.h"
 #include "ruby/3/compiler_is.h"
+#include "ruby/3/token_paste.h"
 
 /** @cond INTERNAL_MACRO */
 #if ! defined(__cplusplus)
diff --git a/include/ruby/3/attr/deprecated.h b/include/ruby/3/attr/deprecated.h
index 9f939a5..5c3f508 100644
--- a/include/ruby/3/attr/deprecated.h
+++ b/include/ruby/3/attr/deprecated.h
@@ -20,6 +20,8 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/deprecated.h#L20
  *             extension libraries. They could be written in C++98.
  * @brief      Defines #RUBY3_ATTR_DEPRECATED.
  */
+#include "ruby/3/compiler_since.h"
+#include "ruby/3/has/attribute.h"
 #include "ruby/3/has/c_attribute.h"
 #include "ruby/3/has/cpp_attribute.h"
 #include "ruby/3/has/declspec_attribute.h"
diff --git a/include/ruby/3/attr/diagnose_if.h b/include/ruby/3/attr/diagnose_if.h
index 488c3ec..2f09abc 100644
--- a/include/ruby/3/attr/diagnose_if.h
+++ b/include/ruby/3/attr/diagnose_if.h
@@ -20,6 +20,8 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/diagnose_if.h#L20
  *             extension libraries. They could be written in C++98.
  * @brief      Defines #RUBY3_ATTR_DIAGNOSE_IF.
  */
+#include "ruby/3/has/attribute.h"
+#include "ruby/3/warning_push.h"
 
 /** Wraps (or simulates) `__attribute__((diagnose_if))` */
 #if RUBY3_COMPILER_BEFORE(Clang, 5, 0, 0)
diff --git a/include/ruby/3/attr/enum_extensibility.h b/include/ruby/3/attr/enum_extensibility.h
index a56d1a5..15a5b06 100644
--- a/include/ruby/3/attr/enum_extensibility.h
+++ b/include/ruby/3/attr/enum_extensibility.h
@@ -20,6 +20,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/3/attr/enum_extensibility.h#L20
  *             extension libraries. They could be written in C++98.
  * @brief      #RUBY3_ATTR_ENUM_EXTENSIBILITY.
  */
+#include "ruby/3/has/attribute.h"
 
 /** Wraps (or simulates) `__attribute__((enum_extensibility))`  (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]