本文整理汇总了C++中clang::ASTContext类的典型用法代码示例。如果您正苦于以下问题:C++ ASTContext类的具体用法?C++ ASTContext怎么用?C++ ASTContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ASTContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lineBasedShouldSuppress
bool lineBasedShouldSuppress(int beginLine, clang::ASTContext &context)
{
std::string filePath = getMainFilePath(context);
auto commentLinesIt = singleLineMapping.find(filePath);
std::set<int> commentLines;
if (commentLinesIt == singleLineMapping.end())
{
clang::RawCommentList commentList = context.getRawCommentList();
clang::ArrayRef<clang::RawComment *> commentArray = commentList.getComments();
for (auto comment : commentArray)
{
if (std::string::npos !=
comment->getRawText(context.getSourceManager()).find("//!OCLINT"))
{
clang::SourceLocation startLocation = comment->getLocStart();
int startLocationLine =
context.getSourceManager().getPresumedLineNumber(startLocation);
commentLines.insert(startLocationLine);
}
}
singleLineMapping[filePath] = commentLines;
}
else
{
commentLines = commentLinesIt->second;
}
return commentLines.find(beginLine) != commentLines.end();
}
开发者ID:GeekMin,项目名称:oclint,代码行数:31,代码来源:SuppressHelper.cpp
示例2: getClangMetatypeType
static clang::CanQualType getClangMetatypeType(
const clang::ASTContext &clangCtx) {
clang::QualType clangType =
clangCtx.getObjCObjectType(clangCtx.ObjCBuiltinClassTy, 0, 0);
clangType = clangCtx.getObjCObjectPointerType(clangType);
return clangCtx.getCanonicalType(clangType);
}
开发者ID:yasirmcs,项目名称:swift,代码行数:7,代码来源:GenClangType.cpp
示例3: StreamArr
static void StreamArr(llvm::raw_ostream& o, const void* V, clang::QualType Ty,
clang::ASTContext& C) {
const clang::ArrayType* ArrTy = Ty->getAsArrayTypeUnsafe();
clang::QualType ElementTy = ArrTy->getElementType();
if (ElementTy->isCharType())
StreamCharPtr(o, (const char*)V);
else if (Ty->isConstantArrayType()) {
// Stream a constant array by streaming up to 5 elements.
const clang::ConstantArrayType* CArrTy
= C.getAsConstantArrayType(Ty);
const llvm::APInt& APSize = CArrTy->getSize();
size_t ElBytes = C.getTypeSize(ElementTy) / C.getCharWidth();
size_t Size = (size_t)APSize.getZExtValue();
o << "{ ";
for (size_t i = 0; i < Size; ++i) {
StreamValue(o, (const char*) V + i * ElBytes, ElementTy, C);
if (i + 1 < Size) {
if (i == 4) {
o << "...";
break;
}
else o << ", ";
}
}
o << " }";
} else
StreamPtr(o, V);
}
开发者ID:rpatkennyiii,项目名称:root,代码行数:28,代码来源:ValuePrinter.cpp
示例4: getClangIdType
static clang::CanQualType getClangIdType(
const clang::ASTContext &clangCtx) {
clang::QualType clangType =
clangCtx.getObjCObjectType(clangCtx.ObjCBuiltinIdTy, nullptr, 0);
clangType = clangCtx.getObjCObjectPointerType(clangType);
return clangCtx.getCanonicalType(clangType);
}
开发者ID:PiersonBro,项目名称:swift,代码行数:7,代码来源:GenClangType.cpp
示例5: getClangDecayedVaListType
static clang::CanQualType getClangDecayedVaListType(
const clang::ASTContext &clangCtx) {
clang::QualType clangType =
clangCtx.getCanonicalType(clangCtx.getBuiltinVaListType());
if (clangType->isConstantArrayType())
clangType = clangCtx.getDecayedType(clangType);
return clangCtx.getCanonicalType(clangType);
}
开发者ID:yasirmcs,项目名称:swift,代码行数:8,代码来源:GenClangType.cpp
示例6: getClangVectorType
static clang::CanQualType getClangVectorType(const clang::ASTContext &ctx,
clang::BuiltinType::Kind eltKind,
clang::VectorType::VectorKind vecKind,
StringRef numEltsString) {
unsigned numElts;
bool failedParse = numEltsString.getAsInteger<unsigned>(10, numElts);
assert(!failedParse && "vector type name didn't end in count?");
(void) failedParse;
auto eltTy = getClangBuiltinTypeFromKind(ctx, eltKind);
auto vecTy = ctx.getVectorType(eltTy, numElts, vecKind);
return ctx.getCanonicalType(vecTy);
}
开发者ID:yasirmcs,项目名称:swift,代码行数:13,代码来源:GenClangType.cpp
示例7: HandleTranslationUnit
virtual void HandleTranslationUnit(clang::ASTContext &ctx)
{
llvm::raw_ostream &out = llvm::errs();
clang::TranslationUnitDecl *translationUnit = ctx.getTranslationUnitDecl();
MyDeclVisitor(out, _astinfo).Visit(translationUnit);
}
开发者ID:wkia,项目名称:white-knight-is-alive,代码行数:7,代码来源:testclang.cpp
示例8: markedParentsAsSuppress
bool markedParentsAsSuppress(const T &node, clang::ASTContext &context, oclint::RuleBase *rule)
{
const auto &parents = context.getParents(node);
if (parents.empty())
{
return false;
}
clang::ast_type_traits::DynTypedNode dynTypedNode = parents.front();
const clang::Decl *aDecl = dynTypedNode.get<clang::Decl>();
if (aDecl)
{
if (markedAsSuppress(aDecl, rule))
{
return true;
}
return markedParentsAsSuppress(*aDecl, context, rule);
}
const clang::Stmt *aStmt = dynTypedNode.get<clang::Stmt>();
if (aStmt)
{
return markedParentsAsSuppress(*aStmt, context, rule);
}
return false;
}
开发者ID:GeekMin,项目名称:oclint,代码行数:26,代码来源:SuppressHelper.cpp
示例9: HandleTranslationUnit
void HandleTranslationUnit(clang::ASTContext &astContext) override {
const auto &sourceManager = astContext.getSourceManager();
const auto cursorSourceLocation = sourceManager.translateLineCol(sourceManager.getMainFileID(),
line,
column);
if (cursorSourceLocation.isValid())
collectUnifiedSymbolResoltions(astContext, cursorSourceLocation);
}
开发者ID:yueying,项目名称:qt-creator,代码行数:9,代码来源:findusrforcursoraction.cpp
示例10: ExitIfError
void ExitIfError(clang::ASTContext &Context)
{
DiagnosticsEngine & diags = Context.getDiagnostics();
if (diags.hasErrorOccurred()) {
unsigned DiagID = diags.getCustomDiagID(DiagnosticsEngine::Fatal,
"previous errors prevent further compilation");
diags.Report(DiagID);
exit(1);
}
}
开发者ID:CarlEbeling,项目名称:OpenHT,代码行数:10,代码来源:HtDesign.cpp
示例11: HandleTranslationUnit
void ReplaceArrayAccessWithIndex::HandleTranslationUnit(clang::ASTContext &Ctx)
{
TransAssert(Collector && "NULL Collector");
Collector->TraverseDecl(Ctx.getTranslationUnitDecl());
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
doRewrite();
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
}
开发者ID:vgvassilev,项目名称:creduce,代码行数:20,代码来源:ReplaceArrayAccessWithIndex.cpp
示例12: checkAndAnalyze
void WebCLConsumer::checkAndAnalyze(clang::ASTContext &context)
{
clang::TranslationUnitDecl *decl = context.getTranslationUnitDecl();
for (Visitors::iterator i = visitors_.begin(); i != visitors_.end(); ++i) {
// There is no point to continue if an error has been reported.
if (!hasErrors(context)) {
WebCLVisitor *visitor = (*i);
visitor->TraverseDecl(decl);
}
}
}
开发者ID:ChiahungTai,项目名称:webcl-validator,代码行数:11,代码来源:WebCLConsumer.cpp
示例13: GetTokenBeforeLocation
clang::Token GetTokenBeforeLocation(clang::SourceLocation loc,
const clang::ASTContext& ast_context) {
clang::Token token;
token.setKind(clang::tok::unknown);
clang::LangOptions lang_options = ast_context.getLangOpts();
const clang::SourceManager& source_manager = ast_context.getSourceManager();
clang::SourceLocation file_start_loc =
source_manager.getLocForStartOfFile(source_manager.getFileID(loc));
loc = loc.getLocWithOffset(-1);
while (loc != file_start_loc) {
loc = clang::Lexer::GetBeginningOfToken(loc, source_manager, lang_options);
if (!clang::Lexer::getRawToken(loc, token, source_manager, lang_options)) {
if (!token.is(clang::tok::comment)) {
break;
}
}
loc = loc.getLocWithOffset(-1);
}
return token;
}
开发者ID:hfeeki,项目名称:llvm-clang-samples,代码行数:20,代码来源:try_matcher.cpp
示例14:
PPIncludeCallback::PPIncludeCallback(
ParserContext& ctx_,
clang::ASTContext& astContext_,
MangledNameCache& mangledNameCache_,
clang::Preprocessor&) :
_ctx(ctx_),
_cppSourceType("CPP"),
_clangSrcMgr(astContext_.getSourceManager()),
_fileLocUtil(astContext_.getSourceManager()),
_mangledNameCache(mangledNameCache_)
{
}
开发者ID:Ericsson,项目名称:CodeCompass,代码行数:12,代码来源:ppincludecallback.cpp
示例15: collect
RangeSet collect(clang::ASTContext &astContext, oclint::RuleBase *rule)
{
_rule = rule;
_sourceManager = &astContext.getSourceManager();
_range.clear();
clang::DeclContext *decl = astContext.getTranslationUnitDecl();
for (clang::DeclContext::decl_iterator declIt = decl->decls_begin(),
declEnd = decl->decls_end(); declIt != declEnd; ++declIt)
{
clang::SourceLocation startLocation = (*declIt)->getLocStart();
if (startLocation.isValid() &&
_sourceManager->getMainFileID() == _sourceManager->getFileID(startLocation))
{
(void) /* explicitly ignore the return of this function */
clang::RecursiveASTVisitor<DeclAnnotationRangeCollector>::TraverseDecl(*declIt);
}
}
return _range;
}
开发者ID:GeekMin,项目名称:oclint,代码行数:21,代码来源:SuppressHelper.cpp
示例16: lineBasedShouldSuppress
bool lineBasedShouldSuppress(int beginLine, clang::ASTContext &context)
{
std::string filePath = getMainFilePath(context);
auto commentLinesIt = singleLineMapping.find(filePath);
std::set<int> commentLines;
if (commentLinesIt == singleLineMapping.end())
{
clang::RawCommentList commentList = context.getRawCommentList();
clang::ArrayRef<clang::RawComment *> commentArray = commentList.getComments();
for (auto comment : commentArray)
{
// g++ 4.8 on Ubuntu 14.04 LTS doesn't support regex yet,
// so we will ship this once Ubuntu 16.04 releases
#if defined(__APPLE__) || defined(__MACH__)
std::string commentString = comment->getRawText(context.getSourceManager()).str();
std::regex CAPARegex =
std::regex("//! *CAPA", std::regex::basic | std::regex::icase);
if (std::regex_search(commentString, CAPARegex))
#else
if (std::string::npos !=
comment->getRawText(context.getSourceManager()).find("//!CAPA"))
#endif
{
clang::SourceLocation startLocation = comment->getLocStart();
int startLocationLine =
context.getSourceManager().getPresumedLineNumber(startLocation);
commentLines.insert(startLocationLine);
}
}
singleLineMapping[filePath] = commentLines;
}
else
{
commentLines = commentLinesIt->second;
}
return commentLines.find(beginLine) != commentLines.end();
}
开发者ID:Jhana1,项目名称:CAPA,代码行数:39,代码来源:SuppressHelper.cpp
示例17: HandleTranslationUnit
virtual void HandleTranslationUnit(clang::ASTContext& Ctx) override {
/* if (PP.getDiagnostics().hasErrorOccurred())
return;*/
ci.getPreprocessor().getDiagnostics().getClient();
BrowserASTVisitor v(annotator);
v.TraverseDecl(Ctx.getTranslationUnitDecl());
annotator.generate(ci.getSema(), WasInDatabase);
}
开发者ID:antmd,项目名称:woboq_codebrowser,代码行数:13,代码来源:main.cpp
示例18: mPP
RSContext::RSContext(clang::Preprocessor &PP,
clang::ASTContext &Ctx,
const clang::TargetInfo &Target,
PragmaList *Pragmas,
unsigned int TargetAPI,
std::vector<std::string> *GeneratedFileNames)
: mPP(PP),
mCtx(Ctx),
mTarget(Target),
mPragmas(Pragmas),
mTargetAPI(TargetAPI),
mGeneratedFileNames(GeneratedFileNames),
mTargetData(NULL),
mLLVMContext(llvm::getGlobalContext()),
mLicenseNote(NULL),
mRSPackageName("android.renderscript"),
version(0),
mMangleCtx(Ctx.createMangleContext()) {
slangAssert(mGeneratedFileNames && "Must supply GeneratedFileNames");
// For #pragma rs export_type
PP.AddPragmaHandler(
"rs", RSPragmaHandler::CreatePragmaExportTypeHandler(this));
// For #pragma rs java_package_name
PP.AddPragmaHandler(
"rs", RSPragmaHandler::CreatePragmaJavaPackageNameHandler(this));
// For #pragma rs set_reflect_license
PP.AddPragmaHandler(
"rs", RSPragmaHandler::CreatePragmaReflectLicenseHandler(this));
// For #pragma version
PP.AddPragmaHandler(RSPragmaHandler::CreatePragmaVersionHandler(this));
// Prepare target data
mTargetData = new llvm::TargetData(Target.getTargetDescription());
return;
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:40,代码来源:slang_rs_context.cpp
示例19: mPP
RSContext::RSContext(clang::Preprocessor &PP,
clang::ASTContext &Ctx,
const clang::TargetInfo &Target,
PragmaList *Pragmas,
unsigned int TargetAPI,
bool Verbose)
: mPP(PP),
mCtx(Ctx),
mPragmas(Pragmas),
mTargetAPI(TargetAPI),
mVerbose(Verbose),
mDataLayout(NULL),
mLLVMContext(llvm::getGlobalContext()),
mLicenseNote(NULL),
mRSPackageName("android.renderscript"),
version(0),
mMangleCtx(Ctx.createMangleContext()),
mIs64Bit(Target.getPointerWidth(0) == 64) {
AddPragmaHandlers(PP, this);
// Prepare target data
mDataLayout = new llvm::DataLayout(Target.getTargetDescription());
}
开发者ID:aurorarom,项目名称:JsonUtil,代码行数:24,代码来源:slang_rs_context.cpp
示例20: GetScalarTypeForClangType
static lldb_private::Scalar::Type
GetScalarTypeForClangType (clang::ASTContext &ast_context, clang::QualType clang_type, uint32_t &count)
{
count = 1;
switch (clang_type->getTypeClass())
{
default:
break;
case clang::Type::FunctionNoProto:
case clang::Type::FunctionProto:
break;
case clang::Type::IncompleteArray:
case clang::Type::VariableArray:
break;
case clang::Type::ConstantArray:
break;
case clang::Type::ExtVector:
case clang::Type::Vector:
// TODO: Set this to more than one???
break;
case clang::Type::Builtin:
switch (cast<clang::BuiltinType>(clang_type)->getKind())
{
default: assert(0 && "Unknown builtin type!");
case clang::BuiltinType::Void:
break;
case clang::BuiltinType::Bool:
case clang::BuiltinType::Char_S:
case clang::BuiltinType::SChar:
case clang::BuiltinType::WChar:
case clang::BuiltinType::Char16:
case clang::BuiltinType::Char32:
case clang::BuiltinType::Short:
case clang::BuiltinType::Int:
case clang::BuiltinType::Long:
case clang::BuiltinType::LongLong:
case clang::BuiltinType::Int128:
return lldb_private::Scalar::GetValueTypeForSignedIntegerWithByteSize ((ast_context.getTypeSize(clang_type)/CHAR_BIT)/count);
case clang::BuiltinType::Char_U:
case clang::BuiltinType::UChar:
case clang::BuiltinType::UShort:
case clang::BuiltinType::UInt:
case clang::BuiltinType::ULong:
case clang::BuiltinType::ULongLong:
case clang::BuiltinType::UInt128:
case clang::BuiltinType::NullPtr:
return lldb_private::Scalar::GetValueTypeForUnsignedIntegerWithByteSize ((ast_context.getTypeSize(clang_type)/CHAR_BIT)/count);
case clang::BuiltinType::Float:
case clang::BuiltinType::Double:
case clang::BuiltinType::LongDouble:
return lldb_private::Scalar::GetValueTypeForFloatWithByteSize ((ast_context.getTypeSize(clang_type)/CHAR_BIT)/count);
}
break;
// All pointer types are represented as unsigned integer encodings.
// We may nee to add a eEncodingPointer if we ever need to know the
// difference
case clang::Type::ObjCObjectPointer:
case clang::Type::BlockPointer:
case clang::Type::Pointer:
case clang::Type::LValueReference:
case clang::Type::RValueReference:
case clang::Type::MemberPointer:
return lldb_private::Scalar::GetValueTypeForUnsignedIntegerWithByteSize ((ast_context.getTypeSize(clang_type)/CHAR_BIT)/count);
// Complex numbers are made up of floats
case clang::Type::Complex:
count = 2;
return lldb_private::Scalar::GetValueTypeForFloatWithByteSize ((ast_context.getTypeSize(clang_type)/CHAR_BIT) / count);
case clang::Type::ObjCInterface: break;
case clang::Type::Record: break;
case clang::Type::Enum:
return lldb_private::Scalar::GetValueTypeForSignedIntegerWithByteSize ((ast_context.getTypeSize(clang_type)/CHAR_BIT)/count);
case clang::Type::Typedef:
return GetScalarTypeForClangType(ast_context, cast<clang::TypedefType>(clang_type)->LookThroughTypedefs(), count);
break;
case clang::Type::TypeOfExpr:
case clang::Type::TypeOf:
case clang::Type::Decltype:
//case clang::Type::QualifiedName:
case clang::Type::TemplateSpecialization: break;
}
count = 0;
return lldb_private::Scalar::e_void;
}
开发者ID:ice799,项目名称:lldb,代码行数:96,代码来源:ClangStmtVisitor.cpp
注:本文中的clang::ASTContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论