[clang] [Draft] Summary Based Analysis Prototype (PR #144224)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 14 07:08:26 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/Sema/SummaryAttribute.h clang/include/clang/Sema/SummaryConsumer.h clang/include/clang/Sema/SummaryContext.h clang/lib/Sema/SummaryAttribute.cpp clang/lib/Sema/SummaryConsumer.cpp clang/lib/Sema/SummaryContext.cpp clang/include/clang/Frontend/CompilerInstance.h clang/include/clang/Frontend/FrontendOptions.h clang/include/clang/Sema/Sema.h clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/FrontendAction.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/StaticAnalyzer/Core/CallEvent.cpp clang/lib/StaticAnalyzer/Core/ExprEngine.cpp clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Sema/SummaryAttribute.h b/clang/include/clang/Sema/SummaryAttribute.h
index 27ceede1e..213bce59c 100644
--- a/clang/include/clang/Sema/SummaryAttribute.h
+++ b/clang/include/clang/Sema/SummaryAttribute.h
@@ -18,7 +18,7 @@ class SummaryAttr {
protected:
SummaryAttr(SummaryAttrKind Kind, const char *Spelling)
- : Kind(Kind), Spelling(Spelling){};
+ : Kind(Kind), Spelling(Spelling) {};
public:
virtual ~SummaryAttr() = default;
diff --git a/clang/include/clang/Sema/SummaryConsumer.h b/clang/include/clang/Sema/SummaryConsumer.h
index 3d308b846..928a6543e 100644
--- a/clang/include/clang/Sema/SummaryConsumer.h
+++ b/clang/include/clang/Sema/SummaryConsumer.h
@@ -15,9 +15,9 @@ public:
SummaryConsumer(const SummaryContext &SummaryCtx) : SummaryCtx(&SummaryCtx) {}
virtual ~SummaryConsumer() = default;
- virtual void ProcessStartOfSourceFile(){};
- virtual void ProcessFunctionSummary(const FunctionSummary &){};
- virtual void ProcessEndOfSourceFile(){};
+ virtual void ProcessStartOfSourceFile() {};
+ virtual void ProcessFunctionSummary(const FunctionSummary &) {};
+ virtual void ProcessEndOfSourceFile() {};
};
class PrintingSummaryConsumer : public SummaryConsumer {
@@ -27,7 +27,7 @@ public:
};
class JSONPrintingSummaryConsumer : public PrintingSummaryConsumer {
- llvm::json::OStream JOS;
+ llvm::json::OStream JOS;
public:
JSONPrintingSummaryConsumer(const SummaryContext &SummaryCtx, raw_ostream &OS)
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index fb4bfbc82..8780aa3eb 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -741,8 +741,8 @@ CompilerInstance::createCodeCompletionConsumer(Preprocessor &PP,
}
void CompilerInstance::createSummaryConsumer() {
- const std::string& SummaryFile = getFrontendOpts().SummaryFile;
- if(SummaryFile.empty())
+ const std::string &SummaryFile = getFrontendOpts().SummaryFile;
+ if (SummaryFile.empty())
return;
std::error_code EC;
diff --git a/clang/lib/Sema/SummaryConsumer.cpp b/clang/lib/Sema/SummaryConsumer.cpp
index 043873f23..d2d342430 100644
--- a/clang/lib/Sema/SummaryConsumer.cpp
+++ b/clang/lib/Sema/SummaryConsumer.cpp
@@ -2,7 +2,8 @@
#include "clang/Sema/SummaryContext.h"
namespace clang {
-void JSONPrintingSummaryConsumer::ProcessFunctionSummary(const FunctionSummary &Summary) {
+void JSONPrintingSummaryConsumer::ProcessFunctionSummary(
+ const FunctionSummary &Summary) {
JOS.object([&] {
JOS.attribute("id", llvm::json::Value(Summary.getID()));
JOS.attributeObject("attrs", [&] {
diff --git a/clang/lib/Sema/SummaryContext.cpp b/clang/lib/Sema/SummaryContext.cpp
index b4e494510..e3e9facfe 100644
--- a/clang/lib/Sema/SummaryContext.cpp
+++ b/clang/lib/Sema/SummaryContext.cpp
@@ -92,7 +92,8 @@ void SummaryContext::ParseSummaryFromJSON(const llvm::json::Array &Summary) {
std::set<const SummaryAttr *> FunctionAttrs;
const llvm::json::Array *FunctionAttributes =
FunctionSummary->getObject("attrs")->getArray("function");
- for(auto attrIt = FunctionAttributes->begin(); attrIt != FunctionAttributes->end(); ++attrIt) {
+ for (auto attrIt = FunctionAttributes->begin();
+ attrIt != FunctionAttributes->end(); ++attrIt) {
for (auto &&Attr : Attributes) {
if (Attr->parse(*attrIt->getAsString()))
FunctionAttrs.emplace(Attr.get());
@@ -101,7 +102,8 @@ void SummaryContext::ParseSummaryFromJSON(const llvm::json::Array &Summary) {
std::set<SmallVector<char>> Calls;
const llvm::json::Array *CallEntries = FunctionSummary->getArray("calls");
- for(auto callIt = CallEntries->begin(); callIt != CallEntries->end(); ++callIt) {
+ for (auto callIt = CallEntries->begin(); callIt != CallEntries->end();
+ ++callIt) {
auto *Obj = callIt->getAsObject();
Calls.emplace(SmallString<128>(*Obj->getString("id")));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/144224
More information about the cfe-commits
mailing list