| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json |
| 4 |
|
| 5 |
// RUN: clang-scan-deps -compilation-database %t/cdb.json | FileCheck %s |
| 6 |
|
| 7 |
// CHECK: t.c |
| 8 |
// CHECK: top.h |
| 9 |
// CHECK: n1.h |
| 10 |
// CHECK: n2.h |
| 11 |
// CHECK: n3.h |
| 12 |
|
| 13 |
//--- cdb.json.template |
| 14 |
[ |
| 15 |
{ |
| 16 |
"directory": "DIR", |
| 17 |
"command": "clang -fsyntax-only DIR/t.c", |
| 18 |
"file": "DIR/t.c" |
| 19 |
} |
| 20 |
] |
| 21 |
|
| 22 |
//--- t.c |
| 23 |
|
| 24 |
#include "top.h" |
| 25 |
#define INCLUDE_N3 |
| 26 |
#include "top.h" |
| 27 |
|
| 28 |
//--- top.h |
| 29 |
#ifndef _TOP_H_ |
| 30 |
#define _TOP_H_ |
| 31 |
|
| 32 |
#include "n1.h" |
| 33 |
|
| 34 |
#endif |
| 35 |
|
| 36 |
// More stuff after following '#endif', should invalidate the macro guard optimization, |
| 37 |
// and allow `top.h` to get re-included. |
| 38 |
#include "n2.h" |
| 39 |
|
| 40 |
//--- n1.h |
| 41 |
|
| 42 |
//--- n2.h |
| 43 |
#ifdef INCLUDE_N3 |
| 44 |
#include "n3.h" |
| 45 |
#endif |
| 46 |
|
| 47 |
//--- n3.h |