clang  14.0.0git
Macros | Enumerations | Functions
SarifDiagnostics.cpp File Reference
#include "clang/Analysis/MacroExpansionContext.h"
#include "clang/Analysis/PathDiagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/Version.h"
#include "clang/Lex/Preprocessor.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)

◆ CHECKER [2/2]

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

◆ GET_CHECKERS [1/2]

#define GET_CHECKERS

◆ GET_CHECKERS [2/2]

#define GET_CHECKERS

Enumeration Type Documentation

◆ Importance

enum Importance
strong
Enumerator
Important 
Essential 
Unimportant 

Definition at line 207 of file SarifDiagnostics.cpp.

Function Documentation

◆ adjustColumnPos()

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

Definition at line 156 of file SarifDiagnostics.cpp.

References clang::SourceLocation::isInvalid(), Ret(), and SM.

Referenced by createTextRegion().

◆ calculateImportance()

static Importance calculateImportance ( const PathDiagnosticPiece &  Piece)
static

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

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

◆ createArtifactLocation() [1/2]

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

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

References clang::File, fileNameToURI(), getFileName(), and string().

◆ createCodeFlow()

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

Definition at line 274 of file SarifDiagnostics.cpp.

References createThreadFlow().

Referenced by createResult().

◆ createLocation()

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

Definition at line 231 of file SarifDiagnostics.cpp.

References createMessage(), and Ret().

Referenced by createResult(), and createThreadFlow().

◆ createMessage()

static json::Object createMessage ( StringRef  Text)
static

Definition at line 227 of file SarifDiagnostics.cpp.

References Text.

Referenced by createLocation(), 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 198 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

◆ createRule()

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

◆ createRules()

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

Definition at line 339 of file SarifDiagnostics.cpp.

References P.

Referenced by createTool().

◆ createRun()

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

Definition at line 366 of file SarifDiagnostics.cpp.

◆ createTextRegion()

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

◆ createThreadFlow()

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

◆ createThreadFlowLocation()

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

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

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

◆ fileNameToURI()

static std::string fileNameToURI ( StringRef  Filename)
static

Definition at line 83 of file SarifDiagnostics.cpp.

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

Referenced by createArtifactLocation().

◆ getFileName()

static StringRef getFileName ( const FileEntry FE)
static

◆ getRuleDescription()

static StringRef getRuleDescription ( StringRef  CheckName)
static

Definition at line 303 of file SarifDiagnostics.cpp.

Referenced by createRule().

◆ getRuleHelpURIStr()

static StringRef getRuleHelpURIStr ( StringRef  CheckName)
static

Definition at line 314 of file SarifDiagnostics.cpp.

Referenced by createRule().

◆ importanceToStr()

static StringRef importanceToStr ( Importance  I)
static

Definition at line 209 of file SarifDiagnostics.cpp.

References Essential, Important, and Unimportant.

Referenced by createThreadFlowLocation().

◆ percentEncodeURICharacter()

static std::string percentEncodeURICharacter ( char  C)
static

Definition at line 71 of file SarifDiagnostics.cpp.

References string().

Referenced by fileNameToURI().