clang: lib/StaticAnalyzer/Checkers/Yaml.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKER_YAML_H

15#define LLVM_CLANG_LIB_STATICANALYZER_CHECKER_YAML_H

16

19#include "llvm/Support/VirtualFileSystem.h"

20#include "llvm/Support/YAMLTraits.h"

21#include

22

24namespace ento {

25

26

27

28

29template <class T, class Checker>

31 StringRef Option, StringRef ConfigFile) {

32 if (ConfigFile.trim().empty())

33 return std::nullopt;

34

39 llvm::ErrorOr<std::unique_ptrllvm::MemoryBuffer> Buffer =

40 VFS.getBufferForFile(ConfigFile.str());

41

42 if (Buffer.getError()) {

44 "a valid filename instead of '" +

45 std::string(ConfigFile) + "'");

46 return std::nullopt;

47 }

48

49 llvm::yaml::Input Input(Buffer.get()->getBuffer());

50 T Config;

51 Input >> Config;

52

53 if (std::error_code ec = Input.error()) {

55 "a valid yaml file: " + ec.message());

56 return std::nullopt;

57 }

58

59 return Config;

60}

61

62}

63}

64

65#endif

Defines the SourceManager interface.

SourceManager & getSourceManager()

llvm::vfs::FileSystem & getVirtualFileSystem() const

FileManager & getFileManager() const

ASTContext & getASTContext() const

void reportInvalidCheckerOptionValue(const CheckerFrontend *Checker, StringRef OptionName, StringRef ExpectedValueDesc) const

Emits an error through a DiagnosticsEngine about an invalid user supplied checker option value.

Simple checker classes that implement one frontend (i.e.

std::optional< T > getConfiguration(CheckerManager &Mgr, Checker *Chk, StringRef Option, StringRef ConfigFile)

Read the given file from the filesystem and parse it as a yaml file.

Definition Yaml.h:30

The JSON file list parser is used to communicate input to InstallAPI.

const FunctionProtoType * T