Skip to content
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

[libclang] Declaration inside If Statement cursor missing when calling clang_visitChildren #107

Open
koyote opened this issue Jan 23, 2020 · 1 comment
Labels
clang:tooling LibTooling

Comments

@koyote
Copy link

koyote commented Jan 23, 2020

Hi,

The following legal C++17 code produces the following AST if you call clang from the terminal with -Xclang -ast-dump -std=c++17 -fsyntax-only:

void x() {
  if (int i = 0; i < 1)
    return;
}
[...]
FunctionDecl 0x20b5aafe150 <Test.cpp:1:1, line:4:1> line:1:6 x 'void ()'
  `-CompoundStmt 0x20b5aafe3a8 <col:10, line:4:1>
    `-IfStmt 0x20b5aafe388 <line:2:1, line:3:4> has_init
      |-DeclStmt 0x20b5aafe2e0 <line:2:4, col:13>
      | `-VarDecl 0x20b5aafe250 <col:4, col:12> col:8 used i 'int' cinit
      |   `-IntegerLiteral 0x20b5aafe2b8 <col:12> 'int' 0
      |-BinaryOperator 0x20b5aafe358 <col:15, col:19> 'bool' '<'
      | |-ImplicitCastExpr 0x20b5aafe340 <col:15> 'int' <LValueToRValue>
      | | `-DeclRefExpr 0x20b5aafe2f8 <col:15> 'int' lvalue Var 0x20b5aafe250 'i' 'int'
      | `-IntegerLiteral 0x20b5aafe318 <col:19> 'int' 1
      `-ReturnStmt 0x20b5aafe378 <line:3:4>

Note the DeclStmt cursor and children.
However, when using libclang on the same code by calling clang_visitChildren, the DeclStmt cursor and its children are never 'visited'. This was tested using the latest Windows x64 build (9.0.0)

Teemperor pushed a commit to Teemperor/llvm-project that referenced this issue Feb 24, 2020
@RKSimon RKSimon added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Apr 12, 2022
@llvmbot
Copy link
Member

llvmbot commented Apr 12, 2022

@llvm/issue-subscribers-clang-frontend

@EugeneZelenko EugeneZelenko added clang:tooling LibTooling and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 12, 2022
cuviper pushed a commit to cuviper/llvm-project that referenced this issue Aug 27, 2023
[PowerPC] Handle FP physical register in inline asm constraint.
mjklemm pushed a commit to mjklemm/llvm-project that referenced this issue Jul 4, 2024
…lvm#107)

When emitting the ops required to compute the target loop's trip count,
flang might emit ops outside the target regions that operands defined
inside the region. This is fixed up by `HostClausesInsertionGuard`
already.

However, the current support only handles simple cases. If the loop
control contains more elaborate expressions, the fix up logic does not
handle it properly. This PR handles such cases.
RevySR pushed a commit to revyos/llvm-project that referenced this issue Jul 27, 2024
alexanderguy pushed a commit to alexanderguy/llvm-project that referenced this issue Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:tooling LibTooling
Projects
None yet
Development

No branches or pull requests

4 participants