-
Notifications
You must be signed in to change notification settings - Fork 32
add GetSpellingFromOperator
& GetOperatorFromSpelling
#628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2070,7 +2070,8 @@ void make_narg_call(const FunctionDecl* FD, const std::string& return_type, | |
if (op_flag) { | ||
callbuf << ", "; | ||
} else { | ||
callbuf << ' ' << Cpp::getOperatorSpelling(FD->getOverloadedOperator()) | ||
callbuf << ' ' | ||
<< clang::getOperatorSpelling(FD->getOverloadedOperator()) | ||
<< ' '; | ||
} | ||
} | ||
|
@@ -3559,6 +3560,19 @@ std::string GetFunctionArgName(TCppFunction_t func, TCppIndex_t param_index) { | |
return PI->getNameAsString(); | ||
} | ||
|
||
std::string GetSpellingFromOperator(Operator Operator) { | ||
return clang::getOperatorSpelling((clang::OverloadedOperatorKind)Operator); | ||
} | ||
|
||
Operator GetOperatorFromSpelling(const std::string& op) { | ||
#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ | ||
if ((Spelling) == op) { \ | ||
return (Operator)OO_##Name; \ | ||
} | ||
#include "clang/Basic/OperatorKinds.def" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage] return PI->getNameAsString();
^ Additional contextlib/CppInterOp/CppInterOp.cpp:3564: 'PI' initialized to a null pointer value clang::ParmVarDecl* PI = nullptr;
^ lib/CppInterOp/CppInterOp.cpp:3566: Assuming null pointer is passed into cast if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(D))
^ lib/CppInterOp/CppInterOp.cpp:3566: 'FD' is null if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(D))
^ lib/CppInterOp/CppInterOp.cpp:3566: Taking false branch if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(D))
^ lib/CppInterOp/CppInterOp.cpp:3568: Assuming null pointer is passed into cast else if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(D))
^ lib/CppInterOp/CppInterOp.cpp:3568: 'FD' is null else if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(D))
^ lib/CppInterOp/CppInterOp.cpp:3568: Taking false branch else if (auto* FD = llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(D))
^ lib/CppInterOp/CppInterOp.cpp:3571: Called C++ object pointer is null return PI->getNameAsString();
^ |
||
return Operator::OP_None; | ||
} | ||
|
||
OperatorArity GetOperatorArity(TCppFunction_t op) { | ||
Decl* D = static_cast<Decl*>(op); | ||
if (auto* FD = llvm::dyn_cast<FunctionDecl>(D)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
auto* D = (clang::Decl*)func; ^