File: iwyu_verrs.h

package info (click to toggle)
iwyu 8.23-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,336 kB
  • sloc: cpp: 17,440; python: 6,416; ansic: 1,307; sh: 55; makefile: 29
file content (52 lines) | stat: -rw-r--r-- 1,997 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//===--- iwyu_verrs.h - debug output for include-what-you-use -------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// This module controls logging and verbosity levels for include-what-you-use.

#ifndef INCLUDE_WHAT_YOU_USE_IWYU_VERRS_H_
#define INCLUDE_WHAT_YOU_USE_IWYU_VERRS_H_

#include "clang/Basic/FileEntry.h"
// IWYU can't see the use inside unexpanded macro VERRS(). All users of VERRS()
// would need to include raw_ostream.h for operator<<() anyway, so export the
// type for correctness and convenience.
#include "llvm/Support/raw_ostream.h"  // IWYU pragma: export

namespace include_what_you_use {

void SetVerboseLevel(int level);
int GetVerboseLevel();

// Returns true if we should print a message at the given verbosity level.
inline bool ShouldPrint(int verbose_level) {
  return verbose_level <= GetVerboseLevel();
}

// Returns true if we should print information about a symbol in the
// given file, at the current verbosity level.  For instance, at most
// normal verbosities, we don't print information about symbols in
// system header files.
bool ShouldPrintSymbolFromFile(clang::OptionalFileEntryRef file);

// VERRS(n) << blah;
// prints blah to errs() if the verbose level is >= n.
#define VERRS(verbose_level) \
  if (!::include_what_you_use::ShouldPrint( \
          verbose_level)) ; else ::llvm::errs()

// Prints to errs() if the verbose level is at a high enough level to
// print symbols that occur in the given file.  This is only valid
// when used inside a class, such as IwyuAstConsumer, that defines a
// method named ShouldPrintSymbolFromFile().
#define ERRSYM(file_entry) \
  if (!ShouldPrintSymbolFromFile(file_entry)) ; else ::llvm::errs()

}  // namespace include_what_you_use

#endif  // INCLUDE_WHAT_YOU_USE_IWYU_VERRS_H_