clang 8.0.0

Macros | Enumerations | Functions
SarifDiagnostics.cpp File Reference
`#include "clang/Basic/Version.h"`
`#include "clang/Lex/Preprocessor.h"`
`#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"`
`#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"`
`#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"`
`#include "llvm/ADT/STLExtras.h"`
`#include "llvm/ADT/StringMap.h"`
`#include "llvm/Support/JSON.h"`
`#include "llvm/Support/Path.h"`
`#include "clang/StaticAnalyzer/Checkers/Checkers.inc"`
Include dependency graph for SarifDiagnostics.cpp:

Go to the source code of this file.

## Macros
#define | GET_CHECKERS
#define | CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) .Case(FULLNAME, HELPTEXT)
#define | GET_CHECKERS
#define | CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) .Case(FULLNAME, DOC_URI)

## Enumerations
enum | Importance { Importance::Important, Importance::Essential, Importance::Unimportant }

## Functions
static StringRef | getFileName (const FileEntry &FE)
static std::string | percentEncodeURICharacter (char C)
static std::string | fileNameToURI (StringRef Filename)
static json::Object | createFileLocation (const FileEntry &FE)
static json::Object | createFile (const FileEntry &FE)
static json::Object | createFileLocation (const FileEntry &FE, json::Array &Files)
static json::Object | createTextRegion (SourceRange R, const SourceManager &SM)
static json::Object | createPhysicalLocation (SourceRange R, const FileEntry &FE, const SourceManager &SMgr, json::Array &Files)
static StringRef | importanceToStr (Importance I)
static json::Object | createThreadFlowLocation (json::Object &&Location, Importance I)
static json::Object | createMessage (StringRef Text)
static json::Object | createLocation (json::Object &&PhysicalLocation, StringRef Message="")
static Importance | calculateImportance (const PathDiagnosticPiece &Piece)
static json::Object | createThreadFlow (const PathPieces &Pieces, json::Array &Files)
static json::Object | createCodeFlow (const PathPieces &Pieces, json::Array &Files)
static json::Object | createTool ()
static json::Object | createResult (const PathDiagnostic &Diag, json::Array &Files, const StringMap< unsigned > &RuleMapping)
static StringRef | getRuleDescription (StringRef CheckName)
static StringRef | getRuleHelpURIStr (StringRef CheckName)
static json::Object | createRule (const PathDiagnostic &Diag)
static json::Array | createRules (std::vector< const PathDiagnostic *> &Diags, StringMap< unsigned > &RuleMapping)
static json::Object | createResources (std::vector< const PathDiagnostic *> &Diags, StringMap< unsigned > &RuleMapping)
static json::Object | createRun (std::vector< const PathDiagnostic *> &Diags)

## Macro Definition Documentation

## ◆ CHECKER [1/2]

#define CHECKER | ( |  | FULLNAME,
|  |  | CLASS,
|  |  | HELPTEXT,
|  |  | DOC_URI
| ) |  | .Case(FULLNAME, HELPTEXT)

Referenced by getRuleDescription(), and getRuleHelpURIStr().

## ◆ CHECKER [2/2]

#define CHECKER | ( |  | FULLNAME,
|  |  | CLASS,
|  |  | HELPTEXT,
|  |  | DOC_URI
| ) |  | .Case(FULLNAME, DOC_URI)

## ◆ GET_CHECKERS [1/2]

#define GET_CHECKERS

Referenced by getRuleDescription(), and getRuleHelpURIStr().

## ◆ GET_CHECKERS [2/2]

#define GET_CHECKERS

## Enumeration Type Documentation

## ◆ Importance

enum Importance
| strong

Enumerator
Important |
Essential |
Unimportant |

Definition at line 161 of file SarifDiagnostics.cpp.

## Function Documentation

## ◆ calculateImportance()

static Importance calculateImportance | ( | const PathDiagnosticPiece & | Piece | ) |
| static

Definition at line 193 of file SarifDiagnostics.cpp.

References Essential, Important, clang::serialized_diags::Note, and Unimportant.

Referenced by createThreadFlow().

## ◆ createCodeFlow()

static json::Object createCodeFlow | ( | const PathPieces & | Pieces,
|  | json::Array & | Files
| ) |  |
| static

Definition at line 225 of file SarifDiagnostics.cpp.

References createThreadFlow().

Referenced by createResult().

## ◆ createFile()

static json::Object createFile | ( | const FileEntry & | FE | ) |
| static

Definition at line 114 of file SarifDiagnostics.cpp.

References createFileLocation(), and clang::FileEntry::getSize().

## ◆ createFileLocation() [1/2]

static json::Object createFileLocation | ( | const FileEntry & | FE | ) |
| static

Definition at line 110 of file SarifDiagnostics.cpp.

References fileNameToURI(), and getFileName().

Referenced by createFile(), and createPhysicalLocation().

## ◆ createFileLocation() [2/2]

static json::Object createFileLocation | ( | const FileEntry & | FE,
|  | json::Array & | Files
| ) |  |
| static

Definition at line 121 of file SarifDiagnostics.cpp.

