clang 19.0.0git
Functions
Sarif.cpp File Reference

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

#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/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/Path.h"
#include <optional>
#include <string>
#include <utility>

Go to the source code of this file.

Functions

static StringRef getFileName (FileEntryRef 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.
 
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(), and clang::SourceLocation::isInvalid().

Referenced by createTextRegion().

◆ createLocation()

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

Definition at line 166 of file Sarif.cpp.

References createMessage().

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 clang::C, Filename, Iter, and percentEncodeURICharacter().

◆ getFileName()

static StringRef getFileName ( FileEntryRef  FE)
static

◆ importanceToStr()

static StringRef importanceToStr ( ThreadFlowImportance  I)
static

Definition at line 174 of file Sarif.cpp.

Referenced by createThreadFlowLocation().

◆ percentEncodeURICharacter()

static std::string percentEncodeURICharacter ( char  C)
static

Definition at line 54 of file Sarif.cpp.

References clang::C, and contains().

Referenced by fileNameToURI().

◆ resultLevelToStr()

static StringRef resultLevelToStr ( SarifResultLevel  R)
static