[PATCH] D102923: [clang][lex] Remark on search path usage
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 11 12:39:29 PDT 2021
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.
Thanks; I think this was worth it. I like how clean it looks with `-verify` in place.
LGTM if you add a couple more header map tests, explained inline.
================
Comment at: clang/test/Preprocessor/search-path-usage-headers.m:78-91
+
+// Check that header maps are reported.
+//
+// RUN: sed "s|DIR|%/S/Inputs/search-path-usage|g" %S/Inputs/search-path-usage/b.hmap.json.template > %t/b.hmap.json
+// RUN: %hmaptool write %t/b.hmap.json %t/b.hmap
+// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
+// RUN: -I %t/b.hmap \
----------------
This is a good positive test, but I don't see a negative test or the "matched but not ultimately found" case I mentioned before.
You can add a RUN like this for the negative test:
```
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// -I%t/b.hmap \
// -I%S/Inputs/search-path-usage/d \
// -DHMAP_NO_MATCH -verify
#ifdef HMAP_NO_MATCH
#include "d.h" // expected-remark {{search path used: ../d'}}
#endif
```
(same hmap, but not found in the headermap)
and like this for the "matched in header map but not ultimately found" case (different hmap, pointing at a file that won't be found):
```
// RUN: sed "s|DIR|%/S/Inputs/search-path-usage/missing-subdir|g" \
// RUN: %S/Inputs/search-path-usage/b.hmap.json.template > %t/b-missing.hmap.json
// RUN: %hmaptool write %t/b-missing.hmap.json %t/b-missing.hmap
// RUN: %clang_cc1 -Eonly %s -Rsearch-path-usage \
// RUN: -I %t/b-missing.hmap \
// RUN: -I b \
// RUN: -DHMAP_MATCHED_BUT_MISSING -verify
#ifdef HMAP_MATCHED_BUT_MISSING
#include "b.h" // \
// expected-remark {{search path used: ../b-missing.hmap}} \
// expected-error {{file not found: "b.h" [or whatever it is in the end]}}
#endif
```
(Maybe would be good to have a `__has_include`-matched-but-missing test as well? I'll leave it up to you.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102923/new/
https://reviews.llvm.org/D102923
More information about the cfe-commits
mailing list