clang 24.0.0git
SarifDiagnostics.cpp File Reference
#include "SarifDiagnostics.h"
#include "HTMLDiagnostics.h"
#include "clang/Analysis/IssueHash.h"
#include "clang/Analysis/MacroExpansionContext.h"
#include "clang/Analysis/PathDiagnostic.h"
#include "clang/Basic/Sarif.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Version.h"
#include "clang/Frontend/DiagnosticRenderer.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/Path.h"
#include <memory>
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"

Go to the source code of this file.

Macros

#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN)
#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN)

Functions

static StringRef getRuleDescription (StringRef CheckName)
static StringRef getRuleHelpURIStr (StringRef CheckName)
static ThreadFlowImportance calculateImportance (const PathDiagnosticPiece &Piece)
static CharSourceRange getDisplayCharRange (const PathDiagnosticLocation &Loc, const LangOptions &LO)
 Returns the character range to report for Loc.
static SmallVector< ThreadFlow, 8 > createThreadFlows (const PathDiagnostic *Diag, const LangOptions &LO)
static StringMap< uint32_tcreateRuleMapping (const std::vector< const PathDiagnostic * > &Diags, SarifDocumentWriter &SarifWriter)

Variables

static const llvm::StringRef IssueHashKey = "clang/issueHash/v1"

Macro Definition Documentation

◆ CHECKER [1/2]

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

◆ CHECKER [2/2]

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

◆ GET_CHECKERS [1/2]

#define GET_CHECKERS

◆ GET_CHECKERS [2/2]

#define GET_CHECKERS

Function Documentation

◆ calculateImportance()

◆ createRuleMapping()

◆ createThreadFlows()

◆ getDisplayCharRange()

CharSourceRange getDisplayCharRange ( const PathDiagnosticLocation & Loc,
const LangOptions & LO )
static

Returns the character range to report for Loc.

A thread flow needs a location for every piece, so an unusable range falls back to a caret rather than being dropped, which would truncate the path.

Definition at line 135 of file SarifDiagnostics.cpp.

References clang::Lexer::getAsCharRange(), clang::CharSourceRange::getCharRange(), clang::getExpansionRangeInFile(), clang::FullSourceLoc::getFileID(), and clang::CharSourceRange::getTokenRange().

Referenced by createThreadFlows().

◆ getRuleDescription()

StringRef getRuleDescription ( StringRef CheckName)
static

Definition at line 90 of file SarifDiagnostics.cpp.

Referenced by createRuleMapping().

◆ getRuleHelpURIStr()

StringRef getRuleHelpURIStr ( StringRef CheckName)
static

Definition at line 101 of file SarifDiagnostics.cpp.

Referenced by createRuleMapping().

Variable Documentation

◆ IssueHashKey

const llvm::StringRef IssueHashKey = "clang/issueHash/v1"
static

Definition at line 188 of file SarifDiagnostics.cpp.