示例#1
0
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();
}
示例#2
0
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);
}
示例#3
0
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);
}
示例#4
0
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);
}
示例#5
0
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);
}
示例#6
0
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);
}
示例#7
0
  virtual void HandleTranslationUnit(clang::ASTContext &ctx)
  {
    llvm::raw_ostream &out = llvm::errs();
    clang::TranslationUnitDecl *translationUnit = ctx.getTranslationUnitDecl();

    MyDeclVisitor(out, _astinfo).Visit(translationUnit);
  }
示例#8
0
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;
}
    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);
    }
示例#10
0
	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);
		}
	}
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;
}
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);
        }
    }
}
示例#13
0
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;
}
示例#14
0
PPIncludeCallback::PPIncludeCallback(
  ParserContext& ctx_,
  clang::ASTContext& astContext_,
  MangledNameCache& mangledNameCache_,
  clang::Preprocessor&) :
    _ctx(ctx_),
    _cppSourceType("CPP"),
    _clangSrcMgr(astContext_.getSourceManager()),
    _fileLocUtil(astContext_.getSourceManager()),
    _mangledNameCache(mangledNameCache_)
{
}
示例#15
0
    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;
    }
示例#16
0
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();
}
示例#17
0
    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);
    }
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;
}
示例#19
0
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());
}
示例#20
0
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;
}
示例#21
0
static clang::CanQualType getClangSelectorType(
    const clang::ASTContext &clangCtx) {
    return clangCtx.getPointerType(clangCtx.ObjCBuiltinSelTy);
}
示例#22
0
void ClangToSageTranslator::HandleTranslationUnit(clang::ASTContext & ast_context) {
    Traverse(ast_context.getTranslationUnitDecl());
}
示例#23
0
 virtual void HandleTranslationUnit(clang::ASTContext &Context)
 {
    Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 }
