clang  16.0.0git
Functions
Sarif.cpp File Reference
#include "clang/Basic/Sarif.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/Path.h"
#include <string>
#include <utility>
Include dependency graph for Sarif.cpp:

Go to the source code of this file.

Functions

static StringRef getFileName (const FileEntry &FE)
 
static unsigned int adjustColumnPos (FullSourceLoc Loc, unsigned int TokenLen=0)
 Calculate the column position expressed in the number of UTF-8 code points from column start to the source location. More...
 
URI
static std::string percentEncodeURICharacter (char C)
 
static std::string fileNameToURI (StringRef Filename)
 
SARIF Utilities
json::Object createMessage (StringRef Text)
 
static json::Object createTextRegion (const SourceManager &SM, const CharSourceRange &R)
 
static json::Object createLocation (json::Object &&PhysicalLocation, StringRef Message="")
 
static StringRef importanceToStr (ThreadFlowImportance I)
 
static StringRef resultLevelToStr (SarifResultLevel R)
 
static json::Object createThreadFlowLocation (json::Object &&Location, const ThreadFlowImportance &Importance)
 

Detailed Description

This file contains the declaration of the SARIFDocumentWriter class, and associated builders such as:

Definition in file Sarif.cpp.

Function Documentation

◆ adjustColumnPos()

static unsigned int adjustColumnPos ( FullSourceLoc  Loc,
unsigned int  TokenLen = 0 
)
static

Calculate the column position expressed in the number of UTF-8 code points from column start to the source location.

Parameters
LocThe source location whose column needs to be calculated.
TokenLenOptional hint for when the token is multiple bytes long.
Returns
The column number as a UTF-8 aware byte offset from column start to the effective source location.

Definition at line 117 of file Sarif.cpp.

References clang::SourceManager::getBufferOrNone(), clang::FullSourceLoc::getDecomposedExpansionLoc(), clang::FullSourceLoc::getExpansionColumnNumber(), clang::FullSourceLoc::getManager(), clang::SourceLocation::isInvalid(), and Ret().

Referenced by createTextRegion().

◆ createLocation()

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

Definition at line 166 of file Sarif.cpp.

References createMessage(), and Ret().

Referenced by clang::SarifDocumentWriter::appendResult().

◆ createMessage()

json::Object createMessage ( StringRef  Text)

Definition at line 144 of file Sarif.cpp.

References Text.

Referenced by clang::SarifDocumentWriter::appendResult(), and createLocation().

◆ createTextRegion()

static json::Object createTextRegion ( const SourceManager SM,
const CharSourceRange R 
)
static

◆ createThreadFlowLocation()

static json::Object createThreadFlowLocation ( json::Object &&  Location,
const ThreadFlowImportance Importance 
)
static

Definition at line 202 of file Sarif.cpp.

References importanceToStr().

◆ fileNameToURI()

static std::string fileNameToURI ( StringRef  Filename)
static

Definition at line 71 of file Sarif.cpp.

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

◆ getFileName()

static StringRef getFileName ( const FileEntry FE)
static

◆ importanceToStr()

static StringRef importanceToStr ( ThreadFlowImportance  I)
static

Definition at line 174 of file Sarif.cpp.

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

Referenced by createThreadFlowLocation().

◆ percentEncodeURICharacter()

static std::string percentEncodeURICharacter ( char  C)
static

Definition at line 53 of file Sarif.cpp.

References string().

Referenced by fileNameToURI().

◆ resultLevelToStr()

static StringRef resultLevelToStr ( SarifResultLevel  R)
static