Files
clang-p2996/clang/test/Modules/double-quotes.m
Bruno Cardoso Lopes a9c51fe089 Re-apply: Warning for framework headers using double quote includes
Introduce -Wquoted-include-in-framework-header, which should fire a warning
whenever a quote include appears in a framework header and suggest a fix-it.
For instance, for header A.h added in the tests, this is how the warning looks
like:

./A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
#include "A0.h"
         ^~~~~~
         <A/A0.h>
./A.framework/Headers/A.h:3:10: warning: double-quoted include "B.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
#include "B.h"
         ^~~~~
         <B.h>

This helps users to prevent frameworks from using local headers when in fact
they should be targetting system level ones.

The warning is off by default.

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

rdar://problem/37077034

llvm-svn: 335375
2018-06-22 18:05:17 +00:00

40 lines
1.8 KiB
Objective-C

// REQUIRES: shell
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: %hmaptool write %S/Inputs/double-quotes/a.hmap.json %t/a.hmap
// RUN: %hmaptool write %S/Inputs/double-quotes/x.hmap.json %t/x.hmap
// RUN: sed -e "s:TEST_DIR:%S/Inputs/double-quotes:g" \
// RUN: %S/Inputs/double-quotes/z.yaml > %t/z.yaml
// The output with and without modules should be the same
// RUN: %clang_cc1 \
// RUN: -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
// RUN: -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
// RUN: -Wquoted-include-in-framework-header -fsyntax-only %s -verify
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
// RUN: -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
// RUN: -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
// RUN: -Wquoted-include-in-framework-header -fsyntax-only %s \
// RUN: 2>%t/stderr
// The same warnings show up when modules is on but -verify doesn't get it
// because they only show up under the module A building context.
// RUN: FileCheck --input-file=%t/stderr %s
// CHECK: double-quoted include "A0.h" in framework header, expected angle-bracketed instead
// CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed instead
// CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed instead
#import "A.h"
#import <Z/Z.h>
int bar() { return foo(); }
// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:1{{double-quoted include "A0.h" in framework header, expected angle-bracketed instead}}
// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:2{{double-quoted include "B.h" in framework header, expected angle-bracketed instead}}
// expected-warning@Inputs/double-quotes/flat-header-path/Z.h:1{{double-quoted include "B.h" in framework header, expected angle-bracketed instead}}