clang::QualType
AppleObjCTypeEncodingParser::BuildType (clang::ASTContext &ast_ctx, StringLexer& type, bool for_expression, uint32_t *bitfield_bit_size)
{
    if (!type.HasAtLeast(1))
        return clang::QualType();
    
    switch (type.Peek())
    {
    default:
        break;
    case '{':
        return BuildStruct(ast_ctx, type, for_expression);
    case '[':
        return BuildArray(ast_ctx, type, for_expression);
    case '(':
        return BuildUnion(ast_ctx, type, for_expression);
    case '@':
        return BuildObjCObjectPointerType(ast_ctx, type, for_expression);
    }
    
    switch (type.Next())
    {
    default:
        type.PutBack(1);
        return clang::QualType();
    case 'c':
        return ast_ctx.CharTy;
    case 'i':
        return ast_ctx.IntTy;
    case 's':
        return ast_ctx.ShortTy;
    case 'l':
        return ast_ctx.getIntTypeForBitwidth(32, true);
        // this used to be done like this:
        //   ClangASTContext *lldb_ctx = ClangASTContext::GetASTContext(&ast_ctx);
        //   if (!lldb_ctx)
        //      return clang::QualType();
        //   return lldb_ctx->GetIntTypeFromBitSize(32, true).GetQualType();
        // which uses one of the constants if one is available, but we don't think all this work is necessary.
    case 'q':
        return ast_ctx.LongLongTy;
    case 'C':
        return ast_ctx.UnsignedCharTy;
    case 'I':
        return ast_ctx.UnsignedIntTy;
    case 'S':
        return ast_ctx.UnsignedShortTy;
    case 'L':
        return ast_ctx.getIntTypeForBitwidth(32, false);
        // see note for 'l'
    case 'Q':
        return ast_ctx.UnsignedLongLongTy;
    case 'f':
        return ast_ctx.FloatTy;
    case 'd':
        return ast_ctx.DoubleTy;
    case 'B':
        return ast_ctx.BoolTy;
    case 'v':
        return ast_ctx.VoidTy;
    case '*':
        return ast_ctx.getPointerType(ast_ctx.CharTy);
    case '#':
        return ast_ctx.getObjCClassType();
    case ':':
        return ast_ctx.getObjCSelType();
    case 'b':
        {
            uint32_t size = ReadNumber(type);
            if (bitfield_bit_size)
            {
                *bitfield_bit_size = size;
                return ast_ctx.UnsignedIntTy; // FIXME: the spec is fairly vague here.
            }
            else
                return clang::QualType();
        }
    case 'r':
        {
            clang::QualType target_type = BuildType(ast_ctx, type, for_expression);
            if (target_type.isNull())
                return clang::QualType();
            else if (target_type == ast_ctx.UnknownAnyTy)
                return ast_ctx.UnknownAnyTy;
            else
                return ast_ctx.getConstType(target_type);
        }
    case '^':
        {
            if (!for_expression && type.NextIf('?'))
            {
                // if we are not supporting the concept of unknownAny, but what is being created here is an unknownAny*, then
                // we can just get away with a void*
                // this is theoretically wrong (in the same sense as 'theoretically nothing exists') but is way better than outright failure
                // in many practical cases
                return ast_ctx.VoidPtrTy;
            }
            else
            {
                clang::QualType target_type = BuildType(ast_ctx, type, for_expression);
                if (target_type.isNull())
                    return clang::QualType();
                else if (target_type == ast_ctx.UnknownAnyTy)
                    return ast_ctx.UnknownAnyTy;
                else
                    return ast_ctx.getPointerType(target_type);
            }
        }
    case '?':
        return for_expression ? ast_ctx.UnknownAnyTy : clang::QualType();
    }
}
bool WebCLConsumer::hasErrors(clang::ASTContext &context) const
{
    clang::DiagnosticsEngine &diags = context.getDiagnostics();
    return diags.hasErrorOccurred() || diags.hasUnrecoverableErrorOccurred();
}
// the runtime can emit these in the form of @"SomeType", giving more specifics
// this would be interesting for expression parser interop, but since we actually try
// to avoid exposing the ivar info to the expression evaluator, consume but ignore the type info
// and always return an 'id'; if anything, dynamic typing will resolve things for us anyway
clang::QualType
AppleObjCTypeEncodingParser::BuildObjCObjectPointerType (clang::ASTContext &ast_ctx, lldb_utility::StringLexer& type, bool for_expression)
{
    if (!type.NextIf('@'))
        return clang::QualType();
    
    std::string name;
    
    if (type.NextIf('"'))
    {
        // We have to be careful here.  We're used to seeing
        //   @"NSString"
        // but in records it is possible that the string following an @ is the name of the next field and @ means "id".
        // This is the case if anything unquoted except for "}", the end of the type, or another name follows the quoted string.
        //
        // E.g.
        // - @"NSString"@ means "id, followed by a field named NSString of type id"
        // - @"NSString"} means "a pointer to NSString and the end of the struct"
        // - @"NSString""nextField" means "a pointer to NSString and a field named nextField"
        // - @"NSString" followed by the end of the string means "a pointer to NSString"
        //
        // As a result, the rule is: If we see @ followed by a quoted string, we peek.
        // - If we see }, ), ], the end of the string, or a quote ("), the quoted string is a class name.
        // - If we see anything else, the quoted string is a field name and we push it back onto type.

        name = ReadQuotedString(type);
        
        if (type.HasAtLeast(1))
        {
            switch (type.Peek())
            {
            default:
                // roll back
                type.PutBack(name.length() + 2); // undo our consumption of the string and of the quotes
                name.clear();
                break;
            case '}':
            case ')':
            case ']':
            case '"':
                // the quoted string is a class name – see the rule
                break;
            }
        }
        else
        {
            // the quoted string is a class name – see the rule
        }
    }
    
    if (for_expression && !name.empty())
    {
        size_t less_than_pos = name.find_first_of('<');
        
        if (less_than_pos != std::string::npos)
        {
            if (less_than_pos == 0)
                return ast_ctx.getObjCIdType();
            else
                name.erase(less_than_pos);
        }
        
        DeclVendor *decl_vendor = m_runtime.GetDeclVendor();
        
        assert (decl_vendor); // how are we parsing type encodings for expressions if a type vendor isn't in play?
        
        const bool append = false;
        const uint32_t max_matches = 1;
        std::vector<clang::NamedDecl *> decls;
        
        uint32_t num_types = decl_vendor->FindDecls(ConstString(name),
                                                    append,
                                                    max_matches,
                                                    decls);

        // The user can forward-declare something that has no definition.  The runtime doesn't prohibit this at all.
        // This is a rare and very weird case.  We keep this assert in debug builds so we catch other weird cases.
#ifdef LLDB_CONFIGURATION_DEBUG
        assert(num_types);
#else
        if (!num_types)
            return ast_ctx.getObjCIdType();
#endif
        
        return ClangASTContext::GetTypeForDecl(decls[0]).GetPointerType().GetQualType();
    }
    else
    {
        // We're going to resolve this dynamically anyway, so just smile and wave.
        return ast_ctx.getObjCIdType();
    }
}
bool GenericAstNode::getRangeInMainFile(std::pair<int, int> &result, clang::SourceManager const &manager, clang::ASTContext &context)
{
    auto range = getRange();
    if (range.isInvalid())
    {
        return false;
    }
    auto start = manager.getDecomposedSpellingLoc(range.getBegin());
    auto end = manager.getDecomposedSpellingLoc(clang::Lexer::getLocForEndOfToken(range.getEnd(), 0, manager, context.getLangOpts()));
    if (start.first != end.first || start.first != manager.getMainFileID())
    {
        //Not in the same file, or not in the main file (probably #included)
        return false;
    }
    result = std::make_pair(start.second, end.second);
    return true;
}
 /**
  * Method called only when the entire file is parsed.
  */
   void HandleTranslationUnit( clang::ASTContext & context ) override
   {
     // Recursively visit the AST.
     myrecvisitor.TraverseDecl( context.getTranslationUnitDecl() );
   }
示例#29
0
 virtual void Initialize(clang::ASTContext& Ctx) override {
     annotator.setSourceMgr(Ctx.getSourceManager(), Ctx.getLangOpts());
     annotator.setMangleContext(Ctx.createMangleContext());
     ci.getPreprocessor().addPPCallbacks(maybe_unique(new PreprocessorCallback(annotator, ci.getPreprocessor())));
     ci.getDiagnostics().setClient(new BrowserDiagnosticClient(annotator), true);
 }
示例#30
0
 void HandleTranslationUnit(clang::ASTContext& ctx) {
    MyASTVisitor visitor(ctx.getSourceManager(), _db);
    visitor.TraverseDecl(ctx.getTranslationUnitDecl());
 }