Comments (2)
@llvm/issue-subscribers-clang-frontend
Author: Anatol Pomozov (anatol)
It is easier to see it with the following example:
int func1();
typedef double (*callback)(int param1);
The test.c
above contains 1 function and one callback declaration (a typedef for a function pointer type). Now let's produce the JSON AST for the example above with clang -Xclang -ast-dump=json test.c
. We get the AST and the the bits relevant to our example are
The func1
AST:
{
"id": "0x598de3e85e50",
"kind": "FunctionDecl",
"loc": {
"offset": 4,
"file": "llvm.c",
"line": 1,
"col": 5,
"tokLen": 5
},
"range": {
"begin": {
"offset": 0,
"col": 1,
"tokLen": 3
},
"end": {
"offset": 10,
"col": 11,
"tokLen": 1
}
},
"name": "func1",
"mangledName": "func1",
"type": {
"qualType": "int ()"
}
},
In this example there is no node for the return type (int
). We have a full function signature that includes the function parameters. But it makes sense to have a node for the return type itself to avoid parsing types at the client side. Note that callback declaration below does contain a node for the return type.
Now let's look at the second example for callback:
{
"id": "0x598de3e860b8",
"kind": "TypedefDecl",
"loc": {
"offset": 31,
"line": 3,
"col": 18,
"tokLen": 8
},
"range": {
"begin": {
"offset": 14,
"col": 1,
"tokLen": 7
},
"end": {
"offset": 51,
"col": 38,
"tokLen": 1
}
},
"name": "callback",
"type": {
"qualType": "double (*)(int)"
},
"inner": [
{
"id": "0x598de3e86050",
"kind": "PointerType",
"type": {
"qualType": "double (*)(int)"
},
"inner": [
{
"id": "0x598de3e85ff0",
"kind": "ParenType",
"type": {
"qualType": "double (int)"
},
"inner": [
{
"id": "0x598de3e85fc0",
"kind": "FunctionProtoType",
"type": {
"qualType": "double (int)"
},
"cc": "cdecl",
"inner": [
{
"id": "0x598de3e270e0",
"kind": "BuiltinType",
"type": {
"qualType": "double"
}
},
{
"id": "0x598de3e26fc0",
"kind": "BuiltinType",
"type": {
"qualType": "int"
}
}
]
}
]
}
]
}
In this example the function parameters (e.g. node 0x598de3e26fc0
) do not contain parameter names. Note that function declaration does contain such information.
$ clang --version
clang version 17.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
from llvm-project.
from llvm-project.
Related Issues (20)
- In C++20, clang __is_trivially_constructible(std::atomic<float>) is false HOT 3
- [HLSL] Don't extend 3-element vectors to 4
- UBSAN + OrcJIT crashes when code is placed at beginning of page HOT 2
- [Attributor]: AAPointerInfo does not keep track of access bins properly when a pointer is copied to a new pointer.
- [AMDGPU] Masked load/store with a uniform but non-trivial mask don't simplify HOT 1
- [HLSL] Write tests for space inside register annotation
- Backend code generator crash while running pass "X86 DAG->DAG Instruction Selection". Maybe related to coroutines. HOT 4
- [Flang][OpenMP] ICE with "LLVM ERROR: not implemented" (omp atomic)
- Inaccurate debug information: Lines that are outside the loop's body are incorrectly being treated as part of the loop body. HOT 3
- LLDB displays inconsistent debug information for a pointer array when compared to the source code. HOT 1
- cppcoreguidelines-special-member-functions requires default destructors when move and copy are deleted
- [AVX-512] `vmovdqu8` constant memory operand not hoisted from loop
- [MIPS] `MIPSELFObjectWriter::sortRelocs()` makes compilation near-unusably slow for O32
- `modernize-use-emplace` fix-it leads to compilation error HOT 3
- [SimplifyCFG] Failure to convert switch to arithmetic due to sinking limitation HOT 1
- suggest `modernize-use-auto` for predicate arguments HOT 2
- #101853 breaks `extern "C" int main...` even when -Wmain is disabled HOT 1
- detect mismatching argument in predicate HOT 1
- [WebAssembly][lld] symbol override with dynamic-linking doesn't work
- [WebAssembly] mysterious imports of aliases
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llvm-project.