Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def WebKitAlpha : Package<"webkit">, ParentPackage<Alpha>;

def CHERI : Package<"cheri">;
def CHERIAlpha : Package<"cheri">, ParentPackage<Alpha>;
def CHERIoT : Package<"cheriot">;

//===----------------------------------------------------------------------===//
// Core Checkers.
Expand Down Expand Up @@ -1862,3 +1863,10 @@ let ParentPackage = CHERIAlpha in {
Documentation<NotDocumented>;

} // end alpha.cheri

let ParentPackage = CHERIoT in {
def CheriotHeapChecker
: Checker<"CheriotHeap">,
HelpText<"Check use of CHERIoT heap allocations APIs">,
Documentation<NotDocumented>;
} // end cheriot
6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ bool riscv::isCheriPurecap(const llvm::opt::ArgList &Args,
return isCheriPurecapABIName(getRISCVABI(Args, Triple));
}

bool riscv::isCheriot(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple) {
auto ABI = getRISCVABI(Args, Triple);
return (Triple.getOS() == llvm::Triple::CheriotRTOS ||
(ABI == "cheriot" || ABI == "cheriot-baremetal"));
}

// Get features except standard extension feature
static void getRISCFeaturesFromMcpu(const Driver &D, const Arg *A,
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Arch/RISCV.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ StringRef getRISCVABI(const llvm::opt::ArgList &Args,
std::string getRISCVArch(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple);
bool isCheriPurecap(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
bool isCheriot(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
std::string getRISCVTargetCPU(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple);
} // end namespace riscv
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3518,6 +3518,9 @@ static void RenderAnalyzerOptions(const ArgList &Args, ArgStringList &CmdArgs,

CmdArgs.push_back("-analyzer-checker=optin.portability.PointerAlignment");
CmdArgs.push_back("-analyzer-checker=alpha.core.PointerSub");

if (tools::riscv::isCheriot(Args, Triple))
CmdArgs.push_back("-analyzer-checker=cheriot");
}

// Default nullability checks.
Expand Down
Loading