-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Clang AST updates for more details #152372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sei-nreimer
wants to merge
2
commits into
llvm:main
Choose a base branch
from
sei-nreimer:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,6 +11,22 @@ | |||||
// similar to RecursiveASTVisitor. | ||||||
// | ||||||
//===----------------------------------------------------------------------===// | ||||||
// | ||||||
// Modifications to this file by SEI staff are copyright Carnegie Mellon | ||||||
// University and contributed under the Apache License v2.0 with LLVM | ||||||
// Exceptions. | ||||||
// | ||||||
// SEI Contributions are made with funding sand support from the Department of | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo, but we probably can't allow this copyright notice anyway, per project policy. |
||||||
// Defense under Contract No. FA8702-15-D-0002 with Carnegie Mellon University | ||||||
// for the operation of the Software Engineering Institute, a federally funded | ||||||
// research and development center. | ||||||
// | ||||||
// The view, opinions, and/or findings contained in this material are those of | ||||||
// the author(s) and should not be construed as an official Government position, | ||||||
// policy, or decision, unless designated by other documentation. | ||||||
// DM24-0194 | ||||||
// | ||||||
//===----------------------------------------------------------------------===// | ||||||
|
||||||
#ifndef LLVM_CLANG_AST_ASTNODETRAVERSER_H | ||||||
#define LLVM_CLANG_AST_ASTNODETRAVERSER_H | ||||||
|
@@ -177,14 +193,34 @@ class ASTNodeTraverser | |||||
if (!SQT.Quals.hasQualifiers()) | ||||||
return Visit(SQT.Ty); | ||||||
|
||||||
getNodeDelegate().AddChild([=] { | ||||||
// SEI: changed from default label to "qualTypeDetail" | ||||||
getNodeDelegate().AddChild("qualTypeDetail", [this, T] { | ||||||
getNodeDelegate().Visit(T); | ||||||
Visit(T.split().Ty); | ||||||
}); | ||||||
|
||||||
// SEI function pointer support. this gets called whenever the three | ||||||
// conditions are met: | ||||||
// 1. the function pointer is not typedef'd | ||||||
// 2. after Visit(VarDecl *) gets called | ||||||
// 3. if VarDecl determines this is a function pointer | ||||||
if (T->isFunctionPointerType()) { | ||||||
// create as a child node to this type | ||||||
getNodeDelegate().AddChild( | ||||||
[=] { getNodeDelegate().Visit(T->getPointeeType()); }); | ||||||
} | ||||||
|
||||||
// SEI: traverse PointerType information | ||||||
if (T->isPointerType()) | ||||||
Visit(T->getPointeeType()); | ||||||
} | ||||||
|
||||||
// SEI: traverse ReturnType information | ||||||
void VisitReturnType(QualType T) { getNodeDelegate().VisitReturnType(T); } | ||||||
|
||||||
void Visit(const Type *T) { | ||||||
getNodeDelegate().AddChild([=] { | ||||||
// SEI: renamed this from default label | ||||||
getNodeDelegate().AddChild("typeDetails", [this, T] { | ||||||
getNodeDelegate().Visit(T); | ||||||
if (!T) | ||||||
return; | ||||||
|
@@ -209,7 +245,8 @@ class ASTNodeTraverser | |||||
} | ||||||
|
||||||
void Visit(const Attr *A) { | ||||||
getNodeDelegate().AddChild([=] { | ||||||
// SEI: renamed from default label | ||||||
getNodeDelegate().AddChild("attrDetails", [this, A] { | ||||||
getNodeDelegate().Visit(A); | ||||||
ConstAttrVisitor<Derived>::Visit(A); | ||||||
}); | ||||||
|
@@ -416,8 +453,20 @@ class ASTNodeTraverser | |||||
Visit(T->getSizeExpr()); | ||||||
} | ||||||
void VisitVectorType(const VectorType *T) { Visit(T->getElementType()); } | ||||||
void VisitFunctionType(const FunctionType *T) { Visit(T->getReturnType()); } | ||||||
void VisitFunctionType(const FunctionType *T) { | ||||||
|
||||||
Visit(T->getReturnType()); | ||||||
|
||||||
// SEI: add functionDetails, incl. return type | ||||||
getNodeDelegate().AddChild("functionDetails", [this, T] { | ||||||
getNodeDelegate().VisitFunctionType(T); | ||||||
getNodeDelegate().VisitReturnType(T->getReturnType()); | ||||||
}); | ||||||
} | ||||||
|
||||||
void VisitFunctionProtoType(const FunctionProtoType *T) { | ||||||
|
||||||
// SEI: visit the function type. this will force the return type info too. | ||||||
VisitFunctionType(T); | ||||||
for (const QualType &PT : T->getParamTypes()) | ||||||
Visit(PT); | ||||||
|
@@ -585,6 +634,12 @@ class ASTNodeTraverser | |||||
Visit(TSI->getTypeLoc()); | ||||||
if (D->hasInit()) | ||||||
Visit(D->getInit()); | ||||||
|
||||||
// SEI: if this is a function pointer, then we need to get the | ||||||
// FunctionProtoType and then make add'l visits. if the FP is typedef'd, | ||||||
// then this behavior occurs for us outside of Visit(VarDecl *) | ||||||
//getNodeDelegate().Visit(D->getType(), true); | ||||||
Visit(D->getType()); | ||||||
} | ||||||
|
||||||
void VisitDecompositionDecl(const DecompositionDecl *D) { | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @llvm-beanz regarding licensing concerns. Pretty sure this is not something we can accept per: https://llvm.org/docs/DeveloperPolicy.html#embedded-copyright-or-contributed-by-statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed. We do not accept embedded copyright notices.