clang 10.0.0git

Macros | Enumerations | Functions
SarifDiagnostics.cpp File Reference
`#include "clang/Analysis/PathDiagnostic.h"`
`#include "clang/Basic/Version.h"`
`#include "clang/Lex/Preprocessor.h"`
`#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"`
`#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"`
`#include "llvm/ADT/STLExtras.h"`
`#include "llvm/ADT/StringMap.h"`
`#include "llvm/Support/ConvertUTF.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, IS_HIDDEN) .Case(FULLNAME, HELPTEXT)
#define | GET_CHECKERS
#define | CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) .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 | createArtifactLocation (const FileEntry &FE)
static json::Object | createArtifact (const FileEntry &FE)
static json::Object | createArtifactLocation (const FileEntry &FE, json::Array &Artifacts)
static unsigned int | adjustColumnPos (const SourceManager &SM, SourceLocation Loc, unsigned int TokenLen=0)
static json::Object | createTextRegion (const LangOptions &LO, SourceRange R, const SourceManager &SM)
static json::Object | createPhysicalLocation (const LangOptions &LO, SourceRange R, const FileEntry &FE, const SourceManager &SMgr, json::Array &Artifacts)
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 LangOptions &LO, const PathPieces &Pieces, json::Array &Artifacts)
static json::Object | createCodeFlow (const LangOptions &LO, const PathPieces &Pieces, json::Array &Artifacts)
static json::Object | createResult (const LangOptions &LO, const PathDiagnostic &Diag, json::Array &Artifacts, 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 | createTool (std::vector< const PathDiagnostic *> &Diags, StringMap< unsigned > &RuleMapping)
static json::Object | createRun (const LangOptions &LO, std::vector< const PathDiagnostic *> &Diags)

## Macro Definition Documentation

## ◆ CHECKER [1/2]

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

Referenced by getRuleDescription(), and getRuleHelpURIStr().

## ◆ CHECKER [2/2]

#define CHECKER | ( |  | FULLNAME,
|  |  | CLASS,
|  |  | HELPTEXT,
|  |  | DOC_URI,
|  |  | IS_HIDDEN
| ) |  | .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 200 of file SarifDiagnostics.cpp.

## Function Documentation

## ◆ adjustColumnPos()

static unsigned int adjustColumnPos | ( | const SourceManager & | SM,
|  | SourceLocation | Loc,
|  | unsigned int | TokenLen = `0`
| ) |  |
| static

Definition at line 148 of file SarifDiagnostics.cpp.

References clang::SourceManager::getBuffer(), clang::SourceManager::getDecomposedExpansionLoc(), clang::SourceManager::getExpansionColumnNumber(), clang::SourceLocation::isInvalid(), and Ret().

Referenced by createTextRegion().

## ◆ calculateImportance()

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

Definition at line 232 of file SarifDiagnostics.cpp.

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

Referenced by createThreadFlow().

## ◆ createArtifact()

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

Definition at line 116 of file SarifDiagnostics.cpp.

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

## ◆ createArtifactLocation() [1/2]

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

Definition at line 112 of file SarifDiagnostics.cpp.

References fileNameToURI(), and getFileName().

Referenced by createArtifact(), and createPhysicalLocation().

## ◆ createArtifactLocation() [2/2]

static json::Object createArtifactLocation | ( | const FileEntry & | FE,
|  | json::Array & | Artifacts
| ) |  |
| static

Definition at line 123 of file SarifDiagnostics.cpp.

References fileNameToURI(), and getFileName().

## ◆ createCodeFlow()

static json::Object createCodeFlow | ( | const LangOptions & | LO,
|  | const PathPieces & | Pieces,
|  | json::Array & | Artifacts
| ) |  |
| static

Definition at line 267 of file SarifDiagnostics.cpp.

References createThreadFlow().

Referenced by createResult().

## ◆ createLocation()

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

Definition at line 224 of file SarifDiagnostics.cpp.

References Ret().

Referenced by createResult(), and createThreadFlow().

## ◆ createMessage()

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

Definition at line 220 of file SarifDiagnostics.cpp.

Referenced by createResult(), and createRule().

## ◆ createPhysicalLocation()

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

Definition at line 191 of file SarifDiagnostics.cpp.

References createArtifactLocation(), and createTextRegion().

Referenced by createResult(), and createThreadFlow().

## ◆ createResult()

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

Definition at line 274 of file SarifDiagnostics.cpp.

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

## ◆ createRule()

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

Definition at line 318 of file SarifDiagnostics.cpp.

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

Referenced by createRules().

## ◆ createRules()

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

Definition at line 332 of file SarifDiagnostics.cpp.

References createRule(), and P.

Referenced by createTool().

## ◆ createRun()

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

Definition at line 359 of file SarifDiagnostics.cpp.

## ◆ createTextRegion()

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

Definition at line 174 of file SarifDiagnostics.cpp.

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

Referenced by createPhysicalLocation().

## ◆ createThreadFlow()

static json::Object createThreadFlow | ( | const LangOptions & | LO,
|  | const PathPieces & | Pieces,
|  | json::Array & | Artifacts
| ) |  |
| static

Definition at line 249 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 214 of file SarifDiagnostics.cpp.

References importanceToStr().

Referenced by createThreadFlow().

## ◆ createTool()

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

Definition at line 349 of file SarifDiagnostics.cpp.

References createRules(), and clang::getClangFullVersion().

## ◆ fileNameToURI()

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

Definition at line 75 of file SarifDiagnostics.cpp.

References End, percentEncodeURICharacter(), and Ret().

Referenced by createArtifactLocation().

## ◆ getFileName()

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

Definition at line 56 of file SarifDiagnostics.cpp.

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

Referenced by createArtifactLocation().

## ◆ getRuleDescription()

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

Definition at line 296 of file SarifDiagnostics.cpp.

References CHECKER, and GET_CHECKERS.

Referenced by createRule().

## ◆ getRuleHelpURIStr()

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

Definition at line 307 of file SarifDiagnostics.cpp.

References CHECKER, and GET_CHECKERS.

Referenced by createRule().

## ◆ importanceToStr()

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

Definition at line 202 of file SarifDiagnostics.cpp.

References Essential, Important, and Unimportant.

Referenced by createThreadFlowLocation().

## ◆ percentEncodeURICharacter()

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

Definition at line 63 of file SarifDiagnostics.cpp.

Referenced by fileNameToURI().