[PATCH] D134654: [clang] Detect header loops

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 30 10:17:05 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/test/Preprocessor/warn-loop-macro-1.h:3
+#define LOOP_MACRO_1
+// expected-warning at +1 {{#include cycle}}
+#include "warn-loop-macro-1.h"
----------------
erichkeane wrote:
> aaron.ballman wrote:
> > For example, as a user, I would look at this diagnostic and assume the compiler is wrong -- "There's no cycle there, the header guard macro protects me against it being a cycle." is not an unreasonable way to view this code.
> I believe our 'include breadcrumbs notes' are printed differently: 
> 
> [ekeane1 at scsel-clx-24 build]$ ./bin/clang -cc1 c.cpp
> In file included from c.cpp:1:
> In file included from ./b.h:1:
> ./a.h:1:2: error: "FOO"
> #error "FOO"
>  ^
> 1 error generated.
> 
Oh wow, I forgot about the fact that we don't use actual notes there! But even still, won't the breadcrumbs in this case be:
```
In file included from warn-loop-main.c:3
warn-loop-macro-1.h:4: warning: #include cycle
#include "warn-loop-macro-1.h"
^
```
That's not really clear (at least to me) due to the header guard protecting against a recursive include.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134654/new/

https://reviews.llvm.org/D134654



More information about the cfe-commits mailing list