-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refined exception handling and noexcept specifications for public APIs
- Reviewed all public APIs to ensure the correct exception specifications. - Corrected APIs that were missing or incorrectly specifying noexcept. - Updated documentation to clearly state which exceptions are thrown by each API. - Fixed several areas where exceptions were not being handled properly, ensuring robust error handling.
- Loading branch information
Showing
14 changed files
with
176 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <clang/AST/ASTConsumer.h> | ||
#include <clang/AST/RecursiveASTVisitor.h> | ||
#include <clang/Frontend/ASTConsumers.h> | ||
#include <clang/Frontend/FrontendActions.h> | ||
#include <clang/Tooling/CommonOptionsParser.h> | ||
#include <clang/Tooling/Tooling.h> | ||
#include <clang/Frontend/CompilerInstance.h> | ||
#include <iostream> | ||
|
||
using namespace clang; | ||
using namespace clang::tooling; | ||
|
||
class FunctionVisitor : public RecursiveASTVisitor<FunctionVisitor> { | ||
public: | ||
explicit FunctionVisitor(ASTContext *context) : context(context) {} | ||
|
||
bool VisitFunctionDecl(FunctionDecl *func) { | ||
// 関数名を取得 | ||
std::string funcName = func->getNameInfo().getName().getAsString(); | ||
|
||
// noexcept が指定されているかどうかを確認 | ||
bool isNoexcept = (func->getExceptionSpecType() == EST_BasicNoexcept); | ||
|
||
// 結果を出力 | ||
std::cout << "Function: " << funcName | ||
<< " - noexcept: " << (isNoexcept ? "true" : "false") | ||
<< std::endl; | ||
|
||
return true; | ||
} | ||
|
||
private: | ||
ASTContext *context; | ||
}; | ||
|
||
class FunctionASTConsumer : public ASTConsumer { | ||
public: | ||
explicit FunctionASTConsumer(ASTContext *context) : visitor(context) {} | ||
|
||
virtual void HandleTranslationUnit(ASTContext &context) override { | ||
visitor.TraverseDecl(context.getTranslationUnitDecl()); | ||
} | ||
|
||
private: | ||
FunctionVisitor visitor; | ||
}; | ||
|
||
class FunctionFrontendAction : public ASTFrontendAction { | ||
public: | ||
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override { | ||
return std::make_unique<FunctionASTConsumer>(&CI.getASTContext()); | ||
} | ||
}; | ||
|
||
static llvm::cl::OptionCategory MyToolCategory("my-tool options"); | ||
|
||
int main(int argc, const char **argv) { | ||
auto optionsParser = CommonOptionsParser::create(argc, argv, MyToolCategory); | ||
if (!optionsParser) { | ||
llvm::errs() << "Error creating CommonOptionsParser\n"; | ||
return 1; | ||
} | ||
|
||
ClangTool tool(optionsParser->getCompilations(), optionsParser->getSourcePathList()); | ||
return tool.run(newFrontendActionFactory<FunctionFrontendAction>().get()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.