本文整理汇总了C++中QualType::getBaseTypeIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C++ QualType::getBaseTypeIdentifier方法的具体用法?C++ QualType::getBaseTypeIdentifier怎么用?C++ QualType::getBaseTypeIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QualType
的用法示例。
在下文中一共展示了QualType::getBaseTypeIdentifier方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckAllocationType
static AllocationTypes CheckAllocationType(const CXXStaticCastExpr* castNode)
{
QualType targetType = castNode->getTypeAsWritten();
if (const IdentifierInfo* info = targetType.getBaseTypeIdentifier())
{
return info->getName().equals("Recycler") ?
AllocationTypes::Recycler : AllocationTypes::NonRecycler;
}
else
{
// Unknown template dependent allocator types
return AllocationTypes::Unknown;
}
}
示例2: VisitFunctionDecl
bool TeslaVisitor::VisitFunctionDecl(FunctionDecl *F) {
// Only analyse non-deleted definitions (i.e. definitions with bodies).
if (!F->doesThisDeclarationHaveABody())
return true;
// We only parse functions that return __tesla_automaton_description*.
const Type *RetTy = F->getResultType().getTypePtr();
if (!RetTy->isPointerType())
return true;
QualType Pointee = RetTy->getPointeeType();
auto TypeID = Pointee.getBaseTypeIdentifier();
if (!TypeID)
return true;
OwningPtr<Parser> P;
StringRef FnName = F->getName();
// Build a Parser appropriate to what we're parsing.
string RetTypeName = TypeID->getName();
if (RetTypeName == AUTOMATON_DESC)
P.reset(Parser::AutomatonParser(F, *Context));
else if ((RetTypeName == AUTOMATON_USAGE) && (FnName != AUTOMATON_USES))
P.reset(Parser::MappingParser(F, *Context));
else
return true;
// Actually parse the function.
if (!P)
return false;
OwningPtr<AutomatonDescription> Description;
OwningPtr<Usage> Use;
if (!P->Parse(Description, Use))
return false;
if (Description)
Automata.push_back(Description.take());
if (Use)
Roots.push_back(Use.take());
return true;
}
示例3: VisitTypeLoc
/// \brief If the new variable name conflicts with any type used in the loop,
/// then we mark that variable name as taken.
bool DeclFinderASTVisitor::VisitTypeLoc(TypeLoc TL) {
QualType QType = TL.getType();
// Check if our name conflicts with a type, to handle for typedefs.
if (QType.getAsString() == Name) {
Found = true;
return false;
}
// Check for base type conflicts. For example, when a struct is being
// referenced in the body of the loop, the above getAsString() will return the
// whole type (ex. "struct s"), but will be caught here.
if (const IdentifierInfo *Ident = QType.getBaseTypeIdentifier()) {
if (Ident->getName() == Name) {
Found = true;
return false;
}
}
return true;
}
示例4: VisitCXXNewExpr
void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred,
ExplodedNodeSet &Dst) {
// FIXME: Much of this should eventually migrate to CXXAllocatorCall.
// Also, we need to decide how allocators actually work -- they're not
// really part of the CXXNewExpr because they happen BEFORE the
// CXXConstructExpr subexpression. See PR12014 for some discussion.
unsigned blockCount = currBldrCtx->blockCount();
const LocationContext *LCtx = Pred->getLocationContext();
DefinedOrUnknownSVal symVal = UnknownVal();
FunctionDecl *FD = CNE->getOperatorNew();
bool IsStandardGlobalOpNewFunction = false;
if (FD && !isa<CXXMethodDecl>(FD) && !FD->isVariadic()) {
if (FD->getNumParams() == 2) {
QualType T = FD->getParamDecl(1)->getType();
if (const IdentifierInfo *II = T.getBaseTypeIdentifier())
// NoThrow placement new behaves as a standard new.
IsStandardGlobalOpNewFunction = II->getName().equals("nothrow_t");
}
else
// Placement forms are considered non-standard.
IsStandardGlobalOpNewFunction = (FD->getNumParams() == 1);
}
// We assume all standard global 'operator new' functions allocate memory in
// heap. We realize this is an approximation that might not correctly model
// a custom global allocator.
if (IsStandardGlobalOpNewFunction)
symVal = svalBuilder.getConjuredHeapSymbolVal(CNE, LCtx, blockCount);
else
symVal = svalBuilder.conjureSymbolVal(nullptr, CNE, LCtx, CNE->getType(),
blockCount);
ProgramStateRef State = Pred->getState();
CallEventManager &CEMgr = getStateManager().getCallEventManager();
CallEventRef<CXXAllocatorCall> Call =
CEMgr.getCXXAllocatorCall(CNE, State, LCtx);
// Invalidate placement args.
// FIXME: Once we figure out how we want allocators to work,
// we should be using the usual pre-/(default-)eval-/post-call checks here.
State = Call->invalidateRegions(blockCount);
if (!State)
return;
// If this allocation function is not declared as non-throwing, failures
// /must/ be signalled by exceptions, and thus the return value will never be
// NULL. -fno-exceptions does not influence this semantics.
// FIXME: GCC has a -fcheck-new option, which forces it to consider the case
// where new can return NULL. If we end up supporting that option, we can
// consider adding a check for it here.
// C++11 [basic.stc.dynamic.allocation]p3.
if (FD) {
QualType Ty = FD->getType();
if (const FunctionProtoType *ProtoType = Ty->getAs<FunctionProtoType>())
if (!ProtoType->isNothrow(getContext()))
State = State->assume(symVal, true);
}
StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
if (CNE->isArray()) {
// FIXME: allocating an array requires simulating the constructors.
// For now, just return a symbolicated region.
const MemRegion *NewReg = symVal.castAs<loc::MemRegionVal>().getRegion();
QualType ObjTy = CNE->getType()->getAs<PointerType>()->getPointeeType();
const ElementRegion *EleReg =
getStoreManager().GetElementZeroRegion(NewReg, ObjTy);
State = State->BindExpr(CNE, Pred->getLocationContext(),
loc::MemRegionVal(EleReg));
Bldr.generateNode(CNE, Pred, State);
return;
}
// FIXME: Once we have proper support for CXXConstructExprs inside
// CXXNewExpr, we need to make sure that the constructed object is not
// immediately invalidated here. (The placement call should happen before
// the constructor call anyway.)
SVal Result = symVal;
if (FD && FD->isReservedGlobalPlacementOperator()) {
// Non-array placement new should always return the placement location.
SVal PlacementLoc = State->getSVal(CNE->getPlacementArg(0), LCtx);
Result = svalBuilder.evalCast(PlacementLoc, CNE->getType(),
CNE->getPlacementArg(0)->getType());
}
// Bind the address of the object, then check to see if we cached out.
State = State->BindExpr(CNE, LCtx, Result);
ExplodedNode *NewN = Bldr.generateNode(CNE, Pred, State);
if (!NewN)
return;
// If the type is not a record, we won't have a CXXConstructExpr as an
// initializer. Copy the value over.
if (const Expr *Init = CNE->getInitializer()) {
if (!isa<CXXConstructExpr>(Init)) {
assert(Bldr.getResults().size() == 1);
Bldr.takeNodes(NewN);
evalBind(Dst, CNE, NewN, Result, State->getSVal(Init, LCtx),
//.........这里部分代码省略.........
示例5: StmtHelper
//.........这里部分代码省略.........
}
string node = x->getStmtClassName();
if(node == "ReturnStmt"){
output += "<return";
}else if(node == "ForStmt"){
output += "<forLoop";
}else if(node == "WhileStmt"){
output += "<whileLoop";
}else if(node == "DoStmt"){
output += "<do";
}else if(node == "IfStmt"){
if(parent->getStmtClassName() != std::string("IfStmt")){
stringstream ssminus;
ssminus << (intLevel-1);
output += "<ifBlock," + ssminus.str() + ">\n";
intLevel += 1;
stringstream ssif;
ssif << intLevel;
level = ssif.str();
}
output += "<ifStatement";
}else if(node == "SwitchStmt"){
output += "<switch";
}else if(node == "CaseStmt"){
output += "<case";
}else if(node == "CXXMemberCallExpr"){
CXXMemberCallExpr* ce = (CXXMemberCallExpr*) x;
Expr* obj = ce->getImplicitObjectArgument();
CallExpr* expr = (CallExpr*) x;
output += "<object: ";
QualType qt = obj->getType();
output += qt.getBaseTypeIdentifier()->getName().str();
output += "; calling func: ";
output += expr->getDirectCallee()->getNameInfo().getAsString();
output += ", " + level + ">\n";
output += "<args";
numClosingArgsNeeded++;
callStack.push(x);
if(callStackDebug){
cerr << "pushing" << endl;
printCallStack();
}
}else if(node == "CallExpr"){
CallExpr* expr = (CallExpr*) x;
output += "<calling func: ";
output += expr->getDirectCallee()->getNameInfo().getAsString();
output += ", " + level + ">\n";
output += "<args";
numClosingArgsNeeded++;
callStack.push(x);
if(callStackDebug){
cerr << "pushing" << endl;
printCallStack();
}
}else if(node == "CXXConstructExpr"){
CXXConstructExpr* ce = (CXXConstructExpr*) x;
//Decl* CD = ce->getConstructor();
string filename;
//if(isInCurFile(Context, CD, filename)){
CXXMethodDecl* MD = ce->getConstructor();
示例6: DeclHelper
//.........这里部分代码省略.........
if(isParentDecl(getDeclParent(D, Context), "Var")){
previousRhsDecl = true;
if(debugPrint){
cout << "setting prev var to true" << endl;
}
}else if(previousRhsDecl && numClosingVarsNeeded > 0){
//if the current node is not a child of a variable declaration
//but the previous node was a child of a variable declation
//then we know to print a </decl>
output +="</variableDecl,1>\n";
numClosingVarsNeeded--;
previousRhsDecl = false;
}
if(node == "Var"){
output += "<variableDecl, " + prevLevel + ">";
numClosingVarsNeeded++;
VarDecl* VD = (VarDecl*) D;
if(!VD->hasInit()){
output +="\n</variableDecl,1>\n";
numClosingVarsNeeded--;
}
}else if(node == "Function"){
FunctionDecl* FD = (FunctionDecl*) D;
output += "<functionDef," + level +">";
//add function name to the output
output += "\n<name: " + FD->getNameInfo().getAsString()
+ "," + nextLevel + ">";
}else if(node == "CXXRecord"){
const Decl* parent = getDeclParent(D, Context);
if(parent && strcmp(parent->getDeclKindName(), "CXXRecord") != 0){
CXXRecordDecl* CD = (CXXRecordDecl*) D;
output += "<classDef," + level + ">";
output += "\n<name: " + CD->getNameAsString() + "," + nextLevel + ">";
output += "\n<bases," + nextLevel + ">";
//iterate over all bases and add them to the output
CXXRecordDecl::base_class_iterator basesItr = CD->bases_begin();
while(basesItr != CD->bases_end()){
QualType qt = basesItr->getType();
output += "\n<base: " + qt.getBaseTypeIdentifier()->getName().str();
output += "," + nextNextLevel + ">";
basesItr++;
}
//iterate over all of the virtual bases and add them to the output
auto vBasesItr = CD->vbases_begin();
while(vBasesItr != CD->vbases_end()){
QualType qt = vBasesItr->getType();
output += "\n<base: " + qt.getBaseTypeIdentifier()->getName().str();
output += "," + nextNextLevel + ">";
vBasesItr++;
}
}
}else if(node == "CXXDestructor"){
CXXDestructorDecl* CD = (CXXDestructorDecl*) D;
if(!CD->isImplicit()){
output += "<functionDef," + level +">";
//add function name to the output
output += "\n<name: ~" + CD->getNameInfo().getAsString()
+ "," + nextLevel + ">";
}
}else if(node == "CXXConstructor"){
CXXConstructorDecl* CD = (CXXConstructorDecl*) D;
if(!CD->isImplicit()){
output += "<functionDef," + level +">";
//add function name to the output
output += "\n<name: " + CD->getNameInfo().getAsString()
+ "," + nextLevel + ">";
}
}else if(node == "CXXMethod"){
CXXMethodDecl* CM = (CXXMethodDecl*) D;
if(!CM->isImplicit()){
output += "<functionDef," + level +">";
//add function name to the output
output += "\n<name: " + CM->getNameInfo().getAsString()
+ "," + nextLevel + ">";
}
}else{
if(debugPrint){
output += "<";
output += node;
output += ">";
}
}
if(output.size() != 0){
cout << output << endl;
}
return true;
}