lib/Sema/StmtResInfer.cpp
// FIXME: Once all statements of the declaration are passed, the restricitons
// inferring can be performed. This is only allowed in auto-restricted declaration
// Top down
Once all statements of the declaration are passed, the restricitons
inferring can be performed. This is only allowed in auto-restricted declaration
Top down
Once all statements of the declaration are passed the restricitons inferring can be performed . This is only allowed in auto - restricted declaration Top down
void Sema::TryCXXAMPRestrictionInferring(Decl *dcl, Stmt *S) {
  if (!getLangOpts().CPlusPlusAMP ||!dcl ||!dcl->hasAttr<CXXAMPRestrictAUTOAttr>())
    return;
  assert(isa<FunctionDecl>(*dcl) && dcl->hasBody());
  unsigned OtherSpec = CPPAMP_AMP | CPPAMP_CPU;
  if(dcl->hasAttr<CXXAMPRestrictAMPAttr>())
    OtherSpec &= ~CPPAMP_AMP;
  if(dcl->hasAttr<CXXAMPRestrictCPUAttr>())
    OtherSpec &= ~CPPAMP_CPU;
  if (isa<CXXMethodDecl>(dcl) && dyn_cast<CXXMethodDecl>(dcl)->getParent()->isLambda()) {
  } else if(OtherSpec & CPPAMP_AMP) {
    if(!IsInAMPRestricted() && dcl->getParentFunctionOrMethod())
      OtherSpec &= ~CPPAMP_AMP;
    else if(FunctionDecl* FD = dyn_cast<FunctionDecl>(dcl))
     InferFunctionType(FD, OtherSpec);
  }
  if(OtherSpec) {
     StmtResInfer SRI(*this, OtherSpec, &this->getSourceManager());
     OtherSpec = SRI.Infer(S);
    }
  if(OtherSpec) {
    CXXAMPRestrictAUTOAttr *AUTOAttr = dcl->getAttr<CXXAMPRestrictAUTOAttr>();
    assert(AUTOAttr);
    if(OtherSpec & CPPAMP_AMP)
      dcl->addAttr(::new (Context) CXXAMPRestrictAMPAttr(AUTOAttr->getRange(), Context, 0));
    if(OtherSpec & CPPAMP_CPU)
      dcl->addAttr(::new (Context) CXXAMPRestrictCPUAttr(AUTOAttr->getRange(), Context, 0));
  }
  dcl->dropAttr<CXXAMPRestrictAUTOAttr>();
}
void Sema :: TryCXXAMPRestrictionInferring ( Decl * dcl , Stmt * S ) { if ( ! getLangOpts ( ) . CPlusPlusAMP || ! dcl || ! dcl -> hasAttr < CXXAMPRestrictAUTOAttr > ( ) ) return ; assert ( isa < FunctionDecl > ( * dcl ) && dcl -> hasBody ( ) ) ; unsigned OtherSpec = CPPAMP_AMP | CPPAMP_CPU ; if ( dcl -> hasAttr < CXXAMPRestrictAMPAttr > ( ) ) OtherSpec &= ~ CPPAMP_AMP ; if ( dcl -> hasAttr < CXXAMPRestrictCPUAttr > ( ) ) OtherSpec &= ~ CPPAMP_CPU ; if ( isa < CXXMethodDecl > ( dcl ) && dyn_cast < CXXMethodDecl > ( dcl ) -> getParent ( ) -> isLambda ( ) ) { } else if ( OtherSpec & CPPAMP_AMP ) { if ( ! IsInAMPRestricted ( ) && dcl -> getParentFunctionOrMethod ( ) ) OtherSpec &= ~ CPPAMP_AMP ; else if ( FunctionDecl * FD = dyn_cast < FunctionDecl > ( dcl ) ) InferFunctionType ( FD , OtherSpec ) ; } if ( OtherSpec ) { StmtResInfer SRI ( * this , OtherSpec , & this -> getSourceManager ( ) ) ; OtherSpec = SRI . Infer ( S ) ; } if ( OtherSpec ) { CXXAMPRestrictAUTOAttr * AUTOAttr = dcl -> getAttr < CXXAMPRestrictAUTOAttr > ( ) ; assert ( AUTOAttr ) ; if ( OtherSpec & CPPAMP_AMP ) dcl -> addAttr ( :: new ( Context ) CXXAMPRestrictAMPAttr ( AUTOAttr -> getRange ( ) , Context , 0 ) ) ; if ( OtherSpec & CPPAMP_CPU ) dcl -> addAttr ( :: new ( Context ) CXXAMPRestrictCPUAttr ( AUTOAttr -> getRange ( ) , Context , 0 ) ) ; } dcl -> dropAttr < CXXAMPRestrictAUTOAttr > ( ) ; }
FIXME: Once all statements of the declaration are passed, the restricitons
inferring can be performed.
FIXME : Once all statements of the declaration are passed the restricitons inferring can be performed .
// Only allow on funtion definition // Inferring process // skip method in a lambda class (ex: kernel function in parallel_for_each) // Assuming that 'auto' has been already inferred in parent scope if any // Contained in any CPU only caller? // Update non-auto restriction specifiers if any //Place all manually created Attr in where 'auto' physically is // The inferring process is done. Drop AUTO Attribute in this compilation path