Element::getEnclosingElement: Skip macro information.

Previously, we would try to find an element enclosing each macro
access. This is not in general well-defined, especially in the
context of template instantiations -- macros are a lexing-time
concept, and don't map cleanly onto AST elements.
This commit is contained in:
Pavel Avgustinov
2018-08-13 19:09:23 +01:00
parent 9d2dd97f18
commit 64338b0581

View File

@@ -154,8 +154,6 @@ class Element extends @element {
namequalifiers(this, result, _, _) or
initialisers(this, result, _, _) or
exprconv(result, this) or
this = result.(MacroAccess).getParentInvocation() or
result = this.(MacroInvocation).getExpr() or // macroinvocation -> outer Expr
param_decl_bind(this,_,result)
}
@@ -165,17 +163,6 @@ class Element extends @element {
(
not exists(getEnclosingElementPref()) and
(
// macroinvocation -> all enclosed elements
inmacroexpansion(result, this)
or
macrolocationbind(
this.(MacroInvocation),
result.(VariableDeclarationEntry).getLocation())
or
macrolocationbind(
this.(MacroInvocation),
result.(FunctionDeclarationEntry).getLocation())
or
this = result.(Class).getAMember()
or
result = exprEnclosingElement(this)
@@ -225,8 +212,7 @@ private predicate isFromTemplateInstantiationRec(Element e, Element instantiatio
instantiation.(Variable).isConstructedFrom(_) and
e = instantiation
or
isFromTemplateInstantiationRec(e.getEnclosingElement(), instantiation) and
not e instanceof MacroAccess
isFromTemplateInstantiationRec(e.getEnclosingElement(), instantiation)
}
private predicate isFromUninstantiatedTemplateRec(Element e, Element template) {
@@ -239,8 +225,7 @@ private predicate isFromUninstantiatedTemplateRec(Element e, Element template) {
is_variable_template(template) and
e = template
or
isFromUninstantiatedTemplateRec(e.getEnclosingElement(), template) and
not e instanceof MacroAccess
isFromUninstantiatedTemplateRec(e.getEnclosingElement(), template)
}
/**