tinycodinglm / lang /clang003.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 15)
b27bfb3 verified
|
Raw History Blame Contribute Delete
1.13 kB
deepseek-harness trace
System You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing c...

You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.

User

How do I write custom clang-tidy checks?

Assistant
cpp
void MyCheck::registerMatchers(MatchFinder *Finder) {
    Finder->addMatcher(
        callExpr(callee(functionDecl(hasName("gets")))).bind("gets_call"),
        this
    );
}
void MyCheck::check(const MatchFinder::MatchResult &Result) {
    if (auto *Call = Result.Nodes.getNodeAs<CallExpr>("gets_call"))
        diag(Call->getBeginLoc(), "gets() is dangerous, use fgets() instead");
}