HomePhabricator

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

Authored by sammccall on Apr 17 2019, 11:33 AM.

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

llvm-svn: 358605