References fileNameToURI(), and getFileName().

## ◆ createLocation()

static json::Object createLocation | ( | json::Object && | PhysicalLocation,
|  | StringRef | Message = `""`
| ) |  |
| static

Definition at line 185 of file SarifDiagnostics.cpp.

Referenced by createResult(), and createThreadFlow().

## ◆ createMessage()

static json::Object createMessage | ( | StringRef | Text | ) |
| static

Definition at line 181 of file SarifDiagnostics.cpp.

Referenced by createResult(), and createRule().

## ◆ createPhysicalLocation()

static json::Object createPhysicalLocation | ( | SourceRange | R,
|  | const FileEntry & | FE,
|  | const SourceManager & | SMgr,
|  | json::Array & | Files
| ) |  |
| static

Definition at line 154 of file SarifDiagnostics.cpp.

References createFileLocation(), and createTextRegion().

Referenced by createResult(), and createThreadFlow().

## ◆ createResources()

static json::Object createResources | ( | std::vector< const PathDiagnostic *> & | Diags,
|  | StringMap< unsigned > & | RuleMapping
| ) |  |
| static

Definition at line 310 of file SarifDiagnostics.cpp.

References createRules().

## ◆ createResult()

static json::Object createResult | ( | const PathDiagnostic & | Diag,
|  | json::Array & | Files,
|  | const StringMap< unsigned > & | RuleMapping
| ) |  |
| static

Definition at line 238 of file SarifDiagnostics.cpp.

References createCodeFlow(), createLocation(), createMessage(), and createPhysicalLocation().

## ◆ createRule()

static json::Object createRule | ( | const PathDiagnostic & | Diag | ) |
| static

Definition at line 279 of file SarifDiagnostics.cpp.

References createMessage(), getRuleDescription(), and getRuleHelpURIStr().

Referenced by createRules().

## ◆ createRules()

static json::Array createRules | ( | std::vector< const PathDiagnostic *> & | Diags,
|  | StringMap< unsigned > & | RuleMapping
| ) |  |
| static

Definition at line 293 of file SarifDiagnostics.cpp.

References createRule(), and P.

Referenced by createResources().

## ◆ createRun()

static json::Object createRun | ( | std::vector< const PathDiagnostic *> & | Diags | ) |
| static

Definition at line 315 of file SarifDiagnostics.cpp.

## ◆ createTextRegion()

static json::Object createTextRegion | ( | SourceRange | R,
|  | const SourceManager & | SM
| ) |  |
| static

Definition at line 146 of file SarifDiagnostics.cpp.

References clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), clang::SourceManager::getExpansionColumnNumber(), and clang::SourceManager::getExpansionLineNumber().

Referenced by createPhysicalLocation().

## ◆ createThreadFlow()

static json::Object createThreadFlow | ( | const PathPieces & | Pieces,
|  | json::Array & | Files
| ) |  |
| static

Definition at line 209 of file SarifDiagnostics.cpp.

References calculateImportance(), createLocation(), createPhysicalLocation(), createThreadFlowLocation(), and P.

Referenced by createCodeFlow().

## ◆ createThreadFlowLocation()

static json::Object createThreadFlowLocation | ( | json::Object && | Location,
|  | Importance | I
| ) |  |
| static

Definition at line 175 of file SarifDiagnostics.cpp.

References importanceToStr().

Referenced by createThreadFlow().

## ◆ createTool()

static json::Object createTool | ( |  | ) |
| static

Definition at line 231 of file SarifDiagnostics.cpp.

References clang::getClangFullVersion().

## ◆ fileNameToURI()

static std::string fileNameToURI | ( | StringRef | Filename | ) |
| static

Definition at line 73 of file SarifDiagnostics.cpp.

References End, and percentEncodeURICharacter().

Referenced by createFileLocation().

## ◆ getFileName()

static StringRef getFileName | ( | const FileEntry & | FE | ) |
| static

Definition at line 54 of file SarifDiagnostics.cpp.

References Filename, clang::FileEntry::getName(), and clang::FileEntry::tryGetRealPathName().

Referenced by createFileLocation().

## ◆ getRuleDescription()

static StringRef getRuleDescription | ( | StringRef | CheckName | ) |
| static

Definition at line 257 of file SarifDiagnostics.cpp.

References CHECKER, and GET_CHECKERS.

Referenced by createRule().

## ◆ getRuleHelpURIStr()

static StringRef getRuleHelpURIStr | ( | StringRef | CheckName | ) |
| static

Definition at line 268 of file SarifDiagnostics.cpp.

References CHECKER, and GET_CHECKERS.

Referenced by createRule().

## ◆ importanceToStr()

static StringRef importanceToStr | ( | Importance | I | ) |
| static

Definition at line 163 of file SarifDiagnostics.cpp.

References Essential, Important, and Unimportant.

Referenced by createThreadFlowLocation().

## ◆ percentEncodeURICharacter()

static std::string percentEncodeURICharacter | ( | char | C | ) |
| static

Definition at line 61 of file SarifDiagnostics.cpp.

Referenced by fileNameToURI().