Changeset View
Changeset View
Standalone View
Standalone View
plugins/clang/duchain/builder.cpp
Show First 20 Lines • Show All 368 Lines • ▼ Show 20 Line(s) | 368 | //BEGIN build* | |||
---|---|---|---|---|---|
369 | template<CXCursorKind CK, class DeclType, bool hasContext> | 369 | template<CXCursorKind CK, class DeclType, bool hasContext> | ||
370 | CXChildVisitResult buildDeclaration(CXCursor cursor); | 370 | CXChildVisitResult buildDeclaration(CXCursor cursor); | ||
371 | 371 | | |||
372 | template<bool IsInClass> | 372 | template<bool IsInClass> | ||
373 | CXChildVisitResult buildTypeAliasTemplateDecl(CXCursor cursor); | 373 | CXChildVisitResult buildTypeAliasTemplateDecl(CXCursor cursor); | ||
374 | 374 | | |||
375 | CXChildVisitResult buildUse(CXCursor cursor); | 375 | CXChildVisitResult buildUse(CXCursor cursor); | ||
376 | CXChildVisitResult buildMacroExpansion(CXCursor cursor); | 376 | CXChildVisitResult buildMacroExpansion(CXCursor cursor); | ||
377 | | ||||
378 | template<CXCursorKind CK> | ||||
377 | CXChildVisitResult buildCompoundStatement(CXCursor cursor); | 379 | CXChildVisitResult buildCompoundStatement(CXCursor cursor); | ||
378 | CXChildVisitResult buildCXXBaseSpecifier(CXCursor cursor); | 380 | CXChildVisitResult buildCXXBaseSpecifier(CXCursor cursor); | ||
379 | CXChildVisitResult buildParmDecl(CXCursor cursor); | 381 | CXChildVisitResult buildParmDecl(CXCursor cursor); | ||
380 | 382 | | |||
381 | //END build* | 383 | //END build* | ||
382 | 384 | | |||
383 | //BEGIN create* | 385 | //BEGIN create* | ||
384 | template<CXCursorKind CK, class DeclType> | 386 | template<CXCursorKind CK, class DeclType> | ||
▲ Show 20 Lines • Show All 825 Lines • ▼ Show 20 Line(s) | 1209 | { | |||
1210 | // cache that we encountered a macro expansion at this location | 1212 | // cache that we encountered a macro expansion at this location | ||
1211 | unsigned int offset; | 1213 | unsigned int offset; | ||
1212 | clang_getSpellingLocation(clang_getCursorLocation(cursor), nullptr, nullptr, nullptr, &offset); | 1214 | clang_getSpellingLocation(clang_getCursorLocation(cursor), nullptr, nullptr, nullptr, &offset); | ||
1213 | m_macroExpansionLocations << offset; | 1215 | m_macroExpansionLocations << offset; | ||
1214 | 1216 | | |||
1215 | return CXChildVisit_Recurse; | 1217 | return CXChildVisit_Recurse; | ||
1216 | } | 1218 | } | ||
1217 | 1219 | | |||
1220 | template<CXCursorKind CK> | ||||
1218 | CXChildVisitResult Visitor::buildCompoundStatement(CXCursor cursor) | 1221 | CXChildVisitResult Visitor::buildCompoundStatement(CXCursor cursor) | ||
1219 | { | 1222 | { | ||
1220 | if (m_parentContext->context->type() == DUContext::Function) | 1223 | if (CK == CXCursor_LambdaExpr || m_parentContext->context->type() == DUContext::Function) | ||
1221 | { | 1224 | { | ||
1222 | auto context = createContext<CXCursor_CompoundStmt, DUContext::Other>(cursor); | 1225 | auto context = createContext<CK, CK == CXCursor_LambdaExpr ? DUContext::Function : DUContext::Other>(cursor); | ||
1223 | CurrentContext newParent(context, m_parentContext->keepAliveContexts); | 1226 | CurrentContext newParent(context, m_parentContext->keepAliveContexts); | ||
1224 | PushValue<CurrentContext*> pushCurrent(m_parentContext, &newParent); | 1227 | PushValue<CurrentContext*> pushCurrent(m_parentContext, &newParent); | ||
1225 | clang_visitChildren(cursor, &visitCursor, this); | 1228 | clang_visitChildren(cursor, &visitCursor, this); | ||
1226 | return CXChildVisit_Continue; | 1229 | return CXChildVisit_Continue; | ||
1227 | } | 1230 | } | ||
1228 | return CXChildVisit_Recurse; | 1231 | return CXChildVisit_Recurse; | ||
1229 | } | 1232 | } | ||
1230 | 1233 | | |||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Line(s) | 1515 | #define UseCursorKind(CursorKind, ...) case CursorKind: return visitor->dispatchCursor<CursorKind>(__VA_ARGS__); | |||
1555 | case CXCursor_VariableRef: | 1558 | case CXCursor_VariableRef: | ||
1556 | case CXCursor_DeclRefExpr: | 1559 | case CXCursor_DeclRefExpr: | ||
1557 | case CXCursor_MemberRefExpr: | 1560 | case CXCursor_MemberRefExpr: | ||
1558 | case CXCursor_ObjCClassRef: | 1561 | case CXCursor_ObjCClassRef: | ||
1559 | return visitor->buildUse(cursor); | 1562 | return visitor->buildUse(cursor); | ||
1560 | case CXCursor_MacroExpansion: | 1563 | case CXCursor_MacroExpansion: | ||
1561 | return visitor->buildMacroExpansion(cursor); | 1564 | return visitor->buildMacroExpansion(cursor); | ||
1562 | case CXCursor_CompoundStmt: | 1565 | case CXCursor_CompoundStmt: | ||
1563 | return visitor->buildCompoundStatement(cursor); | 1566 | return visitor->buildCompoundStatement<CXCursor_CompoundStmt>(cursor); | ||
1567 | case CXCursor_LambdaExpr: | ||||
1568 | return visitor->buildCompoundStatement<CXCursor_LambdaExpr>(cursor); | ||||
1564 | case CXCursor_CXXBaseSpecifier: | 1569 | case CXCursor_CXXBaseSpecifier: | ||
1565 | return visitor->buildCXXBaseSpecifier(cursor); | 1570 | return visitor->buildCXXBaseSpecifier(cursor); | ||
1566 | case CXCursor_ParmDecl: | 1571 | case CXCursor_ParmDecl: | ||
1567 | return visitor->buildParmDecl(cursor); | 1572 | return visitor->buildParmDecl(cursor); | ||
1568 | // TODO: fix upstream and then just adapt this to UseCursorKind() | 1573 | // TODO: fix upstream and then just adapt this to UseCursorKind() | ||
1569 | case CXCursor_TypeAliasTemplateDecl: | 1574 | case CXCursor_TypeAliasTemplateDecl: | ||
1570 | return visitor->dispatchTypeAliasTemplate(cursor, parent); | 1575 | return visitor->dispatchTypeAliasTemplate(cursor, parent); | ||
1571 | default: | 1576 | default: | ||
Show All 14 Lines |