HomePhabricator

[clangd] Recognize "don't include me directly" pattern, and suppress include…

Description

[clangd] Recognize "don't include me directly" pattern, and suppress include insertion.

Summary:
Typically used with umbrella headers, e.g. GTK:

#if !defined (GTK_H_INSIDE) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

Heuristic is fairly conservative, a quick code search over github showed
a fair number of hits and few/no false positives. (Not all were umbrella
headers, but I'd be happy avoiding include insertion for all of them).

We may want to relax the heuristic later to catch more cases.

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D60815

Details

Committed
sammccallApr 17 2019, 11:33 AM
Differential Revision
D60815: [clangd] Recognize "don't include me directly" pattern, and suppress include insertion.
Branches
Unknown
Tags
Unknown