File: suggest-include.cpp

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (35 lines) | stat: -rw-r--r-- 1,879 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs/suggest-include %s -verify

#include "empty.h" // import the module file

// expected-note@usetextual1.h:2 {{here}}
// expected-note@textual2.h:1 {{here}}
// expected-note@textual3.h:1 {{here}}
// expected-note@textual4.h:1 {{here}}
// expected-note@textual5.h:1 {{here}}
// expected-note@private1.h:1 {{here}}
// expected-note@private2.h:1 {{here}}
// expected-note@private3.h:1 {{here}}

void f() {
  (void)::usetextual1; // expected-error {{missing '#include "usetextual1.h"'}}
  (void)::usetextual2; // expected-error {{missing '#include "usetextual2.h"'}}
  (void)::textual3; // expected-error-re {{{{^}}missing '#include "usetextual3.h"'}}
  // If the declaration is in an include-guarded header, make sure we suggest
  // including that rather than importing a module. In this case, there could
  // be more than one module, and the module name we picked is almost certainly
  // wrong.
  (void)::textual4; // expected-error {{missing '#include "usetextual4.h"'; 'textual4' must be declared before it is used}}
  (void)::textual5; // expected-error {{missing '#include "usetextual5.h"'; 'textual5' must be declared before it is used}}

  // Don't suggest #including a private header.
  // FIXME: We could suggest including "useprivate1.h" here, as it's the only
  // public way to get at this declaration.
  (void)::private1; // expected-error-re {{{{^}}declaration of 'private1'}}
  // FIXME: Should we be suggesting an import at all here? Should declarations
  // in private headers be visible when the surrounding module is imported?
  (void)::private2; // expected-error-re {{{{^}}declaration of 'private2'}}
  // Even if we suggest an include for private1, we should not do so here.
  (void)::private3; // expected-error-re {{{{^}}declaration of 'private3'}}
}