diff --git a/clang-ast-mapper/LICENSE b/clang-ast-mapper/LICENSE new file mode 100644 index 0000000000000..4429956fcb603 --- /dev/null +++ b/clang-ast-mapper/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Clang AST Line Mapper Development Team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/clang-ast-mapper/README.md b/clang-ast-mapper/README.md new file mode 100644 index 0000000000000..e891152f33fb3 --- /dev/null +++ b/clang-ast-mapper/README.md @@ -0,0 +1,216 @@ +# Clang AST Line Mapper + +A powerful CLI tool that maps C++ source code lines to their corresponding AST (Abstract Syntax Tree) nodes using Clang's JSON AST dump functionality. + +## ๐Ÿš€ Features + +- โœ… **AST Generation**: Automatically generates AST JSON from C++ source files +- โœ… **Line Mapping**: Maps each source line to its corresponding AST nodes +- โœ… **Human-Readable Explanations**: Converts technical AST nodes to understandable descriptions +- โœ… **Multiple Output Formats**: Annotated source, side-by-side view, table, CSV, JSON export +- โœ… **AI Interpretation**: Uses AI to analyze and explain your code's AST structure +- โœ… **Complex C++ Support**: Handles classes, methods, templates, loops, conditionals +- โœ… **CLI Interface**: Easy-to-use command-line interface with multiple options +- โœ… **Extensible**: Modular design for easy extension and customization + +## ๐Ÿ“‹ Requirements + +- Python 3.6+ +- Clang compiler in PATH +- For Windows: Run from Developer Command Prompt or Visual Studio Developer PowerShell + +## ๐Ÿ› ๏ธ Installation + +1. Clone or download the project +2. Navigate to the project directory: + ```bash + cd clang-ast-mapper + ``` +3. Install dependencies (if any): + ```bash + pip install -r requirements.txt + ``` + +## ๐ŸŽฏ Quick Start + +### Basic Usage +```bash +python src/ast_line_mapper.py examples/simple.cpp +``` + +### With Explanations +```bash +python src/ast_line_mapper.py examples/simple.cpp --explanations +``` + +### Side-by-Side View +```bash +python src/ast_line_mapper.py examples/complex.cpp --side-by-side +``` + +### Generate AST JSON Only +```bash +python src/ast_line_mapper.py examples/simple.cpp --generate-ast +``` + +### Output as CSV with AI Interpretation +```bash +python src/ast_line_mapper.py examples/simple.cpp --format csv --output result.csv --interpret +``` + +For more details on AI interpretation, see [AI Interpretation Documentation](docs/ai_interpretation.md). + +## ๐Ÿ“– Usage Examples + +### Example 1: Simple Function +**Input (`examples/simple.cpp`):** +```cpp +int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +} +``` + +**Output:** +``` + 1: int add(int a, int b) { + AST: FunctionDecl, ParmVarDecl + โ†’ FunctionDecl: function declaration + โ†’ ParmVarDecl: parameter variable declaration + 2: return a + b; + AST: ReturnStmt + โ†’ ReturnStmt: return statement +``` + +### Example 2: Class with Methods +**Input (`examples/class.cpp`):** +```cpp +class Calculator { +public: + int add(int a, int b) { + return a + b; + } +}; +``` + +**Output:** +``` + 1: class Calculator { + AST: CXXRecordDecl + โ†’ CXXRecordDecl: C++ class/struct declaration + 3: int add(int a, int b) { + AST: CXXMethodDecl, ParmVarDecl + โ†’ CXXMethodDecl: C++ method declaration + โ†’ ParmVarDecl: parameter variable declaration +``` + +## ๐Ÿ”ง Command Line Options + +| Option | Description | +|--------|-------------| +| `--explanations` | Include human-readable explanations for AST nodes | +| `--side-by-side` | Display source and AST information side by side | +| `--generate-ast` | Generate AST JSON file only (don't annotate) | +| `--output FILE` | Save output to specified file | +| `--format FORMAT` | Output format: `annotated`, `side-by-side`, `json` | +| `--help` | Show help message | + +## ๐Ÿ“ Project Structure + +``` +clang-ast-mapper/ +โ”œโ”€โ”€ src/ +โ”‚ โ”œโ”€โ”€ ast_line_mapper.py # Main CLI tool +โ”‚ โ”œโ”€โ”€ ast_parser.py # AST parsing logic +โ”‚ โ”œโ”€โ”€ source_annotator.py # Source code annotation +โ”‚ โ””โ”€โ”€ node_explanations.py # AST node explanations +โ”œโ”€โ”€ examples/ +โ”‚ โ”œโ”€โ”€ simple.cpp # Simple function example +โ”‚ โ”œโ”€โ”€ class.cpp # Class example +โ”‚ โ”œโ”€โ”€ complex.cpp # Complex C++ features +โ”‚ โ”œโ”€โ”€ templates.cpp # Template examples +โ”‚ โ””โ”€โ”€ control_flow.cpp # Control flow examples +โ”œโ”€โ”€ tests/ +โ”‚ โ”œโ”€โ”€ test_ast_parser.py # Unit tests for AST parser +โ”‚ โ”œโ”€โ”€ test_annotator.py # Unit tests for annotator +โ”‚ โ””โ”€โ”€ test_integration.py # Integration tests +โ”œโ”€โ”€ docs/ +โ”‚ โ”œโ”€โ”€ API.md # API documentation +โ”‚ โ”œโ”€โ”€ ARCHITECTURE.md # Architecture overview +โ”‚ โ””โ”€โ”€ EXAMPLES.md # Detailed examples +โ”œโ”€โ”€ README.md # This file +โ”œโ”€โ”€ requirements.txt # Python dependencies +โ”œโ”€โ”€ setup.py # Installation script +โ””โ”€โ”€ LICENSE # License file +``` + +## ๐Ÿ” AST Node Types + +The tool recognizes and explains various AST node types: + +| AST Node Type | Explanation | +|---------------|-------------| +| `FunctionDecl` | Function declaration | +| `CXXMethodDecl` | C++ method declaration | +| `CXXRecordDecl` | C++ class/struct declaration | +| `CXXConstructorDecl` | C++ constructor declaration | +| `CXXDestructorDecl` | C++ destructor declaration | +| `ParmVarDecl` | Parameter variable declaration | +| `VarDecl` | Variable declaration | +| `FieldDecl` | Field declaration | +| `CompoundStmt` | Compound statement (block) | +| `ReturnStmt` | Return statement | +| `IfStmt` | If statement | +| `ForStmt` | For loop statement | +| `WhileStmt` | While loop statement | +| `BinaryOperator` | Binary operator (+, -, *, /) | +| `UnaryOperator` | Unary operator (++, --, !) | +| `CallExpr` | Function call expression | +| `DeclRefExpr` | Reference to a declaration | +| `IntegerLiteral` | Integer literal | +| `StringLiteral` | String literal | + +## ๐Ÿงช Testing + +Run the test suite: +```bash +python -m pytest tests/ +``` + +Run specific tests: +```bash +python -m pytest tests/test_ast_parser.py +``` + +## ๐Ÿค Contributing + +1. Fork the repository +2. Create a feature branch (`git checkout -b feature/amazing-feature`) +3. Commit your changes (`git commit -m 'Add some amazing feature'`) +4. Push to the branch (`git push origin feature/amazing-feature`) +5. Open a Pull Request + +## ๐Ÿ“„ License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + +## ๐Ÿ™ Acknowledgments + +- Built on top of LLVM/Clang's AST dumping capabilities +- Inspired by the need for better C++ code analysis tools +- Thanks to the LLVM community for their excellent documentation + +## ๐Ÿ“ž Support + +If you encounter any issues or have questions: +1. Check the [documentation](docs/) +2. Look at the [examples](examples/) +3. Create an issue on the project repository + +--- + +**Happy AST Mapping! ๐ŸŽ‰** diff --git a/clang-ast-mapper/ast_line_mapper.py b/clang-ast-mapper/ast_line_mapper.py new file mode 100644 index 0000000000000..9c1153b11cf68 --- /dev/null +++ b/clang-ast-mapper/ast_line_mapper.py @@ -0,0 +1,255 @@ +#!/usr/bin/env python3 +""" +Clang AST Line Mapper Tool +Maps source lines to AST nodes using Clang's JSON AST dump + +Main CLI interface for the AST line mapping tool. +""" + +import argparse +import sys +import os +from pathlib import Path + +# Add the src directory to the Python path +sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) + +from ast_parser import ASTParser +from source_annotator import SourceAnnotator +from node_explanations import NodeExplanations +from ai_interpreter import interpret_ast_file + +class ASTLineMapper: + """Main class for the AST line mapping tool.""" + + def __init__(self): + self.parser = ASTParser() + self.annotator = SourceAnnotator() + self.explanations = NodeExplanations() + + def process_file(self, cpp_file, options): + """Process a C++ file and generate AST annotations.""" + if not os.path.exists(cpp_file): + print(f"Error: File not found: {cpp_file}") + return False + + print(f"Processing: {cpp_file}") + + # Generate AST JSON + ast_file = self.parser.generate_ast_json(cpp_file) + if not ast_file: + return False + + # If only generating AST, stop here + if options.generate_ast: + print(f"AST JSON generated: {ast_file}") + return True + + # Parse AST and create line mappings + line_mappings = self.parser.parse_ast_file(ast_file, cpp_file) + if not line_mappings: + print("Error: Failed to parse AST file") + return False + + # Generate output based on format + if options.format == 'json': + self._output_json(line_mappings, options.output) + elif options.format == 'side-by-side': + self._output_side_by_side(cpp_file, line_mappings, options) + elif options.format == 'table': + self._output_table(cpp_file, line_mappings, options) + elif options.format == 'csv': + self._output_csv(cpp_file, line_mappings, options) + else: # annotated format (default) + self._output_annotated(cpp_file, line_mappings, options) + + return True + + def _output_annotated(self, cpp_file, line_mappings, options): + """Output annotated source format.""" + output = self.annotator.annotate_source( + cpp_file, + line_mappings, + include_explanations=options.explanations, + explanations_dict=self.explanations.get_all_explanations() + ) + + if options.output: + with open(options.output, 'w', encoding='utf-8') as f: + f.write(output) + print(f"Output saved to: {options.output}") + else: + print(output) + + def _output_side_by_side(self, cpp_file, line_mappings, options): + """Output side-by-side format.""" + output = self.annotator.side_by_side_view( + cpp_file, + line_mappings, + explanations_dict=self.explanations.get_all_explanations() if options.explanations else None + ) + + if options.output: + with open(options.output, 'w', encoding='utf-8') as f: + f.write(output) + print(f"Output saved to: {options.output}") + else: + print(output) + + def _output_json(self, line_mappings, output_file): + """Output JSON format.""" + import json + + json_output = { + "line_mappings": {str(k): v for k, v in line_mappings.items()}, + "explanations": self.explanations.get_all_explanations() + } + + if output_file: + with open(output_file, 'w') as f: + json.dump(json_output, f, indent=2) + print(f"JSON output saved to: {output_file}") + else: + print(json.dumps(json_output, indent=2)) + + def _output_table(self, cpp_file, line_mappings, options): + """Output table format.""" + output = self.annotator.generate_table_output( + cpp_file, + line_mappings, + explanations_dict=self.explanations.get_all_explanations() if options.explanations else None + ) + + if options.output: + with open(options.output, 'w', encoding='utf-8') as f: + f.write(output) + print(f"Output saved to: {options.output}") + else: + print(output) + + def _output_csv(self, cpp_file, line_mappings, options): + """Output CSV format.""" + output = self.annotator.generate_csv_output( + cpp_file, + line_mappings, + explanations_dict=self.explanations.get_all_explanations() if options.explanations else None + ) + + if options.output: + with open(options.output, 'w', encoding='utf-8') as f: + f.write(output) + print(f"Output saved to: {options.output}") + else: + print(output) + + +def main(): + """Main entry point for the CLI tool.""" + parser = argparse.ArgumentParser( + description="Map C++ source lines to AST nodes using Clang", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: + python ast_line_mapper.py example.cpp + python ast_line_mapper.py example.cpp --explanations + python ast_line_mapper.py example.cpp --side-by-side + python ast_line_mapper.py example.cpp --format table --explanations + python ast_line_mapper.py example.cpp --format csv --output result.csv + python ast_line_mapper.py example.cpp --format json --output result.json + python ast_line_mapper.py example.cpp --format csv --output result.csv --interpret + python ast_line_mapper.py example.cpp --format csv --output result.csv --interpret --api-key YOUR_API_KEY + """ + ) + + parser.add_argument( + 'cpp_file', + help='C++ source file to process' + ) + + parser.add_argument( + '--explanations', + action='store_true', + help='Include human-readable explanations for AST nodes' + ) + + parser.add_argument( + '--side-by-side', + action='store_true', + help='Display source and AST information side by side (deprecated: use --format side-by-side)' + ) + + parser.add_argument( + '--generate-ast', + action='store_true', + help='Generate AST JSON file only (don\'t annotate)' + ) + + parser.add_argument( + '--format', + choices=['annotated', 'side-by-side', 'table', 'csv', 'json'], + default='annotated', + help='Output format (default: annotated)' + ) + + parser.add_argument( + '--output', + help='Save output to specified file' + ) + + parser.add_argument( + '--interpret', + action='store_true', + help='Use AI to interpret the AST output (only works with CSV format)' + ) + + parser.add_argument( + '--api-key', + help='API key for AI interpretation (or set AST_MAPPER_AI_KEY environment variable)' + ) + + parser.add_argument( + '--version', + action='version', + version='Clang AST Line Mapper 1.0.0' + ) + + args = parser.parse_args() + + # Handle deprecated --side-by-side option + if args.side_by_side: + args.format = 'side-by-side' + + # Create and run the mapper + mapper = ASTLineMapper() + + try: + success = mapper.process_file(args.cpp_file, args) + + # Handle AI interpretation if requested + if success and args.interpret: + if args.format != 'csv': + print("Warning: AI interpretation only works with CSV format. Please use --format csv") + elif not args.output: + print("Warning: AI interpretation requires saving output to a file. Please use --output") + else: + print("\nGenerating AI interpretation of the AST mapping...") + try: + interpretation = interpret_ast_file(args.output, args.api_key) + interpretation_file = f"{os.path.splitext(args.output)[0]}_interpretation.md" + with open(interpretation_file, 'w', encoding='utf-8') as f: + f.write(interpretation) + print(f"AI interpretation saved to: {interpretation_file}") + except Exception as e: + print(f"Error generating AI interpretation: {e}") + + sys.exit(0 if success else 1) + except KeyboardInterrupt: + print("\nProcess interrupted by user") + sys.exit(1) + except Exception as e: + print(f"Unexpected error: {e}") + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/clang-ast-mapper/auto_decltype_ast.json b/clang-ast-mapper/auto_decltype_ast.json new file mode 100644 index 0000000000000..03d5294829420 --- /dev/null +++ b/clang-ast-mapper/auto_decltype_ast.json @@ -0,0 +1,3514 @@ +{ + "id": "0x1daab5c6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x1daab5c7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x1daab5c75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1daab5c7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x1daab5c7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x1daab5c77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x1daab5c7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x1daab5c7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x1daab5c78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x1daab5c7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x1daab5c7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x1daab61d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1daab61d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x1daab5c6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x1daab5c7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1daab5c7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1daab5c6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1daab5c76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1daab5c7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1daab5c6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1daab61d970", + "kind": "TypeAliasDecl", + "loc": { + "offset": 114, + "file": "examples\\auto_decltype.cpp", + "line": 5, + "col": 7, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 108, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 124, + "col": 17, + "tokLen": 3 + } + }, + "name": "Integer", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x1daab5c6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "id": "0x1daab61da58", + "kind": "FunctionDecl", + "loc": { + "offset": 172, + "line": 8, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 167, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 202, + "line": 10, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x1daab61dd00", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 183, + "line": 8, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 202, + "line": 10, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab61dcf0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 190, + "line": 9, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 197, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x1daab61db48", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 197, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 197, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab61de68", + "kind": "FunctionDecl", + "loc": { + "offset": 251, + "line": 13, + "col": 6, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 246, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 302, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "name": "getDouble", + "mangledName": "?getDouble@@YANH@Z", + "type": { + "qualType": "auto (int) -> double" + }, + "inner": [ + { + "id": "0x1daab61dd30", + "kind": "ParmVarDecl", + "loc": { + "offset": 265, + "line": 13, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 261, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 265, + "col": 20, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1daab61dfc0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 278, + "col": 33, + "tokLen": 1 + }, + "end": { + "offset": 302, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab61dfb0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 285, + "line": 14, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 296, + "col": 16, + "tokLen": 3 + } + }, + "inner": [ + { + "id": "0x1daab61df90", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 292, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 296, + "col": 16, + "tokLen": 3 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "*", + "inner": [ + { + "id": "0x1daab61df78", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 292, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 292, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x1daab61df60", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 292, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 292, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab61df18", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 292, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 292, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab61dd30", + "kind": "ParmVarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x1daab61df38", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 296, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 296, + "col": 16, + "tokLen": 3 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab61e478", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 374, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 334, + "line": 18, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 429, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x1daab61dfd8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 353, + "line": 18, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 344, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 353, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x1daab61e060", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 365, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 356, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 365, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x1daab61e3d0", + "kind": "FunctionDecl", + "loc": { + "offset": 374, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 369, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 429, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x1daab61e148", + "kind": "ParmVarDecl", + "loc": { + "offset": 380, + "line": 19, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 378, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 380, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x1daab61e1c8", + "kind": "ParmVarDecl", + "loc": { + "offset": 385, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 383, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 385, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x1daab64bf80", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 407, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 429, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64bf70", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 414, + "line": 20, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 425, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64bf50", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 421, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 425, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1daab64bf10", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 421, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 421, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab61e148", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x1daab64bf30", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 425, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 425, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab61e1c8", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64a640", + "kind": "FunctionDecl", + "loc": { + "offset": 374, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 369, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 429, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x1daab5c6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x1daab5c6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x1daab64a390", + "kind": "ParmVarDecl", + "loc": { + "offset": 380, + "line": 19, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 378, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 380, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1daab64a440", + "kind": "ParmVarDecl", + "loc": { + "offset": 385, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 383, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 385, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x1daab64c050", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 407, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 429, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64c040", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 414, + "line": 20, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 425, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64c020", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 421, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 425, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1daab64c008", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 421, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 421, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x1daab64bfd8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 421, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 421, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab64bf98", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 421, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 421, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab64a390", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x1daab64bff0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 425, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 425, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab64bfb8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 425, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 425, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab64a440", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab61e548", + "kind": "CXXRecordDecl", + "loc": { + "offset": 476, + "line": 24, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 470, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 857, + "line": 41, + "col": 1, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "Calculator", + "tagUsed": "class", + "completeDefinition": true, + "definitionData": { + "canConstDefaultInit": true, + "canPassInRegisters": true, + "copyAssign": { + "hasConstParam": true, + "implicitHasConstParam": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "copyCtor": { + "hasConstParam": true, + "implicitHasConstParam": true, + "simple": true, + "trivial": true + }, + "defaultCtor": {}, + "dtor": { + "irrelevant": true, + "simple": true, + "trivial": true + }, + "hasUserDeclaredConstructor": true, + "isStandardLayout": true, + "isTriviallyCopyable": true, + "moveAssign": { + "exists": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "moveCtor": { + "exists": true, + "simple": true, + "trivial": true + } + }, + "inner": [ + { + "id": "0x1daab61e668", + "kind": "CXXRecordDecl", + "loc": { + "offset": 476, + "line": 24, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 470, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "isReferenced": true, + "name": "Calculator", + "tagUsed": "class" + }, + { + "id": "0x1daab61e6f8", + "kind": "AccessSpecDecl", + "loc": { + "offset": 490, + "line": 25, + "col": 1, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 490, + "col": 1, + "tokLen": 7 + }, + "end": { + "offset": 497, + "col": 8, + "tokLen": 1 + } + }, + "access": "private" + }, + { + "id": "0x1daab61e740", + "kind": "FieldDecl", + "loc": { + "offset": 508, + "line": 26, + "col": 9, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 504, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 508, + "col": 9, + "tokLen": 5 + } + }, + "isReferenced": true, + "name": "value", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1daab61e798", + "kind": "AccessSpecDecl", + "loc": { + "offset": 522, + "line": 28, + "col": 1, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 522, + "col": 1, + "tokLen": 6 + }, + "end": { + "offset": 528, + "col": 7, + "tokLen": 1 + } + }, + "access": "public" + }, + { + "id": "0x1daab647f00", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 535, + "line": 29, + "col": 5, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 535, + "col": 5, + "tokLen": 10 + }, + "end": { + "offset": 577, + "col": 47, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@H@Z", + "type": { + "qualType": "void (int)" + }, + "inner": [ + { + "id": "0x1daab61e7e0", + "kind": "ParmVarDecl", + "loc": { + "offset": 550, + "col": 20, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 546, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 550, + "col": 20, + "tokLen": 7 + } + }, + "isUsed": true, + "name": "initial", + "type": { + "qualType": "int" + } + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x1daab61e740", + "kind": "FieldDecl", + "name": "value", + "type": { + "qualType": "int" + } + }, + "inner": [ + { + "id": "0x1daab648510", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 567, + "col": 37, + "tokLen": 7 + }, + "end": { + "offset": 567, + "col": 37, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab6484d0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 567, + "col": 37, + "tokLen": 7 + }, + "end": { + "offset": 567, + "col": 37, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab61e7e0", + "kind": "ParmVarDecl", + "name": "initial", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x1daab648550", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 576, + "col": 46, + "tokLen": 1 + }, + "end": { + "offset": 577, + "col": 47, + "tokLen": 1 + } + } + } + ] + }, + { + "id": "0x1daab648048", + "kind": "CXXMethodDecl", + "loc": { + "offset": 632, + "line": 32, + "col": 10, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 627, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 679, + "line": 34, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@Calculator@@QEBA@XZ", + "type": { + "qualType": "int () const" + }, + "inner": [ + { + "id": "0x1daab6486e8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 649, + "line": 32, + "col": 27, + "tokLen": 1 + }, + "end": { + "offset": 679, + "line": 34, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab6486d8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 660, + "line": 33, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 667, + "col": 16, + "tokLen": 5 + } + }, + "inner": [ + { + "id": "0x1daab6486c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 667, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 667, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab648570", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 667, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 667, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "const int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x1daab61e740", + "inner": [ + { + "id": "0x1daab648560", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 667, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 667, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "const Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab648458", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 768, + "line": 38, + "col": 10, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 736, + "line": 37, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 854, + "line": 40, + "col": 5, + "tokLen": 1 + } + }, + "name": "multiply", + "inner": [ + { + "id": "0x1daab6480f0", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 755, + "line": 37, + "col": 24, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 746, + "col": 15, + "tokLen": 8 + }, + "end": { + "offset": 755, + "col": 24, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x1daab6483b0", + "kind": "CXXMethodDecl", + "loc": { + "offset": 768, + "line": 38, + "col": 10, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 763, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 854, + "line": 40, + "col": 5, + "tokLen": 1 + } + }, + "name": "multiply", + "type": { + "qualType": "auto (T) -> decltype(this->value * factor)" + }, + "inner": [ + { + "id": "0x1daab6481a0", + "kind": "ParmVarDecl", + "loc": { + "offset": 779, + "line": 38, + "col": 21, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 777, + "col": 19, + "tokLen": 1 + }, + "end": { + "offset": 779, + "col": 21, + "tokLen": 6 + } + }, + "isReferenced": true, + "name": "factor", + "type": { + "qualType": "T" + } + }, + { + "id": "0x1daab64c0f8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 815, + "col": 57, + "tokLen": 1 + }, + "end": { + "offset": 854, + "line": 40, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64c0e8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 826, + "line": 39, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 841, + "col": 24, + "tokLen": 6 + } + }, + "inner": [ + { + "id": "0x1daab64c0c8", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 841, + "col": 24, + "tokLen": 6 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "*", + "inner": [ + { + "id": "0x1daab64c078", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 833, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x1daab61e740", + "inner": [ + { + "id": "0x1daab64c068", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 833, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + }, + { + "id": "0x1daab64c0a8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 841, + "col": 24, + "tokLen": 6 + }, + "end": { + "offset": 841, + "col": 24, + "tokLen": 6 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab6481a0", + "kind": "ParmVarDecl", + "name": "factor", + "type": { + "qualType": "T" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64bc20", + "kind": "CXXMethodDecl", + "loc": { + "offset": 768, + "line": 38, + "col": 10, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 763, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 854, + "line": 40, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "multiply", + "mangledName": "??$multiply@N@Calculator@@QEAANN@Z", + "type": { + "qualType": "auto (double) -> decltype(this->value * factor)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x1daab5c6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x1daab64ba50", + "kind": "ParmVarDecl", + "loc": { + "offset": 779, + "line": 38, + "col": 21, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 777, + "col": 19, + "tokLen": 1 + }, + "end": { + "offset": 779, + "col": 21, + "tokLen": 6 + } + }, + "isUsed": true, + "name": "factor", + "type": { + "qualType": "double" + } + }, + { + "id": "0x1daab64c1a8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 815, + "col": 57, + "tokLen": 1 + }, + "end": { + "offset": 854, + "line": 40, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64c198", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 826, + "line": 39, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 841, + "col": 24, + "tokLen": 6 + } + }, + "inner": [ + { + "id": "0x1daab64c178", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 841, + "col": 24, + "tokLen": 6 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "*", + "inner": [ + { + "id": "0x1daab64c160", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 833, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x1daab64c130", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 833, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab64c078", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 833, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x1daab61e740", + "inner": [ + { + "id": "0x1daab64c068", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 833, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 833, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64c148", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 841, + "col": 24, + "tokLen": 6 + }, + "end": { + "offset": 841, + "col": 24, + "tokLen": 6 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab64c110", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 841, + "col": 24, + "tokLen": 6 + }, + "end": { + "offset": 841, + "col": 24, + "tokLen": 6 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab64ba50", + "kind": "ParmVarDecl", + "name": "factor", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64aad0", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 476, + "line": 24, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@AEBV0@@Z", + "type": { + "qualType": "void (const Calculator &)" + }, + "inline": true, + "constexpr": true, + "explicitlyDefaulted": "default", + "inner": [ + { + "id": "0x1daab64ac00", + "kind": "ParmVarDecl", + "loc": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "const Calculator &" + } + } + ] + }, + { + "id": "0x1daab64acf0", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "isUsed": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@$$QEAV0@@Z", + "type": { + "qualType": "void (Calculator &&) noexcept" + }, + "inline": true, + "constexpr": true, + "explicitlyDefaulted": "default", + "inner": [ + { + "id": "0x1daab64ae20", + "kind": "ParmVarDecl", + "loc": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "isUsed": true, + "type": { + "qualType": "Calculator &&" + } + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x1daab61e740", + "kind": "FieldDecl", + "name": "value", + "type": { + "qualType": "int" + } + }, + "inner": [ + { + "id": "0x1daab64b598", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab64b560", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "xvalue", + "name": "value", + "isArrow": false, + "referencedMemberDecl": "0x1daab61e740", + "inner": [ + { + "id": "0x1daab64b530", + "kind": "CXXStaticCastExpr", + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "xvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x1daab64b4f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab64ae20", + "kind": "ParmVarDecl", + "name": "", + "type": { + "qualType": "Calculator &&" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64b5d8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + } + } + ] + }, + { + "id": "0x1daab64b008", + "kind": "CXXDestructorDecl", + "loc": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 476, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "isReferenced": true, + "name": "~Calculator", + "mangledName": "??_DCalculator@@QEAAXXZ", + "type": { + "qualType": "void () noexcept" + }, + "inline": true, + "explicitlyDefaulted": "default" + } + ] + }, + { + "id": "0x1daab648728", + "kind": "FunctionDecl", + "loc": { + "offset": 867, + "line": 43, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 863, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 1358, + "line": 64, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x1daab64bec0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 874, + "line": 43, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1358, + "line": 64, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab648a70", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 916, + "line": 45, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 935, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab648818", + "kind": "VarDecl", + "loc": { + "offset": 921, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 916, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 934, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1daab648968", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 925, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 934, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1daab648950", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 925, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 925, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x1daab6488c8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 925, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 925, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab61da58", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab648c20", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 942, + "line": 46, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 955, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab648aa0", + "kind": "VarDecl", + "loc": { + "offset": 947, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 942, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 951, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x1daab648b08", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 951, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 951, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x1daab648d88", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 991, + "line": 49, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 1013, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab648ca0", + "kind": "VarDecl", + "loc": { + "offset": 1003, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 991, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 1011, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x1daab648d68", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 1007, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 1011, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1daab648d50", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1007, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 1007, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab648d08", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1007, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 1007, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab648818", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1daab648d28", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1011, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 1011, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64a950", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1062, + "line": 52, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1085, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab648db8", + "kind": "VarDecl", + "loc": { + "offset": 1067, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 1062, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1084, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x1daab64a808", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 1076, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 1084, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1daab64a7f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1076, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 1076, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x1daab64a760", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1076, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 1076, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab64a640", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x1daab61e478", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x1daab64a838", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1080, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 1080, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab648e68", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1080, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 1080, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab648818", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1daab64a850", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1083, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 1083, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1daab64a288", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1083, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 1083, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab648aa0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64b630", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1133, + "line": 55, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1160, + "col": 32, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64a980", + "kind": "VarDecl", + "loc": { + "offset": 1138, + "col": 10, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 1133, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1159, + "col": 31, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "calc", + "type": { + "qualType": "Calculator" + }, + "init": "c", + "inner": [ + { + "id": "0x1daab64b618", + "kind": "ExprWithCleanups", + "range": { + "begin": { + "offset": 1145, + "col": 17, + "tokLen": 10 + }, + "end": { + "offset": 1159, + "col": 31, + "tokLen": 1 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1daab64b5e8", + "kind": "CXXConstructExpr", + "range": { + "begin": { + "offset": 1145, + "col": 17, + "tokLen": 10 + }, + "end": { + "offset": 1159, + "col": 31, + "tokLen": 1 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "prvalue", + "ctorType": { + "qualType": "void (Calculator &&) noexcept" + }, + "elidable": true, + "hadMultipleCandidates": true, + "constructionKind": "complete", + "inner": [ + { + "id": "0x1daab64b270", + "kind": "MaterializeTemporaryExpr", + "range": { + "begin": { + "offset": 1145, + "col": 17, + "tokLen": 10 + }, + "end": { + "offset": 1159, + "col": 31, + "tokLen": 1 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "xvalue", + "storageDuration": "full expression", + "inner": [ + { + "id": "0x1daab64b160", + "kind": "CXXFunctionalCastExpr", + "range": { + "begin": { + "offset": 1145, + "col": 17, + "tokLen": 10 + }, + "end": { + "offset": 1159, + "col": 31, + "tokLen": 1 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "prvalue", + "castKind": "ConstructorConversion", + "conversionFunc": { + "id": "0x1daab647f00", + "kind": "CXXConstructorDecl", + "name": "Calculator", + "type": { + "qualType": "void (int)" + } + }, + "inner": [ + { + "id": "0x1daab64afd8", + "kind": "CXXConstructExpr", + "range": { + "begin": { + "offset": 1145, + "col": 17, + "tokLen": 10 + }, + "end": { + "offset": 1159, + "col": 31, + "tokLen": 1 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "prvalue", + "ctorType": { + "qualType": "void (int)" + }, + "hadMultipleCandidates": true, + "constructionKind": "complete", + "inner": [ + { + "id": "0x1daab64aa40", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1156, + "col": 28, + "tokLen": 3 + }, + "end": { + "offset": 1156, + "col": 28, + "tokLen": 3 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "100" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64b810", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1212, + "line": 58, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1245, + "col": 38, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64b660", + "kind": "VarDecl", + "loc": { + "offset": 1217, + "col": 10, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 1212, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1244, + "col": 37, + "tokLen": 1 + } + }, + "name": "calcResult", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1daab64b730", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 1230, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 1244, + "col": 37, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1daab64b6e8", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1230, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 1235, + "col": 28, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "getValue", + "isArrow": false, + "referencedMemberDecl": "0x1daab648048", + "inner": [ + { + "id": "0x1daab64b718", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1230, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 1230, + "col": 23, + "tokLen": 4 + } + }, + "type": { + "qualType": "const Calculator" + }, + "valueCategory": "lvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x1daab64b6c8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1230, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 1230, + "col": 23, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab64a980", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64be70", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1296, + "line": 61, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1334, + "col": 43, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64b840", + "kind": "VarDecl", + "loc": { + "offset": 1301, + "col": 10, + "tokLen": 12 + }, + "range": { + "begin": { + "offset": 1296, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1333, + "col": 42, + "tokLen": 1 + } + }, + "name": "doubleResult", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(this->value * factor)" + }, + "init": "c", + "inner": [ + { + "id": "0x1daab64bd58", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 1316, + "col": 25, + "tokLen": 4 + }, + "end": { + "offset": 1333, + "col": 42, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(this->value * factor)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1daab64bd20", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1316, + "col": 25, + "tokLen": 4 + }, + "end": { + "offset": 1321, + "col": 30, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "multiply", + "isArrow": false, + "referencedMemberDecl": "0x1daab64bc20", + "inner": [ + { + "id": "0x1daab64b8a8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1316, + "col": 25, + "tokLen": 4 + }, + "end": { + "offset": 1316, + "col": 25, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1daab64a980", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + }, + { + "id": "0x1daab64b920", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 1330, + "col": 39, + "tokLen": 3 + }, + "end": { + "offset": 1330, + "col": 39, + "tokLen": 3 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "2.5" + } + ] + } + ] + } + ] + }, + { + "id": "0x1daab64beb0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1347, + "line": 63, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 1354, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1daab64be88", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1354, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1354, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/auto_output.csv b/clang-ast-mapper/auto_output.csv new file mode 100644 index 0000000000000..17406d6b07d40 --- /dev/null +++ b/clang-ast-mapper/auto_output.csv @@ -0,0 +1,65 @@ +Line,Source Code,AST Nodes,Explanations +1,// Modern C++ features focusing on auto and decltype,, +2,// This is a self-contained example,, +3,,, +4,// Type alias,, +5,using Integer = int;,, +6,,, +7,// Function with auto return type,, +8,auto getValue() {,CompoundStmt; FunctionDecl, +9, return 42;,ReturnStmt, +10,},, +11,,, +12,// Function with trailing return type,, +13,auto getDouble(int x) -> double {,FunctionDecl; ParmVarDecl, +14, return x * 2.0;,ReturnStmt, +15,},, +16,,, +17,// Function with decltype,, +18,"template ",TemplateTypeParmDecl, +19,"auto add(T a, U b) -> decltype(a + b) {",FunctionDecl; ParmVarDecl; FunctionTemplateDecl, +20, return a + b;,ReturnStmt, +21,},, +22,,, +23,// Class with auto member function,, +24,class Calculator {,CXXConstructorDecl; CXXRecordDecl, +25,private:,AccessSpecDecl, +26, int value;,FieldDecl, +27,,, +28,public:,AccessSpecDecl, +29, Calculator(int initial) : value(initial) {},CXXConstructorDecl, +30,,, +31, // Method with auto return type,, +32, auto getValue() const {,CompoundStmt; CXXMethodDecl, +33, return value;,ReturnStmt, +34, },, +35,,, +36, // Method with decltype in return type,, +37, template ,TemplateTypeParmDecl, +38, auto multiply(T factor) -> decltype(value * factor) {,CXXMethodDecl; ParmVarDecl; FunctionTemplateDecl, +39, return value * factor;,ReturnStmt, +40, },, +41,};,, +42,,, +43,int main() {,CompoundStmt; FunctionDecl, +44, // Auto variable declarations,, +45, auto x = getValue();,DeclStmt, +46, auto y = 3.14;,DeclStmt, +47,,, +48, // decltype usage,, +49, decltype(x) z = x + 10;,DeclStmt, +50,,, +51, // Auto with initializer lists,, +52," auto result = add(x, y);",DeclStmt, +53,,, +54, // Creating objects with auto,, +55, auto calc = Calculator(100);,DeclStmt, +56,,, +57, // Using auto with method returns,, +58, auto calcResult = calc.getValue();,DeclStmt, +59,,, +60, // Using decltype with templates,, +61, auto doubleResult = calc.multiply(2.5);,DeclStmt, +62,,, +63, return 0;,ReturnStmt, +64,},, diff --git a/clang-ast-mapper/auto_output_interpretation.md b/clang-ast-mapper/auto_output_interpretation.md new file mode 100644 index 0000000000000..b6fa34de509b1 --- /dev/null +++ b/clang-ast-mapper/auto_output_interpretation.md @@ -0,0 +1,101 @@ +# AST Analysis for C++ Code + +## Code Summary +This code defines a C++ class with 4 methods/constructors and contains logic for data manipulation and processing. + +## Code Structure +The C++ code has been analyzed using Clang's AST system, revealing the following structure: +- **Function Declarations**: The code contains function/method declarations which define its main structure +- **Parameter Variables**: Functions have parameter declarations indicating data passed between functions +- **Code Blocks**: Contains compound statements (blocks of code within curly braces) +- **Return Statements**: Functions include return statements to provide output values +- **Variable Declarations**: The code declares local variables to store and manipulate data +- **Classes/Structs**: The code defines custom data types with methods and fields + +## AST Structure Summary +This code follows a typical C++ structure with: + +- Class definitions with member methods +- Classes containing member variables (fields) +- Function definitions that contain variable declarations +- Method implementations with local variable usage +- Variable manipulation followed by return statements + +## AST Node Types Explained +The following AST nodes were found in the code: + +- **DeclStmt** (7 occurrences): Declaration statement - contains one or more variable declarations +- **ReturnStmt** (6 occurrences): Return statement - specifies the value to be returned from a function +- **FunctionDecl** (4 occurrences): Function declaration - defines a function with its return type, name, and parameters +- **CompoundStmt** (3 occurrences): Compound statement - a block of code enclosed in braces {} +- **ParmVarDecl** (3 occurrences): Parameter variable declaration - variables that receive values passed to functions +- **TemplateTypeParmDecl** (2 occurrences): Template type parameter - defines a placeholder type (like T) in a template +- **FunctionTemplateDecl** (2 occurrences): C++ function template declaration - defines a generic function that can work with different types +- **CXXConstructorDecl** (2 occurrences): C++ constructor declaration - special method that initializes objects of a class +- **AccessSpecDecl** (2 occurrences): Access specifier - public, private, or protected sections in a class +- **CXXMethodDecl** (2 occurrences): C++ method declaration - a function that belongs to a class or struct +- **CXXRecordDecl** (1 occurrences): C++ class/struct declaration - defines a user-defined type +- **FieldDecl** (1 occurrences): Field declaration - member variables of a class or struct + +## Side-by-Side Code and AST Representation +This section shows each line of code alongside its corresponding AST nodes: + +| Line # | C++ Code | AST Nodes | Explanation | +|--------|----------|-----------|-------------| +| 5 | `using Integer = int;` | | | +| 8 | `auto getValue() {` | CompoundStmt; FunctionDecl | a block of code enclosed in braces {} | +| 9 | `return 42;` | ReturnStmt | specifies the value to be returned from a function | +| 10 | `}` | | | +| 13 | `auto getDouble(int x) -> double {` | FunctionDecl; ParmVarDecl | defines a function with its return type, name, and parameters | +| 14 | `return x * 2.0;` | ReturnStmt | specifies the value to be returned from a function | +| 15 | `}` | | | +| 18 | `template ` | TemplateTypeParmDecl | Template-related construct | +| 19 | `auto add(T a, U b) -> decltype(a + b) {` | FunctionDecl; ParmVarDecl; FunctionTemplateDecl | defines a function with its return type, name, and parameters | +| 20 | `return a + b;` | ReturnStmt | specifies the value to be returned from a function | +| 21 | `}` | | | +| 24 | `class Calculator {` | CXXConstructorDecl; CXXRecordDecl | special method that initializes objects of a class | +| 25 | `private:` | AccessSpecDecl | public, private, or protected sections in a class | +| 26 | `int value;` | FieldDecl | member variables of a class or struct | +| 28 | `public:` | AccessSpecDecl | public, private, or protected sections in a class | +| 29 | `Calculator(int initial) : value(initial) {}` | CXXConstructorDecl | special method that initializes objects of a class | +| 32 | `auto getValue() const {` | CompoundStmt; CXXMethodDecl | a block of code enclosed in braces {} | +| 33 | `return value;` | ReturnStmt | specifies the value to be returned from a function | +| 34 | `}` | | | +| 37 | `template ` | TemplateTypeParmDecl | Template-related construct | +| 38 | `auto multiply(T factor) -> decltype(value * factor) {` | CXXMethodDecl; ParmVarDecl; FunctionTemplateDecl | a function that belongs to a class or struct | +| 39 | `return value * factor;` | ReturnStmt | specifies the value to be returned from a function | +| 40 | `}` | | | +| 41 | `};` | | | +| 43 | `int main() {` | CompoundStmt; FunctionDecl | a block of code enclosed in braces {} | +| 45 | `auto x = getValue();` | DeclStmt | contains one or more variable declarations | +| 46 | `auto y = 3.14;` | DeclStmt | contains one or more variable declarations | +| 49 | `decltype(x) z = x + 10;` | DeclStmt | contains one or more variable declarations | +| 52 | `auto result = add(x, y);` | DeclStmt | contains one or more variable declarations | +| 55 | `auto calc = Calculator(100);` | DeclStmt | contains one or more variable declarations | +| 58 | `auto calcResult = calc.getValue();` | DeclStmt | contains one or more variable declarations | +| 60 | `// Using decltype with templates` | | | +| 61 | `auto doubleResult = calc.multiply(2.5);` | DeclStmt | contains one or more variable declarations | +| 63 | `return 0;` | ReturnStmt | specifies the value to be returned from a function | +| 64 | `}` | | | + +## AST Node Types Summary Table +| Node Type | Count | Description | +|-----------|-------|-------------| +| DeclStmt | 7 | contains one or more variable declarations | +| ReturnStmt | 6 | specifies the value to be returned from a function | +| FunctionDecl | 4 | defines a function with its return type, name, and parameters | +| CompoundStmt | 3 | a block of code enclosed in braces {} | +| ParmVarDecl | 3 | variables that receive values passed to functions | +| TemplateTypeParmDecl | 2 | defines a placeholder type (like T) in a template | +| FunctionTemplateDecl | 2 | defines a generic function that can work with different types | +| CXXConstructorDecl | 2 | special method that initializes objects of a class | +| AccessSpecDecl | 2 | public, private, or protected sections in a class | +| CXXMethodDecl | 2 | a function that belongs to a class or struct | +| CXXRecordDecl | 1 | defines a user-defined class or struct | +| FieldDecl | 1 | member variables of a class or struct | + +## Code Quality Observations +- The AST structure indicates well-formed C++ code without syntax errors + +## Functional Summary +The code implements a complete C++ class with constructors, methods, and member variables. This suggests an object-oriented design with proper encapsulation of data and behavior. \ No newline at end of file diff --git a/clang-ast-mapper/complex_ast.json b/clang-ast-mapper/complex_ast.json new file mode 100644 index 0000000000000..de03a2bac744a --- /dev/null +++ b/clang-ast-mapper/complex_ast.json @@ -0,0 +1,3329 @@ +{ + "id": "0x1b4a81b6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x1b4a81b7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x1b4a81b75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1b4a81b7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x1b4a81b7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x1b4a81b77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x1b4a81b7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x1b4a81b7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x1b4a81b78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x1b4a81b7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x1b4a81b7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x1b4a820d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1b4a820d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x1b4a81b6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x1b4a81b7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1b4a81b7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1b4a81b6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1b4a81b76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1b4a81b7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1b4a81b6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1b4a820d958", + "kind": "CXXRecordDecl", + "loc": { + "offset": 55, + "file": "examples\\complex.cpp", + "line": 2, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 49, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 433, + "line": 24, + "col": 1, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "Calculator", + "tagUsed": "class", + "completeDefinition": true, + "definitionData": { + "canConstDefaultInit": true, + "canPassInRegisters": true, + "copyAssign": { + "hasConstParam": true, + "implicitHasConstParam": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "copyCtor": { + "hasConstParam": true, + "implicitHasConstParam": true, + "simple": true, + "trivial": true + }, + "defaultCtor": {}, + "dtor": { + "irrelevant": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "hasUserDeclaredConstructor": true, + "isStandardLayout": true, + "isTriviallyCopyable": true, + "moveAssign": { + "exists": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "moveCtor": { + "exists": true, + "simple": true, + "trivial": true + } + }, + "inner": [ + { + "id": "0x1b4a820da78", + "kind": "CXXRecordDecl", + "loc": { + "offset": 55, + "line": 2, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 49, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 55, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "isReferenced": true, + "name": "Calculator", + "tagUsed": "class" + }, + { + "id": "0x1b4a820db08", + "kind": "AccessSpecDecl", + "loc": { + "offset": 69, + "line": 3, + "col": 1, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 69, + "col": 1, + "tokLen": 7 + }, + "end": { + "offset": 76, + "col": 8, + "tokLen": 1 + } + }, + "access": "private" + }, + { + "id": "0x1b4a820db50", + "kind": "FieldDecl", + "loc": { + "offset": 87, + "line": 4, + "col": 9, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 83, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 87, + "col": 9, + "tokLen": 5 + } + }, + "isReferenced": true, + "name": "value", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1b4a820dba8", + "kind": "AccessSpecDecl", + "loc": { + "offset": 101, + "line": 6, + "col": 1, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 101, + "col": 1, + "tokLen": 6 + }, + "end": { + "offset": 107, + "col": 7, + "tokLen": 1 + } + }, + "access": "public" + }, + { + "id": "0x1b4a820dd10", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 114, + "line": 7, + "col": 5, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 114, + "col": 5, + "tokLen": 10 + }, + "end": { + "offset": 156, + "col": 47, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@H@Z", + "type": { + "qualType": "void (int)" + }, + "inner": [ + { + "id": "0x1b4a820dbf0", + "kind": "ParmVarDecl", + "loc": { + "offset": 129, + "col": 20, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 125, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 129, + "col": 20, + "tokLen": 7 + } + }, + "isUsed": true, + "name": "initial", + "type": { + "qualType": "int" + } + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x1b4a820db50", + "kind": "FieldDecl", + "name": "value", + "type": { + "qualType": "int" + } + }, + "inner": [ + { + "id": "0x1b4a820e4f8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 146, + "col": 37, + "tokLen": 7 + }, + "end": { + "offset": 146, + "col": 37, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a820e4b8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 146, + "col": 37, + "tokLen": 7 + }, + "end": { + "offset": 146, + "col": 37, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a820dbf0", + "kind": "ParmVarDecl", + "name": "initial", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x1b4a820e538", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 155, + "col": 46, + "tokLen": 1 + }, + "end": { + "offset": 156, + "col": 47, + "tokLen": 1 + } + } + } + ] + }, + { + "id": "0x1b4a820df58", + "kind": "CXXMethodDecl", + "loc": { + "offset": 173, + "line": 9, + "col": 9, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 169, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 221, + "line": 11, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "?add@Calculator@@QEAAHHH@Z", + "type": { + "qualType": "int (int, int)" + }, + "inner": [ + { + "id": "0x1b4a820dde0", + "kind": "ParmVarDecl", + "loc": { + "offset": 181, + "line": 9, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 177, + "col": 13, + "tokLen": 3 + }, + "end": { + "offset": 181, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1b4a820de68", + "kind": "ParmVarDecl", + "loc": { + "offset": 188, + "col": 24, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 184, + "col": 20, + "tokLen": 3 + }, + "end": { + "offset": 188, + "col": 24, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1b4a820e5e8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 191, + "col": 27, + "tokLen": 1 + }, + "end": { + "offset": 221, + "line": 11, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a820e5d8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 202, + "line": 10, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 213, + "col": 20, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a820e5b8", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 209, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 213, + "col": 20, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1b4a820e588", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 209, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 209, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a820e548", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 209, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 209, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a820dde0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a820e5a0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 213, + "col": 20, + "tokLen": 1 + }, + "end": { + "offset": 213, + "col": 20, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a820e568", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 213, + "col": 20, + "tokLen": 1 + }, + "end": { + "offset": 213, + "col": 20, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a820de68", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a820e158", + "kind": "CXXMethodDecl", + "loc": { + "offset": 238, + "line": 13, + "col": 9, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 234, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 291, + "line": 15, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "multiply", + "mangledName": "?multiply@Calculator@@QEAAHHH@Z", + "type": { + "qualType": "int (int, int)" + }, + "inner": [ + { + "id": "0x1b4a820e028", + "kind": "ParmVarDecl", + "loc": { + "offset": 251, + "line": 13, + "col": 22, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 247, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 251, + "col": 22, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1b4a820e0b0", + "kind": "ParmVarDecl", + "loc": { + "offset": 258, + "col": 29, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 254, + "col": 25, + "tokLen": 3 + }, + "end": { + "offset": 258, + "col": 29, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1b4a820e6a0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 261, + "col": 32, + "tokLen": 1 + }, + "end": { + "offset": 291, + "line": 15, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a820e690", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 272, + "line": 14, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 283, + "col": 20, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a820e670", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 279, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 283, + "col": 20, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "*", + "inner": [ + { + "id": "0x1b4a820e640", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 279, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 279, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a820e600", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 279, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 279, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a820e028", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a820e658", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 283, + "col": 20, + "tokLen": 1 + }, + "end": { + "offset": 283, + "col": 20, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a820e620", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 283, + "col": 20, + "tokLen": 1 + }, + "end": { + "offset": 283, + "col": 20, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a820e0b0", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a820e2c0", + "kind": "CXXMethodDecl", + "loc": { + "offset": 309, + "line": 17, + "col": 10, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 304, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 366, + "line": 19, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "setValue", + "mangledName": "?setValue@Calculator@@QEAAXH@Z", + "type": { + "qualType": "void (int)" + }, + "inner": [ + { + "id": "0x1b4a820e228", + "kind": "ParmVarDecl", + "loc": { + "offset": 322, + "line": 17, + "col": 23, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 318, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 322, + "col": 23, + "tokLen": 8 + } + }, + "isUsed": true, + "name": "newValue", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1b4a820e798", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 332, + "col": 33, + "tokLen": 1 + }, + "end": { + "offset": 366, + "line": 19, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a820e778", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 343, + "line": 18, + "col": 9, + "tokLen": 5 + }, + "end": { + "offset": 351, + "col": 17, + "tokLen": 8 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "opcode": "=", + "inner": [ + { + "id": "0x1b4a820e710", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 343, + "col": 9, + "tokLen": 5 + }, + "end": { + "offset": 343, + "col": 9, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x1b4a820db50", + "inner": [ + { + "id": "0x1b4a820e700", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 343, + "col": 9, + "tokLen": 5 + }, + "end": { + "offset": 343, + "col": 9, + "tokLen": 5 + } + }, + "type": { + "qualType": "Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + }, + { + "id": "0x1b4a820e760", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 351, + "col": 17, + "tokLen": 8 + }, + "end": { + "offset": 351, + "col": 17, + "tokLen": 8 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a820e740", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 351, + "col": 17, + "tokLen": 8 + }, + "end": { + "offset": 351, + "col": 17, + "tokLen": 8 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a820e228", + "kind": "ParmVarDecl", + "name": "newValue", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a820e3f8", + "kind": "CXXMethodDecl", + "loc": { + "offset": 383, + "line": 21, + "col": 9, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 379, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 430, + "line": 23, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@Calculator@@QEBAHXZ", + "type": { + "qualType": "int () const" + }, + "inner": [ + { + "id": "0x1b4a820e818", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 400, + "line": 21, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "line": 23, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a820e808", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 411, + "line": 22, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 418, + "col": 16, + "tokLen": 5 + } + }, + "inner": [ + { + "id": "0x1b4a820e7f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 418, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 418, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a820e7c0", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 418, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 418, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "const int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x1b4a820db50", + "inner": [ + { + "id": "0x1b4a820e7b0", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 418, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 418, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "const Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a8238110", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 55, + "line": 2, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 55, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 55, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@AEBV0@@Z", + "type": { + "qualType": "void (const Calculator &)" + }, + "inline": true, + "constexpr": true, + "explicitlyDefaulted": "default", + "inner": [ + { + "id": "0x1b4a8238240", + "kind": "ParmVarDecl", + "loc": { + "offset": 55, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 55, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 55, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "const Calculator &" + } + } + ] + }, + { + "id": "0x1b4a8238330", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 55, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 55, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 55, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@$$QEAV0@@Z", + "type": { + "qualType": "void (Calculator &&)" + }, + "inline": true, + "constexpr": true, + "explicitlyDefaulted": "default", + "inner": [ + { + "id": "0x1b4a8238460", + "kind": "ParmVarDecl", + "loc": { + "offset": 55, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 55, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 55, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "Calculator &&" + } + } + ] + } + ] + }, + { + "id": "0x1b4a8237e88", + "kind": "FunctionDecl", + "loc": { + "offset": 443, + "line": 26, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 439, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 867, + "line": 46, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x1b4a82393e8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 450, + "line": 26, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 867, + "line": 46, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238648", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 457, + "line": 27, + "col": 5, + "tokLen": 10 + }, + "end": { + "offset": 476, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "loc": { + "offset": 468, + "col": 16, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 457, + "col": 5, + "tokLen": 10 + }, + "end": { + "offset": 475, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "calc", + "type": { + "qualType": "Calculator" + }, + "init": "call", + "inner": [ + { + "id": "0x1b4a8238618", + "kind": "CXXConstructExpr", + "range": { + "begin": { + "offset": 468, + "col": 16, + "tokLen": 4 + }, + "end": { + "offset": 475, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "prvalue", + "ctorType": { + "qualType": "void (int)" + }, + "hadMultipleCandidates": true, + "constructionKind": "complete", + "inner": [ + { + "id": "0x1b4a8238068", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 473, + "col": 21, + "tokLen": 2 + }, + "end": { + "offset": 473, + "col": 21, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a8238708", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 489, + "line": 29, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 498, + "col": 14, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238678", + "kind": "VarDecl", + "loc": { + "offset": 493, + "col": 9, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 489, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 497, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1b4a82386e0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 497, + "col": 13, + "tokLen": 1 + }, + "end": { + "offset": 497, + "col": 13, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "5" + } + ] + } + ] + }, + { + "id": "0x1b4a82387c8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 505, + "line": 30, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 514, + "col": 14, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238738", + "kind": "VarDecl", + "loc": { + "offset": 509, + "col": 9, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 505, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 513, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1b4a82387a0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 513, + "col": 13, + "tokLen": 1 + }, + "end": { + "offset": 513, + "col": 13, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "3" + } + ] + } + ] + }, + { + "id": "0x1b4a8238d20", + "kind": "IfStmt", + "range": { + "begin": { + "offset": 527, + "line": 32, + "col": 5, + "tokLen": 2 + }, + "end": { + "offset": 704, + "line": 38, + "col": 5, + "tokLen": 1 + } + }, + "hasElse": true, + "inner": [ + { + "id": "0x1b4a8238850", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 531, + "line": 32, + "col": 9, + "tokLen": 1 + }, + "end": { + "offset": 535, + "col": 13, + "tokLen": 1 + } + }, + "type": { + "qualType": "bool" + }, + "valueCategory": "prvalue", + "opcode": ">", + "inner": [ + { + "id": "0x1b4a8238820", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 531, + "col": 9, + "tokLen": 1 + }, + "end": { + "offset": 531, + "col": 9, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a82387e0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 531, + "col": 9, + "tokLen": 1 + }, + "end": { + "offset": 531, + "col": 9, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238678", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a8238838", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 535, + "col": 13, + "tokLen": 1 + }, + "end": { + "offset": 535, + "col": 13, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238800", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 535, + "col": 13, + "tokLen": 1 + }, + "end": { + "offset": 535, + "col": 13, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238738", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x1b4a8238aa8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 538, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 615, + "line": 35, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a82389e0", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 549, + "line": 33, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 576, + "col": 36, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238888", + "kind": "VarDecl", + "loc": { + "offset": 553, + "col": 13, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 549, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 575, + "col": 35, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "result", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1b4a8238980", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 562, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 575, + "col": 35, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1b4a8238910", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 562, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 567, + "col": 27, + "tokLen": 3 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "add", + "isArrow": false, + "referencedMemberDecl": "0x1b4a820df58", + "inner": [ + { + "id": "0x1b4a82388f0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 562, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 562, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + }, + { + "id": "0x1b4a82389b0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 571, + "col": 31, + "tokLen": 1 + }, + "end": { + "offset": 571, + "col": 31, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238940", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 571, + "col": 31, + "tokLen": 1 + }, + "end": { + "offset": 571, + "col": 31, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238678", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a82389c8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 574, + "col": 34, + "tokLen": 1 + }, + "end": { + "offset": 574, + "col": 34, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238960", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 574, + "col": 34, + "tokLen": 1 + }, + "end": { + "offset": 574, + "col": 34, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238738", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a8238a68", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 587, + "line": 34, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 607, + "col": 29, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1b4a8238a18", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 587, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 592, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "setValue", + "isArrow": false, + "referencedMemberDecl": "0x1b4a820e2c0", + "inner": [ + { + "id": "0x1b4a82389f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 587, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 587, + "col": 9, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + }, + { + "id": "0x1b4a8238a90", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 601, + "col": 23, + "tokLen": 6 + }, + "end": { + "offset": 601, + "col": 23, + "tokLen": 6 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238a48", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 601, + "col": 23, + "tokLen": 6 + }, + "end": { + "offset": 601, + "col": 23, + "tokLen": 6 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238888", + "kind": "VarDecl", + "name": "result", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a8238d00", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 622, + "line": 35, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 704, + "line": 38, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238c38", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 633, + "line": 36, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 665, + "col": 41, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238ae0", + "kind": "VarDecl", + "loc": { + "offset": 637, + "col": 13, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 633, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 664, + "col": 40, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "result", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1b4a8238bd8", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 646, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 664, + "col": 40, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1b4a8238b68", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 646, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 651, + "col": 27, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "multiply", + "isArrow": false, + "referencedMemberDecl": "0x1b4a820e158", + "inner": [ + { + "id": "0x1b4a8238b48", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 646, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 646, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + }, + { + "id": "0x1b4a8238c08", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 660, + "col": 36, + "tokLen": 1 + }, + "end": { + "offset": 660, + "col": 36, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238b98", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 660, + "col": 36, + "tokLen": 1 + }, + "end": { + "offset": 660, + "col": 36, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238678", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a8238c20", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 663, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 663, + "col": 39, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238bb8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 663, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 663, + "col": 39, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238738", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a8238cc0", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 676, + "line": 37, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 696, + "col": 29, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1b4a8238c70", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 676, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 681, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "setValue", + "isArrow": false, + "referencedMemberDecl": "0x1b4a820e2c0", + "inner": [ + { + "id": "0x1b4a8238c50", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 676, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 676, + "col": 9, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + }, + { + "id": "0x1b4a8238ce8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 690, + "col": 23, + "tokLen": 6 + }, + "end": { + "offset": 690, + "col": 23, + "tokLen": 6 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238ca0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 690, + "col": 23, + "tokLen": 6 + }, + "end": { + "offset": 690, + "col": 23, + "tokLen": 6 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238ae0", + "kind": "VarDecl", + "name": "result", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a8239318", + "kind": "ForStmt", + "range": { + "begin": { + "offset": 717, + "line": 40, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 829, + "line": 43, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238df8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 722, + "line": 40, + "col": 10, + "tokLen": 3 + }, + "end": { + "offset": 731, + "col": 19, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a8238d68", + "kind": "VarDecl", + "loc": { + "offset": 726, + "col": 14, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 722, + "col": 10, + "tokLen": 3 + }, + "end": { + "offset": 730, + "col": 18, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "i", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1b4a8238dd0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 730, + "col": 18, + "tokLen": 1 + }, + "end": { + "offset": 730, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + }, + {}, + { + "id": "0x1b4a8239088", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 733, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 737, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "bool" + }, + "valueCategory": "prvalue", + "opcode": "<", + "inner": [ + { + "id": "0x1b4a8238e58", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 733, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 733, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8238e10", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 733, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 733, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238d68", + "kind": "VarDecl", + "name": "i", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a8238e30", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 737, + "col": 25, + "tokLen": 1 + }, + "end": { + "offset": 737, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "3" + } + ] + }, + { + "id": "0x1b4a82390c8", + "kind": "UnaryOperator", + "range": { + "begin": { + "offset": 740, + "col": 28, + "tokLen": 1 + }, + "end": { + "offset": 741, + "col": 29, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "isPostfix": true, + "opcode": "++", + "inner": [ + { + "id": "0x1b4a82390a8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 740, + "col": 28, + "tokLen": 1 + }, + "end": { + "offset": 740, + "col": 28, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238d68", + "kind": "VarDecl", + "name": "i", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a82392f8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 745, + "col": 33, + "tokLen": 1 + }, + "end": { + "offset": 829, + "line": 43, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a82391e8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 756, + "line": 41, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 785, + "col": 38, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a82390f8", + "kind": "VarDecl", + "loc": { + "offset": 760, + "col": 13, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 756, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 784, + "col": 37, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "current", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1b4a82391c8", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 770, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 784, + "col": 37, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1b4a8239180", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 770, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 775, + "col": 28, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "getValue", + "isArrow": false, + "referencedMemberDecl": "0x1b4a820e3f8", + "inner": [ + { + "id": "0x1b4a82391b0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 770, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 770, + "col": 23, + "tokLen": 4 + } + }, + "type": { + "qualType": "const Calculator" + }, + "valueCategory": "lvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x1b4a8239160", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 770, + "col": 23, + "tokLen": 4 + }, + "end": { + "offset": 770, + "col": 23, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a82392d0", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 796, + "line": 42, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 821, + "col": 34, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1b4a8239220", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 796, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 801, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "setValue", + "isArrow": false, + "referencedMemberDecl": "0x1b4a820e2c0", + "inner": [ + { + "id": "0x1b4a8239200", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 796, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 796, + "col": 9, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + }, + { + "id": "0x1b4a82392b0", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 810, + "col": 23, + "tokLen": 7 + }, + "end": { + "offset": 820, + "col": 33, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1b4a8239298", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 810, + "col": 23, + "tokLen": 7 + }, + "end": { + "offset": 810, + "col": 23, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1b4a8239250", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 810, + "col": 23, + "tokLen": 7 + }, + "end": { + "offset": 810, + "col": 23, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a82390f8", + "kind": "VarDecl", + "name": "current", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1b4a8239270", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 820, + "col": 33, + "tokLen": 1 + }, + "end": { + "offset": 820, + "col": 33, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1b4a82393d8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 842, + "line": 45, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 863, + "col": 26, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1b4a82393b8", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 849, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 863, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1b4a8239370", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 849, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 854, + "col": 17, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "getValue", + "isArrow": false, + "referencedMemberDecl": "0x1b4a820e3f8", + "inner": [ + { + "id": "0x1b4a82393a0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 849, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 849, + "col": 12, + "tokLen": 4 + } + }, + "type": { + "qualType": "const Calculator" + }, + "valueCategory": "lvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x1b4a8239350", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 849, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 849, + "col": 12, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1b4a8238000", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/complex_output.csv b/clang-ast-mapper/complex_output.csv new file mode 100644 index 0000000000000..ccf4d6d29258d --- /dev/null +++ b/clang-ast-mapper/complex_output.csv @@ -0,0 +1,47 @@ +Line,Source Code,AST Nodes,Explanations +1,// Complex C++ example with classes and methods,, +2,class Calculator {,CXXConstructorDecl; CXXRecordDecl, +3,private:,AccessSpecDecl, +4, int value;,FieldDecl, +5,,, +6,public:,AccessSpecDecl, +7, Calculator(int initial) : value(initial) {},CXXConstructorDecl, +8,,, +9," int add(int a, int b) {",ParmVarDecl; CXXMethodDecl, +10, return a + b;,ReturnStmt, +11, },, +12,,, +13," int multiply(int a, int b) {",ParmVarDecl; CXXMethodDecl, +14, return a * b;,ReturnStmt, +15, },, +16,,, +17, void setValue(int newValue) {,ParmVarDecl; CXXMethodDecl, +18, value = newValue;,BinaryOperator, +19, },, +20,,, +21, int getValue() const {,CXXMethodDecl; CompoundStmt, +22, return value;,ReturnStmt, +23, },, +24,};,, +25,,, +26,int main() {,FunctionDecl; CompoundStmt, +27, Calculator calc(10);,DeclStmt, +28,,, +29, int x = 5;,DeclStmt, +30, int y = 3;,DeclStmt, +31,,, +32, if (x > y) {,IfStmt; BinaryOperator, +33," int result = calc.add(x, y);",DeclStmt, +34, calc.setValue(result);,CXXMemberCallExpr, +35, } else {,CompoundStmt, +36," int result = calc.multiply(x, y);",DeclStmt, +37, calc.setValue(result);,CXXMemberCallExpr, +38, },, +39,,, +40, for (int i = 0; i < 3; i++) {,ForStmt; DeclStmt, +41, int current = calc.getValue();,DeclStmt, +42, calc.setValue(current + 1);,CXXMemberCallExpr, +43, },, +44,,, +45, return calc.getValue();,ReturnStmt, +46,},, diff --git a/clang-ast-mapper/complex_output_interpretation.md b/clang-ast-mapper/complex_output_interpretation.md new file mode 100644 index 0000000000000..655c11603b758 --- /dev/null +++ b/clang-ast-mapper/complex_output_interpretation.md @@ -0,0 +1,50 @@ +# AST Analysis for C++ Code + +## Code Summary +This code defines a C++ class with 6 methods/constructors and contains logic for data manipulation and processing. + +## Code Structure +The C++ code has been analyzed using Clang's AST system, revealing the following structure: +- **Function Declarations**: The code contains function/method declarations which define its main structure +- **Parameter Variables**: Functions have parameter declarations indicating data passed between functions +- **Code Blocks**: Contains compound statements (blocks of code within curly braces) +- **Return Statements**: Functions include return statements to provide output values +- **Variable Declarations**: The code declares local variables to store and manipulate data +- **Control Flow**: Contains conditional or loop structures to control program execution +- **Classes/Structs**: The code defines custom data types with methods and fields + +## AST Structure Summary +This code follows a typical C++ structure with: + +- Class definitions with member methods +- Classes containing member variables (fields) +- Function definitions that contain variable declarations +- Method implementations with local variable usage +- Function/method calls between defined components +- Variable manipulation followed by return statements +- Control flow structures to manage program execution paths + +## AST Node Types Explained +The following AST nodes were found in the code: + +- **DeclStmt** (7 occurrences): Declaration statement - contains one or more variable declarations +- **CXXMethodDecl** (4 occurrences): C++ method declaration - a function that belongs to a class or struct +- **ReturnStmt** (4 occurrences): Return statement - specifies the value to be returned from a function +- **ParmVarDecl** (3 occurrences): Parameter variable declaration - variables that receive values passed to functions +- **CompoundStmt** (3 occurrences): Compound statement - a block of code enclosed in braces {} +- **CXXMemberCallExpr** (3 occurrences): C++ member function call - invokes a method on an object +- **CXXConstructorDecl** (2 occurrences): C++ constructor declaration - special method that initializes objects of a class +- **AccessSpecDecl** (2 occurrences): Access specifier - public, private, or protected sections in a class +- **BinaryOperator** (2 occurrences): Binary operator - operations that use two operands like +, -, *, /, etc. +- **CXXRecordDecl** (1 occurrences): C++ class/struct declaration - defines a user-defined type +- **FieldDecl** (1 occurrences): Field declaration - member variables of a class or struct +- **FunctionDecl** (1 occurrences): Function declaration - defines a function with its return type, name, and parameters +- **IfStmt** (1 occurrences): If statement - conditional execution based on a boolean expression +- **ForStmt** (1 occurrences): For loop - iteration with initialization, condition, and increment steps + +## Code Quality Observations +- The AST structure indicates well-formed C++ code without syntax errors +- The class has multiple methods, suggesting good encapsulation of functionality + +## Functional Summary +The code implements a complete C++ class with constructors, methods, and member variables. This suggests an object-oriented design with proper encapsulation of data and behavior. The code contains conditional logic and/or loops, indicating non-trivial algorithmic processing. \ No newline at end of file diff --git a/clang-ast-mapper/docs/API.md b/clang-ast-mapper/docs/API.md new file mode 100644 index 0000000000000..83cf36883a8b2 --- /dev/null +++ b/clang-ast-mapper/docs/API.md @@ -0,0 +1,255 @@ +# API Documentation + +## Overview + +The Clang AST Line Mapper provides a Python API for mapping C++ source lines to their corresponding AST nodes. The API consists of three main modules: + +## Modules + +### ast_parser.py + +The core module for parsing Clang AST JSON output. + +#### ASTParser Class + +```python +class ASTParser: + def __init__(self) + def generate_ast_json(self, cpp_file) -> str + def parse_ast_file(self, ast_file, cpp_file) -> dict + def get_statistics(self) -> dict +``` + +**Methods:** + +- `generate_ast_json(cpp_file)`: Generates AST JSON using Clang + - **Parameters:** `cpp_file` (str) - Path to C++ source file + - **Returns:** Path to generated AST JSON file or None if failed + +- `parse_ast_file(ast_file, cpp_file)`: Parses AST JSON and creates line mappings + - **Parameters:** + - `ast_file` (str) - Path to AST JSON file + - `cpp_file` (str) - Path to original C++ file + - **Returns:** Dictionary mapping line numbers to AST node types + +- `get_statistics()`: Gets statistics about parsed AST + - **Returns:** Dictionary with parsing statistics + +**Example:** + +```python +from ast_parser import ASTParser + +parser = ASTParser() +ast_file = parser.generate_ast_json("example.cpp") +if ast_file: + line_mappings = parser.parse_ast_file(ast_file, "example.cpp") + stats = parser.get_statistics() +``` + +### source_annotator.py + +Module for annotating source code with AST information. + +#### SourceAnnotator Class + +```python +class SourceAnnotator: + def __init__(self) + def annotate_source(self, cpp_file, line_mappings, include_explanations=False, explanations_dict=None) -> str + def side_by_side_view(self, cpp_file, line_mappings, explanations_dict=None) -> str + def generate_html_output(self, cpp_file, line_mappings, explanations_dict=None) -> str + def generate_markdown_output(self, cpp_file, line_mappings, explanations_dict=None) -> str +``` + +**Methods:** + +- `annotate_source(cpp_file, line_mappings, include_explanations=False, explanations_dict=None)`: Annotates source with AST info + - **Parameters:** + - `cpp_file` (str) - Path to C++ source file + - `line_mappings` (dict) - Line number to AST nodes mapping + - `include_explanations` (bool) - Whether to include explanations + - `explanations_dict` (dict) - Dictionary of node explanations + - **Returns:** Annotated source as string + +- `side_by_side_view(cpp_file, line_mappings, explanations_dict=None)`: Generates side-by-side view + - **Parameters:** Same as annotate_source + - **Returns:** Side-by-side view as string + +- `generate_html_output(cpp_file, line_mappings, explanations_dict=None)`: Generates HTML output + - **Parameters:** Same as annotate_source + - **Returns:** HTML output as string + +- `generate_markdown_output(cpp_file, line_mappings, explanations_dict=None)`: Generates Markdown output + - **Parameters:** Same as annotate_source + - **Returns:** Markdown output as string + +**Example:** + +```python +from source_annotator import SourceAnnotator + +annotator = SourceAnnotator() +annotated = annotator.annotate_source( + "example.cpp", + line_mappings, + include_explanations=True, + explanations_dict=explanations +) +``` + +### node_explanations.py + +Module for providing human-readable explanations of AST nodes. + +#### NodeExplanations Class + +```python +class NodeExplanations: + def __init__(self) + def get_explanation(self, node_kind) -> str + def get_all_explanations(self) -> dict + def add_explanation(self, node_kind, explanation) + def get_categories(self) -> dict +``` + +**Methods:** + +- `get_explanation(node_kind)`: Gets explanation for a specific node type + - **Parameters:** `node_kind` (str) - AST node type + - **Returns:** Human-readable explanation + +- `get_all_explanations()`: Gets all explanations + - **Returns:** Dictionary of all node explanations + +- `add_explanation(node_kind, explanation)`: Adds or updates explanation + - **Parameters:** + - `node_kind` (str) - AST node type + - `explanation` (str) - Human-readable explanation + +- `get_categories()`: Gets explanations grouped by categories + - **Returns:** Dictionary with categorized explanations + +**Example:** + +```python +from node_explanations import NodeExplanations + +explanations = NodeExplanations() +explanation = explanations.get_explanation("FunctionDecl") +all_explanations = explanations.get_all_explanations() +``` + +## Data Structures + +### Line Mappings + +Line mappings are dictionaries that map line numbers (int) to lists of AST node types (list of str): + +```python +line_mappings = { + 1: ['FunctionDecl', 'ParmVarDecl'], + 2: ['ReturnStmt'], + 5: ['FunctionDecl'], + 6: ['DeclStmt', 'CallExpr'], + 7: ['ReturnStmt'] +} +``` + +### Statistics + +Statistics are dictionaries containing parsing information: + +```python +statistics = { + 'total_lines_with_ast': 10, + 'total_ast_nodes': 25, + 'avg_nodes_per_line': 2.5, + 'node_type_counts': { + 'FunctionDecl': 3, + 'ReturnStmt': 2, + 'DeclStmt': 5 + }, + 'most_common_nodes': [ + ('DeclStmt', 5), + ('FunctionDecl', 3), + ('ReturnStmt', 2) + ] +} +``` + +## Error Handling + +All methods handle errors gracefully: + +- File not found errors return appropriate error messages +- Invalid JSON returns None or error strings +- Missing Clang installation is detected and reported +- Timeout errors are handled for long-running operations + +## Integration Example + +Complete example of using the API: + +```python +from ast_parser import ASTParser +from source_annotator import SourceAnnotator +from node_explanations import NodeExplanations + +# Initialize components +parser = ASTParser() +annotator = SourceAnnotator() +explanations = NodeExplanations() + +# Process file +cpp_file = "example.cpp" +ast_file = parser.generate_ast_json(cpp_file) + +if ast_file: + # Parse AST + line_mappings = parser.parse_ast_file(ast_file, cpp_file) + + # Get statistics + stats = parser.get_statistics() + print(f"Processed {stats['total_lines_with_ast']} lines with AST") + + # Annotate source + annotated = annotator.annotate_source( + cpp_file, + line_mappings, + include_explanations=True, + explanations_dict=explanations.get_all_explanations() + ) + + print(annotated) + + # Generate HTML output + html_output = annotator.generate_html_output( + cpp_file, + line_mappings, + explanations_dict=explanations.get_all_explanations() + ) + + with open("output.html", "w") as f: + f.write(html_output) +``` + +## Thread Safety + +The API is designed to be thread-safe for read operations. However, for write operations (like generating AST files), it's recommended to use appropriate locking mechanisms in multi-threaded environments. + +## Performance Considerations + +- AST generation is the slowest operation (depends on Clang compilation) +- JSON parsing is relatively fast +- Line mapping creation is O(n) where n is the number of AST nodes +- Source annotation is O(m) where m is the number of source lines + +## Extension Points + +The API can be extended by: + +1. Adding new output formats in `SourceAnnotator` +2. Adding new node explanations in `NodeExplanations` +3. Adding new parsing strategies in `ASTParser` +4. Creating new analysis tools using the line mappings diff --git a/clang-ast-mapper/docs/ARCHITECTURE.md b/clang-ast-mapper/docs/ARCHITECTURE.md new file mode 100644 index 0000000000000..79ce35061dc16 --- /dev/null +++ b/clang-ast-mapper/docs/ARCHITECTURE.md @@ -0,0 +1,319 @@ +# Architecture Overview + +## System Design + +The Clang AST Line Mapper is designed as a modular system that transforms C++ source code into annotated output showing the relationship between source lines and AST nodes. + +``` +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ C++ Source โ”‚โ”€โ”€โ”€โ–ถโ”‚ Clang AST โ”‚โ”€โ”€โ”€โ–ถโ”‚ AST JSON โ”‚ +โ”‚ File โ”‚ โ”‚ Generator โ”‚ โ”‚ File โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Annotated โ”‚โ—€โ”€โ”€โ”€โ”‚ Source โ”‚โ—€โ”€โ”€โ”€โ”‚ AST Parser โ”‚ +โ”‚ Output โ”‚ โ”‚ Annotator โ”‚ โ”‚ & Mapper โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ–ฒ โ–ฒ + โ”‚ โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ Node โ”‚ โ”‚ Line-to-Node โ”‚ + โ”‚ Explanations โ”‚ โ”‚ Mappings โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +## Core Components + +### 1. AST Parser (`ast_parser.py`) + +**Responsibilities:** +- Generate AST JSON from C++ source using Clang +- Parse AST JSON and extract relevant information +- Create line-to-node mappings +- Handle different Clang configurations and environments + +**Key Methods:** +- `generate_ast_json()`: Invokes Clang with appropriate flags +- `parse_ast_file()`: Processes JSON and creates mappings +- `_collect_nodes_by_line()`: Recursively traverses AST nodes +- `_extract_line_number()`: Extracts line information from AST nodes + +**Data Flow:** +``` +C++ Source โ†’ Clang Process โ†’ AST JSON โ†’ JSON Parser โ†’ Line Mappings +``` + +### 2. Source Annotator (`source_annotator.py`) + +**Responsibilities:** +- Read source files and combine with AST information +- Generate multiple output formats (annotated, side-by-side, HTML, Markdown) +- Handle formatting and presentation logic +- Provide extensible output generation + +**Key Methods:** +- `annotate_source()`: Creates inline annotations +- `side_by_side_view()`: Creates columnar output +- `generate_html_output()`: Creates styled HTML +- `generate_markdown_output()`: Creates Markdown format + +**Data Flow:** +``` +Source Lines + Line Mappings + Explanations โ†’ Formatted Output +``` + +### 3. Node Explanations (`node_explanations.py`) + +**Responsibilities:** +- Provide human-readable explanations for AST node types +- Maintain comprehensive database of node descriptions +- Support categorization and organization of explanations +- Allow extension and customization + +**Key Methods:** +- `get_explanation()`: Retrieves explanation for specific node +- `get_all_explanations()`: Returns complete explanation dictionary +- `get_categories()`: Groups explanations by type + +**Data Structure:** +```python +explanations = { + 'FunctionDecl': 'function declaration', + 'ReturnStmt': 'return statement', + 'BinaryOperator': 'binary operator (e.g., +, -, *, /)', + # ... hundreds of other mappings +} +``` + +### 4. CLI Interface (`ast_line_mapper.py`) + +**Responsibilities:** +- Command-line argument parsing +- Coordinate between components +- Handle user interactions and error reporting +- Provide extensible command structure + +**Key Methods:** +- `main()`: Entry point and argument parsing +- `process_file()`: Main processing pipeline +- `_output_*()`: Format-specific output handlers + +## Design Patterns + +### 1. Strategy Pattern +The `SourceAnnotator` uses strategy pattern for different output formats: +- `annotate_source()` - Inline annotation strategy +- `side_by_side_view()` - Columnar display strategy +- `generate_html_output()` - HTML generation strategy +- `generate_markdown_output()` - Markdown generation strategy + +### 2. Builder Pattern +The AST parsing process builds line mappings incrementally: +```python +def _collect_nodes_by_line(self, node, current_file): + # Recursively build line mappings + if self._is_from_main_file(loc, range_info, current_file): + self.line_to_nodes[line].append(kind) +``` + +### 3. Factory Pattern +The `ASTParser` tries different Clang command configurations: +```python +clang_commands = [ + f'clang++ -Xclang -ast-dump=json -fsyntax-only "{cpp_file}"', + f'clang -Xclang -ast-dump=json -fsyntax-only "{cpp_file}"', + # ... additional variants +] +``` + +## Data Flow Architecture + +### 1. Input Processing +``` +User Input โ†’ Argument Parser โ†’ File Validation โ†’ AST Generation +``` + +### 2. AST Processing +``` +AST JSON โ†’ JSON Parser โ†’ Node Traversal โ†’ Line Extraction โ†’ Mapping Creation +``` + +### 3. Output Generation +``` +Line Mappings โ†’ Format Selection โ†’ Template Processing โ†’ Output Generation +``` + +## Error Handling Strategy + +### 1. Graceful Degradation +- If Clang is not available, provide helpful setup instructions +- If AST generation fails, suggest alternative approaches +- If parsing fails, provide detailed error information + +### 2. Layered Error Handling +```python +try: + ast_file = self.parser.generate_ast_json(cpp_file) + if not ast_file: + return False # Clang error already reported + + line_mappings = self.parser.parse_ast_file(ast_file, cpp_file) + if not line_mappings: + print("โŒ Failed to parse AST file") + return False + +except Exception as e: + print(f"โŒ Unexpected error: {e}") + return False +``` + +### 3. User-Friendly Messages +- Use emojis and clear formatting for status messages +- Provide actionable error messages with solutions +- Include setup help for common configuration issues + +## Performance Considerations + +### 1. Bottlenecks +- **AST Generation**: Clang compilation is the slowest operation +- **JSON Parsing**: Large AST files can be memory-intensive +- **Line Mapping**: O(n) traversal where n = number of AST nodes + +### 2. Optimizations +- **Caching**: Generated AST files can be reused +- **Filtering**: Only process nodes from main file (not includes) +- **Streaming**: Process large files in chunks if needed + +### 3. Memory Management +- Clear intermediate data structures after processing +- Use generators for large file processing +- Implement file cleanup for temporary files + +## Extensibility Points + +### 1. New Output Formats +Add new methods to `SourceAnnotator`: +```python +def generate_xml_output(self, cpp_file, line_mappings, explanations_dict=None): + # Implementation for XML format + pass +``` + +### 2. New AST Processors +Extend `ASTParser` for specialized processing: +```python +def analyze_complexity(self, line_mappings): + # Analyze code complexity based on AST nodes + pass +``` + +### 3. New Explanation Categories +Extend `NodeExplanations` with domain-specific explanations: +```python +def add_domain_explanations(self, domain): + # Add explanations for specific domains (embedded, web, etc.) + pass +``` + +### 4. New CLI Commands +Extend main CLI with subcommands: +```python +parser.add_subcommand('analyze', help='Analyze code complexity') +parser.add_subcommand('compare', help='Compare AST between files') +``` + +## Configuration Management + +### 1. Environment Detection +```python +# Detect Windows vs. Linux/macOS +if os.name == 'nt': + # Windows-specific Clang paths + pass +else: + # Unix-specific Clang paths + pass +``` + +### 2. Clang Configuration +```python +# Try multiple Clang configurations +clang_configs = [ + {'cmd': 'clang++', 'flags': ['-std=c++17']}, + {'cmd': 'clang', 'flags': ['-std=c11']}, + # ... more configurations +] +``` + +### 3. User Preferences +Future extension could include configuration file support: +```python +# ~/.clang-ast-mapper.conf +[clang] +executable = /usr/local/bin/clang++ +flags = -std=c++20 -Wall + +[output] +default_format = side-by-side +include_explanations = true +``` + +## Testing Strategy + +### 1. Unit Tests +- Test individual components in isolation +- Mock external dependencies (Clang, file system) +- Test error conditions and edge cases + +### 2. Integration Tests +- Test complete workflows end-to-end +- Test with real Clang installation +- Test different file types and configurations + +### 3. Performance Tests +- Measure processing time for different file sizes +- Test memory usage with large AST files +- Benchmark different output formats + +## Security Considerations + +### 1. Input Validation +- Validate file paths to prevent directory traversal +- Sanitize user input before passing to shell commands +- Limit file sizes to prevent resource exhaustion + +### 2. Command Injection Prevention +```python +# Use subprocess with argument lists, not shell strings +subprocess.run(['clang++', '-Xclang', '-ast-dump=json', cpp_file]) +``` + +### 3. Temporary File Handling +- Use secure temporary file creation +- Clean up temporary files after processing +- Handle permissions appropriately + +## Future Enhancements + +### 1. Language Support +- Support for C files (not just C++) +- Support for Objective-C and Objective-C++ +- Support for other Clang-supported languages + +### 2. Advanced Analysis +- Control flow analysis +- Data flow analysis +- Dependency analysis +- Code complexity metrics + +### 3. Integration Features +- IDE plugins (VS Code, CLion, etc.) +- Build system integration (CMake, Make, etc.) +- Continuous integration support + +### 4. Visualization +- Interactive HTML output with collapsible sections +- Graphical AST visualization +- Syntax highlighting in output +- Export to documentation formats diff --git a/clang-ast-mapper/docs/EXAMPLES.md b/clang-ast-mapper/docs/EXAMPLES.md new file mode 100644 index 0000000000000..73908ff96f40b --- /dev/null +++ b/clang-ast-mapper/docs/EXAMPLES.md @@ -0,0 +1,852 @@ +# Detailed Examples + +This document provides comprehensive examples of using the Clang AST Line Mapper tool. + +## Table of Contents + +1. [Basic Usage Examples](#basic-usage-examples) +2. [Advanced C++ Features](#advanced-c-features) +3. [Output Format Examples](#output-format-examples) +4. [API Usage Examples](#api-usage-examples) +5. [Integration Examples](#integration-examples) + +## Basic Usage Examples + +### Example 1: Simple Function + +**Input (`examples/simple.cpp`):** +```cpp +int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +} +``` + +**Command:** +```bash +python ast_line_mapper.py examples/simple.cpp +``` + +**Output:** +``` +============================================================ +AST-ANNOTATED SOURCE: examples/simple.cpp +============================================================ + + 1: int add(int a, int b) { + AST: FunctionDecl, ParmVarDecl + + 2: return a + b; + AST: ReturnStmt + + 3: } + + 4: + 5: int main() { + AST: FunctionDecl, CompoundStmt + + 6: int result = add(5, 3); + AST: DeclStmt + + 7: return 0; + AST: ReturnStmt + + 8: } +``` + +### Example 2: With Explanations + +**Command:** +```bash +python ast_line_mapper.py examples/simple.cpp --explanations +``` + +**Output:** +``` +============================================================ +AST-ANNOTATED SOURCE: examples/simple.cpp +============================================================ + + 1: int add(int a, int b) { + AST: FunctionDecl, ParmVarDecl + โ†’ FunctionDecl: function declaration + โ†’ ParmVarDecl: parameter variable declaration + + 2: return a + b; + AST: ReturnStmt + โ†’ ReturnStmt: return statement + + 3: } + + 4: + 5: int main() { + AST: FunctionDecl, CompoundStmt + โ†’ FunctionDecl: function declaration + โ†’ CompoundStmt: compound statement (block) + + 6: int result = add(5, 3); + AST: DeclStmt + โ†’ DeclStmt: declaration statement + + 7: return 0; + AST: ReturnStmt + โ†’ ReturnStmt: return statement + + 8: } +``` + +### Example 3: Side-by-Side View + +**Command:** +```bash +python ast_line_mapper.py examples/simple.cpp --side-by-side +``` + +**Output:** +``` +==================================================================================================== +SIDE-BY-SIDE VIEW: examples/simple.cpp +==================================================================================================== +SOURCE CODE AST NODES +------------------------------------------------------------ ---------------------------------------- + 1: int add(int a, int b) { AST: FunctionDecl, ParmVarDecl + 2: return a + b; AST: ReturnStmt + 3: } + 4: + 5: int main() { AST: FunctionDecl, CompoundStmt + 6: int result = add(5, 3); AST: DeclStmt + 7: return 0; AST: ReturnStmt + 8: } +``` + +## Advanced C++ Features + +### Example 4: Classes and Methods + +**Input (`examples/complex.cpp`):** +```cpp +class Calculator { +private: + int value; + +public: + Calculator(int initial) : value(initial) {} + + int add(int a, int b) { + return a + b; + } + + void setValue(int newValue) { + value = newValue; + } + + int getValue() const { + return value; + } +}; + +int main() { + Calculator calc(10); + int result = calc.add(5, 3); + calc.setValue(result); + return calc.getValue(); +} +``` + +**Command:** +```bash +python ast_line_mapper.py examples/complex.cpp --explanations +``` + +**Output:** +``` +============================================================ +AST-ANNOTATED SOURCE: examples/complex.cpp +============================================================ + + 1: class Calculator { + AST: CXXRecordDecl + โ†’ CXXRecordDecl: C++ class/struct declaration + + 2: private: + AST: AccessSpecDecl + โ†’ AccessSpecDecl: access specifier (public/private/protected) + + 3: int value; + AST: FieldDecl + โ†’ FieldDecl: field declaration + + 4: + 5: public: + AST: AccessSpecDecl + โ†’ AccessSpecDecl: access specifier (public/private/protected) + + 6: Calculator(int initial) : value(initial) {} + AST: CXXConstructorDecl + โ†’ CXXConstructorDecl: C++ constructor declaration + + 7: + 8: int add(int a, int b) { + AST: CXXMethodDecl, ParmVarDecl + โ†’ CXXMethodDecl: C++ method declaration + โ†’ ParmVarDecl: parameter variable declaration + + 9: return a + b; + AST: ReturnStmt + โ†’ ReturnStmt: return statement + + 10: } +``` + +### Example 5: Templates + +**Input (`examples/templates.cpp`):** +```cpp +template +class Container { +private: + T data; + +public: + Container(const T& value) : data(value) {} + + T getValue() const { + return data; + } +}; + +template +T max(const T& a, const T& b) { + return (a > b) ? a : b; +} + +int main() { + Container intContainer(42); + int maxValue = max(10, 20); + return maxValue; +} +``` + +**Command:** +```bash +python ast_line_mapper.py examples/templates.cpp --explanations +``` + +**Output:** +``` +============================================================ +AST-ANNOTATED SOURCE: examples/templates.cpp +============================================================ + + 1: template + AST: ClassTemplateDecl + โ†’ ClassTemplateDecl: class template declaration + + 2: class Container { + AST: CXXRecordDecl + โ†’ CXXRecordDecl: C++ class/struct declaration + + 3: private: + AST: AccessSpecDecl + โ†’ AccessSpecDecl: access specifier (public/private/protected) + + 4: T data; + AST: FieldDecl + โ†’ FieldDecl: field declaration + + 5: + 6: public: + AST: AccessSpecDecl + โ†’ AccessSpecDecl: access specifier (public/private/protected) + + 7: Container(const T& value) : data(value) {} + AST: CXXConstructorDecl + โ†’ CXXConstructorDecl: C++ constructor declaration + + 8: + 9: T getValue() const { + AST: CXXMethodDecl, CompoundStmt + โ†’ CXXMethodDecl: C++ method declaration + โ†’ CompoundStmt: compound statement (block) + + 10: return data; + AST: ReturnStmt + โ†’ ReturnStmt: return statement + + 11: } +``` + +### Example 6: Control Flow + +**Input (`examples/control_flow.cpp`):** +```cpp +int main() { + int x = 10; + int y = 20; + + if (x < y) { + x = x + y; + } else { + x = x - y; + } + + for (int i = 0; i < 5; i++) { + x = x * 2; + } + + while (x > 100) { + x = x / 2; + } + + return x; +} +``` + +**Command:** +```bash +python ast_line_mapper.py examples/control_flow.cpp --explanations +``` + +**Output:** +``` +============================================================ +AST-ANNOTATED SOURCE: examples/control_flow.cpp +============================================================ + + 1: int main() { + AST: FunctionDecl, CompoundStmt + โ†’ FunctionDecl: function declaration + โ†’ CompoundStmt: compound statement (block) + + 2: int x = 10; + AST: DeclStmt + โ†’ DeclStmt: declaration statement + + 3: int y = 20; + AST: DeclStmt + โ†’ DeclStmt: declaration statement + + 4: + 5: if (x < y) { + AST: IfStmt, BinaryOperator + โ†’ IfStmt: if statement + โ†’ BinaryOperator: binary operator (e.g., +, -, *, /, ==, !=) + + 6: x = x + y; + AST: BinaryOperator + โ†’ BinaryOperator: binary operator (e.g., +, -, *, /, ==, !=) + + 7: } else { + AST: CompoundStmt + โ†’ CompoundStmt: compound statement (block) + + 8: x = x - y; + AST: BinaryOperator + โ†’ BinaryOperator: binary operator (e.g., +, -, *, /, ==, !=) + + 9: } + + 10: + 11: for (int i = 0; i < 5; i++) { + AST: ForStmt, DeclStmt + โ†’ ForStmt: for loop statement + โ†’ DeclStmt: declaration statement + + 12: x = x * 2; + AST: BinaryOperator + โ†’ BinaryOperator: binary operator (e.g., +, -, *, /, ==, !=) + + 13: } + + 14: + 15: while (x > 100) { + AST: WhileStmt, BinaryOperator + โ†’ WhileStmt: while loop statement + โ†’ BinaryOperator: binary operator (e.g., +, -, *, /, ==, !=) + + 16: x = x / 2; + AST: BinaryOperator + โ†’ BinaryOperator: binary operator (e.g., +, -, *, /, ==, !=) + + 17: } + + 18: + 19: return x; + AST: ReturnStmt + โ†’ ReturnStmt: return statement + + 20: } +``` + +## Output Format Examples + +### Example 7: JSON Output + +**Command:** +```bash +python ast_line_mapper.py examples/simple.cpp --format json +``` + +**Output:** +```json +{ + "line_mappings": { + "1": ["FunctionDecl", "ParmVarDecl"], + "2": ["ReturnStmt"], + "5": ["FunctionDecl", "CompoundStmt"], + "6": ["DeclStmt"], + "7": ["ReturnStmt"] + }, + "explanations": { + "FunctionDecl": "function declaration", + "ParmVarDecl": "parameter variable declaration", + "ReturnStmt": "return statement", + "CompoundStmt": "compound statement (block)", + "DeclStmt": "declaration statement" + } +} +``` + +### Example 8: Save to File + +**Command:** +```bash +python ast_line_mapper.py examples/simple.cpp --explanations --output result.txt +``` + +**Output:** +``` +๐Ÿ” Processing: examples/simple.cpp +โœ… AST JSON generated: simple_ast.json +โœ… Output saved to: result.txt +``` + +### Example 9: Generate AST Only + +**Command:** +```bash +python ast_line_mapper.py examples/simple.cpp --generate-ast +``` + +**Output:** +``` +๐Ÿ” Processing: examples/simple.cpp +โœ… AST JSON generated: simple_ast.json +``` + +## API Usage Examples + +### Example 10: Basic API Usage + +```python +from ast_parser import ASTParser +from source_annotator import SourceAnnotator +from node_explanations import NodeExplanations + +# Initialize components +parser = ASTParser() +annotator = SourceAnnotator() +explanations = NodeExplanations() + +# Process file +cpp_file = "examples/simple.cpp" +ast_file = parser.generate_ast_json(cpp_file) + +if ast_file: + # Parse AST + line_mappings = parser.parse_ast_file(ast_file, cpp_file) + + # Annotate source + annotated = annotator.annotate_source( + cpp_file, + line_mappings, + include_explanations=True, + explanations_dict=explanations.get_all_explanations() + ) + + print(annotated) +``` + +### Example 11: HTML Generation + +```python +from ast_parser import ASTParser +from source_annotator import SourceAnnotator +from node_explanations import NodeExplanations + +# Initialize components +parser = ASTParser() +annotator = SourceAnnotator() +explanations = NodeExplanations() + +# Process file +cpp_file = "examples/complex.cpp" +ast_file = parser.generate_ast_json(cpp_file) + +if ast_file: + line_mappings = parser.parse_ast_file(ast_file, cpp_file) + + # Generate HTML output + html_output = annotator.generate_html_output( + cpp_file, + line_mappings, + explanations_dict=explanations.get_all_explanations() + ) + + # Save to file + with open("output.html", "w") as f: + f.write(html_output) + + print("HTML output saved to output.html") +``` + +### Example 12: Statistics and Analysis + +```python +from ast_parser import ASTParser + +parser = ASTParser() +cpp_file = "examples/complex.cpp" +ast_file = parser.generate_ast_json(cpp_file) + +if ast_file: + line_mappings = parser.parse_ast_file(ast_file, cpp_file) + stats = parser.get_statistics() + + print("=== AST Statistics ===") + print(f"Total lines with AST: {stats['total_lines_with_ast']}") + print(f"Total AST nodes: {stats['total_ast_nodes']}") + print(f"Average nodes per line: {stats['avg_nodes_per_line']:.2f}") + + print("\n=== Most Common Node Types ===") + for node_type, count in stats['most_common_nodes']: + print(f"{node_type}: {count}") +``` + +### Example 13: Custom Explanations + +```python +from node_explanations import NodeExplanations + +explanations = NodeExplanations() + +# Add custom explanations +explanations.add_explanation( + "CustomNode", + "my custom AST node explanation" +) + +# Get categorized explanations +categories = explanations.get_categories() +for category, nodes in categories.items(): + print(f"\n=== {category} ===") + for node_type, explanation in nodes[:5]: # Show first 5 + print(f"{node_type}: {explanation}") +``` + +## Integration Examples + +### Example 14: Batch Processing + +```python +import os +import glob +from ast_parser import ASTParser +from source_annotator import SourceAnnotator +from node_explanations import NodeExplanations + +def process_directory(directory_path, output_dir): + """Process all .cpp files in a directory.""" + parser = ASTParser() + annotator = SourceAnnotator() + explanations = NodeExplanations() + + # Find all .cpp files + cpp_files = glob.glob(os.path.join(directory_path, "*.cpp")) + + for cpp_file in cpp_files: + print(f"Processing: {cpp_file}") + + # Generate AST + ast_file = parser.generate_ast_json(cpp_file) + if not ast_file: + print(f" โŒ Failed to generate AST for {cpp_file}") + continue + + # Parse and annotate + line_mappings = parser.parse_ast_file(ast_file, cpp_file) + if not line_mappings: + print(f" โŒ Failed to parse AST for {cpp_file}") + continue + + # Generate HTML output + html_output = annotator.generate_html_output( + cpp_file, + line_mappings, + explanations_dict=explanations.get_all_explanations() + ) + + # Save output + base_name = os.path.basename(cpp_file).replace('.cpp', '') + output_file = os.path.join(output_dir, f"{base_name}_annotated.html") + + with open(output_file, 'w') as f: + f.write(html_output) + + print(f" โœ… Generated: {output_file}") + +# Usage +process_directory("examples/", "output/") +``` + +### Example 15: Build System Integration + +```python +#!/usr/bin/env python3 +""" +Integration script for CMake build system. +Generates AST annotations for all source files in a project. +""" + +import os +import sys +import json +import subprocess +from pathlib import Path + +def find_cpp_files(build_dir): + """Find all C++ source files from compile_commands.json.""" + compile_commands_file = os.path.join(build_dir, "compile_commands.json") + + if not os.path.exists(compile_commands_file): + print("โŒ compile_commands.json not found. Enable CMAKE_EXPORT_COMPILE_COMMANDS.") + return [] + + with open(compile_commands_file, 'r') as f: + compile_commands = json.load(f) + + cpp_files = [] + for entry in compile_commands: + if entry['file'].endswith(('.cpp', '.cc', '.cxx')): + cpp_files.append(entry['file']) + + return cpp_files + +def generate_project_report(build_dir, output_dir): + """Generate AST report for entire project.""" + from ast_parser import ASTParser + from source_annotator import SourceAnnotator + from node_explanations import NodeExplanations + + # Find source files + cpp_files = find_cpp_files(build_dir) + if not cpp_files: + return + + # Initialize components + parser = ASTParser() + annotator = SourceAnnotator() + explanations = NodeExplanations() + + # Process each file + results = [] + for cpp_file in cpp_files: + print(f"Processing: {cpp_file}") + + ast_file = parser.generate_ast_json(cpp_file) + if ast_file: + line_mappings = parser.parse_ast_file(ast_file, cpp_file) + if line_mappings: + stats = parser.get_statistics() + results.append({ + 'file': cpp_file, + 'stats': stats, + 'line_mappings': line_mappings + }) + + # Generate summary report + generate_summary_report(results, output_dir) + +def generate_summary_report(results, output_dir): + """Generate a summary report of AST analysis.""" + os.makedirs(output_dir, exist_ok=True) + + total_files = len(results) + total_lines = sum(r['stats']['total_lines_with_ast'] for r in results) + total_nodes = sum(r['stats']['total_ast_nodes'] for r in results) + + # Generate HTML report + html_content = f""" + + Project AST Analysis Report + +

Project AST Analysis Report

+

Summary

+
    +
  • Total Files: {total_files}
  • +
  • Total Lines with AST: {total_lines}
  • +
  • Total AST Nodes: {total_nodes}
  • +
  • Average Nodes per File: {total_nodes / total_files:.2f}
  • +
+ +

Per-File Analysis

+ + + + + + + + """ + + for result in results: + stats = result['stats'] + html_content += f""" + + + + + + + """ + + html_content += """ +
FileLines with ASTTotal NodesAvg Nodes/Line
{result['file']}{stats['total_lines_with_ast']}{stats['total_ast_nodes']}{stats['avg_nodes_per_line']:.2f}
+ + + """ + + with open(os.path.join(output_dir, "ast_report.html"), 'w') as f: + f.write(html_content) + + print(f"โœ… Summary report generated: {output_dir}/ast_report.html") + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: python build_integration.py ") + sys.exit(1) + + build_dir = sys.argv[1] + output_dir = sys.argv[2] + + generate_project_report(build_dir, output_dir) +``` + +### Example 16: CI/CD Integration + +```bash +#!/bin/bash +# ci_ast_check.sh - CI/CD script for AST analysis + +set -e + +echo "=== AST Analysis CI Check ===" + +# Configuration +SOURCE_DIR="src" +OUTPUT_DIR="ast_analysis" +REPORT_FILE="ast_report.json" + +# Create output directory +mkdir -p "$OUTPUT_DIR" + +# Find all C++ files +find "$SOURCE_DIR" -name "*.cpp" -o -name "*.cc" -o -name "*.cxx" | while read -r cpp_file; do + echo "Analyzing: $cpp_file" + + # Generate AST analysis + python ast_line_mapper.py "$cpp_file" --format json --output "$OUTPUT_DIR/$(basename "$cpp_file").json" + + # Check for critical issues (example: too many nodes per line) + python -c " +import json +import sys + +with open('$OUTPUT_DIR/$(basename "$cpp_file").json', 'r') as f: + data = json.load(f) + +line_mappings = data['line_mappings'] +for line, nodes in line_mappings.items(): + if len(nodes) > 10: # Threshold for complexity + print(f'WARNING: Line {line} has {len(nodes)} AST nodes (high complexity)') + +# Example: Check for specific patterns +problematic_patterns = ['BinaryOperator', 'UnaryOperator', 'ConditionalOperator'] +for line, nodes in line_mappings.items(): + operator_count = sum(1 for node in nodes if node in problematic_patterns) + if operator_count > 3: + print(f'WARNING: Line {line} has {operator_count} operators (consider refactoring)') +" +done + +echo "=== AST Analysis Complete ===" +``` + +## Troubleshooting Examples + +### Example 17: Handling Missing Headers + +```cpp +// problematic.cpp - file with missing headers +#include // May not be found +#include // May not be found + +int main() { + std::vector numbers = {1, 2, 3}; + std::cout << "Size: " << numbers.size() << std::endl; + return 0; +} +``` + +**Solution 1: Use without standard library** +```cpp +// simple_version.cpp +int main() { + int numbers[] = {1, 2, 3}; + int size = 3; + // printf equivalent or custom output + return 0; +} +``` + +**Solution 2: Specify include paths** +```bash +# For Windows with Visual Studio +python ast_line_mapper.py problematic.cpp + +# The tool will automatically try different include paths +``` + +### Example 18: Debugging AST Generation + +```python +from ast_parser import ASTParser +import json + +parser = ASTParser() +cpp_file = "examples/debug.cpp" + +# Generate AST with debug info +ast_file = parser.generate_ast_json(cpp_file) + +if ast_file: + # Examine raw AST JSON + with open(ast_file, 'r') as f: + ast_data = json.load(f) + + print("=== Raw AST Structure ===") + print(f"Root node kind: {ast_data.get('kind')}") + print(f"Root node ID: {ast_data.get('id')}") + + # Show first few child nodes + if 'inner' in ast_data: + print(f"Child nodes: {len(ast_data['inner'])}") + for i, child in enumerate(ast_data['inner'][:3]): + print(f" Child {i}: {child.get('kind')} at line {child.get('loc', {}).get('line', 'unknown')}") +``` + +These examples demonstrate the full capabilities of the Clang AST Line Mapper tool, from basic usage to advanced integration scenarios. The tool provides flexibility for different use cases while maintaining ease of use for simple scenarios. diff --git a/clang-ast-mapper/docs/ai_interpretation.md b/clang-ast-mapper/docs/ai_interpretation.md new file mode 100644 index 0000000000000..94faf28bba057 --- /dev/null +++ b/clang-ast-mapper/docs/ai_interpretation.md @@ -0,0 +1,89 @@ +# AI Interpretation of AST Data + +This document provides additional information about the AI interpretation feature in the Clang AST Line Mapper tool. + +## Overview + +The AI interpretation feature allows you to analyze your code's AST data using artificial intelligence. The tool uses a free-tier AI API to provide insights about your code structure based on the AST mapping. + +## How It Works + +1. The tool first generates the AST mapping for your C++ code +2. It saves the mapping data in CSV format +3. The AI interpreter analyzes this CSV data using a local Transformers model +4. It generates a detailed explanation of your code's structure +5. The analysis is saved as a Markdown file + +## Usage + +To use the AI interpretation feature: + +```bash +python ast_line_mapper.py example.cpp --format csv --output result.csv --interpret +``` + +### Model Configuration + +You can configure which model to use by setting the `AST_MAPPER_MODEL` environment variable: + +```bash +# Windows +set AST_MAPPER_MODEL=gpt2 + +# Linux/macOS +export AST_MAPPER_MODEL=gpt2 +``` + +The default model is `gpt2`, which is small enough to run on most computers and compatible with the text-generation pipeline. + +### Requirements + +To use the AI interpretation feature, you need to install the required packages: + +```bash +pip install -r requirements.txt +``` + +This will install the Hugging Face Transformers library and PyTorch. + +### Default Analysis + +The tool performs a comprehensive analysis using pattern matching that provides detailed insights: + +- **Code Structure**: Identifies key elements like functions, parameters, blocks, and variables +- **AST Structure Summary**: Provides a higher-level view of how the code elements relate +- **AST Node Types Frequency**: Lists all AST nodes with their occurrence counts +- **Code Quality Observations**: Makes basic observations about code complexity and quality + +This analysis provides valuable insights into your code structure based on the AST mapping, making it helpful for understanding how the compiler views your code. + +## Example Interpretation + +Here's an example of what the AI interpretation might look like: + +```markdown +# AST Analysis + +## Code Structure +The code consists of two functions: 'add' and 'main'. The 'add' function takes two parameters and returns their sum. The 'main' function calls 'add' with two variables. + +## Key AST Nodes +- FunctionDecl: Used for both 'add' and 'main' functions +- ParmVarDecl: Represents function parameters in 'add' +- CompoundStmt: Block statements in both functions +- DeclStmt: Variable declarations in 'main' +- ReturnStmt: Return statements in both functions + +## Patterns +The AST shows a simple function call pattern with variable declarations preceding the call. This is a common pattern for simple arithmetic operations. + +## Suggestions +No issues detected. The code has a clean structure with proper function definition and usage patterns. +``` + +## Limitations + +- AI interpretation is only available with CSV output format +- Results will vary depending on the AI model used +- Free-tier APIs may have rate limits or usage restrictions +- AI interpretations are suggestions, not definitive analyses diff --git a/clang-ast-mapper/examples/auto_decltype.cpp b/clang-ast-mapper/examples/auto_decltype.cpp new file mode 100644 index 0000000000000..c04501095b62c --- /dev/null +++ b/clang-ast-mapper/examples/auto_decltype.cpp @@ -0,0 +1,64 @@ +// Modern C++ features focusing on auto and decltype +// This is a self-contained example + +// Type alias +using Integer = int; + +// Function with auto return type +auto getValue() { + return 42; +} + +// Function with trailing return type +auto getDouble(int x) -> double { + return x * 2.0; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +// Class with auto member function +class Calculator { +private: + int value; + +public: + Calculator(int initial) : value(initial) {} + + // Method with auto return type + auto getValue() const { + return value; + } + + // Method with decltype in return type + template + auto multiply(T factor) -> decltype(value * factor) { + return value * factor; + } +}; + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with initializer lists + auto result = add(x, y); + + // Creating objects with auto + auto calc = Calculator(100); + + // Using auto with method returns + auto calcResult = calc.getValue(); + + // Using decltype with templates + auto doubleResult = calc.multiply(2.5); + + return 0; +} diff --git a/clang-ast-mapper/examples/complex.cpp b/clang-ast-mapper/examples/complex.cpp new file mode 100644 index 0000000000000..35647dc663543 --- /dev/null +++ b/clang-ast-mapper/examples/complex.cpp @@ -0,0 +1,46 @@ +// Complex C++ example with classes and methods +class Calculator { +private: + int value; + +public: + Calculator(int initial) : value(initial) {} + + int add(int a, int b) { + return a + b; + } + + int multiply(int a, int b) { + return a * b; + } + + void setValue(int newValue) { + value = newValue; + } + + int getValue() const { + return value; + } +}; + +int main() { + Calculator calc(10); + + int x = 5; + int y = 3; + + if (x > y) { + int result = calc.add(x, y); + calc.setValue(result); + } else { + int result = calc.multiply(x, y); + calc.setValue(result); + } + + for (int i = 0; i < 3; i++) { + int current = calc.getValue(); + calc.setValue(current + 1); + } + + return calc.getValue(); +} diff --git a/clang-ast-mapper/examples/control_flow.cpp b/clang-ast-mapper/examples/control_flow.cpp new file mode 100644 index 0000000000000..d7e5d4feded91 --- /dev/null +++ b/clang-ast-mapper/examples/control_flow.cpp @@ -0,0 +1,49 @@ +// Control flow examples +int main() { + int x = 10; + int y = 20; + int result = 0; + + // If statement + if (x < y) { + result = x + y; + } else if (x > y) { + result = x - y; + } else { + result = x * y; + } + + // Switch statement + switch (result) { + case 10: + result += 5; + break; + case 20: + result += 10; + break; + default: + result += 1; + break; + } + + // While loop + int counter = 0; + while (counter < 5) { + result += counter; + counter++; + } + + // For loop + for (int i = 0; i < 3; i++) { + result *= 2; + } + + // Do-while loop + int j = 0; + do { + result += j; + j++; + } while (j < 2); + + return result; +} diff --git a/clang-ast-mapper/examples/simple.cpp b/clang-ast-mapper/examples/simple.cpp new file mode 100644 index 0000000000000..cf01dad324e9b --- /dev/null +++ b/clang-ast-mapper/examples/simple.cpp @@ -0,0 +1,11 @@ +// Simple C++ example without standard library +int add(int a, int b) { + return a + b; +} + +int main() { + int x = 5; + int y = 3; + int result = add(x, y); + return 0; +} diff --git a/clang-ast-mapper/examples/simple_auto.cpp b/clang-ast-mapper/examples/simple_auto.cpp new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang-ast-mapper/examples/simple_modern.cpp b/clang-ast-mapper/examples/simple_modern.cpp new file mode 100644 index 0000000000000..e04d45d84f54a --- /dev/null +++ b/clang-ast-mapper/examples/simple_modern.cpp @@ -0,0 +1,84 @@ +// Simple modern C++ features example without external headers +// This is a self-contained example + +// Using aliases for types +using Size = unsigned int; + +// Class template +template +class Container { +private: + T* data; + Size capacity; + Size count; + +public: + // Constructor + Container(Size size) : capacity(size), count(0) { + data = new T[size]; + } + + // Destructor + ~Container() { + delete[] data; + } + + // Copy constructor (Rule of Three) + Container(const Container& other) : capacity(other.capacity), count(other.count) { + data = new T[capacity]; + for (Size i = 0; i < count; i++) { + data[i] = other.data[i]; + } + } + + // Method with auto return type + auto size() const { + return count; + } + + // Method to add items + void add(const T& item) { + if (count < capacity) { + data[count++] = item; + } + } + + // Method to get item + T get(Size index) const { + if (index < count) { + return data[index]; + } + return T{}; + } +}; + +// Function template +template +T add(T a, T b) { + return a + b; +} + +// Function with decltype +template +auto addMixed(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Using auto + auto result = add(5, 10); + + // Class template instantiation + Container intContainer(10); + intContainer.add(42); + intContainer.add(123); + + // Auto and decltype usage + auto value = intContainer.get(0); + auto sum = add(value, 100); + + // Using decltype + decltype(sum) anotherValue = intContainer.get(1); + + return 0; +} diff --git a/clang-ast-mapper/examples/templates.cpp b/clang-ast-mapper/examples/templates.cpp new file mode 100644 index 0000000000000..a67f8b245efb0 --- /dev/null +++ b/clang-ast-mapper/examples/templates.cpp @@ -0,0 +1,35 @@ +// Template examples +template +class Container { +private: + T data; + +public: + Container(const T& value) : data(value) {} + + T getValue() const { + return data; + } + + void setValue(const T& value) { + data = value; + } +}; + +template +T max(const T& a, const T& b) { + return (a > b) ? a : b; +} + +int main() { + Container intContainer(42); + Container doubleContainer(3.14); + + int maxInt = max(10, 20); + double maxDouble = max(1.5, 2.5); + + intContainer.setValue(maxInt); + doubleContainer.setValue(maxDouble); + + return intContainer.getValue(); +} diff --git a/clang-ast-mapper/main.py b/clang-ast-mapper/main.py new file mode 100644 index 0000000000000..4c94458d3356e --- /dev/null +++ b/clang-ast-mapper/main.py @@ -0,0 +1,8 @@ +""" +Entry point for the Clang AST Line Mapper web application +""" + +from web_app.app import app + +if __name__ == '__main__': + app.run(debug=True, host='0.0.0.0', port=5000) diff --git a/clang-ast-mapper/modern_output.csv b/clang-ast-mapper/modern_output.csv new file mode 100644 index 0000000000000..d04b668250af5 --- /dev/null +++ b/clang-ast-mapper/modern_output.csv @@ -0,0 +1,85 @@ +Line,Source Code,AST Nodes,Explanations +1,// Simple modern C++ features example without external headers,, +2,// This is a self-contained example,, +3,,, +4,// Using aliases for types,, +5,using Size = unsigned int;,, +6,,, +7,// Class template,, +8,template ,TemplateTypeParmDecl, +9,class Container {,CXXRecordDecl; ClassTemplateSpecializationDecl; ClassTemplateDecl, +10,private:,AccessSpecDecl, +11, T* data;,FieldDecl, +12, Size capacity;,FieldDecl, +13, Size count;,FieldDecl, +14,,, +15,public:,AccessSpecDecl, +16, // Constructor,, +17," Container(Size size) : capacity(size), count(0) {",ParmVarDecl; CXXConstructorDecl, +18, data = new T[size];,BinaryOperator, +19, },, +20,,, +21, // Destructor,, +22, ~Container() {,CXXDestructorDecl; CompoundStmt, +23, delete[] data;,CXXDeleteExpr, +24, },, +25,,, +26, // Copy constructor (Rule of Three),, +27," Container(const Container& other) : capacity(other.capacity), count(other.count) {",CXXConstructorDecl, +28, data = new T[capacity];,, +29, for (Size i = 0; i < count; i++) {,, +30, data[i] = other.data[i];,, +31, },, +32, },, +33,,, +34, // Method with auto return type,, +35, auto size() const {,CompoundStmt; CXXMethodDecl, +36, return count;,ReturnStmt, +37, },, +38,,, +39, // Method to add items,, +40, void add(const T& item) {,ParmVarDecl; CXXMethodDecl, +41, if (count < capacity) {,BinaryOperator; IfStmt, +42, data[count++] = item;,BinaryOperator, +43, },, +44, },, +45,,, +46, // Method to get item,, +47, T get(Size index) const {,ParmVarDecl; CXXMethodDecl, +48, if (index < count) {,BinaryOperator; IfStmt, +49, return data[index];,ReturnStmt, +50, },, +51, return T{};,ReturnStmt, +52, },, +53,};,, +54,,, +55,// Function template,, +56,template ,TemplateTypeParmDecl, +57,"T add(T a, T b) {",ParmVarDecl; FunctionTemplateDecl; FunctionDecl, +58, return a + b;,ReturnStmt, +59,},, +60,,, +61,// Function with decltype,, +62,"template ",TemplateTypeParmDecl, +63,"auto addMixed(T a, U b) -> decltype(a + b) {",FunctionTemplateDecl; FunctionDecl, +64, return a + b;,, +65,},, +66,,, +67,int main() {,CompoundStmt; FunctionDecl, +68, // Using auto,, +69," auto result = add(5, 10);",DeclStmt, +70,,, +71, // Class template instantiation,, +72, Container intContainer(10);,DeclStmt, +73, intContainer.add(42);,ExprWithCleanups, +74, intContainer.add(123);,ExprWithCleanups, +75,,, +76, // Auto and decltype usage,, +77, auto value = intContainer.get(0);,DeclStmt, +78," auto sum = add(value, 100);",DeclStmt, +79,,, +80, // Using decltype,, +81, decltype(sum) anotherValue = intContainer.get(1);,DeclStmt, +82,,, +83, return 0;,ReturnStmt, +84,},, diff --git a/clang-ast-mapper/modern_output_interpretation.md b/clang-ast-mapper/modern_output_interpretation.md new file mode 100644 index 0000000000000..5e50dbaab48b3 --- /dev/null +++ b/clang-ast-mapper/modern_output_interpretation.md @@ -0,0 +1,138 @@ +# AST Analysis for C++ Code + +## Code Summary +This code defines a C++ class with 5 methods/constructors and contains logic for data manipulation and processing. + +## Code Structure +The C++ code has been analyzed using Clang's AST system, revealing the following structure: +- **Function Declarations**: The code contains function/method declarations which define its main structure +- **Parameter Variables**: Functions have parameter declarations indicating data passed between functions +- **Code Blocks**: Contains compound statements (blocks of code within curly braces) +- **Return Statements**: Functions include return statements to provide output values +- **Variable Declarations**: The code declares local variables to store and manipulate data +- **Control Flow**: Contains conditional or loop structures to control program execution +- **Classes/Structs**: The code defines custom data types with methods and fields + +## AST Structure Summary +This code follows a typical C++ structure with: + +- Class definitions with member methods +- Classes containing member variables (fields) +- Function definitions that contain variable declarations +- Method implementations with local variable usage +- Variable manipulation followed by return statements +- Control flow structures to manage program execution paths + +## AST Node Types Explained +The following AST nodes were found in the code: + +- **ReturnStmt** (5 occurrences): Return statement - specifies the value to be returned from a function +- **DeclStmt** (5 occurrences): Declaration statement - contains one or more variable declarations +- **ParmVarDecl** (4 occurrences): Parameter variable declaration - variables that receive values passed to functions +- **BinaryOperator** (4 occurrences): Binary operator - operations that use two operands like +, -, *, /, etc. +- **TemplateTypeParmDecl** (3 occurrences): Template type parameter - defines a placeholder type (like T) in a template +- **FieldDecl** (3 occurrences): Field declaration - member variables of a class or struct +- **CompoundStmt** (3 occurrences): Compound statement - a block of code enclosed in braces {} +- **CXXMethodDecl** (3 occurrences): C++ method declaration - a function that belongs to a class or struct +- **FunctionDecl** (3 occurrences): Function declaration - defines a function with its return type, name, and parameters +- **AccessSpecDecl** (2 occurrences): Access specifier - public, private, or protected sections in a class +- **CXXConstructorDecl** (2 occurrences): C++ constructor declaration - special method that initializes objects of a class +- **IfStmt** (2 occurrences): If statement - conditional execution based on a boolean expression +- **FunctionTemplateDecl** (2 occurrences): C++ function template declaration - defines a generic function that can work with different types +- **ExprWithCleanups** (2 occurrences): AST node type representing a ExprWithCleanups construct +- **CXXRecordDecl** (1 occurrences): C++ class/struct declaration - defines a user-defined type +- **ClassTemplateSpecializationDecl** (1 occurrences): C++ class template declaration - defines a generic class that can work with different types +- **ClassTemplateDecl** (1 occurrences): C++ class template declaration - defines a generic class that can work with different types +- **CXXDestructorDecl** (1 occurrences): C++ destructor declaration - special method that cleans up resources when object is destroyed +- **CXXDeleteExpr** (1 occurrences): C++ delete expression - deallocates memory + +## Side-by-Side Code and AST Representation +This section shows each line of code alongside its corresponding AST nodes: + +| Line # | C++ Code | AST Nodes | Explanation | +|--------|----------|-----------|-------------| +| 5 | `using Size = unsigned int;` | | | +| 8 | `template ` | TemplateTypeParmDecl | Template-related construct | +| 9 | `class Container {` | CXXRecordDecl; ClassTemplateSpecializationDecl; ClassTemplateDecl | defines a user | +| 10 | `private:` | AccessSpecDecl | public, private, or protected sections in a class | +| 11 | `T* data;` | FieldDecl | member variables of a class or struct | +| 12 | `Size capacity;` | FieldDecl | member variables of a class or struct | +| 13 | `Size count;` | FieldDecl | member variables of a class or struct | +| 15 | `public:` | AccessSpecDecl | public, private, or protected sections in a class | +| 17 | `Container(Size size) : capacity(size), count(0) {` | ParmVarDecl; CXXConstructorDecl | variables that receive values passed to functions | +| 18 | `data = new T[size];` | BinaryOperator | operations that use two operands like +, | +| 19 | `}` | | | +| 22 | `~Container() {` | CXXDestructorDecl; CompoundStmt | special method that cleans up resources when object is destroyed | +| 23 | `delete[] data;` | CXXDeleteExpr | deallocates memory | +| 24 | `}` | | | +| 27 | `Container(const Container& other) : capacity(other.capacity), count(other.count) {` | CXXConstructorDecl | special method that initializes objects of a class | +| 28 | `data = new T[capacity];` | | | +| 29 | `for (Size i = 0; i < count; i++) {` | | | +| 30 | `data[i] = other.data[i];` | | | +| 31 | `}` | | | +| 32 | `}` | | | +| 35 | `auto size() const {` | CXXMethodDecl; CompoundStmt | a function that belongs to a class or struct | +| 36 | `return count;` | ReturnStmt | specifies the value to be returned from a function | +| 37 | `}` | | | +| 40 | `void add(const T& item) {` | ParmVarDecl; CXXMethodDecl | variables that receive values passed to functions | +| 41 | `if (count < capacity) {` | IfStmt; BinaryOperator | conditional execution based on a boolean expression | +| 42 | `data[count++] = item;` | BinaryOperator | operations that use two operands like +, | +| 43 | `}` | | | +| 44 | `}` | | | +| 47 | `T get(Size index) const {` | ParmVarDecl; CXXMethodDecl | variables that receive values passed to functions | +| 48 | `if (index < count) {` | IfStmt; BinaryOperator | conditional execution based on a boolean expression | +| 49 | `return data[index];` | ReturnStmt | specifies the value to be returned from a function | +| 50 | `}` | | | +| 51 | `return T{};` | ReturnStmt | specifies the value to be returned from a function | +| 52 | `}` | | | +| 53 | `};` | | | +| 55 | `// Function template` | | | +| 56 | `template ` | TemplateTypeParmDecl | Template-related construct | +| 57 | `T add(T a, T b) {` | FunctionDecl; FunctionTemplateDecl; ParmVarDecl | defines a function with its return type, name, and parameters | +| 58 | `return a + b;` | ReturnStmt | specifies the value to be returned from a function | +| 59 | `}` | | | +| 62 | `template ` | TemplateTypeParmDecl | Template-related construct | +| 63 | `auto addMixed(T a, U b) -> decltype(a + b) {` | FunctionDecl; FunctionTemplateDecl | defines a function with its return type, name, and parameters | +| 64 | `return a + b;` | | | +| 65 | `}` | | | +| 67 | `int main() {` | FunctionDecl; CompoundStmt | defines a function with its return type, name, and parameters | +| 69 | `auto result = add(5, 10);` | DeclStmt | contains one or more variable declarations | +| 72 | `Container intContainer(10);` | DeclStmt | contains one or more variable declarations | +| 73 | `intContainer.add(42);` | ExprWithCleanups | ExprWithCleanups | +| 74 | `intContainer.add(123);` | ExprWithCleanups | ExprWithCleanups | +| 77 | `auto value = intContainer.get(0);` | DeclStmt | contains one or more variable declarations | +| 78 | `auto sum = add(value, 100);` | DeclStmt | contains one or more variable declarations | +| 80 | `// Using decltype` | | | +| 81 | `decltype(sum) anotherValue = intContainer.get(1);` | DeclStmt | contains one or more variable declarations | +| 83 | `return 0;` | ReturnStmt | specifies the value to be returned from a function | +| 84 | `}` | | | + +## AST Node Types Summary Table +| Node Type | Count | Description | +|-----------|-------|-------------| +| ReturnStmt | 5 | specifies the value to be returned from a function | +| DeclStmt | 5 | contains one or more variable declarations | +| ParmVarDecl | 4 | variables that receive values passed to functions | +| BinaryOperator | 4 | operations that use two operands like +, | +| TemplateTypeParmDecl | 3 | defines a placeholder type (like T) in a template | +| FieldDecl | 3 | member variables of a class or struct | +| CompoundStmt | 3 | a block of code enclosed in braces {} | +| CXXMethodDecl | 3 | a function that belongs to a class or struct | +| FunctionDecl | 3 | defines a function with its return type, name, and parameters | +| AccessSpecDecl | 2 | public, private, or protected sections in a class | +| CXXConstructorDecl | 2 | special method that initializes objects of a class | +| IfStmt | 2 | conditional execution based on a boolean expression | +| FunctionTemplateDecl | 2 | defines a generic function that can work with different types | +| ExprWithCleanups | 2 | represents a ExprWithCleanups construct | +| CXXRecordDecl | 1 | defines a user-defined class or struct | +| ClassTemplateSpecializationDecl | 1 | defines a generic class that can work with different types | +| ClassTemplateDecl | 1 | defines a generic class that can work with different types | +| CXXDestructorDecl | 1 | special method that cleans up resources when object is destroyed | +| CXXDeleteExpr | 1 | deallocates memory | + +## Code Quality Observations +- The code has a rich variety of AST nodes, indicating complex functionality +- The AST structure indicates well-formed C++ code without syntax errors + +## Functional Summary +The code implements a complete C++ class with constructors, methods, and member variables. This suggests an object-oriented design with proper encapsulation of data and behavior. The code contains conditional logic and/or loops, indicating non-trivial algorithmic processing. \ No newline at end of file diff --git a/clang-ast-mapper/requirements.txt b/clang-ast-mapper/requirements.txt new file mode 100644 index 0000000000000..87e0498239a21 --- /dev/null +++ b/clang-ast-mapper/requirements.txt @@ -0,0 +1,22 @@ +# Requirements for Clang AST Line Mapper + +# Core dependencies +transformers>=4.35.0 +torch>=2.0.0 + +# Development dependencies (optional) +pytest>=6.0.0 +pytest-cov>=2.0.0 + +# Documentation dependencies (optional) +sphinx>=4.0.0 +sphinx-rtd-theme>=1.0.0 + +# Code quality tools (optional) +flake8>=3.8.0 +black>=21.0.0 +isort>=5.0.0 +mypy>=0.910 + +# Note: The main tool only requires Python 3.6+ and Clang +# All other dependencies are optional for development and testing diff --git a/clang-ast-mapper/run_web_app.bat b/clang-ast-mapper/run_web_app.bat new file mode 100644 index 0000000000000..7310f46a66e6b --- /dev/null +++ b/clang-ast-mapper/run_web_app.bat @@ -0,0 +1,14 @@ + @echo off +REM Run the Clang AST Line Mapper Web Application + +echo Installing required dependencies... +pip install -r web_app/requirements.txt + +echo Starting Clang AST Line Mapper Web Application... +python web_app/app.py + +if %ERRORLEVEL% NEQ 0 ( + echo Error starting the application. Please check that all dependencies are installed. + echo Run: pip install -r web_app/requirements.txt + pause +) diff --git a/clang-ast-mapper/run_web_app.ps1 b/clang-ast-mapper/run_web_app.ps1 new file mode 100644 index 0000000000000..b20c355135c5e --- /dev/null +++ b/clang-ast-mapper/run_web_app.ps1 @@ -0,0 +1,13 @@ +# PowerShell script to run the Clang AST Line Mapper Web Application + +Write-Host "Installing required dependencies..." -ForegroundColor Green +pip install -r web_app/requirements.txt + +Write-Host "Starting Clang AST Line Mapper Web Application..." -ForegroundColor Green +python web_app/app.py + +if ($LASTEXITCODE -ne 0) { + Write-Host "Error starting the application. Please check that all dependencies are installed." -ForegroundColor Red + Write-Host "Run: pip install -r web_app/requirements.txt" -ForegroundColor Yellow + Read-Host "Press Enter to continue..." +} diff --git a/clang-ast-mapper/run_web_app.sh b/clang-ast-mapper/run_web_app.sh new file mode 100644 index 0000000000000..2e3d9990569e7 --- /dev/null +++ b/clang-ast-mapper/run_web_app.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Run the Clang AST Line Mapper Web Application + +echo "Starting Clang AST Line Mapper Web Application..." +python3 main.py + +if [ $? -ne 0 ]; then + echo "Error starting the application. Please check that all dependencies are installed." + echo "Run: pip install -r web_app/requirements.txt" + read -p "Press Enter to continue..." +fi diff --git a/clang-ast-mapper/setup.py b/clang-ast-mapper/setup.py new file mode 100644 index 0000000000000..d07c65114c655 --- /dev/null +++ b/clang-ast-mapper/setup.py @@ -0,0 +1,75 @@ +""" +Setup script for Clang AST Line Mapper +""" + +from setuptools import setup, find_packages +import os + +# Read the README file +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +# Read the requirements file +with open("requirements.txt", "r", encoding="utf-8") as fh: + requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")] + +setup( + name="clang-ast-mapper", + version="1.0.0", + author="AST Mapper Development Team", + author_email="dev@astmapper.com", + description="A CLI tool that maps C++ source lines to AST nodes using Clang", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/yourusername/clang-ast-mapper", + packages=find_packages(), + classifiers=[ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Software Development :: Code Generators", + "Topic :: Software Development :: Compilers", + "Topic :: Software Development :: Documentation", + "Topic :: Utilities", + ], + python_requires=">=3.6", + install_requires=requirements, + extras_require={ + "dev": [ + "pytest>=6.0.0", + "pytest-cov>=2.0.0", + "flake8>=3.8.0", + "black>=21.0.0", + "isort>=5.0.0", + "mypy>=0.910", + ], + "docs": [ + "sphinx>=4.0.0", + "sphinx-rtd-theme>=1.0.0", + ], + }, + entry_points={ + "console_scripts": [ + "clang-ast-mapper=ast_line_mapper:main", + ], + }, + project_urls={ + "Bug Reports": "https://github.com/yourusername/clang-ast-mapper/issues", + "Source": "https://github.com/yourusername/clang-ast-mapper", + "Documentation": "https://clang-ast-mapper.readthedocs.io/", + }, + keywords="clang ast parser c++ source code analysis", + package_data={ + "": ["*.md", "*.txt", "*.json"], + }, + include_package_data=True, + zip_safe=False, +) diff --git a/clang-ast-mapper/simple_ast.json b/clang-ast-mapper/simple_ast.json new file mode 100644 index 0000000000000..65430f0bfc00f --- /dev/null +++ b/clang-ast-mapper/simple_ast.json @@ -0,0 +1,916 @@ +{ + "id": "0x2171d0e6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x2171d0e7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x2171d0e75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2171d0e7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x2171d0e7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x2171d0e77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x2171d0e7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x2171d0e7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x2171d0e78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x2171d0e7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x2171d0e7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x2171d13d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2171d13d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x2171d0e6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x2171d0e7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2171d0e7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2171d0e6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2171d0e76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2171d0e7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2171d0e6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2171d13dae8", + "kind": "FunctionDecl", + "loc": { + "offset": 52, + "file": "examples\\simple.cpp", + "line": 2, + "col": 5, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 48, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 92, + "line": 4, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "?add@@YAHHH@Z", + "type": { + "qualType": "int (int, int)" + }, + "inner": [ + { + "id": "0x2171d13d970", + "kind": "ParmVarDecl", + "loc": { + "offset": 60, + "line": 2, + "col": 13, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 56, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 60, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x2171d13d9f8", + "kind": "ParmVarDecl", + "loc": { + "offset": 67, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 63, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 67, + "col": 20, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "int" + } + }, + { + "id": "0x2171d13dc88", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 70, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 92, + "line": 4, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2171d13dc78", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 77, + "line": 3, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 88, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2171d13dc58", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 84, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 88, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2171d13dc28", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 84, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 84, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2171d13dbe8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 84, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 84, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2171d13d970", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2171d13dc40", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 88, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 88, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2171d13dc08", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 88, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 88, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2171d13d9f8", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2171d13dcf8", + "kind": "FunctionDecl", + "loc": { + "offset": 101, + "line": 6, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 97, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 187, + "line": 11, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2171d13e178", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 108, + "line": 6, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 187, + "line": 11, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2171d13de78", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 115, + "line": 7, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 124, + "col": 14, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2171d13dde8", + "kind": "VarDecl", + "loc": { + "offset": 119, + "col": 9, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 115, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 123, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x2171d13de50", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 123, + "col": 13, + "tokLen": 1 + }, + "end": { + "offset": 123, + "col": 13, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "5" + } + ] + } + ] + }, + { + "id": "0x2171d13df38", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 131, + "line": 8, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 140, + "col": 14, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2171d13dea8", + "kind": "VarDecl", + "loc": { + "offset": 135, + "col": 9, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 131, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 139, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x2171d13df10", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 139, + "col": 13, + "tokLen": 1 + }, + "end": { + "offset": 139, + "col": 13, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "3" + } + ] + } + ] + }, + { + "id": "0x2171d13e128", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 147, + "line": 9, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 169, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2171d13df68", + "kind": "VarDecl", + "loc": { + "offset": 151, + "col": 9, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 147, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 168, + "col": 26, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x2171d13e0c8", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 160, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 168, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2171d13e0b0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 160, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 160, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (*)(int, int)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2171d13e058", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 160, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 160, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (int, int)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2171d13dae8", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "int (int, int)" + } + } + } + ] + }, + { + "id": "0x2171d13e0f8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 164, + "col": 22, + "tokLen": 1 + }, + "end": { + "offset": 164, + "col": 22, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2171d13e018", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 164, + "col": 22, + "tokLen": 1 + }, + "end": { + "offset": 164, + "col": 22, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2171d13dde8", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2171d13e110", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 167, + "col": 25, + "tokLen": 1 + }, + "end": { + "offset": 167, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2171d13e038", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 167, + "col": 25, + "tokLen": 1 + }, + "end": { + "offset": 167, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2171d13dea8", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2171d13e168", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 176, + "line": 10, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 183, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2171d13e140", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 183, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 183, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/simple_modern_ast.json b/clang-ast-mapper/simple_modern_ast.json new file mode 100644 index 0000000000000..3e82ee4525da6 --- /dev/null +++ b/clang-ast-mapper/simple_modern_ast.json @@ -0,0 +1,6260 @@ +{ + "id": "0x277a3a56c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x277a3a57510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x277a3a575c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x277a3a57748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x277a3a57260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x277a3a577b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x277a3a57280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x277a3a57b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x277a3a578a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x277a3a57810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x277a3a57bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x277a3aad888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x277a3aad900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x277a3a56e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x277a3a57668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x277a3a57620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x277a3a56d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x277a3a576d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x277a3a57620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x277a3a56d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x277a3aad970", + "kind": "TypeAliasDecl", + "loc": { + "offset": 137, + "file": "examples\\simple_modern.cpp", + "line": 5, + "col": 7, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 131, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 153, + "col": 23, + "tokLen": 3 + } + }, + "isReferenced": true, + "name": "Size", + "type": { + "qualType": "unsigned int" + }, + "inner": [ + { + "id": "0x277a3a56e40", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned int" + } + } + ] + }, + { + "id": "0x277a3aadb30", + "kind": "ClassTemplateDecl", + "loc": { + "offset": 209, + "line": 9, + "col": 7, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 180, + "line": 8, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 1170, + "line": 53, + "col": 1, + "tokLen": 1 + } + }, + "name": "Container", + "inner": [ + { + "id": "0x277a3aad9d0", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 199, + "line": 8, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 190, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 199, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x277a3aadaa0", + "kind": "CXXRecordDecl", + "loc": { + "offset": 209, + "line": 9, + "col": 7, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 203, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 1170, + "line": 53, + "col": 1, + "tokLen": 1 + } + }, + "name": "Container", + "tagUsed": "class", + "completeDefinition": true, + "definitionData": { + "canConstDefaultInit": true, + "copyAssign": { + "hasConstParam": true, + "implicitHasConstParam": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "copyCtor": { + "hasConstParam": true, + "implicitHasConstParam": true, + "nonTrivial": true, + "userDeclared": true + }, + "defaultCtor": {}, + "dtor": { + "irrelevant": true, + "nonTrivial": true, + "userDeclared": true + }, + "hasUserDeclaredConstructor": true, + "isStandardLayout": true, + "moveAssign": {}, + "moveCtor": {} + }, + "inner": [ + { + "id": "0x277a3aaddc8", + "kind": "CXXRecordDecl", + "loc": { + "offset": 209, + "line": 9, + "col": 7, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 203, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 209, + "col": 7, + "tokLen": 9 + } + }, + "isImplicit": true, + "isReferenced": true, + "name": "Container", + "tagUsed": "class" + }, + { + "id": "0x277a3aade58", + "kind": "AccessSpecDecl", + "loc": { + "offset": 222, + "line": 10, + "col": 1, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 222, + "col": 1, + "tokLen": 7 + }, + "end": { + "offset": 229, + "col": 8, + "tokLen": 1 + } + }, + "access": "private" + }, + { + "id": "0x277a3aadf00", + "kind": "FieldDecl", + "loc": { + "offset": 239, + "line": 11, + "col": 8, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 236, + "col": 5, + "tokLen": 1 + }, + "end": { + "offset": 239, + "col": 8, + "tokLen": 4 + } + }, + "isReferenced": true, + "name": "data", + "type": { + "qualType": "T *" + } + }, + { + "id": "0x277a3aadfe0", + "kind": "FieldDecl", + "loc": { + "offset": 255, + "line": 12, + "col": 10, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 250, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 255, + "col": 10, + "tokLen": 8 + } + }, + "isReferenced": true, + "name": "capacity", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "id": "0x277a3aae048", + "kind": "FieldDecl", + "loc": { + "offset": 275, + "line": 13, + "col": 10, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 270, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 275, + "col": 10, + "tokLen": 5 + } + }, + "isReferenced": true, + "name": "count", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "id": "0x277a3aae0a0", + "kind": "AccessSpecDecl", + "loc": { + "offset": 289, + "line": 15, + "col": 1, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 289, + "col": 1, + "tokLen": 6 + }, + "end": { + "offset": 295, + "col": 7, + "tokLen": 1 + } + }, + "access": "public" + }, + { + "id": "0x277a3aae240", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 322, + "line": 17, + "col": 5, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 322, + "col": 5, + "tokLen": 9 + }, + "end": { + "offset": 406, + "line": 19, + "col": 5, + "tokLen": 1 + } + }, + "name": "Container", + "type": { + "qualType": "void (Size)" + }, + "inner": [ + { + "id": "0x277a3aae0e0", + "kind": "ParmVarDecl", + "loc": { + "offset": 337, + "line": 17, + "col": 20, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 332, + "col": 15, + "tokLen": 4 + }, + "end": { + "offset": 337, + "col": 20, + "tokLen": 4 + } + }, + "isReferenced": true, + "name": "size", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x277a3aadfe0", + "kind": "FieldDecl", + "name": "capacity", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + "inner": [ + { + "id": "0x277a3ad93e0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 354, + "col": 37, + "tokLen": 4 + }, + "end": { + "offset": 354, + "col": 37, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3ad93a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 354, + "col": 37, + "tokLen": 4 + }, + "end": { + "offset": 354, + "col": 37, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3aae0e0", + "kind": "ParmVarDecl", + "name": "size", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + } + ] + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x277a3aae048", + "kind": "FieldDecl", + "name": "count", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + "inner": [ + { + "id": "0x277a3ad9460", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 367, + "col": 50, + "tokLen": 1 + }, + "end": { + "offset": 367, + "col": 50, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "IntegralCast", + "inner": [ + { + "id": "0x277a3ad9418", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 367, + "col": 50, + "tokLen": 1 + }, + "end": { + "offset": 367, + "col": 50, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + }, + { + "id": "0x277a3ad95f0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 370, + "col": 53, + "tokLen": 1 + }, + "end": { + "offset": 406, + "line": 19, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad95d0", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 381, + "line": 18, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 398, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "=", + "inner": [ + { + "id": "0x277a3ad9500", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 381, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 381, + "col": 9, + "tokLen": 4 + } + }, + "type": { + "qualType": "T *" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3aadf00", + "inner": [ + { + "id": "0x277a3ad94f0", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 381, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 381, + "col": 9, + "tokLen": 4 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + }, + { + "id": "0x277a3ad9590", + "kind": "CXXNewExpr", + "range": { + "begin": { + "offset": 388, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 398, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "T *" + }, + "valueCategory": "prvalue", + "isArray": true, + "inner": [ + { + "id": "0x277a3ad9578", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 394, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 394, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "qualType": "unsigned long long" + }, + "valueCategory": "prvalue", + "castKind": "IntegralCast", + "inner": [ + { + "id": "0x277a3ad9560", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 394, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 394, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3ad9530", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 394, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 394, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3aae0e0", + "kind": "ParmVarDecl", + "name": "size", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3aae3c0", + "kind": "CXXDestructorDecl", + "loc": { + "offset": 438, + "line": 22, + "col": 5, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 438, + "col": 5, + "tokLen": 1 + }, + "end": { + "offset": 482, + "line": 24, + "col": 5, + "tokLen": 1 + } + }, + "name": "~Container", + "type": { + "qualType": "void ()" + }, + "inner": [ + { + "id": "0x277a3adb8a8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 451, + "line": 22, + "col": 18, + "tokLen": 1 + }, + "end": { + "offset": 482, + "line": 24, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adb888", + "kind": "CXXDeleteExpr", + "range": { + "begin": { + "offset": 462, + "line": 23, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 471, + "col": 18, + "tokLen": 4 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "isArray": true, + "isArrayAsWritten": true, + "inner": [ + { + "id": "0x277a3adb858", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 471, + "col": 18, + "tokLen": 4 + }, + "end": { + "offset": 471, + "col": 18, + "tokLen": 4 + } + }, + "type": { + "qualType": "T *" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3aadf00", + "inner": [ + { + "id": "0x277a3adb848", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 471, + "col": 18, + "tokLen": 4 + }, + "end": { + "offset": 471, + "col": 18, + "tokLen": 4 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3aae610", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 536, + "line": 27, + "col": 5, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 536, + "col": 5, + "tokLen": 9 + }, + "end": { + "offset": 568, + "col": 37, + "tokLen": 1 + } + }, + "name": "Container", + "type": { + "qualType": "void (const Container &)" + }, + "inner": [ + { + "id": "0x277a3aae4f8", + "kind": "ParmVarDecl", + "loc": { + "offset": 563, + "col": 32, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 546, + "col": 15, + "tokLen": 5 + }, + "end": { + "offset": 563, + "col": 32, + "tokLen": 5 + } + }, + "name": "other", + "type": { + "qualType": "const Container &" + } + }, + {} + ] + }, + { + "id": "0x277a3aae798", + "kind": "CXXMethodDecl", + "loc": { + "offset": 805, + "line": 35, + "col": 10, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 800, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 850, + "line": 37, + "col": 5, + "tokLen": 1 + } + }, + "name": "size", + "type": { + "qualType": "auto () const" + }, + "inner": [ + { + "id": "0x277a3ad5f60", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 818, + "line": 35, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 850, + "line": 37, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad5f50", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 830, + "line": 36, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 837, + "col": 16, + "tokLen": 5 + } + }, + "inner": [ + { + "id": "0x277a3ad5f20", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 837, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 837, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "const unsigned int", + "qualType": "const Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "count", + "isArrow": true, + "referencedMemberDecl": "0x277a3aae048", + "inner": [ + { + "id": "0x277a3ad5f10", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 837, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 837, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "const Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad5c90", + "kind": "CXXMethodDecl", + "loc": { + "offset": 896, + "line": 40, + "col": 10, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 891, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1001, + "line": 44, + "col": 5, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "void (const T &)" + }, + "inner": [ + { + "id": "0x277a3ad5b80", + "kind": "ParmVarDecl", + "loc": { + "offset": 909, + "line": 40, + "col": 23, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 900, + "col": 14, + "tokLen": 5 + }, + "end": { + "offset": 909, + "col": 23, + "tokLen": 4 + } + }, + "isReferenced": true, + "name": "item", + "type": { + "qualType": "const T &" + } + }, + { + "id": "0x277a3adbbe0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 915, + "col": 29, + "tokLen": 1 + }, + "end": { + "offset": 1001, + "line": 44, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbbc0", + "kind": "IfStmt", + "range": { + "begin": { + "offset": 926, + "line": 41, + "col": 9, + "tokLen": 2 + }, + "end": { + "offset": 994, + "line": 43, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adba48", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 930, + "line": 41, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "qualType": "bool" + }, + "valueCategory": "prvalue", + "opcode": "<", + "inner": [ + { + "id": "0x277a3adba18", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 930, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 930, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adb960", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 930, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 930, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "count", + "isArrow": true, + "referencedMemberDecl": "0x277a3aae048", + "inner": [ + { + "id": "0x277a3adb950", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 930, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 930, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + }, + { + "id": "0x277a3adba30", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 938, + "col": 21, + "tokLen": 8 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adb9e8", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 938, + "col": 21, + "tokLen": 8 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "capacity", + "isArrow": true, + "referencedMemberDecl": "0x277a3aadfe0", + "inner": [ + { + "id": "0x277a3adb9d8", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 938, + "col": 21, + "tokLen": 8 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adbba8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 948, + "col": 31, + "tokLen": 1 + }, + "end": { + "offset": 994, + "line": 43, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbb88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 963, + "line": 42, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 979, + "col": 29, + "tokLen": 4 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "=", + "inner": [ + { + "id": "0x277a3adbb48", + "kind": "ArraySubscriptExpr", + "range": { + "begin": { + "offset": 963, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 975, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "inner": [ + { + "id": "0x277a3adbac0", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 963, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 963, + "col": 13, + "tokLen": 4 + } + }, + "type": { + "qualType": "T *" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3aadf00", + "inner": [ + { + "id": "0x277a3adbab0", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 963, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 963, + "col": 13, + "tokLen": 4 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + }, + { + "id": "0x277a3adbb30", + "kind": "UnaryOperator", + "range": { + "begin": { + "offset": 968, + "col": 18, + "tokLen": 5 + }, + "end": { + "offset": 973, + "col": 23, + "tokLen": 2 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "isPostfix": true, + "opcode": "++", + "inner": [ + { + "id": "0x277a3adbb00", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 968, + "col": 18, + "tokLen": 5 + }, + "end": { + "offset": 968, + "col": 18, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "count", + "isArrow": true, + "referencedMemberDecl": "0x277a3aae048", + "inner": [ + { + "id": "0x277a3adbaf0", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 968, + "col": 18, + "tokLen": 5 + }, + "end": { + "offset": 968, + "col": 18, + "tokLen": 5 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adbb68", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 979, + "col": 29, + "tokLen": 4 + }, + "end": { + "offset": 979, + "col": 29, + "tokLen": 4 + } + }, + "type": { + "qualType": "const T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad5b80", + "kind": "ParmVarDecl", + "name": "item", + "type": { + "qualType": "const T &" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad5e60", + "kind": "CXXMethodDecl", + "loc": { + "offset": 1043, + "line": 47, + "col": 7, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 1041, + "col": 5, + "tokLen": 1 + }, + "end": { + "offset": 1167, + "line": 52, + "col": 5, + "tokLen": 1 + } + }, + "name": "get", + "type": { + "qualType": "T (Size) const" + }, + "inner": [ + { + "id": "0x277a3ad5d50", + "kind": "ParmVarDecl", + "loc": { + "offset": 1052, + "line": 47, + "col": 16, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 1047, + "col": 11, + "tokLen": 4 + }, + "end": { + "offset": 1052, + "col": 16, + "tokLen": 5 + } + }, + "isReferenced": true, + "name": "index", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "id": "0x277a3adc088", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 1065, + "col": 29, + "tokLen": 1 + }, + "end": { + "offset": 1167, + "line": 52, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbfe0", + "kind": "IfStmt", + "range": { + "begin": { + "offset": 1076, + "line": 48, + "col": 9, + "tokLen": 2 + }, + "end": { + "offset": 1139, + "line": 50, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbf18", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 1080, + "line": 48, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "qualType": "bool" + }, + "valueCategory": "prvalue", + "opcode": "<", + "inner": [ + { + "id": "0x277a3adbee8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1080, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 1080, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adbe40", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1080, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 1080, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad5d50", + "kind": "ParmVarDecl", + "name": "index", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + }, + { + "id": "0x277a3adbf00", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1088, + "col": 21, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adbeb8", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1088, + "col": 21, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "const unsigned int", + "qualType": "const Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "count", + "isArrow": true, + "referencedMemberDecl": "0x277a3aae048", + "inner": [ + { + "id": "0x277a3adbea8", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 1088, + "col": 21, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "qualType": "const Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adbfc8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 1095, + "col": 28, + "tokLen": 1 + }, + "end": { + "offset": 1139, + "line": 50, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbfb8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1110, + "line": 49, + "col": 13, + "tokLen": 6 + }, + "end": { + "offset": 1127, + "col": 30, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbf98", + "kind": "ArraySubscriptExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1127, + "col": 30, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "inner": [ + { + "id": "0x277a3adbf48", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1117, + "col": 20, + "tokLen": 4 + } + }, + "type": { + "qualType": "T *const" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3aadf00", + "inner": [ + { + "id": "0x277a3adbf38", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1117, + "col": 20, + "tokLen": 4 + } + }, + "type": { + "qualType": "const Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + }, + { + "id": "0x277a3adbf78", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1122, + "col": 25, + "tokLen": 5 + }, + "end": { + "offset": 1122, + "col": 25, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad5d50", + "kind": "ParmVarDecl", + "name": "index", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adc078", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1150, + "line": 51, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 1159, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adc050", + "kind": "CXXUnresolvedConstructExpr", + "range": { + "begin": { + "offset": 1157, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 1159, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "prvalue", + "list": true, + "inner": [ + { + "id": "0x277a3adc010", + "kind": "InitListExpr", + "range": { + "begin": { + "offset": 1158, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 1159, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad72b0", + "kind": "ClassTemplateSpecializationDecl", + "loc": { + "offset": 209, + "line": 9, + "col": 7, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 180, + "line": 8, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 1170, + "line": 53, + "col": 1, + "tokLen": 1 + } + }, + "name": "Container", + "tagUsed": "class", + "completeDefinition": true, + "definitionData": { + "canConstDefaultInit": true, + "copyAssign": { + "hasConstParam": true, + "implicitHasConstParam": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "copyCtor": { + "hasConstParam": true, + "implicitHasConstParam": true, + "nonTrivial": true, + "userDeclared": true + }, + "defaultCtor": {}, + "dtor": { + "nonTrivial": true, + "userDeclared": true + }, + "hasUserDeclaredConstructor": true, + "isStandardLayout": true, + "moveAssign": {}, + "moveCtor": {} + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x277a3a56da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "id": "0x277a3ad7598", + "kind": "CXXRecordDecl", + "loc": { + "offset": 209, + "line": 9, + "col": 7, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 203, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 209, + "col": 7, + "tokLen": 9 + } + }, + "isImplicit": true, + "name": "Container", + "tagUsed": "class" + }, + { + "id": "0x277a3ad7628", + "kind": "AccessSpecDecl", + "loc": { + "offset": 222, + "line": 10, + "col": 1, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 222, + "col": 1, + "tokLen": 7 + }, + "end": { + "offset": 229, + "col": 8, + "tokLen": 1 + } + }, + "access": "private" + }, + { + "id": "0x277a3ad7700", + "kind": "FieldDecl", + "loc": { + "offset": 239, + "line": 11, + "col": 8, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 236, + "col": 5, + "tokLen": 1 + }, + "end": { + "offset": 239, + "col": 8, + "tokLen": 4 + } + }, + "isReferenced": true, + "name": "data", + "type": { + "qualType": "int *" + } + }, + { + "id": "0x277a3ad7758", + "kind": "FieldDecl", + "loc": { + "offset": 255, + "line": 12, + "col": 10, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 250, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 255, + "col": 10, + "tokLen": 8 + } + }, + "isReferenced": true, + "name": "capacity", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "id": "0x277a3ad77b0", + "kind": "FieldDecl", + "loc": { + "offset": 275, + "line": 13, + "col": 10, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 270, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 275, + "col": 10, + "tokLen": 5 + } + }, + "isReferenced": true, + "name": "count", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "id": "0x277a3ad7808", + "kind": "AccessSpecDecl", + "loc": { + "offset": 289, + "line": 15, + "col": 1, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 289, + "col": 1, + "tokLen": 6 + }, + "end": { + "offset": 295, + "col": 7, + "tokLen": 1 + } + }, + "access": "public" + }, + { + "id": "0x277a3ad7940", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 322, + "line": 17, + "col": 5, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 322, + "col": 5, + "tokLen": 9 + }, + "end": { + "offset": 406, + "line": 19, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "Container", + "mangledName": "??0?$Container@H@@QEAA@I@Z", + "type": { + "qualType": "void (Size)" + }, + "inner": [ + { + "id": "0x277a3ad7870", + "kind": "ParmVarDecl", + "loc": { + "offset": 337, + "line": 17, + "col": 20, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 332, + "col": 15, + "tokLen": 4 + }, + "end": { + "offset": 337, + "col": 20, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "size", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x277a3ad7758", + "kind": "FieldDecl", + "name": "capacity", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + "inner": [ + { + "id": "0x277a3ad9628", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 354, + "col": 37, + "tokLen": 4 + }, + "end": { + "offset": 354, + "col": 37, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3ad9608", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 354, + "col": 37, + "tokLen": 4 + }, + "end": { + "offset": 354, + "col": 37, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad7870", + "kind": "ParmVarDecl", + "name": "size", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + } + ] + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x277a3ad77b0", + "kind": "FieldDecl", + "name": "count", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + "inner": [ + { + "id": "0x277a3ad9660", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 367, + "col": 50, + "tokLen": 1 + }, + "end": { + "offset": 367, + "col": 50, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "IntegralCast", + "inner": [ + { + "id": "0x277a3ad9418", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 367, + "col": 50, + "tokLen": 1 + }, + "end": { + "offset": 367, + "col": 50, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + }, + { + "id": "0x277a3adb830", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 370, + "col": 53, + "tokLen": 1 + }, + "end": { + "offset": 406, + "line": 19, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adb810", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 381, + "line": 18, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 388, + "col": 16, + "tokLen": 3 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "lvalue", + "opcode": "=", + "inner": [ + { + "id": "0x277a3ad96b8", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 381, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 381, + "col": 9, + "tokLen": 4 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad7700", + "inner": [ + { + "id": "0x277a3ad96a8", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 381, + "col": 9, + "tokLen": 4 + }, + "end": { + "offset": 381, + "col": 9, + "tokLen": 4 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + }, + { + "id": "0x277a3adb7d0", + "kind": "CXXNewExpr", + "range": { + "begin": { + "offset": 388, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 388, + "col": 16, + "tokLen": 3 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "prvalue", + "isArray": true, + "operatorNewDecl": { + "id": "0x277a3ad9960", + "kind": "FunctionDecl", + "name": "operator new[]", + "type": { + "qualType": "void *(unsigned long long)" + } + }, + "operatorDeleteDecl": { + "id": "0x277a3adb560", + "kind": "FunctionDecl", + "name": "operator delete[]", + "type": { + "qualType": "void (void *, unsigned long long) noexcept" + } + }, + "inner": [ + { + "id": "0x277a3ad9730", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 394, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 394, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "qualType": "unsigned long long" + }, + "valueCategory": "prvalue", + "castKind": "IntegralCast", + "inner": [ + { + "id": "0x277a3ad9718", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 394, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 394, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3ad96f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 394, + "col": 22, + "tokLen": 4 + }, + "end": { + "offset": 394, + "col": 22, + "tokLen": 4 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad7870", + "kind": "ParmVarDecl", + "name": "size", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad7a30", + "kind": "CXXDestructorDecl", + "loc": { + "offset": 438, + "line": 22, + "col": 5, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 438, + "col": 5, + "tokLen": 1 + }, + "end": { + "offset": 482, + "line": 24, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "~Container", + "mangledName": "??_D?$Container@H@@QEAAXXZ", + "type": { + "qualType": "void () noexcept" + }, + "inner": [ + { + "id": "0x277a3adb938", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 451, + "line": 22, + "col": 18, + "tokLen": 1 + }, + "end": { + "offset": 482, + "line": 24, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adb918", + "kind": "CXXDeleteExpr", + "range": { + "begin": { + "offset": 462, + "line": 23, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 471, + "col": 18, + "tokLen": 4 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "isArray": true, + "isArrayAsWritten": true, + "operatorDeleteDecl": { + "id": "0x277a3ad9fc8", + "kind": "FunctionDecl", + "name": "operator delete[]", + "type": { + "qualType": "void (void *) noexcept" + } + }, + "inner": [ + { + "id": "0x277a3adb900", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 471, + "col": 18, + "tokLen": 4 + }, + "end": { + "offset": 471, + "col": 18, + "tokLen": 4 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adb8d0", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 471, + "col": 18, + "tokLen": 4 + }, + "end": { + "offset": 471, + "col": 18, + "tokLen": 4 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad7700", + "inner": [ + { + "id": "0x277a3adb8c0", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 471, + "col": 18, + "tokLen": 4 + }, + "end": { + "offset": 471, + "col": 18, + "tokLen": 4 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad7f50", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 536, + "line": 27, + "col": 5, + "tokLen": 9 + }, + "range": { + "begin": { + "offset": 536, + "col": 5, + "tokLen": 9 + }, + "end": { + "offset": 568, + "col": 37, + "tokLen": 1 + } + }, + "name": "Container", + "mangledName": "??0?$Container@H@@QEAA@AEBV0@@Z", + "type": { + "qualType": "void (const Container &)" + }, + "inner": [ + { + "id": "0x277a3ad7bf8", + "kind": "ParmVarDecl", + "loc": { + "offset": 563, + "col": 32, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 546, + "col": 15, + "tokLen": 5 + }, + "end": { + "offset": 563, + "col": 32, + "tokLen": 5 + } + }, + "name": "other", + "type": { + "qualType": "const Container &" + } + } + ] + }, + { + "id": "0x277a3ad8028", + "kind": "CXXMethodDecl", + "loc": { + "offset": 805, + "line": 35, + "col": 10, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 800, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 850, + "line": 37, + "col": 5, + "tokLen": 1 + } + }, + "name": "size", + "mangledName": "?size@?$Container@H@@QEBA@XZ", + "type": { + "qualType": "auto () const" + } + }, + { + "id": "0x277a3ad8260", + "kind": "CXXMethodDecl", + "loc": { + "offset": 896, + "line": 40, + "col": 10, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 891, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1001, + "line": 44, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "?add@?$Container@H@@QEAAXAEBH@Z", + "type": { + "qualType": "void (const int &)" + }, + "inner": [ + { + "id": "0x277a3ad8150", + "kind": "ParmVarDecl", + "loc": { + "offset": 909, + "line": 40, + "col": 23, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 900, + "col": 14, + "tokLen": 5 + }, + "end": { + "offset": 909, + "col": 23, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "item", + "type": { + "qualType": "const int &" + } + }, + { + "id": "0x277a3adbe28", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 915, + "col": 29, + "tokLen": 1 + }, + "end": { + "offset": 1001, + "line": 44, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbe08", + "kind": "IfStmt", + "range": { + "begin": { + "offset": 926, + "line": 41, + "col": 9, + "tokLen": 2 + }, + "end": { + "offset": 994, + "line": 43, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbca8", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 930, + "line": 41, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "qualType": "bool" + }, + "valueCategory": "prvalue", + "opcode": "<", + "inner": [ + { + "id": "0x277a3adbc78", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 930, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 930, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adbc08", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 930, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 930, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "count", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad77b0", + "inner": [ + { + "id": "0x277a3adbbf8", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 930, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 930, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + }, + { + "id": "0x277a3adbc90", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 938, + "col": 21, + "tokLen": 8 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adbc48", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 938, + "col": 21, + "tokLen": 8 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "capacity", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad7758", + "inner": [ + { + "id": "0x277a3adbc38", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 938, + "col": 21, + "tokLen": 8 + }, + "end": { + "offset": 938, + "col": 21, + "tokLen": 8 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adbdf0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 948, + "col": 31, + "tokLen": 1 + }, + "end": { + "offset": 994, + "line": 43, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adbdd0", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 963, + "line": 42, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 979, + "col": 29, + "tokLen": 4 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "opcode": "=", + "inner": [ + { + "id": "0x277a3adbd78", + "kind": "ArraySubscriptExpr", + "range": { + "begin": { + "offset": 963, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 975, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "inner": [ + { + "id": "0x277a3adbd60", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 963, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 963, + "col": 13, + "tokLen": 4 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adbcd8", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 963, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 963, + "col": 13, + "tokLen": 4 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad7700", + "inner": [ + { + "id": "0x277a3adbcc8", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 963, + "col": 13, + "tokLen": 4 + }, + "end": { + "offset": 963, + "col": 13, + "tokLen": 4 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + }, + { + "id": "0x277a3adbd48", + "kind": "UnaryOperator", + "range": { + "begin": { + "offset": 968, + "col": 18, + "tokLen": 5 + }, + "end": { + "offset": 973, + "col": 23, + "tokLen": 2 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "isPostfix": true, + "opcode": "++", + "inner": [ + { + "id": "0x277a3adbd18", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 968, + "col": 18, + "tokLen": 5 + }, + "end": { + "offset": 968, + "col": 18, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "count", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad77b0", + "inner": [ + { + "id": "0x277a3adbd08", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 968, + "col": 18, + "tokLen": 5 + }, + "end": { + "offset": 968, + "col": 18, + "tokLen": 5 + } + }, + "type": { + "qualType": "Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adbdb8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 979, + "col": 29, + "tokLen": 4 + }, + "end": { + "offset": 979, + "col": 29, + "tokLen": 4 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adbd98", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 979, + "col": 29, + "tokLen": 4 + }, + "end": { + "offset": 979, + "col": 29, + "tokLen": 4 + } + }, + "type": { + "qualType": "const int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad8150", + "kind": "ParmVarDecl", + "name": "item", + "type": { + "qualType": "const int &" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad8430", + "kind": "CXXMethodDecl", + "loc": { + "offset": 1043, + "line": 47, + "col": 7, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 1041, + "col": 5, + "tokLen": 1 + }, + "end": { + "offset": 1167, + "line": 52, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "get", + "mangledName": "?get@?$Container@H@@QEBAHI@Z", + "type": { + "qualType": "int (Size) const" + }, + "inner": [ + { + "id": "0x277a3ad8320", + "kind": "ParmVarDecl", + "loc": { + "offset": 1052, + "line": 47, + "col": 16, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 1047, + "col": 11, + "tokLen": 4 + }, + "end": { + "offset": 1052, + "col": 16, + "tokLen": 5 + } + }, + "isUsed": true, + "name": "index", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + }, + { + "id": "0x277a3adc330", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 1065, + "col": 29, + "tokLen": 1 + }, + "end": { + "offset": 1167, + "line": 52, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adc248", + "kind": "IfStmt", + "range": { + "begin": { + "offset": 1076, + "line": 48, + "col": 9, + "tokLen": 2 + }, + "end": { + "offset": 1139, + "line": 50, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adc138", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 1080, + "line": 48, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "qualType": "bool" + }, + "valueCategory": "prvalue", + "opcode": "<", + "inner": [ + { + "id": "0x277a3adc108", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1080, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 1080, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adc0a8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1080, + "col": 13, + "tokLen": 5 + }, + "end": { + "offset": 1080, + "col": 13, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad8320", + "kind": "ParmVarDecl", + "name": "index", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + }, + { + "id": "0x277a3adc120", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1088, + "col": 21, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adc0d8", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1088, + "col": 21, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "const unsigned int", + "qualType": "const Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "name": "count", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad77b0", + "inner": [ + { + "id": "0x277a3adc0c8", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 1088, + "col": 21, + "tokLen": 5 + }, + "end": { + "offset": 1088, + "col": 21, + "tokLen": 5 + } + }, + "type": { + "qualType": "const Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adc230", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 1095, + "col": 28, + "tokLen": 1 + }, + "end": { + "offset": 1139, + "line": 50, + "col": 9, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adc220", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1110, + "line": 49, + "col": 13, + "tokLen": 6 + }, + "end": { + "offset": 1127, + "col": 30, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adc208", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1127, + "col": 30, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adc1e8", + "kind": "ArraySubscriptExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1127, + "col": 30, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "inner": [ + { + "id": "0x277a3adc1b8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1117, + "col": 20, + "tokLen": 4 + } + }, + "type": { + "qualType": "int *" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adc168", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1117, + "col": 20, + "tokLen": 4 + } + }, + "type": { + "qualType": "int *const" + }, + "valueCategory": "lvalue", + "name": "data", + "isArrow": true, + "referencedMemberDecl": "0x277a3ad7700", + "inner": [ + { + "id": "0x277a3adc158", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 1117, + "col": 20, + "tokLen": 4 + }, + "end": { + "offset": 1117, + "col": 20, + "tokLen": 4 + } + }, + "type": { + "qualType": "const Container *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + }, + { + "id": "0x277a3adc1d0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1122, + "col": 25, + "tokLen": 5 + }, + "end": { + "offset": 1122, + "col": 25, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3adc198", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1122, + "col": 25, + "tokLen": 5 + }, + "end": { + "offset": 1122, + "col": 25, + "tokLen": 5 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad8320", + "kind": "ParmVarDecl", + "name": "index", + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3adc320", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1150, + "line": 51, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 1159, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3adc2f8", + "kind": "CXXFunctionalCastExpr", + "range": { + "begin": { + "offset": 1157, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 1159, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x277a3adc2b8", + "kind": "InitListExpr", + "range": { + "begin": { + "offset": 1158, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 1159, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad6278", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 1223, + "line": 57, + "col": 3, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 1198, + "line": 56, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 1259, + "line": 59, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x277a3ad5f78", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 1217, + "line": 56, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1208, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 1217, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x277a3ad61d0", + "kind": "FunctionDecl", + "loc": { + "offset": 1223, + "line": 57, + "col": 3, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 1221, + "col": 1, + "tokLen": 1 + }, + "end": { + "offset": 1259, + "line": 59, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "T (T, T)" + }, + "inner": [ + { + "id": "0x277a3ad6030", + "kind": "ParmVarDecl", + "loc": { + "offset": 1229, + "line": 57, + "col": 9, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1227, + "col": 7, + "tokLen": 1 + }, + "end": { + "offset": 1229, + "col": 9, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x277a3ad60b0", + "kind": "ParmVarDecl", + "loc": { + "offset": 1234, + "col": 14, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1232, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1234, + "col": 14, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "T" + } + }, + { + "id": "0x277a3ad92d0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 1237, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 1259, + "line": 59, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad92c0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1244, + "line": 58, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 1255, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad92a0", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 1251, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1255, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x277a3ad9260", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1251, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1251, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad6030", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x277a3ad9280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1255, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 1255, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad60b0", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "T" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad6fc0", + "kind": "FunctionDecl", + "loc": { + "offset": 1223, + "line": 57, + "col": 3, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 1221, + "col": 1, + "tokLen": 1 + }, + "end": { + "offset": 1259, + "line": 59, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@H@@YAHHH@Z", + "type": { + "qualType": "int (int, int)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x277a3a56da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "id": "0x277a3ad6e20", + "kind": "ParmVarDecl", + "loc": { + "offset": 1229, + "line": 57, + "col": 9, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1227, + "col": 7, + "tokLen": 1 + }, + "end": { + "offset": 1229, + "col": 9, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x277a3ad6ea0", + "kind": "ParmVarDecl", + "loc": { + "offset": 1234, + "col": 14, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1232, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1234, + "col": 14, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "int" + } + }, + { + "id": "0x277a3ad9388", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 1237, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 1259, + "line": 59, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad9378", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1244, + "line": 58, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 1255, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad9358", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 1251, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1255, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x277a3ad9328", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1251, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1251, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3ad92e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1251, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1251, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad6e20", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x277a3ad9340", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1255, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 1255, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3ad9308", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1255, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 1255, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad6ea0", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad6828", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 1331, + "line": 63, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 1291, + "line": 62, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 1331, + "line": 63, + "col": 6, + "tokLen": 8 + } + }, + "name": "addMixed", + "inner": [ + { + "id": "0x277a3ad6390", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 1310, + "line": 62, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1301, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 1310, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x277a3ad6410", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 1322, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1313, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 1322, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x277a3ad6780", + "kind": "FunctionDecl", + "loc": { + "offset": 1331, + "line": 63, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 1326, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 1331, + "col": 6, + "tokLen": 8 + } + }, + "name": "addMixed", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x277a3ad64f8", + "kind": "ParmVarDecl", + "loc": { + "offset": 1342, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1340, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 1342, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x277a3ad6578", + "kind": "ParmVarDecl", + "loc": { + "offset": 1347, + "col": 22, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 1345, + "col": 20, + "tokLen": 1 + }, + "end": { + "offset": 1347, + "col": 22, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + {} + ] + } + ] + }, + { + "id": "0x277a3ad6958", + "kind": "FunctionDecl", + "loc": { + "offset": 1400, + "line": 67, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 1396, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 1811, + "line": 84, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x277a3ad9210", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 1407, + "line": 67, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1811, + "line": 84, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad7280", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1433, + "line": 69, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1457, + "col": 29, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad6c88", + "kind": "VarDecl", + "loc": { + "offset": 1438, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 1433, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1456, + "col": 28, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x277a3ad7168", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 1447, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 1456, + "col": 28, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad7150", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1447, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 1447, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (*)(int, int)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x277a3ad70c8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1447, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 1447, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (int, int)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad6fc0", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "int (int, int)" + } + }, + "foundReferencedDecl": { + "id": "0x277a3ad6278", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x277a3ad6d38", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1451, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 1451, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "5" + }, + { + "id": "0x277a3ad6d60", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1454, + "col": 26, + "tokLen": 2 + }, + "end": { + "offset": 1454, + "col": 26, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad86e0", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1507, + "line": 72, + "col": 5, + "tokLen": 9 + }, + "end": { + "offset": 1538, + "col": 36, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad7480", + "kind": "VarDecl", + "loc": { + "offset": 1522, + "col": 20, + "tokLen": 12 + }, + "range": { + "begin": { + "offset": 1507, + "col": 5, + "tokLen": 9 + }, + "end": { + "offset": 1537, + "col": 35, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "intContainer", + "type": { + "qualType": "Container" + }, + "init": "call", + "inner": [ + { + "id": "0x277a3ad8678", + "kind": "CXXConstructExpr", + "range": { + "begin": { + "offset": 1522, + "col": 20, + "tokLen": 12 + }, + "end": { + "offset": 1537, + "col": 35, + "tokLen": 1 + } + }, + "type": { + "qualType": "Container" + }, + "valueCategory": "prvalue", + "ctorType": { + "qualType": "void (Size)" + }, + "hadMultipleCandidates": true, + "constructionKind": "complete", + "inner": [ + { + "id": "0x277a3ad8520", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1535, + "col": 33, + "tokLen": 2 + }, + "end": { + "offset": 1535, + "col": 33, + "tokLen": 2 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "IntegralCast", + "inner": [ + { + "id": "0x277a3ad74e8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1535, + "col": 33, + "tokLen": 2 + }, + "end": { + "offset": 1535, + "col": 33, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad87b0", + "kind": "ExprWithCleanups", + "range": { + "begin": { + "offset": 1545, + "line": 73, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1564, + "col": 24, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad8770", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 1545, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1564, + "col": 24, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad8718", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1545, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1558, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "add", + "isArrow": false, + "referencedMemberDecl": "0x277a3ad8260", + "inner": [ + { + "id": "0x277a3ad86f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1545, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1545, + "col": 5, + "tokLen": 12 + } + }, + "type": { + "qualType": "Container" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad7480", + "kind": "VarDecl", + "name": "intContainer", + "type": { + "qualType": "Container" + } + } + } + ] + }, + { + "id": "0x277a3ad8798", + "kind": "MaterializeTemporaryExpr", + "range": { + "begin": { + "offset": 1562, + "col": 22, + "tokLen": 2 + }, + "end": { + "offset": 1562, + "col": 22, + "tokLen": 2 + } + }, + "type": { + "qualType": "const int" + }, + "valueCategory": "lvalue", + "storageDuration": "full expression", + "boundToLValueRef": true, + "inner": [ + { + "id": "0x277a3ad8748", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1562, + "col": 22, + "tokLen": 2 + }, + "end": { + "offset": 1562, + "col": 22, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad8880", + "kind": "ExprWithCleanups", + "range": { + "begin": { + "offset": 1572, + "line": 74, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1592, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad8840", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 1572, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1592, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "void" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad87e8", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1572, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1585, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "add", + "isArrow": false, + "referencedMemberDecl": "0x277a3ad8260", + "inner": [ + { + "id": "0x277a3ad87c8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1572, + "col": 5, + "tokLen": 12 + }, + "end": { + "offset": 1572, + "col": 5, + "tokLen": 12 + } + }, + "type": { + "qualType": "Container" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad7480", + "kind": "VarDecl", + "name": "intContainer", + "type": { + "qualType": "Container" + } + } + } + ] + }, + { + "id": "0x277a3ad8868", + "kind": "MaterializeTemporaryExpr", + "range": { + "begin": { + "offset": 1589, + "col": 22, + "tokLen": 3 + }, + "end": { + "offset": 1589, + "col": 22, + "tokLen": 3 + } + }, + "type": { + "qualType": "const int" + }, + "valueCategory": "lvalue", + "storageDuration": "full expression", + "boundToLValueRef": true, + "inner": [ + { + "id": "0x277a3ad8818", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1589, + "col": 22, + "tokLen": 3 + }, + "end": { + "offset": 1589, + "col": 22, + "tokLen": 3 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "123" + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad8b10", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1638, + "line": 77, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1670, + "col": 37, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad88b0", + "kind": "VarDecl", + "loc": { + "offset": 1643, + "col": 10, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 1638, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1669, + "col": 36, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "value", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x277a3ad89a8", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 1651, + "col": 18, + "tokLen": 12 + }, + "end": { + "offset": 1669, + "col": 36, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad8938", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1651, + "col": 18, + "tokLen": 12 + }, + "end": { + "offset": 1664, + "col": 31, + "tokLen": 3 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "get", + "isArrow": false, + "referencedMemberDecl": "0x277a3ad8430", + "inner": [ + { + "id": "0x277a3ad8990", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1651, + "col": 18, + "tokLen": 12 + }, + "end": { + "offset": 1651, + "col": 18, + "tokLen": 12 + } + }, + "type": { + "qualType": "const Container" + }, + "valueCategory": "lvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x277a3ad8918", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1651, + "col": 18, + "tokLen": 12 + }, + "end": { + "offset": 1651, + "col": 18, + "tokLen": 12 + } + }, + "type": { + "qualType": "Container" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad7480", + "kind": "VarDecl", + "name": "intContainer", + "type": { + "qualType": "Container" + } + } + } + ] + } + ] + }, + { + "id": "0x277a3ad89d0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1668, + "col": 35, + "tokLen": 1 + }, + "end": { + "offset": 1668, + "col": 35, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "IntegralCast", + "inner": [ + { + "id": "0x277a3ad8968", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1668, + "col": 35, + "tokLen": 1 + }, + "end": { + "offset": 1668, + "col": 35, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad8dd0", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1677, + "line": 78, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1703, + "col": 31, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad8b40", + "kind": "VarDecl", + "loc": { + "offset": 1682, + "col": 10, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 1677, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 1702, + "col": 30, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "sum", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x277a3ad8cd0", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 1688, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 1702, + "col": 30, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad8cb8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1688, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 1688, + "col": 16, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (*)(int, int)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x277a3ad8c90", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1688, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 1688, + "col": 16, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (int, int)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad6fc0", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "int (int, int)" + } + }, + "foundReferencedDecl": { + "id": "0x277a3ad6278", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x277a3ad8d00", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1692, + "col": 20, + "tokLen": 5 + }, + "end": { + "offset": 1692, + "col": 20, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x277a3ad8bf0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1692, + "col": 20, + "tokLen": 5 + }, + "end": { + "offset": 1692, + "col": 20, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad88b0", + "kind": "VarDecl", + "name": "value", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x277a3ad8c10", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1699, + "col": 27, + "tokLen": 3 + }, + "end": { + "offset": 1699, + "col": 27, + "tokLen": 3 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "100" + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad91c0", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 1739, + "line": 81, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 1787, + "col": 53, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad9088", + "kind": "VarDecl", + "loc": { + "offset": 1753, + "col": 19, + "tokLen": 12 + }, + "range": { + "begin": { + "offset": 1739, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 1786, + "col": 52, + "tokLen": 1 + } + }, + "name": "anotherValue", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(sum)" + }, + "init": "c", + "inner": [ + { + "id": "0x277a3ad9180", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 1768, + "col": 34, + "tokLen": 12 + }, + "end": { + "offset": 1786, + "col": 52, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x277a3ad9110", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 1768, + "col": 34, + "tokLen": 12 + }, + "end": { + "offset": 1781, + "col": 47, + "tokLen": 3 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "get", + "isArrow": false, + "referencedMemberDecl": "0x277a3ad8430", + "inner": [ + { + "id": "0x277a3ad9168", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1768, + "col": 34, + "tokLen": 12 + }, + "end": { + "offset": 1768, + "col": 34, + "tokLen": 12 + } + }, + "type": { + "qualType": "const Container" + }, + "valueCategory": "lvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x277a3ad90f0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 1768, + "col": 34, + "tokLen": 12 + }, + "end": { + "offset": 1768, + "col": 34, + "tokLen": 12 + } + }, + "type": { + "qualType": "Container" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x277a3ad7480", + "kind": "VarDecl", + "name": "intContainer", + "type": { + "qualType": "Container" + } + } + } + ] + } + ] + }, + { + "id": "0x277a3ad91a8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 1785, + "col": 51, + "tokLen": 1 + }, + "end": { + "offset": 1785, + "col": 51, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "unsigned int", + "qualType": "Size", + "typeAliasDeclId": "0x277a3aad970" + }, + "valueCategory": "prvalue", + "castKind": "IntegralCast", + "inner": [ + { + "id": "0x277a3ad9140", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1785, + "col": 51, + "tokLen": 1 + }, + "end": { + "offset": 1785, + "col": 51, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad9200", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 1800, + "line": 83, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 1807, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x277a3ad91d8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 1807, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 1807, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + }, + { + "id": "0x277a3ad9788", + "kind": "FunctionDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "operator new", + "mangledName": "??2@YAPEAX_K@Z", + "type": { + "qualType": "void *(unsigned long long)" + }, + "inner": [ + { + "id": "0x277a3ad9890", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "unsigned long long" + } + }, + { + "id": "0x277a3ad9830", + "kind": "VisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true, + "visibility": "default" + }, + { + "id": "0x277a3ad9908", + "kind": "ReturnsNonNullAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + }, + { + "id": "0x277a3ad9930", + "kind": "AllocSizeAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x277a3ad9960", + "kind": "FunctionDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "isUsed": true, + "name": "operator new[]", + "mangledName": "??_U@YAPEAX_K@Z", + "type": { + "qualType": "void *(unsigned long long)" + }, + "inner": [ + { + "id": "0x277a3ad9a68", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "unsigned long long" + } + }, + { + "id": "0x277a3ad9a08", + "kind": "VisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true, + "visibility": "default" + }, + { + "id": "0x277a3ad9ae0", + "kind": "ReturnsNonNullAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + }, + { + "id": "0x277a3ad9b08", + "kind": "AllocSizeAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x277a3ad9bb8", + "kind": "FunctionDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "operator delete", + "mangledName": "??3@YAXPEAX@Z", + "type": { + "qualType": "void (void *) noexcept" + }, + "inner": [ + { + "id": "0x277a3ad9cc0", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "void *" + } + }, + { + "id": "0x277a3ad9c60", + "kind": "VisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true, + "visibility": "default" + } + ] + }, + { + "id": "0x277a3ad9dc0", + "kind": "FunctionDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "operator delete", + "mangledName": "??3@YAXPEAX_K@Z", + "type": { + "qualType": "void (void *, unsigned long long) noexcept" + }, + "inner": [ + { + "id": "0x277a3ad9ec8", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "void *" + } + }, + { + "id": "0x277a3ad9f38", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "unsigned long long" + } + }, + { + "id": "0x277a3ad9e68", + "kind": "VisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true, + "visibility": "default" + } + ] + }, + { + "id": "0x277a3ad9fc8", + "kind": "FunctionDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "isUsed": true, + "name": "operator delete[]", + "mangledName": "??_V@YAXPEAX@Z", + "type": { + "qualType": "void (void *) noexcept" + }, + "inner": [ + { + "id": "0x277a3adb4e8", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "void *" + } + }, + { + "id": "0x277a3adb488", + "kind": "VisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true, + "visibility": "default" + } + ] + }, + { + "id": "0x277a3adb560", + "kind": "FunctionDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "isUsed": true, + "name": "operator delete[]", + "mangledName": "??_V@YAXPEAX_K@Z", + "type": { + "qualType": "void (void *, unsigned long long) noexcept" + }, + "inner": [ + { + "id": "0x277a3adb668", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "void *" + } + }, + { + "id": "0x277a3adb6d8", + "kind": "ParmVarDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "type": { + "qualType": "unsigned long long" + } + }, + { + "id": "0x277a3adb608", + "kind": "VisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true, + "visibility": "default" + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/simple_output.csv b/clang-ast-mapper/simple_output.csv new file mode 100644 index 0000000000000..8589173e92741 --- /dev/null +++ b/clang-ast-mapper/simple_output.csv @@ -0,0 +1,12 @@ +Line,Source Code,AST Nodes,Explanations +1,// Simple C++ example without standard library,, +2,"int add(int a, int b) {",ParmVarDecl, +3, return a + b;,ReturnStmt, +4,},, +5,,, +6,int main() {,FunctionDecl; CompoundStmt, +7, int x = 5;,DeclStmt, +8, int y = 3;,DeclStmt, +9," int result = add(x, y);",DeclStmt, +10, return 0;,ReturnStmt, +11,},, diff --git a/clang-ast-mapper/simple_output.html b/clang-ast-mapper/simple_output.html new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang-ast-mapper/simple_output_interpretation.md b/clang-ast-mapper/simple_output_interpretation.md new file mode 100644 index 0000000000000..58550471b5bf3 --- /dev/null +++ b/clang-ast-mapper/simple_output_interpretation.md @@ -0,0 +1,25 @@ +# AST Analysis for C++ Code + +## Code Structure +The C++ code has been analyzed using Clang's AST system, revealing the following structure: +- **Function Declarations**: The code contains function declarations which define its main structure +- **Parameter Variables**: Functions have parameter declarations indicating data passed between functions +- **Code Blocks**: Contains compound statements (blocks of code within curly braces) +- **Return Statements**: Functions include return statements to provide output values +- **Variable Declarations**: The code declares local variables to store and manipulate data + +## AST Structure Summary +This code follows a typical C++ structure with: + +- Function definitions that contain variable declarations +- Variable manipulation followed by return statements + +## AST Node Types Frequency +- **DeclStmt**: 3 occurrences +- **ReturnStmt**: 2 occurrences +- **ParmVarDecl**: 1 occurrences +- **FunctionDecl**: 1 occurrences +- **CompoundStmt**: 1 occurrences + +## Code Quality Observations +- The AST structure indicates well-formed C++ code without syntax errors \ No newline at end of file diff --git a/clang-ast-mapper/simple_table.txt b/clang-ast-mapper/simple_table.txt new file mode 100644 index 0000000000000..dcca5f742729f --- /dev/null +++ b/clang-ast-mapper/simple_table.txt @@ -0,0 +1,15 @@ +AST Table for: simple.cpp +======================================================================================================================== +Line | Source Code | AST Nodes +-----+--------------------------------------------------------------+--------------------------------------------------- +1 | // Simple C++ example without standard library | +2 | int add(int a, int b) { | ParmVarDecl +3 | return a + b; | ReturnStmt +4 | } | +5 | | +6 | int main() { | CompoundStmt, FunctionDecl +7 | int x = 5; | DeclStmt +8 | int y = 3; | DeclStmt +9 | int result = add(x, y); | DeclStmt +10 | return 0; | ReturnStmt +11 | } | \ No newline at end of file diff --git a/clang-ast-mapper/src/__init__.py b/clang-ast-mapper/src/__init__.py new file mode 100644 index 0000000000000..ad8ab73b82ad8 --- /dev/null +++ b/clang-ast-mapper/src/__init__.py @@ -0,0 +1,5 @@ +""" +Package initialization for Clang AST Line Mapper +""" + +# Empty init file to make the directory a Python package diff --git a/clang-ast-mapper/src/ai_interpreter.py b/clang-ast-mapper/src/ai_interpreter.py new file mode 100644 index 0000000000000..526a53e012514 --- /dev/null +++ b/clang-ast-mapper/src/ai_interpreter.py @@ -0,0 +1,598 @@ +""" +AI Interpreter Module for Clang AST Mapper + +This module provides functionality to interpret AST mapping data using +the Hugging Face Transformers library for local inference. It analyzes +CSV output and provides insights about the code structure based on AST +node information. +""" + +import os +import csv +import json +from typing import Dict, List, Optional, Tuple + +# Import Transformers library conditionally to not break if not installed +TRANSFORMERS_AVAILABLE = False +try: + from transformers import pipeline + TRANSFORMERS_AVAILABLE = True +except ImportError: + pass + +class AIInterpreter: + """Class for interpreting AST data using AI models.""" + + def __init__(self, api_key: Optional[str] = None): + """ + Initialize the AI interpreter. + + Args: + api_key: Optional API key for the AI service. If not provided, + will try to get from environment variable AST_MAPPER_AI_KEY. + (No longer needed for local inference but kept for compatibility) + """ + self.model_name = os.environ.get('AST_MAPPER_MODEL', 'gpt2') + self.pipeline = None + + # Initialize the pipeline if Transformers is available + if TRANSFORMERS_AVAILABLE: + try: + self.pipeline = pipeline("text-generation", model=self.model_name) + print(f"Successfully loaded model: {self.model_name}") + except Exception as e: + print(f"Error loading model: {e}") + print("Falling back to default interpretation") + + def interpret_csv(self, csv_file: str) -> str: + """ + Interpret a CSV file containing AST mapping data. + + Args: + csv_file: Path to the CSV file to interpret + + Returns: + A string containing the AI interpretation of the AST data + """ + # Read the CSV file + ast_data = self._read_csv(csv_file) + if not ast_data: + return "Error: Failed to read CSV file or file is empty." + + # Prepare the data for the AI model + prompt = self._prepare_prompt(ast_data) + + # For now, always use the default interpretation which is more reliable + # for this specific task than general-purpose language models + return self._get_default_interpretation(prompt, csv_file) + + def _read_csv(self, csv_file: str) -> List[Dict]: + """ + Read a CSV file and convert it to a list of dictionaries. + + Args: + csv_file: Path to the CSV file + + Returns: + A list of dictionaries containing the CSV data + """ + try: + with open(csv_file, 'r', encoding='utf-8') as f: + reader = csv.DictReader(f) + return list(reader) + except Exception as e: + print(f"Error reading CSV file: {e}") + return [] + + def _prepare_prompt(self, ast_data: List[Dict]) -> str: + """ + Prepare a prompt for the AI model based on AST data. + + Args: + ast_data: List of dictionaries containing AST data + + Returns: + A prompt string for the AI model + """ + # Extract relevant information from the AST data + code_lines = [] + ast_info = [] + + for row in ast_data: + line_num = row.get('Line', '') + source_code = row.get('Source Code', '') + ast_nodes = row.get('AST Nodes', '') + explanations = row.get('Explanations', '') + + if source_code: + code_lines.append(f"{line_num}: {source_code}") + + if ast_nodes: + ast_info.append(f"Line {line_num}: {ast_nodes} - {explanations}") + + # Create the prompt + prompt = f"""Analyze this C++ code and its AST mapping: + +SOURCE CODE: +```cpp +{''.join(code_lines)} +``` + +AST MAPPINGS: +{chr(10).join(ast_info)} + +As a compiler expert, provide the following analysis: +1. Explain the overall structure of this code based on the AST +2. Highlight key AST nodes and what they tell us about the code +3. Explain any patterns or interesting features revealed by the AST mapping +4. If there are any potential issues or optimizations suggested by the AST structure +""" + return prompt + + def _get_ai_interpretation(self, prompt: str) -> str: + """ + Get an AI interpretation of the AST data. + + Args: + prompt: The prompt to send to the AI model + + Returns: + The AI's interpretation of the AST data + """ + # If Transformers is not available or pipeline failed to initialize, use default + if not TRANSFORMERS_AVAILABLE or self.pipeline is None: + return self._get_default_interpretation(prompt) + + try: + # Simplify the prompt for better results + simplified_prompt = "Analyze this C++ code and its Abstract Syntax Tree mapping:\n\n" + prompt + + # Generate the interpretation + result = self.pipeline(simplified_prompt, max_new_tokens=500, do_sample=True, temperature=0.7) + + # Extract the generated text + if isinstance(result, list) and result: + generated_text = result[0].get('generated_text', '') + # Return only the newly generated part, not the input prompt + return generated_text[len(simplified_prompt):].strip() + + return "Failed to generate interpretation." + + except Exception as e: + print(f"Error generating interpretation: {e}") + return self._get_default_interpretation(prompt) + + def _get_default_interpretation(self, prompt: str, csv_file_path: str = None) -> str: + """ + Provide a default interpretation when API access fails. + + Args: + prompt: The original prompt (used for analysis) + csv_file_path: Optional path to the CSV file for direct reading + + Returns: + A default interpretation based on basic pattern matching + """ + # Extract code lines from the prompt + code_section = prompt.split("```cpp")[1].split("```")[0] if "```cpp" in prompt else "" + ast_section = prompt.split("AST MAPPINGS:")[1].split("As a compiler expert")[0] if "AST MAPPINGS:" in prompt else "" + + # Count AST node types + node_types = {} + for line in ast_section.split('\n'): + if ':' in line: + for node in line.split('-')[0].split(':')[-1].split(';'): + node = node.strip() + if node: + node_types[node] = node_types.get(node, 0) + 1 + + # Dictionary with explanations for common AST nodes + node_explanations = { + "FunctionDecl": "Function declaration - defines a function with its return type, name, and parameters", + "CXXMethodDecl": "C++ method declaration - a function that belongs to a class or struct", + "CXXConstructorDecl": "C++ constructor declaration - special method that initializes objects of a class", + "CXXDestructorDecl": "C++ destructor declaration - special method that cleans up resources when object is destroyed", + "ParmVarDecl": "Parameter variable declaration - variables that receive values passed to functions", + "VarDecl": "Variable declaration - defines a variable with its type and name", + "FieldDecl": "Field declaration - member variables of a class or struct", + "DeclStmt": "Declaration statement - contains one or more variable declarations", + "ReturnStmt": "Return statement - specifies the value to be returned from a function", + "CompoundStmt": "Compound statement - a block of code enclosed in braces {}", + "IfStmt": "If statement - conditional execution based on a boolean expression", + "ForStmt": "For loop - iteration with initialization, condition, and increment steps", + "WhileStmt": "While loop - iteration based on a condition", + "DoStmt": "Do-while loop - iteration that checks condition after each execution", + "SwitchStmt": "Switch statement - multi-way branch based on a value", + "CaseStmt": "Case statement - individual branch in a switch statement", + "BinaryOperator": "Binary operator - operations that use two operands like +, -, *, /, etc.", + "UnaryOperator": "Unary operator - operations that use one operand like !, ~, ++, --, etc.", + "CallExpr": "Function call expression - invokes a function with arguments", + "CXXMemberCallExpr": "C++ member function call - invokes a method on an object", + "CXXRecordDecl": "C++ class/struct declaration - defines a user-defined type", + "AccessSpecDecl": "Access specifier - public, private, or protected sections in a class", + "TemplateDecl": "Template declaration - defines a template for generic programming", + "ImplicitCastExpr": "Implicit type conversion - automatic conversion of expressions", + "ExplicitCastExpr": "Explicit type conversion - programmer-specified type casting", + "MemberExpr": "Member expression - accessing a member of an object or class", + "DeclRefExpr": "Declaration reference - refers to a previously declared entity", + "IntegerLiteral": "Integer literal - represents a constant integer value", + "FloatingLiteral": "Floating point literal - represents a constant floating-point value", + "StringLiteral": "String literal - represents a constant string value", + "NullStmt": "Null statement - empty statement represented by a semicolon", + "InitListExpr": "Initializer list - initializes an object with a list of values", + "CXXNewExpr": "C++ new expression - dynamically allocates memory", + "CXXDeleteExpr": "C++ delete expression - deallocates memory", + "CXXThisExpr": "C++ this expression - refers to the current object" + } + + # Generate code summary + code_summary = self._generate_code_summary(code_section, node_types) + + # Generate a basic analysis + analysis = [ + "# AST Analysis for C++ Code", + "", + "## Code Summary", + code_summary, + "", + "## Code Structure", + "The C++ code has been analyzed using Clang's AST system, revealing the following structure:", + ] + + # Check for function declarations + if "FunctionDecl" in str(node_types) or "CXXMethodDecl" in str(node_types): + analysis.append("- **Function Declarations**: The code contains function/method declarations which define its main structure") + + # Check for parameter declarations + if "ParmVarDecl" in str(node_types): + analysis.append("- **Parameter Variables**: Functions have parameter declarations indicating data passed between functions") + + # Check for compound statements (blocks) + if "CompoundStmt" in str(node_types): + analysis.append("- **Code Blocks**: Contains compound statements (blocks of code within curly braces)") + + # Check for return statements + if "ReturnStmt" in str(node_types): + analysis.append("- **Return Statements**: Functions include return statements to provide output values") + + # Check for declarations + if "DeclStmt" in str(node_types) or "VarDecl" in str(node_types): + analysis.append("- **Variable Declarations**: The code declares local variables to store and manipulate data") + + # Check for control flow + has_control_flow = any(k for k in node_types.keys() if "If" in k or "For" in k or "While" in k or "Switch" in k) + if has_control_flow: + analysis.append("- **Control Flow**: Contains conditional or loop structures to control program execution") + + # Check for class definitions + if "CXXRecordDecl" in str(node_types): + analysis.append("- **Classes/Structs**: The code defines custom data types with methods and fields") + + # Add a summary section + analysis.append("") + analysis.append("## AST Structure Summary") + analysis.append("This code follows a typical C++ structure with:") + analysis.append("") + + if "CXXRecordDecl" in str(node_types) and "CXXMethodDecl" in str(node_types): + analysis.append("- Class definitions with member methods") + + if "CXXRecordDecl" in str(node_types) and "FieldDecl" in str(node_types): + analysis.append("- Classes containing member variables (fields)") + + if "FunctionDecl" in str(node_types) and "DeclStmt" in str(node_types): + analysis.append("- Function definitions that contain variable declarations") + + if "CXXMethodDecl" in str(node_types) and "DeclStmt" in str(node_types): + analysis.append("- Method implementations with local variable usage") + + if any(k for k in node_types.keys() if "CallExpr" in k): + analysis.append("- Function/method calls between defined components") + + if "DeclStmt" in str(node_types) and "ReturnStmt" in str(node_types): + analysis.append("- Variable manipulation followed by return statements") + + if has_control_flow: + analysis.append("- Control flow structures to manage program execution paths") + + # Add detailed explanations of each node type + analysis.append("") + analysis.append("## AST Node Types Explained") + analysis.append("The following AST nodes were found in the code:") + analysis.append("") + + for node, count in sorted(node_types.items(), key=lambda x: x[1], reverse=True): + # Get explanation for this node type with enhanced fallbacks for template-related nodes + explanation = node_explanations.get(node, None) + if explanation is None: + # Handle template-related nodes specially + if "Template" in node: + if "ClassTemplate" in node: + explanation = f"C++ class template declaration - defines a generic class that can work with different types" + elif "FunctionTemplate" in node: + explanation = f"C++ function template declaration - defines a generic function that can work with different types" + elif "TemplateTypeParm" in node: + explanation = f"Template type parameter - defines a placeholder type (like T) in a template" + elif "TemplateSpecialization" in node: + explanation = f"Template specialization - specific implementation of a template for particular types" + else: + explanation = f"Template-related node - part of C++'s generic programming system" + # Handle modern C++ features + elif "CXXAuto" in node: + explanation = f"C++ auto type - represents automatic type deduction" + elif "Decltype" in node: + explanation = f"C++ decltype - determines the type of an expression at compile time" + elif "Lambda" in node: + explanation = f"Lambda expression - represents an anonymous function object" + # Default fallback + else: + explanation = f"AST node type representing a {node} construct" + analysis.append(f"- **{node}** ({count} occurrences): {explanation}") + + # Parse the CSV data to extract line-by-line information + line_data = {} + code_by_line = {} + + # Directly read the CSV file to get accurate mapping + try: + # First, try to read from the actual CSV file if we can infer its path + csv_file_path = csv_file_path # Assuming this is passed to the function + + if csv_file_path and os.path.exists(csv_file_path): + with open(csv_file_path, 'r', encoding='utf-8') as f: + csv_reader = csv.DictReader(f) + for row in csv_reader: + line_num = row.get('Line', '') + if line_num and line_num.isdigit(): + code_by_line[line_num] = row.get('Source Code', '').strip() + nodes = row.get('AST Nodes', '').strip() + if nodes: + line_data[line_num] = [node.strip() for node in nodes.split(';') if node.strip()] + else: + # Fall back to parsing from the prompt + for line in prompt.split("SOURCE CODE:")[1].split("AST MAPPINGS:")[0].strip().replace("```cpp", "").replace("```", "").split('\n'): + if ':' in line: + parts = line.split(':', 1) + if len(parts) > 1 and parts[0].strip().isdigit(): + line_num = parts[0].strip() + code_by_line[line_num] = parts[1].strip() + + # Parse AST mappings from prompt + for line in prompt.split("AST MAPPINGS:")[1].split("As a compiler expert")[0].strip().split('\n'): + if 'Line' in line and ':' in line: + parts = line.split(':', 1) + if len(parts) > 1: + line_match = parts[0].strip().replace('Line', '').strip() + if line_match.isdigit(): + if line_match not in line_data: + line_data[line_match] = [] + # Extract AST nodes + if '-' in parts[1]: + node_part = parts[1].split('-')[0].strip() + nodes = [n.strip() for n in node_part.split(';') if n.strip()] + line_data[line_match].extend(nodes) + else: + nodes = [n.strip() for n in parts[1].split(';') if n.strip()] + line_data[line_match].extend(nodes) + except Exception as e: + print(f"Error parsing CSV data: {e}") + + # Add side-by-side representation if we have both code and AST data + if code_by_line: + analysis.append("") + analysis.append("## Side-by-Side Code and AST Representation") + analysis.append("This section shows each line of code alongside its corresponding AST nodes:") + analysis.append("") + analysis.append("| Line # | C++ Code | AST Nodes | Explanation |") + analysis.append("|-------------|----------------|---------------|------------------|") + + for line_num in sorted(code_by_line.keys(), key=int): + code = code_by_line[line_num] + # Skip empty lines or comment-only lines for brevity + if not code or (code.strip().startswith('//') and int(line_num) % 5 != 0): + continue + + nodes = "; ".join(line_data.get(line_num, [])) + + # Get the explanation for the primary node + node_explanation = "" + if line_num in line_data and line_data[line_num]: + primary_node = line_data[line_num][0] + explanation = node_explanations.get(primary_node, None) + if explanation is None: + # Use the same fallback logic as above + if "Template" in primary_node: + if "ClassTemplate" in primary_node: + explanation = "Class template definition" + elif "FunctionTemplate" in primary_node: + explanation = "Function template definition" + else: + explanation = "Template-related construct" + elif "CXXAuto" in primary_node: + explanation = "Auto type deduction" + elif "Decltype" in primary_node: + explanation = "Type deduction from expression" + elif "Lambda" in primary_node: + explanation = "Anonymous function" + else: + explanation = f"{primary_node}" + else: + # Simplify explanation for table + explanation = explanation.split('-')[1].strip() if '-' in explanation else explanation + + node_explanation = explanation + + analysis.append(f"| {line_num} | `{code}` | {nodes} | {node_explanation} |") + + # Add tabular summary of AST nodes + analysis.append("") + analysis.append("## AST Node Types Summary Table") + analysis.append("| Node Type | Count | Description |") + analysis.append("|-----------|-------|-------------|") + + for node, count in sorted(node_types.items(), key=lambda x: x[1], reverse=True): + explanation = node_explanations.get(node, "") + if explanation: + # Simplify explanation for table if needed + if "-" in explanation: + simple_explanation = explanation.split('-')[1].strip() + else: + simple_explanation = explanation + else: + # Handle template-related nodes specially + if "Template" in node: + if "ClassTemplate" in node: + simple_explanation = "defines a generic class that can work with different types" + elif "FunctionTemplate" in node: + simple_explanation = "defines a generic function that can work with different types" + elif "TemplateTypeParm" in node: + simple_explanation = "defines a placeholder type (like T) in a template" + elif "TemplateSpecialization" in node: + simple_explanation = "specific implementation of a template for particular types" + else: + simple_explanation = "part of C++'s generic programming system" + # Handle modern C++ features + elif "CXXAuto" in node: + simple_explanation = "represents automatic type deduction" + elif "Decltype" in node: + simple_explanation = "determines the type of an expression at compile time" + elif "Lambda" in node: + simple_explanation = "represents an anonymous function object" + # Default fallback + else: + simple_explanation = f"represents a {node} construct" + + # Ensure the explanation is not truncated + if node == "CXXRecordDecl": + simple_explanation = "defines a user-defined class or struct" + + analysis.append(f"| {node} | {count} | {simple_explanation} |") + + # Add code quality notes + analysis.append("") + analysis.append("## Code Quality Observations") + + # Simple heuristics for code quality + if len(node_types) < 5: + analysis.append("- The code is very simple with minimal AST nodes, suggesting straightforward logic") + elif len(node_types) > 15: + analysis.append("- The code has a rich variety of AST nodes, indicating complex functionality") + + analysis.append("- The AST structure indicates well-formed C++ code without syntax errors") + + if "CXXRecordDecl" in str(node_types) and node_types.get("CXXMethodDecl", 0) > 3: + analysis.append("- The class has multiple methods, suggesting good encapsulation of functionality") + + if "CompoundStmt" in str(node_types) and node_types.get("CompoundStmt", 0) > 5: + analysis.append("- Multiple nested compound statements might indicate complex code blocks that could be simplified") + + # Final summary of what the code does + analysis.append("") + analysis.append("## Functional Summary") + analysis.append(self._get_functional_summary(node_types)) + + return "\n".join(analysis) + + def _generate_code_summary(self, code_section, node_types): + """Generate a brief summary of what the code does based on AST nodes.""" + lines = code_section.strip().split('\n') + + # Identify the first few non-comment, non-empty lines as a starting point + code_start = "" + for line in lines: + line = line.strip() + if line and not line.startswith('//') and not line.startswith('/*'): + # Extract just the line number and content + if ':' in line: + parts = line.split(':', 1) + if len(parts) > 1: + line = parts[1].strip() + code_start += line + " " + if len(code_start) > 100: # Limit to reasonable length + break + + # Determine if it's a class, function, or other + if "CXXRecordDecl" in node_types: + class_methods = node_types.get("CXXMethodDecl", 0) + node_types.get("CXXConstructorDecl", 0) + return f"This code defines a C++ class with {class_methods} methods/constructors and contains logic for data manipulation and processing." + elif "FunctionDecl" in node_types and not "CXXMethodDecl" in node_types: + functions = node_types.get("FunctionDecl", 0) + return f"This code contains {functions} standalone C++ functions that perform data processing operations." + else: + return "This C++ code contains various declarations and statements for data processing and manipulation." + + def _get_functional_summary(self, node_types): + """Generate a more detailed functional summary based on AST node patterns.""" + + # Class-based code + if "CXXRecordDecl" in node_types: + has_constructors = "CXXConstructorDecl" in node_types + has_methods = "CXXMethodDecl" in node_types + has_fields = "FieldDecl" in node_types + + summary = "The code implements " + if has_constructors and has_methods and has_fields: + summary += "a complete C++ class with constructors, methods, and member variables. " + summary += "This suggests an object-oriented design with proper encapsulation of data and behavior." + elif has_methods and has_fields: + summary += "a C++ class with methods and member variables, but without explicit constructors. " + summary += "The class likely relies on default construction." + else: + summary += "a simple C++ class structure. " + + # Control flow + if "IfStmt" in node_types or "ForStmt" in node_types or "WhileStmt" in node_types: + summary += " The code contains conditional logic and/or loops, indicating non-trivial algorithmic processing." + + return summary + + # Function-based code + elif "FunctionDecl" in node_types: + summary = "The code consists of standalone C++ functions " + + if "CallExpr" in node_types: + summary += "that call other functions, suggesting a procedural programming approach. " + else: + summary += "without function calls between them, suggesting independent utility functions. " + + if "ReturnStmt" in node_types: + summary += "The functions compute and return values based on their inputs." + else: + summary += "The functions appear to perform operations without returning values (void functions)." + + return summary + + # Default case + else: + return "The code contains basic C++ constructs but does not appear to have a complex structure of classes or functions." + + +# Helper function to be called from CLI +def interpret_ast_file(csv_file: str, api_key: Optional[str] = None) -> str: + """ + Interpret an AST mapping CSV file using AI. + + Args: + csv_file: Path to the CSV file + api_key: Optional API key for the AI service + + Returns: + The AI's interpretation of the AST data + """ + interpreter = AIInterpreter(api_key) + return interpreter.interpret_csv(csv_file) + + +if __name__ == "__main__": + # Test with a sample CSV file + import sys + + if len(sys.argv) < 2: + print("Usage: python ai_interpreter.py [api_key]") + sys.exit(1) + + csv_file = sys.argv[1] + api_key = sys.argv[2] if len(sys.argv) > 2 else None + + result = interpret_ast_file(csv_file, api_key) + print(result) diff --git a/clang-ast-mapper/src/ast_parser.py b/clang-ast-mapper/src/ast_parser.py new file mode 100644 index 0000000000000..b72847de70ebc --- /dev/null +++ b/clang-ast-mapper/src/ast_parser.py @@ -0,0 +1,177 @@ +""" +AST Parser Module +Handles parsing of Clang AST JSON output and line mapping +""" + +import json +import subprocess +import os +from collections import defaultdict +from pathlib import Path + +class ASTParser: + """Parses Clang AST JSON and creates line mappings.""" + + def __init__(self): + self.line_to_nodes = defaultdict(list) + + def generate_ast_json(self, cpp_file): + """Generate AST JSON using Clang.""" + ast_file = self._get_ast_filename(cpp_file) + + # Try different clang commands + clang_commands = [ + f'clang++ -Xclang -ast-dump=json -fsyntax-only "{cpp_file}"', + f'clang -Xclang -ast-dump=json -fsyntax-only "{cpp_file}"', + ] + + # On Windows, try with Visual Studio includes + if os.name == 'nt': + vs_includes = [ + r'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include', + r'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include', + r'C:\Program Files\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include', + ] + + for include_path in vs_includes: + if os.path.exists(include_path): + clang_commands.append( + f'clang++ -Xclang -ast-dump=json -fsyntax-only -I"{include_path}" "{cpp_file}"' + ) + break + + for cmd in clang_commands: + try: + print(f" Trying: {cmd}") + result = subprocess.run(cmd, shell=True, capture_output=True, text=True) + if result.returncode == 0: + with open(ast_file, 'w', encoding='utf-8') as f: + f.write(result.stdout) + print(f" Success: AST JSON generated: {ast_file}") + return ast_file + else: + print(f" Failed: {result.stderr.strip()}") + except Exception as e: + print(f" Exception: {e}") + + print("Failed to generate AST JSON with any Clang command") + self._print_setup_help() + return None + + def _get_ast_filename(self, cpp_file): + """Get the AST filename for a given C++ file.""" + base_name = Path(cpp_file).stem + return f"{base_name}_ast.json" + + def _print_setup_help(self): + """Print help for setting up Clang.""" + print("\nSetup Help:") + print("1. Ensure Clang is installed and in PATH") + print("2. For Windows: Run from Developer Command Prompt or Visual Studio Developer PowerShell") + print("3. For standard library headers, make sure your development environment is properly configured") + print("4. Try compiling a simple file manually first: clang++ -fsyntax-only yourfile.cpp") + + def parse_ast_file(self, ast_file, cpp_file): + """Parse AST JSON file and create line mappings.""" + try: + with open(ast_file, 'r', encoding='utf-8') as f: + ast_data = json.load(f) + except Exception as e: + print(f"Error reading AST JSON: {e}") + return None + + # Clear previous mappings + self.line_to_nodes.clear() + + # Collect nodes by line + self._collect_nodes_by_line(ast_data, cpp_file) + + # Convert to regular dict and remove duplicates + line_mappings = {} + for line_num, nodes in self.line_to_nodes.items(): + line_mappings[line_num] = list(set(nodes)) # Remove duplicates + + return line_mappings + + def _collect_nodes_by_line(self, node, current_file): + """Recursively collect AST nodes by line number.""" + if isinstance(node, dict): + # Check if this node has location information + loc = node.get('loc', {}) + range_info = node.get('range', {}) + + # Try to get line number from 'loc' or 'range.begin' + line = self._extract_line_number(loc, range_info) + + # If we have a line number and node kind, add to mapping + if line and 'kind' in node: + kind = node['kind'] + # Only add if it's from the main file (not includes) + if self._is_from_main_file(loc, range_info, current_file): + self.line_to_nodes[line].append(kind) + + # Recursively process all values + for key, value in node.items(): + if key == 'inner': # 'inner' contains child nodes + self._collect_nodes_by_line(value, current_file) + elif isinstance(value, (dict, list)): + self._collect_nodes_by_line(value, current_file) + + elif isinstance(node, list): + for item in node: + self._collect_nodes_by_line(item, current_file) + + def _extract_line_number(self, loc, range_info): + """Extract line number from location information.""" + # Try to get line number from 'loc' + if 'line' in loc: + return loc['line'] + + # Try to get line number from 'range.begin' + if 'begin' in range_info and isinstance(range_info['begin'], dict): + if 'line' in range_info['begin']: + return range_info['begin']['line'] + + return None + + def _is_from_main_file(self, loc, range_info, current_file): + """Check if the AST node is from the main file (not includes).""" + # Get file information + file_info = loc.get('file') + if not file_info and 'begin' in range_info: + file_info = range_info.get('begin', {}).get('file') + + # If no file info, assume it's from main file + if not file_info: + return True + + # Check if file path matches current file + if isinstance(file_info, str): + # Normalize paths for comparison + file_path = os.path.normpath(file_info) + current_path = os.path.normpath(os.path.abspath(current_file)) + return file_path == current_path + + return True # Default to including if we can't determine + + def get_statistics(self): + """Get statistics about the parsed AST.""" + if not self.line_to_nodes: + return {} + + total_lines = len(self.line_to_nodes) + total_nodes = sum(len(nodes) for nodes in self.line_to_nodes.values()) + + # Count node types + node_counts = defaultdict(int) + for nodes in self.line_to_nodes.values(): + for node in nodes: + node_counts[node] += 1 + + return { + 'total_lines_with_ast': total_lines, + 'total_ast_nodes': total_nodes, + 'avg_nodes_per_line': total_nodes / total_lines if total_lines > 0 else 0, + 'node_type_counts': dict(node_counts), + 'most_common_nodes': sorted(node_counts.items(), key=lambda x: x[1], reverse=True)[:10] + } diff --git a/clang-ast-mapper/src/node_explanations.py b/clang-ast-mapper/src/node_explanations.py new file mode 100644 index 0000000000000..87c01e8d0a778 --- /dev/null +++ b/clang-ast-mapper/src/node_explanations.py @@ -0,0 +1,488 @@ +""" +Node Explanations Module +Provides human-readable explanations for AST node types +""" + +class NodeExplanations: + """Provides explanations for various AST node types.""" + + def __init__(self): + self.explanations = { + # Basic declarations + 'TranslationUnitDecl': 'translation unit (entire file)', + 'FunctionDecl': 'function declaration', + 'VarDecl': 'variable declaration', + 'ParmVarDecl': 'parameter variable declaration', + 'FieldDecl': 'field declaration', + 'TypedefDecl': 'typedef declaration', + 'EnumDecl': 'enum declaration', + 'EnumConstantDecl': 'enum constant declaration', + 'RecordDecl': 'record (struct/union) declaration', + 'UsingDecl': 'using declaration', + 'UsingDirectiveDecl': 'using directive declaration', + 'NamespaceDecl': 'namespace declaration', + 'LinkageSpecDecl': 'linkage specification declaration', + + # C++ specific declarations + 'CXXRecordDecl': 'C++ class/struct declaration', + 'CXXMethodDecl': 'C++ method declaration', + 'CXXConstructorDecl': 'C++ constructor declaration', + 'CXXDestructorDecl': 'C++ destructor declaration', + 'CXXConversionDecl': 'C++ conversion function declaration', + 'CXXOperatorDecl': 'C++ operator declaration', + 'ClassTemplateDecl': 'class template declaration', + 'FunctionTemplateDecl': 'function template declaration', + 'TemplateTypeParmDecl': 'template type parameter declaration', + 'NonTypeTemplateParmDecl': 'non-type template parameter declaration', + 'AccessSpecDecl': 'access specifier (public/private/protected)', + 'FriendDecl': 'friend declaration', + 'StaticAssertDecl': 'static assertion declaration', + + # Statements + 'CompoundStmt': 'compound statement (block)', + 'DeclStmt': 'declaration statement', + 'ExprStmt': 'expression statement', + 'ReturnStmt': 'return statement', + 'IfStmt': 'if statement', + 'SwitchStmt': 'switch statement', + 'CaseStmt': 'case statement', + 'DefaultStmt': 'default statement', + 'WhileStmt': 'while loop statement', + 'DoStmt': 'do-while loop statement', + 'ForStmt': 'for loop statement', + 'CXXForRangeStmt': 'C++ range-based for loop statement', + 'BreakStmt': 'break statement', + 'ContinueStmt': 'continue statement', + 'GotoStmt': 'goto statement', + 'LabelStmt': 'label statement', + 'NullStmt': 'null statement', + 'TryStmt': 'try statement', + 'CXXCatchStmt': 'C++ catch statement', + 'CXXTryStmt': 'C++ try statement', + 'ThrowStmt': 'throw statement', + + # Expressions + 'BinaryOperator': 'binary operator (e.g., +, -, *, /, ==, !=)', + 'UnaryOperator': 'unary operator (e.g., ++, --, !, ~)', + 'ConditionalOperator': 'conditional operator (?:)', + 'AssignmentOperator': 'assignment operator (=, +=, -=, etc.)', + 'CompoundAssignOperator': 'compound assignment operator', + 'CallExpr': 'function call expression', + 'MemberExpr': 'member access expression', + 'ArraySubscriptExpr': 'array subscript expression', + 'DeclRefExpr': 'reference to a declaration', + 'IntegerLiteral': 'integer literal', + 'FloatingLiteral': 'floating-point literal', + 'StringLiteral': 'string literal', + 'CharacterLiteral': 'character literal', + 'BoolLiteral': 'boolean literal', + 'CXXBoolLiteralExpr': 'C++ boolean literal expression', + 'CXXNullPtrLiteralExpr': 'C++ nullptr literal expression', + 'InitListExpr': 'initialization list expression', + 'ParenExpr': 'parenthesized expression', + 'UnaryExprOrTypeTraitExpr': 'sizeof/alignof expression', + 'CStyleCastExpr': 'C-style cast expression', + 'ImplicitCastExpr': 'implicit type cast', + 'ExplicitCastExpr': 'explicit type cast', + 'CXXStaticCastExpr': 'C++ static_cast expression', + 'CXXDynamicCastExpr': 'C++ dynamic_cast expression', + 'CXXReinterpretCastExpr': 'C++ reinterpret_cast expression', + 'CXXConstCastExpr': 'C++ const_cast expression', + 'CXXFunctionalCastExpr': 'C++ functional cast expression', + 'CXXTypeidExpr': 'C++ typeid expression', + 'CXXThisExpr': 'C++ this expression', + 'CXXThrowExpr': 'C++ throw expression', + 'CXXNewExpr': 'C++ new expression', + 'CXXDeleteExpr': 'C++ delete expression', + 'CXXOperatorCallExpr': 'C++ operator call expression', + 'CXXMemberCallExpr': 'C++ member function call expression', + 'CXXConstructExpr': 'C++ constructor call expression', + 'CXXTemporaryObjectExpr': 'C++ temporary object expression', + 'CXXBindTemporaryExpr': 'C++ bind temporary expression', + 'MaterializeTemporaryExpr': 'materialize temporary expression', + 'ExprWithCleanups': 'expression with cleanups', + 'CXXDefaultArgExpr': 'C++ default argument expression', + 'CXXScalarValueInitExpr': 'C++ scalar value initialization', + 'CXXNoexceptExpr': 'C++ noexcept expression', + 'SizeOfPackExpr': 'sizeof pack expression', + 'SubstNonTypeTemplateParmExpr': 'substituted non-type template parameter', + 'DependentScopeDeclRefExpr': 'dependent scope declaration reference', + 'CXXDependentScopeMemberExpr': 'C++ dependent scope member expression', + 'UnresolvedLookupExpr': 'unresolved lookup expression', + 'UnresolvedMemberExpr': 'unresolved member expression', + 'PackExpansionExpr': 'pack expansion expression', + 'CXXFoldExpr': 'C++ fold expression', + 'ConstantExpr': 'constant expression', + 'PredefinedExpr': 'predefined expression (__func__, __FILE__, etc.)', + 'ImaginaryLiteral': 'imaginary literal', + 'CompoundLiteralExpr': 'compound literal expression', + 'ExtVectorElementExpr': 'extended vector element expression', + 'DesignatedInitExpr': 'designated initializer expression', + 'ImplicitValueInitExpr': 'implicit value initialization', + 'VAArgExpr': 'va_arg expression', + 'AddrLabelExpr': 'address of label expression', + 'StmtExpr': 'statement expression', + 'ChooseExpr': 'choose expression', + 'GNUNullExpr': 'GNU null expression', + 'ShuffleVectorExpr': 'shuffle vector expression', + 'ConvertVectorExpr': 'convert vector expression', + 'BlockExpr': 'block expression', + 'GenericSelectionExpr': 'generic selection expression', + 'AtomicExpr': 'atomic expression', + 'TypeTraitExpr': 'type trait expression', + 'ArrayTypeTraitExpr': 'array type trait expression', + 'ExpressionTraitExpr': 'expression trait expression', + 'ObjCStringLiteral': 'Objective-C string literal', + 'ObjCBoolLiteralExpr': 'Objective-C boolean literal', + 'ObjCArrayLiteral': 'Objective-C array literal', + 'ObjCDictionaryLiteral': 'Objective-C dictionary literal', + 'ObjCBoxedExpr': 'Objective-C boxed expression', + 'ObjCSubscriptRefExpr': 'Objective-C subscript reference', + 'ObjCMessageExpr': 'Objective-C message expression', + 'ObjCSelectorExpr': 'Objective-C selector expression', + 'ObjCProtocolExpr': 'Objective-C protocol expression', + 'ObjCIvarRefExpr': 'Objective-C instance variable reference', + 'ObjCPropertyRefExpr': 'Objective-C property reference', + 'ObjCIsaExpr': 'Objective-C isa expression', + 'ObjCIndirectCopyRestoreExpr': 'Objective-C indirect copy restore', + 'ObjCBridgedCastExpr': 'Objective-C bridged cast expression', + 'ObjCForCollectionStmt': 'Objective-C for-in statement', + 'ObjCAtTryStmt': 'Objective-C @try statement', + 'ObjCAtCatchStmt': 'Objective-C @catch statement', + 'ObjCAtFinallyStmt': 'Objective-C @finally statement', + 'ObjCAtThrowStmt': 'Objective-C @throw statement', + 'ObjCAtSynchronizedStmt': 'Objective-C @synchronized statement', + 'ObjCAutoreleasePoolStmt': 'Objective-C @autoreleasepool statement', + + # Types + 'BuiltinType': 'built-in type', + 'ComplexType': 'complex type', + 'PointerType': 'pointer type', + 'BlockPointerType': 'block pointer type', + 'ReferenceType': 'reference type', + 'LValueReferenceType': 'lvalue reference type', + 'RValueReferenceType': 'rvalue reference type', + 'MemberPointerType': 'member pointer type', + 'ArrayType': 'array type', + 'ConstantArrayType': 'constant array type', + 'IncompleteArrayType': 'incomplete array type', + 'VariableArrayType': 'variable array type', + 'DependentSizedArrayType': 'dependent sized array type', + 'VectorType': 'vector type', + 'ExtVectorType': 'extended vector type', + 'FunctionType': 'function type', + 'FunctionProtoType': 'function prototype type', + 'FunctionNoProtoType': 'function no prototype type', + 'UnresolvedUsingType': 'unresolved using type', + 'ParenType': 'parenthesized type', + 'TypedefType': 'typedef type', + 'TypeOfExprType': 'typeof expression type', + 'TypeOfType': 'typeof type', + 'DecltypeType': 'decltype type', + 'UnaryTransformType': 'unary transform type', + 'TagType': 'tag type', + 'RecordType': 'record type', + 'EnumType': 'enum type', + 'ElaboratedType': 'elaborated type', + 'AttributedType': 'attributed type', + 'TemplateTypeParmType': 'template type parameter type', + 'SubstTemplateTypeParmType': 'substituted template type parameter type', + 'SubstTemplateTypeParmPackType': 'substituted template type parameter pack type', + 'TemplateSpecializationType': 'template specialization type', + 'AutoType': 'auto type', + 'DeducedTemplateSpecializationType': 'deduced template specialization type', + 'InjectedClassNameType': 'injected class name type', + 'DependentNameType': 'dependent name type', + 'DependentTemplateSpecializationType': 'dependent template specialization type', + 'PackExpansionType': 'pack expansion type', + 'ObjCObjectType': 'Objective-C object type', + 'ObjCInterfaceType': 'Objective-C interface type', + 'ObjCObjectPointerType': 'Objective-C object pointer type', + 'PipeType': 'pipe type', + 'AtomicType': 'atomic type', + + # Attributes + 'AlignedAttr': 'aligned attribute', + 'PackedAttr': 'packed attribute', + 'NoReturnAttr': 'noreturn attribute', + 'ConstAttr': 'const attribute', + 'PureAttr': 'pure attribute', + 'DeprecatedAttr': 'deprecated attribute', + 'UnavailableAttr': 'unavailable attribute', + 'VisibilityAttr': 'visibility attribute', + 'TypeVisibilityAttr': 'type visibility attribute', + 'DLLExportAttr': 'dllexport attribute', + 'DLLImportAttr': 'dllimport attribute', + 'AlwaysInlineAttr': 'always_inline attribute', + 'NoInlineAttr': 'noinline attribute', + 'FormatAttr': 'format attribute', + 'SectionAttr': 'section attribute', + 'UsedAttr': 'used attribute', + 'UnusedAttr': 'unused attribute', + 'WeakAttr': 'weak attribute', + 'AliasAttr': 'alias attribute', + 'ColdAttr': 'cold attribute', + 'HotAttr': 'hot attribute', + 'NoThrowAttr': 'nothrow attribute', + 'ReturnsTwiceAttr': 'returns_twice attribute', + 'MallocAttr': 'malloc attribute', + 'NoAliasAttr': 'noalias attribute', + 'AllocSizeAttr': 'alloc_size attribute', + 'WarnUnusedResultAttr': 'warn_unused_result attribute', + 'NonNullAttr': 'nonnull attribute', + 'ReturnsNonNullAttr': 'returns_nonnull attribute', + 'AssumeAlignedAttr': 'assume_aligned attribute', + 'AllocAlignAttr': 'alloc_align attribute', + 'EnableIfAttr': 'enable_if attribute', + 'PassObjectSizeAttr': 'pass_object_size attribute', + 'OverridableAttr': 'overridable attribute', + 'ConsumedAttr': 'consumed attribute', + 'CallableWhenAttr': 'callable_when attribute', + 'ParamTypestateAttr': 'param_typestate attribute', + 'ReturnTypestateAttr': 'return_typestate attribute', + 'SetTypestateAttr': 'set_typestate attribute', + 'TestTypestateAttr': 'test_typestate attribute', + 'AcquiredAfterAttr': 'acquired_after attribute', + 'AcquiredBeforeAttr': 'acquired_before attribute', + 'AssertCapabilityAttr': 'assert_capability attribute', + 'AssertSharedLockAttr': 'assert_shared_lock attribute', + 'AssertExclusiveLockAttr': 'assert_exclusive_lock attribute', + 'CapabilityAttr': 'capability attribute', + 'ExclusiveTrylockFunctionAttr': 'exclusive_trylock_function attribute', + 'SharedTrylockFunctionAttr': 'shared_trylock_function attribute', + 'LockReturnedAttr': 'lock_returned attribute', + 'LocksExcludedAttr': 'locks_excluded attribute', + 'ExclusiveLocksRequiredAttr': 'exclusive_locks_required attribute', + 'SharedLocksRequiredAttr': 'shared_locks_required attribute', + 'NoThreadSafetyAnalysisAttr': 'no_thread_safety_analysis attribute', + 'GuardedByAttr': 'guarded_by attribute', + 'PtGuardedByAttr': 'pt_guarded_by attribute', + 'AcquireCapabilityAttr': 'acquire_capability attribute', + 'TryAcquireCapabilityAttr': 'try_acquire_capability attribute', + 'ReleaseCapabilityAttr': 'release_capability attribute', + 'RequiresCapabilityAttr': 'requires_capability attribute', + 'ScopedLockableAttr': 'scoped_lockable attribute', + 'ExternalSourceSymbolAttr': 'external_source_symbol attribute', + 'InternalLinkageAttr': 'internal_linkage attribute', + 'MinSizeAttr': 'minsize attribute', + 'OptimizeNoneAttr': 'optnone attribute', + 'TargetAttr': 'target attribute', + 'CPUSpecificAttr': 'cpu_specific attribute', + 'CPUDispatchAttr': 'cpu_dispatch attribute', + 'CXX11NoReturnAttr': 'C++11 noreturn attribute', + 'CarriesDependencyAttr': 'carries_dependency attribute', + 'FallThroughAttr': 'fallthrough attribute', + 'MaybeUnusedAttr': 'maybe_unused attribute', + 'NoDiscardAttr': 'nodiscard attribute', + 'LifetimeBoundAttr': 'lifetime_bound attribute', + 'NoDestroyAttr': 'no_destroy attribute', + 'NoUniqueAddressAttr': 'no_unique_address attribute', + 'AssumeAttr': 'assume attribute', + 'ObjCExceptionAttr': 'objc_exception attribute', + 'ObjCNSObjectAttr': 'objc_nsobject attribute', + 'ObjCIndependentClassAttr': 'objc_independent_class attribute', + 'ObjCPreciseLifetimeAttr': 'objc_precise_lifetime attribute', + 'ObjCReturnsInnerPointerAttr': 'objc_returns_inner_pointer attribute', + 'ObjCRequiresSuperAttr': 'objc_requires_super attribute', + 'ObjCBridgeAttr': 'objc_bridge attribute', + 'ObjCBridgeMutableAttr': 'objc_bridge_mutable attribute', + 'ObjCBridgeRelatedAttr': 'objc_bridge_related attribute', + 'ObjCDesignatedInitializerAttr': 'objc_designated_initializer attribute', + 'ObjCRuntimeNameAttr': 'objc_runtime_name attribute', + 'ObjCBoxableAttr': 'objc_boxable attribute', + 'FlagEnumAttr': 'flag_enum attribute', + 'EnumExtensibilityAttr': 'enum_extensibility attribute', + 'WebAssemblyImportModuleAttr': 'wasm_import_module attribute', + 'WebAssemblyImportNameAttr': 'wasm_import_name attribute', + 'WebAssemblyExportNameAttr': 'wasm_export_name attribute', + 'CFAuditedTransferAttr': 'cf_audited_transfer attribute', + 'CFUnknownTransferAttr': 'cf_unknown_transfer attribute', + 'CFConsumedAttr': 'cf_consumed attribute', + 'CFReturnsRetainedAttr': 'cf_returns_retained attribute', + 'CFReturnsNotRetainedAttr': 'cf_returns_not_retained attribute', + 'NSConsumedAttr': 'ns_consumed attribute', + 'NSReturnsRetainedAttr': 'ns_returns_retained attribute', + 'NSReturnsNotRetainedAttr': 'ns_returns_not_retained attribute', + 'NSReturnsAutoreleasedAttr': 'ns_returns_autoreleased attribute', + 'NSConsumesSelfAttr': 'ns_consumes_self attribute', + 'NSErrorDomainAttr': 'ns_error_domain attribute', + 'ReturnsNonNullAttr': 'returns_nonnull attribute', + 'SwiftAttr': 'swift attribute', + 'SwiftAsyncAttr': 'swift_async attribute', + 'SwiftAsyncErrorAttr': 'swift_async_error attribute', + 'SwiftAsyncNameAttr': 'swift_async_name attribute', + 'SwiftBridgeAttr': 'swift_bridge attribute', + 'SwiftBridgedTypedefAttr': 'swift_bridged_typedef attribute', + 'SwiftErrorAttr': 'swift_error attribute', + 'SwiftNameAttr': 'swift_name attribute', + 'SwiftNewTypeAttr': 'swift_newtype attribute', + 'SwiftPrivateAttr': 'swift_private attribute', + 'SwiftVersionedAdditionAttr': 'swift_versioned_addition attribute', + 'SwiftVersionedRemovalAttr': 'swift_versioned_removal attribute', + 'AnyX86InterruptAttr': 'x86 interrupt attribute', + 'AnyX86NoCallerSavedRegistersAttr': 'x86 no_caller_saved_registers attribute', + 'AnyX86NoCfCheckAttr': 'x86 nocf_check attribute', + 'X86ForceAlignArgPointerAttr': 'x86 force_align_arg_pointer attribute', + 'PassObjectSizeAttr': 'pass_object_size attribute', + 'CountedByAttr': 'counted_by attribute', + 'TypeTagForDatatypeAttr': 'type_tag_for_datatype attribute', + 'ArgumentWithTypeTagAttr': 'argument_with_type_tag attribute', + 'TypeTagForDatatypeAttr': 'type_tag_for_datatype attribute', + 'ReleaseHandleAttr': 'release_handle attribute', + 'UseHandleAttr': 'use_handle attribute', + 'AcquireHandleAttr': 'acquire_handle attribute', + 'UnsafeBufferUsageAttr': 'unsafe_buffer_usage attribute', + 'PreferredNameAttr': 'preferred_name attribute', + 'StrictFPAttr': 'strict_fp attribute', + 'StrictGuardStackCheckAttr': 'strict_guard_stack_check attribute', + 'NoStackProtectorAttr': 'no_stack_protector attribute', + 'NotTailCalledAttr': 'not_tail_called attribute', + 'DisableTailCallsAttr': 'disable_tail_calls attribute', + 'SuppressAttr': 'suppress attribute', + 'CodeSegAttr': 'code_seg attribute', + 'MicrosoftABIAttr': 'ms_abi attribute', + 'SysVABIAttr': 'sysv_abi attribute', + 'RegCallAttr': 'regcall attribute', + 'PreserveMostAttr': 'preserve_most attribute', + 'PreserveAllAttr': 'preserve_all attribute', + 'SwiftCallAttr': 'swiftcall attribute', + 'VectorCallAttr': 'vectorcall attribute', + 'PcsAttr': 'pcs attribute', + 'IntelOclBiccAttr': 'intel_ocl_bicc attribute', + 'MSP430InterruptAttr': 'msp430_interrupt attribute', + 'MipsInterruptAttr': 'mips_interrupt attribute', + 'MipsLongCallAttr': 'mips_long_call attribute', + 'MipsShortCallAttr': 'mips_short_call attribute', + 'Mips16Attr': 'mips16 attribute', + 'MicroMipsAttr': 'micromips attribute', + 'NoMips16Attr': 'nomips16 attribute', + 'NoMicroMipsAttr': 'nomicromips attribute', + 'AVRInterruptAttr': 'avr_interrupt attribute', + 'AVRSignalAttr': 'avr_signal attribute', + 'WebAssemblyImportModuleAttr': 'wasm_import_module attribute', + 'WebAssemblyImportNameAttr': 'wasm_import_name attribute', + 'WebAssemblyExportNameAttr': 'wasm_export_name attribute', + 'RISCVInterruptAttr': 'riscv_interrupt attribute', + 'AMDGPUKernelCallAttr': 'amdgpu_kernel_call attribute', + 'AMDGPUNumSGPRAttr': 'amdgpu_num_sgpr attribute', + 'AMDGPUNumVGPRAttr': 'amdgpu_num_vgpr attribute', + 'AMDGPUWavesPerEUAttr': 'amdgpu_waves_per_eu attribute', + 'AMDGPUFlatWorkGroupSizeAttr': 'amdgpu_flat_work_group_size attribute', + 'CUDADeviceAttr': 'cuda_device attribute', + 'CUDAGlobalAttr': 'cuda_global attribute', + 'CUDAHostAttr': 'cuda_host attribute', + 'CUDAConstantAttr': 'cuda_constant attribute', + 'CUDASharedAttr': 'cuda_shared attribute', + 'CUDALaunchBoundsAttr': 'cuda_launch_bounds attribute', + 'CUDADeviceBuiltinSurfaceTypeAttr': 'cuda_device_builtin_surface_type attribute', + 'CUDADeviceBuiltinTextureTypeAttr': 'cuda_device_builtin_texture_type attribute', + 'OpenCLKernelAttr': 'opencl_kernel attribute', + 'OpenCLAccessAttr': 'opencl_access attribute', + 'OpenCLPrivateAddressSpaceAttr': 'opencl_private_address_space attribute', + 'OpenCLGlobalAddressSpaceAttr': 'opencl_global_address_space attribute', + 'OpenCLConstantAddressSpaceAttr': 'opencl_constant_address_space attribute', + 'OpenCLLocalAddressSpaceAttr': 'opencl_local_address_space attribute', + 'OpenCLGenericAddressSpaceAttr': 'opencl_generic_address_space attribute', + 'OpenCLIntelReqdSubGroupSizeAttr': 'opencl_intel_reqd_sub_group_size attribute', + 'OpenCLUnrollHintAttr': 'opencl_unroll_hint attribute', + 'RenderScriptKernelAttr': 'renderscript_kernel attribute', + 'HLSLNumThreadsAttr': 'hlsl_numthreads attribute', + 'HLSLShaderAttr': 'hlsl_shader attribute', + 'HLSLResourceBindingAttr': 'hlsl_resource_binding attribute', + 'HLSLPackOffsetAttr': 'hlsl_packoffset attribute', + 'HLSLResourceClassAttr': 'hlsl_resource_class attribute', + 'HLSLROVAttr': 'hlsl_rov attribute', + 'HLSLGroupSharedAddressSpaceAttr': 'hlsl_groupshared_address_space attribute', + 'SYCLKernelAttr': 'sycl_kernel attribute', + 'SYCLSpecialClassAttr': 'sycl_special_class attribute', + 'C11NoReturnAttr': 'C11 noreturn attribute', + 'CXX11NoReturnAttr': 'C++11 noreturn attribute', + 'CarriesDependencyAttr': 'carries_dependency attribute', + 'FallThroughAttr': 'fallthrough attribute', + 'MaybeUnusedAttr': 'maybe_unused attribute', + 'NoDiscardAttr': 'nodiscard attribute', + 'LifetimeBoundAttr': 'lifetime_bound attribute', + 'NoDestroyAttr': 'no_destroy attribute', + 'NoUniqueAddressAttr': 'no_unique_address attribute', + 'LikelyAttr': 'likely attribute', + 'UnlikelyAttr': 'unlikely attribute', + 'AssumeAttr': 'assume attribute', + 'InitSegAttr': 'init_seg attribute', + 'LoopHintAttr': 'loop hint attribute', + 'ModeAttr': 'mode attribute', + 'NoDebugAttr': 'no_debug attribute', + 'NoInstrumentFunctionAttr': 'no_instrument_function attribute', + 'NoProfileFunctionAttr': 'no_profile_function attribute', + 'NoSanitizeAttr': 'no_sanitize attribute', + 'NoSplitStackAttr': 'no_split_stack attribute', + 'ObjCBoxableAttr': 'objc_boxable attribute', + 'ObjCClassStubAttr': 'objc_class_stub attribute', + 'ObjCDirectAttr': 'objc_direct attribute', + 'ObjCDirectMembersAttr': 'objc_direct_members attribute', + 'ObjCNonLazyClassAttr': 'objc_nonlazy_class attribute', + 'ObjCNonRuntimeProtocolAttr': 'objc_non_runtime_protocol attribute', + 'ObjCRuntimeVisibleAttr': 'objc_runtime_visible attribute', + 'ObjCSubclassingRestrictedAttr': 'objc_subclassing_restricted attribute', + 'OMPAllocateDeclAttr': 'omp allocate attribute', + 'OMPCaptureNoInitAttr': 'omp capture no_init attribute', + 'OMPDeclareSimdDeclAttr': 'omp declare simd attribute', + 'OMPDeclareTargetDeclAttr': 'omp declare target attribute', + 'OMPDeclareVariantAttr': 'omp declare variant attribute', + 'OMPThreadPrivateDeclAttr': 'omp threadprivate attribute', + 'PragmaClangBSSSectionAttr': 'pragma clang bss_section attribute', + 'PragmaClangDataSectionAttr': 'pragma clang data_section attribute', + 'PragmaClangRodataSectionAttr': 'pragma clang rodata_section attribute', + 'PragmaClangRelroSectionAttr': 'pragma clang relro_section attribute', + 'PragmaClangTextSectionAttr': 'pragma clang text_section attribute', + 'PureAttr': 'pure attribute', + 'ReqdWorkGroupSizeAttr': 'reqd_work_group_size attribute', + 'RestrictAttr': 'restrict attribute', + 'RetainAttr': 'retain attribute', + 'SelectAnyAttr': 'selectany attribute', + 'SpeculativeLoadHardeningAttr': 'speculative_load_hardening attribute', + 'TLSModelAttr': 'tls_model attribute', + 'ThreadAttr': 'thread attribute', + 'UuidAttr': 'uuid attribute', + 'WorkGroupSizeHintAttr': 'work_group_size_hint attribute', + 'XRayInstrumentAttr': 'xray_instrument attribute', + 'XRayLogArgsAttr': 'xray_log_args attribute', + } + + def get_explanation(self, node_kind): + """Get human-readable explanation for AST node kind.""" + return self.explanations.get(node_kind, f"AST node of type {node_kind}") + + def get_all_explanations(self): + """Get all explanations as a dictionary.""" + return self.explanations.copy() + + def add_explanation(self, node_kind, explanation): + """Add or update an explanation for a node kind.""" + self.explanations[node_kind] = explanation + + def get_categories(self): + """Get explanations grouped by categories.""" + categories = { + 'Declarations': [], + 'Statements': [], + 'Expressions': [], + 'Types': [], + 'Attributes': [], + 'Other': [] + } + + for node_kind, explanation in self.explanations.items(): + if 'Decl' in node_kind: + categories['Declarations'].append((node_kind, explanation)) + elif 'Stmt' in node_kind: + categories['Statements'].append((node_kind, explanation)) + elif 'Expr' in node_kind or 'Literal' in node_kind: + categories['Expressions'].append((node_kind, explanation)) + elif 'Type' in node_kind: + categories['Types'].append((node_kind, explanation)) + elif 'Attr' in node_kind: + categories['Attributes'].append((node_kind, explanation)) + else: + categories['Other'].append((node_kind, explanation)) + + return categories diff --git a/clang-ast-mapper/src/source_annotator.py b/clang-ast-mapper/src/source_annotator.py new file mode 100644 index 0000000000000..64f2d110534f4 --- /dev/null +++ b/clang-ast-mapper/src/source_annotator.py @@ -0,0 +1,399 @@ +""" +Source Annotator Module +Handles annotation of source code with AST information +""" + +import os +from pathlib import Path + +class SourceAnnotator: + """Annotates source code with AST node information.""" + + def __init__(self): + pass + + def annotate_source(self, cpp_file, line_mappings, include_explanations=False, explanations_dict=None): + """Annotate source file with AST node information.""" + try: + with open(cpp_file, 'r', encoding='utf-8') as f: + source_lines = f.readlines() + except Exception as e: + return f"โŒ Error reading source file: {e}" + + output_lines = [] + output_lines.append(f"{'='*60}") + output_lines.append(f"AST-ANNOTATED SOURCE: {cpp_file}") + output_lines.append(f"{'='*60}") + output_lines.append("") + + for line_num, line in enumerate(source_lines, 1): + # Add the source line + output_lines.append(f"{line_num:3d}: {line.rstrip()}") + + # Add AST nodes for this line + if line_num in line_mappings: + nodes = line_mappings[line_num] + if nodes: + output_lines.append(f" AST: {', '.join(nodes)}") + + # Add explanations if requested + if include_explanations and explanations_dict: + for node in nodes: + explanation = explanations_dict.get(node, f"AST node of type {node}") + output_lines.append(f" โ†’ {node}: {explanation}") + + output_lines.append("") # Empty line for readability + + return "\n".join(output_lines) + + def side_by_side_view(self, cpp_file, line_mappings, explanations_dict=None): + """Generate side-by-side view of source and AST nodes.""" + try: + with open(cpp_file, 'r', encoding='utf-8') as f: + source_lines = f.readlines() + except Exception as e: + return f"โŒ Error reading source file: {e}" + + output_lines = [] + output_lines.append(f"{'='*100}") + output_lines.append(f"SIDE-BY-SIDE VIEW: {cpp_file}") + output_lines.append(f"{'='*100}") + output_lines.append(f"{'SOURCE CODE':<60} {'AST NODES':<40}") + output_lines.append(f"{'-'*60} {'-'*40}") + + for line_num, line in enumerate(source_lines, 1): + source_part = f"{line_num:3d}: {line.rstrip()}" + + # Get AST nodes for this line + if line_num in line_mappings and line_mappings[line_num]: + nodes = line_mappings[line_num] + ast_part = f"AST: {', '.join(nodes)}" + else: + ast_part = "" + + output_lines.append(f"{source_part:<60} {ast_part:<40}") + + # Add explanations if available + if explanations_dict and line_num in line_mappings: + for node in line_mappings[line_num]: + explanation = explanations_dict.get(node, f"AST node of type {node}") + if len(explanation) > 35: + explanation = explanation[:32] + "..." + output_lines.append(f"{'':60} โ†’ {node}: {explanation}") + + return "\n".join(output_lines) + + def generate_html_output(self, cpp_file, line_mappings, explanations_dict=None): + """Generate HTML output with syntax highlighting and tooltips.""" + try: + with open(cpp_file, 'r', encoding='utf-8') as f: + source_lines = f.readlines() + except Exception as e: + return f"

Error reading source file: {e}

" + + html_lines = [] + html_lines.append("") + html_lines.append("") + html_lines.append("") + html_lines.append("AST Annotated Source") + html_lines.append("") + html_lines.append("") + html_lines.append("") + html_lines.append(f"

AST-Annotated Source: {os.path.basename(cpp_file)}

") + + # Add table format + html_lines.append('') + html_lines.append('') + html_lines.append('') + html_lines.append('') + html_lines.append('') + html_lines.append('') + if explanations_dict: + html_lines.append('') + html_lines.append('') + html_lines.append('') + html_lines.append('') + + for line_num, line in enumerate(source_lines, 1): + # Create line with AST information + line_class = "source-line" + if line_num in line_mappings and line_mappings[line_num]: + line_class += " has-ast" + + html_lines.append(f'') + html_lines.append(f'') + html_lines.append(f'') + + # Add AST information + if line_num in line_mappings and line_mappings[line_num]: + nodes = line_mappings[line_num] + html_lines.append(f'') + + # Add explanations + if explanations_dict: + explanations_html = [] + for node in nodes: + explanation = explanations_dict.get(node, f"AST node of type {node}") + explanations_html.append(f'
{node}: {explanation}
') + html_lines.append(f'') + else: + html_lines.append('') + if explanations_dict: + html_lines.append('') + + html_lines.append('') + + html_lines.append('') + html_lines.append('
LineSource CodeAST NodesExplanations
{line_num}{self._escape_html(line.rstrip())}{", ".join(nodes)}{"".join(explanations_html)}
') + html_lines.append("") + html_lines.append("") + + return "\n".join(html_lines) + + def _escape_html(self, text): + """Escape HTML special characters.""" + return (text + .replace('&', '&') + .replace('<', '<') + .replace('>', '>') + .replace('"', '"') + .replace("'", ''')) + + def _get_css_styles(self): + """Get CSS styles for HTML output.""" + return """ + body { + font-family: 'Courier New', monospace; + margin: 20px; + background-color: #f5f5f5; + } + + h1 { + color: #333; + border-bottom: 2px solid #007acc; + padding-bottom: 10px; + text-align: center; + } + + .ast-table { + width: 100%; + border-collapse: collapse; + background-color: white; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + border-radius: 5px; + overflow: hidden; + } + + .ast-table th { + background-color: #007acc; + color: white; + padding: 12px; + text-align: left; + font-weight: bold; + } + + .ast-table td { + padding: 8px 12px; + border-bottom: 1px solid #ddd; + vertical-align: top; + } + + .ast-table tr:nth-child(even) { + background-color: #f9f9f9; + } + + .ast-table tr.has-ast { + background-color: #e6f3ff; + } + + .ast-table tr.has-ast:nth-child(even) { + background-color: #d9ecff; + } + + .line-number { + color: #666; + font-weight: bold; + text-align: right; + width: 50px; + } + + .source-code { + color: #333; + font-family: 'Courier New', monospace; + white-space: pre; + min-width: 400px; + } + + .ast-nodes { + color: #007acc; + font-weight: bold; + min-width: 200px; + } + + .explanations { + color: #666; + font-size: 0.9em; + max-width: 300px; + } + + .explanation { + margin-bottom: 4px; + padding: 2px 4px; + background-color: #f0f0f0; + border-radius: 3px; + } + + .explanation strong { + color: #007acc; + } + + /* Hover effects */ + .ast-table tr:hover { + background-color: #fff3cd; + } + + .ast-table tr.has-ast:hover { + background-color: #cce7ff; + } + + /* Responsive design */ + @media (max-width: 768px) { + .ast-table { + font-size: 0.8em; + } + + .ast-table th, + .ast-table td { + padding: 6px 8px; + } + + .source-code { + min-width: 250px; + } + + .explanations { + max-width: 200px; + } + } + """ + + def generate_markdown_output(self, cpp_file, line_mappings, explanations_dict=None): + """Generate Markdown output.""" + try: + with open(cpp_file, 'r', encoding='utf-8') as f: + source_lines = f.readlines() + except Exception as e: + return f"Error reading source file: {e}" + + output_lines = [] + output_lines.append(f"# AST-Annotated Source: {os.path.basename(cpp_file)}") + output_lines.append("") + output_lines.append("```cpp") + + for line_num, line in enumerate(source_lines, 1): + # Add the source line + output_lines.append(f"{line_num:3d}: {line.rstrip()}") + + # Add AST nodes for this line + if line_num in line_mappings and line_mappings[line_num]: + nodes = line_mappings[line_num] + ast_comment = f"// AST: {', '.join(nodes)}" + output_lines.append(f" {ast_comment}") + + # Add explanations if requested + if explanations_dict: + for node in nodes: + explanation = explanations_dict.get(node, f"AST node of type {node}") + output_lines.append(f" // โ†’ {node}: {explanation}") + + output_lines.append("") # Empty line for readability + + output_lines.append("```") + return "\n".join(output_lines) + + def generate_table_output(self, cpp_file, line_mappings, explanations_dict=None): + """Generate table format output.""" + try: + with open(cpp_file, 'r', encoding='utf-8') as f: + source_lines = f.readlines() + except Exception as e: + return f"Error reading source file: {e}" + + output_lines = [] + output_lines.append(f"AST Table for: {os.path.basename(cpp_file)}") + output_lines.append("=" * 120) + + # Table header + output_lines.append(f"{'Line':<4} | {'Source Code':<60} | {'AST Nodes':<50}") + output_lines.append("-" * 4 + "-+-" + "-" * 60 + "-+-" + "-" * 50) + + for line_num, line in enumerate(source_lines, 1): + source_code = line.rstrip() + if len(source_code) > 57: + source_code = source_code[:54] + "..." + + # Get AST nodes for this line + if line_num in line_mappings and line_mappings[line_num]: + nodes = line_mappings[line_num] + ast_nodes = ", ".join(nodes) + if len(ast_nodes) > 47: + ast_nodes = ast_nodes[:44] + "..." + else: + ast_nodes = "" + + output_lines.append(f"{line_num:<4} | {source_code:<60} | {ast_nodes:<50}") + + # Add explanations if requested + if explanations_dict and line_num in line_mappings and line_mappings[line_num]: + for node in line_mappings[line_num]: + explanation = explanations_dict.get(node, f"AST node of type {node}") + if len(explanation) > 47: + explanation = explanation[:44] + "..." + output_lines.append(f"{'':4} | {'':60} | โ†’ {node}: {explanation}") + + return "\n".join(output_lines) + + def generate_csv_output(self, cpp_file, line_mappings, explanations_dict=None): + """Generate CSV format output.""" + import csv + import io + + try: + with open(cpp_file, 'r', encoding='utf-8') as f: + source_lines = f.readlines() + except Exception as e: + return f"Error reading source file: {e}" + + # Use StringIO to build CSV in memory + output_buffer = io.StringIO() + csv_writer = csv.writer(output_buffer, quoting=csv.QUOTE_MINIMAL, lineterminator='\n') + + # Write header + csv_writer.writerow(["Line", "Source Code", "AST Nodes", "Explanations"]) + + for line_num, line in enumerate(source_lines, 1): + source_code = line.rstrip() + + # Get AST nodes for this line + if line_num in line_mappings and line_mappings[line_num]: + nodes = line_mappings[line_num] + ast_nodes = "; ".join(nodes) + + # Get explanations if requested + if explanations_dict: + explanations = [] + for node in nodes: + explanation = explanations_dict.get(node, f"AST node of type {node}") + explanations.append(f"{node}: {explanation}") + explanations_str = "; ".join(explanations) + else: + explanations_str = "" + else: + ast_nodes = "" + explanations_str = "" + + csv_writer.writerow([line_num, source_code, ast_nodes, explanations_str]) + + return output_buffer.getvalue() diff --git a/clang-ast-mapper/src/utils.py b/clang-ast-mapper/src/utils.py new file mode 100644 index 0000000000000..15728e925c882 --- /dev/null +++ b/clang-ast-mapper/src/utils.py @@ -0,0 +1,79 @@ +""" +Utility module for checking environment configuration +""" + +import subprocess +import os +import platform +import sys +from pathlib import Path + +def check_clang_installation(): + """Check if Clang is installed and available in the PATH.""" + try: + # Try to run clang --version + result = subprocess.run(['clang', '--version'], + capture_output=True, + text=True, + timeout=5) + if result.returncode == 0: + return { + 'installed': True, + 'version': result.stdout.split('\n')[0], + 'path': get_clang_path() + } + return { + 'installed': False, + 'error': 'Clang is not responding correctly' + } + except FileNotFoundError: + return { + 'installed': False, + 'error': 'Clang is not installed or not in PATH' + } + except Exception as e: + return { + 'installed': False, + 'error': str(e) + } + +def get_clang_path(): + """Get the path to the clang executable.""" + try: + if platform.system() == 'Windows': + result = subprocess.run(['where', 'clang'], + capture_output=True, + text=True) + else: + result = subprocess.run(['which', 'clang'], + capture_output=True, + text=True) + + if result.returncode == 0: + return result.stdout.strip() + return None + except Exception: + return None + +def get_system_info(): + """Get system information for diagnostics.""" + return { + 'os': platform.system(), + 'os_version': platform.version(), + 'python_version': platform.python_version(), + 'platform': platform.platform(), + 'path': os.environ.get('PATH', '') + } + +def check_environment(): + """Check the environment for all required dependencies.""" + return { + 'clang': check_clang_installation(), + 'system': get_system_info(), + 'python_path': sys.executable, + 'current_dir': os.getcwd(), + 'script_dir': os.path.dirname(os.path.abspath(__file__)), + } + +if __name__ == '__main__': + print(check_environment()) diff --git a/clang-ast-mapper/tests/test_annotator.py b/clang-ast-mapper/tests/test_annotator.py new file mode 100644 index 0000000000000..a8476a2e8648f --- /dev/null +++ b/clang-ast-mapper/tests/test_annotator.py @@ -0,0 +1,164 @@ +""" +Unit tests for Source Annotator +""" + +import unittest +import os +import tempfile +from pathlib import Path + +# Add the src directory to the Python path +import sys +sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src')) + +from source_annotator import SourceAnnotator + +class TestSourceAnnotator(unittest.TestCase): + def setUp(self): + """Set up test fixtures.""" + self.annotator = SourceAnnotator() + + # Create a temporary C++ file for testing + self.temp_cpp = tempfile.NamedTemporaryFile(mode='w', suffix='.cpp', delete=False) + self.temp_cpp.write("""int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +}""") + self.temp_cpp.close() + + # Sample line mappings for testing + self.line_mappings = { + 1: ['FunctionDecl', 'ParmVarDecl'], + 2: ['ReturnStmt'], + 5: ['FunctionDecl'], + 6: ['DeclStmt', 'CallExpr'], + 7: ['ReturnStmt'] + } + + # Sample explanations + self.explanations = { + 'FunctionDecl': 'function declaration', + 'ParmVarDecl': 'parameter variable declaration', + 'ReturnStmt': 'return statement', + 'DeclStmt': 'declaration statement', + 'CallExpr': 'function call expression' + } + + def tearDown(self): + """Clean up test fixtures.""" + if os.path.exists(self.temp_cpp.name): + os.unlink(self.temp_cpp.name) + + def test_annotate_source_basic(self): + """Test basic source annotation.""" + result = self.annotator.annotate_source( + self.temp_cpp.name, + self.line_mappings, + include_explanations=False + ) + + self.assertIsInstance(result, str) + self.assertIn("AST-ANNOTATED SOURCE", result) + self.assertIn("FunctionDecl", result) + self.assertIn("ReturnStmt", result) + + def test_annotate_source_with_explanations(self): + """Test source annotation with explanations.""" + result = self.annotator.annotate_source( + self.temp_cpp.name, + self.line_mappings, + include_explanations=True, + explanations_dict=self.explanations + ) + + self.assertIsInstance(result, str) + self.assertIn("AST-ANNOTATED SOURCE", result) + self.assertIn("FunctionDecl", result) + self.assertIn("function declaration", result) + self.assertIn("โ†’", result) + + def test_side_by_side_view(self): + """Test side-by-side view generation.""" + result = self.annotator.side_by_side_view( + self.temp_cpp.name, + self.line_mappings + ) + + self.assertIsInstance(result, str) + self.assertIn("SIDE-BY-SIDE VIEW", result) + self.assertIn("SOURCE CODE", result) + self.assertIn("AST NODES", result) + self.assertIn("FunctionDecl", result) + + def test_side_by_side_view_with_explanations(self): + """Test side-by-side view with explanations.""" + result = self.annotator.side_by_side_view( + self.temp_cpp.name, + self.line_mappings, + explanations_dict=self.explanations + ) + + self.assertIsInstance(result, str) + self.assertIn("SIDE-BY-SIDE VIEW", result) + self.assertIn("function declaration", result) + self.assertIn("โ†’", result) + + def test_generate_html_output(self): + """Test HTML output generation.""" + result = self.annotator.generate_html_output( + self.temp_cpp.name, + self.line_mappings, + explanations_dict=self.explanations + ) + + self.assertIsInstance(result, str) + self.assertIn("", result) + self.assertIn("", result) + self.assertIn("AST-Annotated Source", result) + self.assertIn("FunctionDecl", result) + self.assertIn("function declaration", result) + + def test_generate_markdown_output(self): + """Test Markdown output generation.""" + result = self.annotator.generate_markdown_output( + self.temp_cpp.name, + self.line_mappings, + explanations_dict=self.explanations + ) + + self.assertIsInstance(result, str) + self.assertIn("# AST-Annotated Source", result) + self.assertIn("```cpp", result) + self.assertIn("// AST:", result) + self.assertIn("FunctionDecl", result) + self.assertIn("function declaration", result) + + def test_escape_html(self): + """Test HTML escaping.""" + test_string = '
Hello & "world"
' + escaped = self.annotator._escape_html(test_string) + + self.assertNotIn('<', escaped) + self.assertNotIn('>', escaped) + self.assertNotIn('&', escaped) + self.assertNotIn('"', escaped) + self.assertIn('<', escaped) + self.assertIn('>', escaped) + self.assertIn('&', escaped) + self.assertIn('"', escaped) + + def test_file_not_found(self): + """Test handling of non-existent files.""" + result = self.annotator.annotate_source( + "non_existent_file.cpp", + self.line_mappings + ) + + self.assertIn("Error reading source file", result) + +if __name__ == '__main__': + unittest.main() diff --git a/clang-ast-mapper/tests/test_ast_parser.py b/clang-ast-mapper/tests/test_ast_parser.py new file mode 100644 index 0000000000000..10ac4bb04544d --- /dev/null +++ b/clang-ast-mapper/tests/test_ast_parser.py @@ -0,0 +1,151 @@ +""" +Unit tests for AST Parser +""" + +import unittest +import os +import tempfile +import json +from pathlib import Path + +# Add the src directory to the Python path +import sys +sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src')) + +from ast_parser import ASTParser + +class TestASTParser(unittest.TestCase): + def setUp(self): + """Set up test fixtures.""" + self.parser = ASTParser() + + # Create a temporary C++ file for testing + self.temp_cpp = tempfile.NamedTemporaryFile(mode='w', suffix='.cpp', delete=False) + self.temp_cpp.write(""" +int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +} +""") + self.temp_cpp.close() + + def tearDown(self): + """Clean up test fixtures.""" + # Remove temporary files + if os.path.exists(self.temp_cpp.name): + os.unlink(self.temp_cpp.name) + + # Remove generated AST file + ast_file = self.parser._get_ast_filename(self.temp_cpp.name) + if os.path.exists(ast_file): + os.unlink(ast_file) + + def test_get_ast_filename(self): + """Test AST filename generation.""" + filename = self.parser._get_ast_filename("test.cpp") + self.assertEqual(filename, "test_ast.json") + + filename = self.parser._get_ast_filename("/path/to/file.cpp") + self.assertEqual(filename, "file_ast.json") + + def test_generate_ast_json(self): + """Test AST JSON generation.""" + ast_file = self.parser.generate_ast_json(self.temp_cpp.name) + + # Check if AST file was created + if ast_file: # Only test if Clang is available + self.assertIsNotNone(ast_file) + self.assertTrue(os.path.exists(ast_file)) + + # Check if file contains valid JSON + with open(ast_file, 'r') as f: + try: + json.load(f) + except json.JSONDecodeError: + self.fail("Generated AST file is not valid JSON") + + def test_parse_ast_file(self): + """Test AST file parsing.""" + # First generate AST + ast_file = self.parser.generate_ast_json(self.temp_cpp.name) + + if ast_file: # Only test if Clang is available + # Parse the AST file + line_mappings = self.parser.parse_ast_file(ast_file, self.temp_cpp.name) + + self.assertIsNotNone(line_mappings) + self.assertIsInstance(line_mappings, dict) + + # Check that we have some line mappings + self.assertGreater(len(line_mappings), 0) + + # Check that line numbers are integers + for line_num in line_mappings.keys(): + self.assertIsInstance(line_num, int) + self.assertGreater(line_num, 0) + + # Check that node lists are lists of strings + for nodes in line_mappings.values(): + self.assertIsInstance(nodes, list) + for node in nodes: + self.assertIsInstance(node, str) + + def test_extract_line_number(self): + """Test line number extraction.""" + # Test with loc having line + loc = {'line': 5} + range_info = {} + line = self.parser._extract_line_number(loc, range_info) + self.assertEqual(line, 5) + + # Test with range.begin having line + loc = {} + range_info = {'begin': {'line': 10}} + line = self.parser._extract_line_number(loc, range_info) + self.assertEqual(line, 10) + + # Test with no line information + loc = {} + range_info = {} + line = self.parser._extract_line_number(loc, range_info) + self.assertIsNone(line) + + def test_is_from_main_file(self): + """Test main file detection.""" + current_file = "/path/to/test.cpp" + + # Test with matching file + loc = {'file': '/path/to/test.cpp'} + range_info = {} + result = self.parser._is_from_main_file(loc, range_info, current_file) + self.assertTrue(result) + + # Test with no file info (should default to True) + loc = {} + range_info = {} + result = self.parser._is_from_main_file(loc, range_info, current_file) + self.assertTrue(result) + + def test_get_statistics(self): + """Test statistics generation.""" + # Test empty statistics + stats = self.parser.get_statistics() + self.assertEqual(stats, {}) + + # Add some test data + self.parser.line_to_nodes[1] = ['FunctionDecl', 'ParmVarDecl'] + self.parser.line_to_nodes[2] = ['ReturnStmt'] + + stats = self.parser.get_statistics() + self.assertEqual(stats['total_lines_with_ast'], 2) + self.assertEqual(stats['total_ast_nodes'], 3) + self.assertEqual(stats['avg_nodes_per_line'], 1.5) + self.assertIn('node_type_counts', stats) + self.assertIn('most_common_nodes', stats) + +if __name__ == '__main__': + unittest.main() diff --git a/clang-ast-mapper/tests/test_integration.py b/clang-ast-mapper/tests/test_integration.py new file mode 100644 index 0000000000000..eac4bec63066d --- /dev/null +++ b/clang-ast-mapper/tests/test_integration.py @@ -0,0 +1,212 @@ +""" +Integration tests for the complete AST Line Mapper tool +""" + +import unittest +import os +import tempfile +import subprocess +import sys +from pathlib import Path + +class TestIntegration(unittest.TestCase): + def setUp(self): + """Set up test fixtures.""" + # Create a temporary C++ file for testing + self.temp_cpp = tempfile.NamedTemporaryFile(mode='w', suffix='.cpp', delete=False) + self.temp_cpp.write(""" +int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +} +""") + self.temp_cpp.close() + + # Get the path to the main script + self.script_path = os.path.join( + os.path.dirname(__file__), + '..', + 'ast_line_mapper.py' + ) + + def tearDown(self): + """Clean up test fixtures.""" + if os.path.exists(self.temp_cpp.name): + os.unlink(self.temp_cpp.name) + + # Clean up generated AST files + base_name = Path(self.temp_cpp.name).stem + ast_file = f"{base_name}_ast.json" + if os.path.exists(ast_file): + os.unlink(ast_file) + + def test_basic_usage(self): + """Test basic usage of the tool.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + self.temp_cpp.name + ], capture_output=True, text=True, timeout=30) + + # Check if the command ran successfully or failed due to missing Clang + if result.returncode == 0: + self.assertIn("AST-ANNOTATED SOURCE", result.stdout) + self.assertIn("FunctionDecl", result.stdout) + else: + # If Clang is not available, check for appropriate error message + self.assertIn("Failed to generate AST JSON", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + + def test_explanations_flag(self): + """Test the --explanations flag.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + self.temp_cpp.name, + '--explanations' + ], capture_output=True, text=True, timeout=30) + + if result.returncode == 0: + self.assertIn("AST-ANNOTATED SOURCE", result.stdout) + self.assertIn("function declaration", result.stdout) + self.assertIn("โ†’", result.stdout) + else: + self.assertIn("Failed to generate AST JSON", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + + def test_side_by_side_flag(self): + """Test the --side-by-side flag.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + self.temp_cpp.name, + '--side-by-side' + ], capture_output=True, text=True, timeout=30) + + if result.returncode == 0: + self.assertIn("SIDE-BY-SIDE VIEW", result.stdout) + self.assertIn("SOURCE CODE", result.stdout) + self.assertIn("AST NODES", result.stdout) + else: + self.assertIn("Failed to generate AST JSON", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + + def test_generate_ast_flag(self): + """Test the --generate-ast flag.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + self.temp_cpp.name, + '--generate-ast' + ], capture_output=True, text=True, timeout=30) + + if result.returncode == 0: + self.assertIn("AST JSON generated", result.stdout) + # Should not contain annotation output + self.assertNotIn("AST-ANNOTATED SOURCE", result.stdout) + else: + self.assertIn("Failed to generate AST JSON", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + + def test_json_format(self): + """Test JSON format output.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + self.temp_cpp.name, + '--format', 'json' + ], capture_output=True, text=True, timeout=30) + + if result.returncode == 0: + # Should contain JSON output + self.assertIn('"line_mappings"', result.stdout) + self.assertIn('"explanations"', result.stdout) + else: + self.assertIn("Failed to generate AST JSON", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + + def test_help_flag(self): + """Test the --help flag.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + '--help' + ], capture_output=True, text=True, timeout=10) + + self.assertEqual(result.returncode, 0) + self.assertIn("Map C++ source lines to AST nodes", result.stdout) + self.assertIn("--explanations", result.stdout) + self.assertIn("--side-by-side", result.stdout) + self.assertIn("--generate-ast", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + + def test_version_flag(self): + """Test the --version flag.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + '--version' + ], capture_output=True, text=True, timeout=10) + + self.assertEqual(result.returncode, 0) + self.assertIn("Clang AST Line Mapper", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + + def test_nonexistent_file(self): + """Test handling of non-existent files.""" + try: + result = subprocess.run([ + sys.executable, + self.script_path, + 'nonexistent_file.cpp' + ], capture_output=True, text=True, timeout=10) + + self.assertNotEqual(result.returncode, 0) + self.assertIn("File not found", result.stdout) + + except subprocess.TimeoutExpired: + self.fail("Tool execution timed out") + except FileNotFoundError: + self.skipTest("Python executable not found") + +if __name__ == '__main__': + unittest.main() diff --git a/clang-ast-mapper/tmp7le5fezq_ast.json b/clang-ast-mapper/tmp7le5fezq_ast.json new file mode 100644 index 0000000000000..c599ebca91241 --- /dev/null +++ b/clang-ast-mapper/tmp7le5fezq_ast.json @@ -0,0 +1,1541 @@ +{ + "id": "0x2c2a93f6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x2c2a93f7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x2c2a93f75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2c2a93f7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x2c2a93f7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x2c2a93f77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x2c2a93f7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x2c2a93f7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x2c2a93f78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x2c2a93f7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x2c2a93f7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x2c2a944d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2c2a944d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x2c2a93f6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x2c2a93f7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c2a93f7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c2a93f6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2c2a93f76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c2a93f7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c2a93f6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2c2a944d9e8", + "kind": "FunctionDecl", + "loc": { + "offset": 36, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmp7le5fezq.cpp", + "line": 7, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 31, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 68, + "line": 11, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2c2a944dc90", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 47, + "line": 7, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 68, + "line": 11, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a944dc80", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 55, + "line": 9, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 62, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x2c2a944dad8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 62, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 62, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x2c2a944e148", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 144, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 103, + "line": 17, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x2c2a944dca8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 122, + "line": 17, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 113, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 122, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x2c2a944dd30", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 134, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 125, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 134, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x2c2a944e0a0", + "kind": "FunctionDecl", + "loc": { + "offset": 144, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 139, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x2c2a944de18", + "kind": "ParmVarDecl", + "loc": { + "offset": 150, + "line": 19, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 148, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 150, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x2c2a944de98", + "kind": "ParmVarDecl", + "loc": { + "offset": 155, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 153, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 155, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x2c2a9477568", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 177, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a9477558", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 185, + "line": 21, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a9477538", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2c2a94774f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a944de18", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x2c2a9477518", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 196, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a944de98", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c2a9477160", + "kind": "FunctionDecl", + "loc": { + "offset": 144, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 139, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x2c2a93f6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x2c2a93f6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x2c2a9476eb0", + "kind": "ParmVarDecl", + "loc": { + "offset": 150, + "line": 19, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 148, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 150, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x2c2a9476f60", + "kind": "ParmVarDecl", + "loc": { + "offset": 155, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 153, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 155, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x2c2a9477638", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 177, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a9477628", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 185, + "line": 21, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a9477608", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2c2a94775f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x2c2a94775c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c2a9477580", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a9476eb0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x2c2a94775d8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 196, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c2a94775a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 196, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a9476f60", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c2a944e240", + "kind": "FunctionDecl", + "loc": { + "offset": 212, + "line": 27, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 208, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 462, + "line": 51, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2c2a94774c0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 219, + "line": 27, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 462, + "line": 51, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a944e590", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 263, + "line": 31, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 282, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a944e338", + "kind": "VarDecl", + "loc": { + "offset": 268, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 263, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 281, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x2c2a944e488", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 272, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 281, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2c2a944e470", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 272, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 272, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2c2a944e3e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 272, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 272, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a944d9e8", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c2a944e740", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 290, + "line": 33, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 303, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a944e5c0", + "kind": "VarDecl", + "loc": { + "offset": 295, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 290, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 299, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x2c2a944e628", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 299, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 299, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x2c2a9476ca8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 342, + "line": 39, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 364, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a944e7c0", + "kind": "VarDecl", + "loc": { + "offset": 354, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 342, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 362, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x2c2a9476c88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 358, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 362, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2c2a944e870", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 358, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 358, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c2a944e828", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 358, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 358, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a944e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2c2a944e848", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 362, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 362, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x2c2a9477470", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 412, + "line": 45, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 435, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a9476cd8", + "kind": "VarDecl", + "loc": { + "offset": 417, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 412, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 434, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x2c2a9477328", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 426, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 434, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2c2a9477310", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 426, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 426, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2c2a9477280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 426, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 426, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a9477160", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x2c2a944e148", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x2c2a9477358", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 430, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c2a9476d88", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 430, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a944e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2c2a9477370", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 433, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 433, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c2a9476da8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 433, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 433, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c2a944e5c0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c2a94774b0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 450, + "line": 49, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 457, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c2a9477488", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 457, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 457, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpclfx01hh_ast.json b/clang-ast-mapper/tmpclfx01hh_ast.json new file mode 100644 index 0000000000000..ef74069c9ab4a --- /dev/null +++ b/clang-ast-mapper/tmpclfx01hh_ast.json @@ -0,0 +1,1541 @@ +{ + "id": "0x2b9d1aa6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x2b9d1aa7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x2b9d1aa75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2b9d1aa7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x2b9d1aa7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x2b9d1aa77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x2b9d1aa7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x2b9d1aa7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x2b9d1aa78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x2b9d1aa7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x2b9d1aa7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x2b9d1afd888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2b9d1afd900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x2b9d1aa6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x2b9d1aa7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2b9d1aa7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2b9d1aa6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2b9d1aa76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2b9d1aa7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2b9d1aa6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2b9d1afd9e8", + "kind": "FunctionDecl", + "loc": { + "offset": 36, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpclfx01hh.cpp", + "line": 7, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 31, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 68, + "line": 11, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2b9d1afdc90", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 47, + "line": 7, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 68, + "line": 11, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1afdc80", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 55, + "line": 9, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 62, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x2b9d1afdad8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 62, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 62, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x2b9d1afe148", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 144, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 103, + "line": 17, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x2b9d1afdca8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 122, + "line": 17, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 113, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 122, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x2b9d1afdd30", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 134, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 125, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 134, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x2b9d1afe0a0", + "kind": "FunctionDecl", + "loc": { + "offset": 144, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 139, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x2b9d1afde18", + "kind": "ParmVarDecl", + "loc": { + "offset": 150, + "line": 19, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 148, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 150, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x2b9d1afde98", + "kind": "ParmVarDecl", + "loc": { + "offset": 155, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 153, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 155, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x2b9d1b27568", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 177, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1b27558", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 185, + "line": 21, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1b27538", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2b9d1b274f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1afde18", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x2b9d1b27518", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 196, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1afde98", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2b9d1b27160", + "kind": "FunctionDecl", + "loc": { + "offset": 144, + "line": 19, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 139, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x2b9d1aa6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x2b9d1aa6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x2b9d1b26eb0", + "kind": "ParmVarDecl", + "loc": { + "offset": 150, + "line": 19, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 148, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 150, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x2b9d1b26f60", + "kind": "ParmVarDecl", + "loc": { + "offset": 155, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 153, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 155, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x2b9d1b27638", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 177, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 201, + "line": 23, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1b27628", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 185, + "line": 21, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1b27608", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2b9d1b275f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x2b9d1b275c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2b9d1b27580", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 192, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 192, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1b26eb0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x2b9d1b275d8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 196, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2b9d1b275a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 196, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 196, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1b26f60", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2b9d1afe240", + "kind": "FunctionDecl", + "loc": { + "offset": 212, + "line": 27, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 208, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 462, + "line": 51, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2b9d1b274c0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 219, + "line": 27, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 462, + "line": 51, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1afe590", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 263, + "line": 31, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 282, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1afe338", + "kind": "VarDecl", + "loc": { + "offset": 268, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 263, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 281, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x2b9d1afe488", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 272, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 281, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2b9d1afe470", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 272, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 272, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2b9d1afe3e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 272, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 272, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1afd9e8", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2b9d1afe740", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 290, + "line": 33, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 303, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1afe5c0", + "kind": "VarDecl", + "loc": { + "offset": 295, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 290, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 299, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x2b9d1afe628", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 299, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 299, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x2b9d1b26ca8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 342, + "line": 39, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 364, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1afe7c0", + "kind": "VarDecl", + "loc": { + "offset": 354, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 342, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 362, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x2b9d1b26c88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 358, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 362, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2b9d1afe870", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 358, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 358, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2b9d1afe828", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 358, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 358, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1afe338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2b9d1afe848", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 362, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 362, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x2b9d1b27470", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 412, + "line": 45, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 435, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1b26cd8", + "kind": "VarDecl", + "loc": { + "offset": 417, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 412, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 434, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x2b9d1b27328", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 426, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 434, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2b9d1b27310", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 426, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 426, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2b9d1b27280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 426, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 426, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1b27160", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x2b9d1afe148", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x2b9d1b27358", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 430, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2b9d1b26d88", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 430, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1afe338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2b9d1b27370", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 433, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 433, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2b9d1b26da8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 433, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 433, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2b9d1afe5c0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2b9d1b274b0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 450, + "line": 49, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 457, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2b9d1b27488", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 457, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 457, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpff0uilk6_ast.json b/clang-ast-mapper/tmpff0uilk6_ast.json new file mode 100644 index 0000000000000..60da77fcabd4b --- /dev/null +++ b/clang-ast-mapper/tmpff0uilk6_ast.json @@ -0,0 +1,1425 @@ +{ + "id": "0x224866a6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x224866a7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x224866a75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x224866a7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x224866a7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x224866a77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x224866a7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x224866a7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x224866a78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x224866a7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x224866a7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x224866fd888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x224866fd900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x224866a6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x224866a7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x224866a7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x224866a6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x224866a76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x224866a7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x224866a6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x224866fd958", + "kind": "CXXRecordDecl", + "loc": { + "offset": 6, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpff0uilk6.cpp", + "line": 1, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 0, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 268, + "line": 31, + "col": 1, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "Calculator", + "tagUsed": "class", + "completeDefinition": true, + "definitionData": { + "canConstDefaultInit": true, + "canPassInRegisters": true, + "copyAssign": { + "hasConstParam": true, + "implicitHasConstParam": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "copyCtor": { + "hasConstParam": true, + "implicitHasConstParam": true, + "simple": true, + "trivial": true + }, + "defaultCtor": {}, + "dtor": { + "irrelevant": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "hasUserDeclaredConstructor": true, + "isStandardLayout": true, + "isTriviallyCopyable": true, + "moveAssign": { + "exists": true, + "needsImplicit": true, + "simple": true, + "trivial": true + }, + "moveCtor": { + "exists": true, + "simple": true, + "trivial": true + } + }, + "inner": [ + { + "id": "0x224866fda78", + "kind": "CXXRecordDecl", + "loc": { + "offset": 6, + "line": 1, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 0, + "col": 1, + "tokLen": 5 + }, + "end": { + "offset": 6, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "isReferenced": true, + "name": "Calculator", + "tagUsed": "class" + }, + { + "id": "0x224866fdb08", + "kind": "AccessSpecDecl", + "loc": { + "offset": 21, + "line": 3, + "col": 1, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 21, + "col": 1, + "tokLen": 7 + }, + "end": { + "offset": 28, + "col": 8, + "tokLen": 1 + } + }, + "access": "private" + }, + { + "id": "0x224866fdb50", + "kind": "FieldDecl", + "loc": { + "offset": 40, + "line": 5, + "col": 9, + "tokLen": 5 + }, + "range": { + "begin": { + "offset": 36, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 40, + "col": 9, + "tokLen": 5 + } + }, + "isReferenced": true, + "name": "value", + "type": { + "qualType": "int" + } + }, + { + "id": "0x224866fdba8", + "kind": "AccessSpecDecl", + "loc": { + "offset": 56, + "line": 9, + "col": 1, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 56, + "col": 1, + "tokLen": 6 + }, + "end": { + "offset": 62, + "col": 7, + "tokLen": 1 + } + }, + "access": "public" + }, + { + "id": "0x224866fdd10", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 70, + "line": 11, + "col": 5, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 70, + "col": 5, + "tokLen": 10 + }, + "end": { + "offset": 112, + "col": 47, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@H@Z", + "type": { + "qualType": "void (int)" + }, + "inner": [ + { + "id": "0x224866fdbf0", + "kind": "ParmVarDecl", + "loc": { + "offset": 85, + "col": 20, + "tokLen": 7 + }, + "range": { + "begin": { + "offset": 81, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 85, + "col": 20, + "tokLen": 7 + } + }, + "isUsed": true, + "name": "initial", + "type": { + "qualType": "int" + } + }, + { + "kind": "CXXCtorInitializer", + "anyInit": { + "id": "0x224866fdb50", + "kind": "FieldDecl", + "name": "value", + "type": { + "qualType": "int" + } + }, + "inner": [ + { + "id": "0x224866fe0f8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 102, + "col": 37, + "tokLen": 7 + }, + "end": { + "offset": 102, + "col": 37, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x224866fe0b8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 102, + "col": 37, + "tokLen": 7 + }, + "end": { + "offset": 102, + "col": 37, + "tokLen": 7 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x224866fdbf0", + "kind": "ParmVarDecl", + "name": "initial", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x224866fe138", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 111, + "col": 46, + "tokLen": 1 + }, + "end": { + "offset": 112, + "col": 47, + "tokLen": 1 + } + } + } + ] + }, + { + "id": "0x224866fdeb8", + "kind": "CXXMethodDecl", + "loc": { + "offset": 131, + "line": 15, + "col": 9, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 127, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 196, + "line": 21, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "?add@Calculator@@QEAAHH@Z", + "type": { + "qualType": "int (int)" + }, + "inner": [ + { + "id": "0x224866fdde0", + "kind": "ParmVarDecl", + "loc": { + "offset": 139, + "line": 15, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 135, + "col": 13, + "tokLen": 3 + }, + "end": { + "offset": 139, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + } + }, + { + "id": "0x224866fe2a0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 142, + "col": 20, + "tokLen": 1 + }, + "end": { + "offset": 196, + "line": 21, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x224866fe208", + "kind": "CompoundAssignOperator", + "range": { + "begin": { + "offset": 154, + "line": 17, + "col": 9, + "tokLen": 5 + }, + "end": { + "offset": 163, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "opcode": "+=", + "computeLHSType": { + "qualType": "int" + }, + "computeResultType": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x224866fe1a0", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 154, + "col": 9, + "tokLen": 5 + }, + "end": { + "offset": 154, + "col": 9, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x224866fdb50", + "inner": [ + { + "id": "0x224866fe190", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 154, + "col": 9, + "tokLen": 5 + }, + "end": { + "offset": 154, + "col": 9, + "tokLen": 5 + } + }, + "type": { + "qualType": "Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + }, + { + "id": "0x224866fe1f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 163, + "col": 18, + "tokLen": 1 + }, + "end": { + "offset": 163, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x224866fe1d0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 163, + "col": 18, + "tokLen": 1 + }, + "end": { + "offset": 163, + "col": 18, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x224866fdde0", + "kind": "ParmVarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x224866fe290", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 176, + "line": 19, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 183, + "col": 16, + "tokLen": 5 + } + }, + "inner": [ + { + "id": "0x224866fe278", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 183, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 183, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x224866fe248", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 183, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 183, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x224866fdb50", + "inner": [ + { + "id": "0x224866fe238", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 183, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 183, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x224866fdff8", + "kind": "CXXMethodDecl", + "loc": { + "offset": 215, + "line": 25, + "col": 9, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 211, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 264, + "line": 29, + "col": 5, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@Calculator@@QEBAHXZ", + "type": { + "qualType": "int () const" + }, + "inner": [ + { + "id": "0x224866fe328", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 232, + "line": 25, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 264, + "line": 29, + "col": 5, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x224866fe318", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 244, + "line": 27, + "col": 9, + "tokLen": 6 + }, + "end": { + "offset": 251, + "col": 16, + "tokLen": 5 + } + }, + "inner": [ + { + "id": "0x224866fe300", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 251, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 251, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x224866fe2d0", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 251, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 251, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "const int" + }, + "valueCategory": "lvalue", + "name": "value", + "isArrow": true, + "referencedMemberDecl": "0x224866fdb50", + "inner": [ + { + "id": "0x224866fe2c0", + "kind": "CXXThisExpr", + "range": { + "begin": { + "offset": 251, + "col": 16, + "tokLen": 5 + }, + "end": { + "offset": 251, + "col": 16, + "tokLen": 5 + } + }, + "type": { + "qualType": "const Calculator *" + }, + "valueCategory": "prvalue", + "implicit": true + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x224866fe620", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 6, + "line": 1, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 6, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 6, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@AEBV0@@Z", + "type": { + "qualType": "void (const Calculator &)" + }, + "inline": true, + "constexpr": true, + "explicitlyDefaulted": "default", + "inner": [ + { + "id": "0x224866fe750", + "kind": "ParmVarDecl", + "loc": { + "offset": 6, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 6, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 6, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "const Calculator &" + } + } + ] + }, + { + "id": "0x22486726c88", + "kind": "CXXConstructorDecl", + "loc": { + "offset": 6, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 6, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 6, + "col": 7, + "tokLen": 10 + } + }, + "isImplicit": true, + "name": "Calculator", + "mangledName": "??0Calculator@@QEAA@$$QEAV0@@Z", + "type": { + "qualType": "void (Calculator &&)" + }, + "inline": true, + "constexpr": true, + "explicitlyDefaulted": "default", + "inner": [ + { + "id": "0x22486726dc0", + "kind": "ParmVarDecl", + "loc": { + "offset": 6, + "col": 7, + "tokLen": 10 + }, + "range": { + "begin": { + "offset": 6, + "col": 7, + "tokLen": 10 + }, + "end": { + "offset": 6, + "col": 7, + "tokLen": 10 + } + }, + "type": { + "qualType": "Calculator &&" + } + } + ] + } + ] + }, + { + "id": "0x224866fe398", + "kind": "FunctionDecl", + "loc": { + "offset": 280, + "line": 35, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 276, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 367, + "line": 43, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x224867270f8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 287, + "line": 35, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 367, + "line": 43, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x22486726fa8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 295, + "line": 37, + "col": 5, + "tokLen": 10 + }, + "end": { + "offset": 314, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x224866fe510", + "kind": "VarDecl", + "loc": { + "offset": 306, + "col": 16, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 295, + "col": 5, + "tokLen": 10 + }, + "end": { + "offset": 313, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "calc", + "type": { + "qualType": "Calculator" + }, + "init": "call", + "inner": [ + { + "id": "0x22486726f78", + "kind": "CXXConstructExpr", + "range": { + "begin": { + "offset": 306, + "col": 16, + "tokLen": 4 + }, + "end": { + "offset": 313, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "prvalue", + "ctorType": { + "qualType": "void (int)" + }, + "hadMultipleCandidates": true, + "constructionKind": "complete", + "inner": [ + { + "id": "0x224866fe578", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 311, + "col": 21, + "tokLen": 2 + }, + "end": { + "offset": 311, + "col": 21, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x22486727038", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 322, + "line": 39, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 332, + "col": 15, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x22486726fe0", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 322, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 327, + "col": 10, + "tokLen": 3 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "add", + "isArrow": false, + "referencedMemberDecl": "0x224866fdeb8", + "inner": [ + { + "id": "0x22486726fc0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 322, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 322, + "col": 5, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x224866fe510", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + }, + { + "id": "0x22486727010", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 331, + "col": 14, + "tokLen": 1 + }, + "end": { + "offset": 331, + "col": 14, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "5" + } + ] + }, + { + "id": "0x224867270e8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 341, + "line": 41, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 362, + "col": 26, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x224867270c8", + "kind": "CXXMemberCallExpr", + "range": { + "begin": { + "offset": 348, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 362, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x22486727080", + "kind": "MemberExpr", + "range": { + "begin": { + "offset": 348, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 353, + "col": 17, + "tokLen": 8 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "name": "getValue", + "isArrow": false, + "referencedMemberDecl": "0x224866fdff8", + "inner": [ + { + "id": "0x224867270b0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 348, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 348, + "col": 12, + "tokLen": 4 + } + }, + "type": { + "qualType": "const Calculator" + }, + "valueCategory": "lvalue", + "castKind": "NoOp", + "inner": [ + { + "id": "0x22486727060", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 348, + "col": 12, + "tokLen": 4 + }, + "end": { + "offset": 348, + "col": 12, + "tokLen": 4 + } + }, + "type": { + "qualType": "Calculator" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x224866fe510", + "kind": "VarDecl", + "name": "calc", + "type": { + "qualType": "Calculator" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpgc0sme0f_ast.json b/clang-ast-mapper/tmpgc0sme0f_ast.json new file mode 100644 index 0000000000000..4b6979e2f5f11 --- /dev/null +++ b/clang-ast-mapper/tmpgc0sme0f_ast.json @@ -0,0 +1,718 @@ +{ + "id": "0x1e418256c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x1e418257510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x1e4182575c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1e418257748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x1e418257260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x1e4182577b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x1e418257280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x1e418257b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x1e4182578a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x1e418257810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x1e418257bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x1e4182ad888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1e4182ad900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x1e418256e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x1e418257668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1e418257620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1e418256d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1e4182576d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1e418257620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1e418256d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1e4182adae8", + "kind": "FunctionDecl", + "loc": { + "offset": 4, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpgc0sme0f.cpp", + "line": 1, + "col": 5, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 0, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 46, + "line": 5, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "?add@@YAHHH@Z", + "type": { + "qualType": "int (int, int)" + }, + "inner": [ + { + "id": "0x1e4182ad970", + "kind": "ParmVarDecl", + "loc": { + "offset": 12, + "line": 1, + "col": 13, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 8, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 12, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1e4182ad9f8", + "kind": "ParmVarDecl", + "loc": { + "offset": 19, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 15, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 19, + "col": 20, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1e4182adc88", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 22, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 46, + "line": 5, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1e4182adc78", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 30, + "line": 3, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1e4182adc58", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1e4182adc28", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 37, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1e4182adbe8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 37, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1e4182ad970", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1e4182adc40", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 41, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1e4182adc08", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 41, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1e4182ad9f8", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1e4182adcf8", + "kind": "FunctionDecl", + "loc": { + "offset": 57, + "line": 9, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 53, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 114, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x1e4182adfd8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 64, + "line": 9, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 114, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1e4182adf88", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 72, + "line": 11, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 94, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1e4182adde8", + "kind": "VarDecl", + "loc": { + "offset": 76, + "col": 9, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 72, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 93, + "col": 26, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1e4182adf58", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 93, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1e4182adf40", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 85, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (*)(int, int)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x1e4182adee8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 85, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (int, int)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1e4182adae8", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "int (int, int)" + } + } + } + ] + }, + { + "id": "0x1e4182ade98", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 89, + "col": 22, + "tokLen": 1 + }, + "end": { + "offset": 89, + "col": 22, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "5" + }, + { + "id": "0x1e4182adec0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 92, + "col": 25, + "tokLen": 1 + }, + "end": { + "offset": 92, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "3" + } + ] + } + ] + } + ] + }, + { + "id": "0x1e4182adfc8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 102, + "line": 13, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 109, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1e4182adfa0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 109, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 109, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpmr5max4f_ast.json b/clang-ast-mapper/tmpmr5max4f_ast.json new file mode 100644 index 0000000000000..19aa45d553e41 --- /dev/null +++ b/clang-ast-mapper/tmpmr5max4f_ast.json @@ -0,0 +1,1541 @@ +{ + "id": "0x26754ce6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x26754ce7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x26754ce75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x26754ce7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x26754ce7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x26754ce77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x26754ce7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x26754ce7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x26754ce78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x26754ce7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x26754ce7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x26754d3d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x26754d3d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x26754ce6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x26754ce7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x26754ce7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x26754ce6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x26754ce76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x26754ce7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x26754ce6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x26754d3d9e8", + "kind": "FunctionDecl", + "loc": { + "offset": 33, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpmr5max4f.cpp", + "line": 5, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 28, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x26754d3dc90", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 44, + "line": 5, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d3dc80", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 52, + "line": 7, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x26754d3dad8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 59, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x26754d3e148", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 100, + "line": 15, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x26754d3dca8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 119, + "line": 15, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 110, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 119, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x26754d3dd30", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 131, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 122, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 131, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x26754d3e0a0", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x26754d3de18", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x26754d3de98", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x26754d67568", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d67558", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d67538", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x26754d674f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d3de18", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x26754d67518", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d3de98", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x26754d67160", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x26754ce6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x26754ce6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x26754d66eb0", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x26754d66f60", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x26754d67638", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d67628", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d67608", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x26754d675f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x26754d675c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x26754d67580", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d66eb0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x26754d675d8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x26754d675a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d66f60", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x26754d3e240", + "kind": "FunctionDecl", + "loc": { + "offset": 209, + "line": 25, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 205, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x26754d674c0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 216, + "line": 25, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d3e590", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 260, + "line": 29, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 279, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d3e338", + "kind": "VarDecl", + "loc": { + "offset": 265, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 260, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x26754d3e488", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x26754d3e470", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x26754d3e3e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d3d9e8", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x26754d3e740", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 287, + "line": 31, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 300, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d3e5c0", + "kind": "VarDecl", + "loc": { + "offset": 292, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 287, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x26754d3e628", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 296, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x26754d66ca8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 339, + "line": 37, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 361, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d3e7c0", + "kind": "VarDecl", + "loc": { + "offset": 351, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 339, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x26754d66c88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x26754d3e870", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x26754d3e828", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d3e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x26754d3e848", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 359, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x26754d67470", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 409, + "line": 43, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 432, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d66cd8", + "kind": "VarDecl", + "loc": { + "offset": 414, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 409, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x26754d67328", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x26754d67310", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x26754d67280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d67160", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x26754d3e148", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x26754d67358", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x26754d66d88", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d3e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x26754d67370", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x26754d66da8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x26754d3e5c0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x26754d674b0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 447, + "line": 47, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x26754d67488", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 454, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpnv9q0rre_ast.json b/clang-ast-mapper/tmpnv9q0rre_ast.json new file mode 100644 index 0000000000000..f0accabd50998 --- /dev/null +++ b/clang-ast-mapper/tmpnv9q0rre_ast.json @@ -0,0 +1,718 @@ +{ + "id": "0x25beaa76c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x25beaa77510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x25beaa775c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x25beaa77748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x25beaa77260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x25beaa777b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x25beaa77280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x25beaa77b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x25beaa778a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x25beaa77810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x25beaa77bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x25beaacd888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x25beaacd900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x25beaa76e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x25beaa77668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x25beaa77620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x25beaa76d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x25beaa776d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x25beaa77620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x25beaa76d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x25beaacdae8", + "kind": "FunctionDecl", + "loc": { + "offset": 4, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpnv9q0rre.cpp", + "line": 1, + "col": 5, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 0, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 46, + "line": 5, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "?add@@YAHHH@Z", + "type": { + "qualType": "int (int, int)" + }, + "inner": [ + { + "id": "0x25beaacd970", + "kind": "ParmVarDecl", + "loc": { + "offset": 12, + "line": 1, + "col": 13, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 8, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 12, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x25beaacd9f8", + "kind": "ParmVarDecl", + "loc": { + "offset": 19, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 15, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 19, + "col": 20, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "int" + } + }, + { + "id": "0x25beaacdc88", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 22, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 46, + "line": 5, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x25beaacdc78", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 30, + "line": 3, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x25beaacdc58", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x25beaacdc28", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 37, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x25beaacdbe8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 37, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x25beaacd970", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x25beaacdc40", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 41, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x25beaacdc08", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 41, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x25beaacd9f8", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x25beaacdcf8", + "kind": "FunctionDecl", + "loc": { + "offset": 57, + "line": 9, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 53, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 114, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x25beaacdfd8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 64, + "line": 9, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 114, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x25beaacdf88", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 72, + "line": 11, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 94, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x25beaacdde8", + "kind": "VarDecl", + "loc": { + "offset": 76, + "col": 9, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 72, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 93, + "col": 26, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x25beaacdf58", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 93, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x25beaacdf40", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 85, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (*)(int, int)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x25beaacdee8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 85, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (int, int)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x25beaacdae8", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "int (int, int)" + } + } + } + ] + }, + { + "id": "0x25beaacde98", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 89, + "col": 22, + "tokLen": 1 + }, + "end": { + "offset": 89, + "col": 22, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "5" + }, + { + "id": "0x25beaacdec0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 92, + "col": 25, + "tokLen": 1 + }, + "end": { + "offset": 92, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "3" + } + ] + } + ] + } + ] + }, + { + "id": "0x25beaacdfc8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 102, + "line": 13, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 109, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x25beaacdfa0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 109, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 109, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpsme749t8_ast.json b/clang-ast-mapper/tmpsme749t8_ast.json new file mode 100644 index 0000000000000..7c7a1ec64a0db --- /dev/null +++ b/clang-ast-mapper/tmpsme749t8_ast.json @@ -0,0 +1,1541 @@ +{ + "id": "0x21254bb6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x21254bb7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x21254bb75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x21254bb7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x21254bb7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x21254bb77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x21254bb7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x21254bb7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x21254bb78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x21254bb7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x21254bb7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x21254c0d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x21254c0d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x21254bb6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x21254bb7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x21254bb7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x21254bb6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x21254bb76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x21254bb7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x21254bb6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x21254c0d9e8", + "kind": "FunctionDecl", + "loc": { + "offset": 30, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpsme749t8.cpp", + "line": 3, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 25, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 62, + "line": 7, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x21254c0dc90", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 41, + "line": 3, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 62, + "line": 7, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c0dc80", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 49, + "line": 5, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 56, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x21254c0dad8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 56, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 56, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x21254c0e148", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 138, + "line": 15, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 97, + "line": 13, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 195, + "line": 19, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x21254c0dca8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 116, + "line": 13, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 107, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 116, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x21254c0dd30", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 128, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 119, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 128, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x21254c0e0a0", + "kind": "FunctionDecl", + "loc": { + "offset": 138, + "line": 15, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 133, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 195, + "line": 19, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x21254c0de18", + "kind": "ParmVarDecl", + "loc": { + "offset": 144, + "line": 15, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 142, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 144, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x21254c0de98", + "kind": "ParmVarDecl", + "loc": { + "offset": 149, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 147, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 149, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x21254c37568", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 171, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 195, + "line": 19, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c37558", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 179, + "line": 17, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 190, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c37538", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 186, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 190, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x21254c374f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 186, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 186, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c0de18", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x21254c37518", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 190, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 190, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c0de98", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x21254c37160", + "kind": "FunctionDecl", + "loc": { + "offset": 138, + "line": 15, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 133, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 195, + "line": 19, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x21254bb6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x21254bb6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x21254c36eb0", + "kind": "ParmVarDecl", + "loc": { + "offset": 144, + "line": 15, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 142, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 144, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x21254c36f60", + "kind": "ParmVarDecl", + "loc": { + "offset": 149, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 147, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 149, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x21254c37638", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 171, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 195, + "line": 19, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c37628", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 179, + "line": 17, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 190, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c37608", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 186, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 190, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x21254c375f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 186, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 186, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x21254c375c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 186, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 186, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x21254c37580", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 186, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 186, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c36eb0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x21254c375d8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 190, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 190, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x21254c375a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 190, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 190, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c36f60", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x21254c0e240", + "kind": "FunctionDecl", + "loc": { + "offset": 206, + "line": 23, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 202, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 456, + "line": 47, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x21254c374c0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 213, + "line": 23, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 456, + "line": 47, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c0e590", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 257, + "line": 27, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 276, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c0e338", + "kind": "VarDecl", + "loc": { + "offset": 262, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 257, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 275, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x21254c0e488", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 266, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 275, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x21254c0e470", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 266, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 266, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x21254c0e3e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 266, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 266, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c0d9e8", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x21254c0e740", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 284, + "line": 29, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 297, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c0e5c0", + "kind": "VarDecl", + "loc": { + "offset": 289, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 284, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 293, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x21254c0e628", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 293, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 293, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x21254c36ca8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 336, + "line": 35, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 358, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c0e7c0", + "kind": "VarDecl", + "loc": { + "offset": 348, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 336, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 356, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x21254c36c88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 352, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 356, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x21254c0e870", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 352, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 352, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x21254c0e828", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 352, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 352, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c0e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x21254c0e848", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 356, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 356, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x21254c37470", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 406, + "line": 41, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 429, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c36cd8", + "kind": "VarDecl", + "loc": { + "offset": 411, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 406, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 428, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x21254c37328", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 420, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 428, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x21254c37310", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 420, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 420, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x21254c37280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 420, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 420, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c37160", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x21254c0e148", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x21254c37358", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 424, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 424, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x21254c36d88", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 424, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 424, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c0e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x21254c37370", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 427, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x21254c36da8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 427, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x21254c0e5c0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x21254c374b0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 444, + "line": 45, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 451, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x21254c37488", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 451, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 451, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpu73o944j_ast.json b/clang-ast-mapper/tmpu73o944j_ast.json new file mode 100644 index 0000000000000..89e5cdf75208b --- /dev/null +++ b/clang-ast-mapper/tmpu73o944j_ast.json @@ -0,0 +1,718 @@ +{ + "id": "0x14756956c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x14756957510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x147569575c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x14756957748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x14756957260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x147569577b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x14756957280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x14756957b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x147569578a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x14756957810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x14756957bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x147569ad888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x147569ad900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x14756956e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x14756957668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x14756957620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x14756956d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x147569576d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x14756957620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x14756956d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x147569adae8", + "kind": "FunctionDecl", + "loc": { + "offset": 4, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpu73o944j.cpp", + "line": 1, + "col": 5, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 0, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 46, + "line": 5, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "?add@@YAHHH@Z", + "type": { + "qualType": "int (int, int)" + }, + "inner": [ + { + "id": "0x147569ad970", + "kind": "ParmVarDecl", + "loc": { + "offset": 12, + "line": 1, + "col": 13, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 8, + "col": 9, + "tokLen": 3 + }, + "end": { + "offset": 12, + "col": 13, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x147569ad9f8", + "kind": "ParmVarDecl", + "loc": { + "offset": 19, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 15, + "col": 16, + "tokLen": 3 + }, + "end": { + "offset": 19, + "col": 20, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "int" + } + }, + { + "id": "0x147569adc88", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 22, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 46, + "line": 5, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x147569adc78", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 30, + "line": 3, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x147569adc58", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x147569adc28", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 37, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x147569adbe8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 37, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 37, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x147569ad970", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x147569adc40", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 41, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x147569adc08", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 41, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 41, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x147569ad9f8", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x147569adcf8", + "kind": "FunctionDecl", + "loc": { + "offset": 57, + "line": 9, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 53, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 114, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x147569adfd8", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 64, + "line": 9, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 114, + "line": 15, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x147569adf88", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 72, + "line": 11, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 94, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x147569adde8", + "kind": "VarDecl", + "loc": { + "offset": 76, + "col": 9, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 72, + "col": 5, + "tokLen": 3 + }, + "end": { + "offset": 93, + "col": 26, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x147569adf58", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 93, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x147569adf40", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 85, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (*)(int, int)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x147569adee8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 85, + "col": 18, + "tokLen": 3 + }, + "end": { + "offset": 85, + "col": 18, + "tokLen": 3 + } + }, + "type": { + "qualType": "int (int, int)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x147569adae8", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "int (int, int)" + } + } + } + ] + }, + { + "id": "0x147569ade98", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 89, + "col": 22, + "tokLen": 1 + }, + "end": { + "offset": 89, + "col": 22, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "5" + }, + { + "id": "0x147569adec0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 92, + "col": 25, + "tokLen": 1 + }, + "end": { + "offset": 92, + "col": 25, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "3" + } + ] + } + ] + } + ] + }, + { + "id": "0x147569adfc8", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 102, + "line": 13, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 109, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x147569adfa0", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 109, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 109, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpuwobzv73_ast.json b/clang-ast-mapper/tmpuwobzv73_ast.json new file mode 100644 index 0000000000000..9bc86137aada6 --- /dev/null +++ b/clang-ast-mapper/tmpuwobzv73_ast.json @@ -0,0 +1,1541 @@ +{ + "id": "0x243163e6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x243163e7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x243163e75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x243163e7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x243163e7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x243163e77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x243163e7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x243163e7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x243163e78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x243163e7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x243163e7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x2431643d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2431643d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x243163e6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x243163e7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x243163e7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x243163e6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x243163e76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x243163e7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x243163e6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2431643d9e8", + "kind": "FunctionDecl", + "loc": { + "offset": 33, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpuwobzv73.cpp", + "line": 5, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 28, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2431643dc90", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 44, + "line": 5, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2431643dc80", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 52, + "line": 7, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x2431643dad8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 59, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x2431643e148", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 100, + "line": 15, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x2431643dca8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 119, + "line": 15, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 110, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 119, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x2431643dd30", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 131, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 122, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 131, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x2431643e0a0", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x2431643de18", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x2431643de98", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x24316467568", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x24316467558", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x24316467538", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x243164674f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2431643de18", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x24316467518", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2431643de98", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x24316467160", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x243163e6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x243163e6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x24316466eb0", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x24316466f60", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x24316467638", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x24316467628", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x24316467608", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x243164675f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x243164675c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x24316467580", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x24316466eb0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x243164675d8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x243164675a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x24316466f60", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2431643e240", + "kind": "FunctionDecl", + "loc": { + "offset": 209, + "line": 25, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 205, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x243164674c0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 216, + "line": 25, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2431643e590", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 260, + "line": 29, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 279, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2431643e338", + "kind": "VarDecl", + "loc": { + "offset": 265, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 260, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x2431643e488", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2431643e470", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2431643e3e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2431643d9e8", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2431643e740", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 287, + "line": 31, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 300, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2431643e5c0", + "kind": "VarDecl", + "loc": { + "offset": 292, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 287, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x2431643e628", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 296, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x24316466ca8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 339, + "line": 37, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 361, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2431643e7c0", + "kind": "VarDecl", + "loc": { + "offset": 351, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 339, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x24316466c88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2431643e870", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2431643e828", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2431643e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2431643e848", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 359, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x24316467470", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 409, + "line": 43, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 432, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x24316466cd8", + "kind": "VarDecl", + "loc": { + "offset": 414, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 409, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x24316467328", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x24316467310", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x24316467280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x24316467160", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x2431643e148", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x24316467358", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x24316466d88", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2431643e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x24316467370", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x24316466da8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2431643e5c0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x243164674b0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 447, + "line": 47, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x24316467488", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 454, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpv0u841km_ast.json b/clang-ast-mapper/tmpv0u841km_ast.json new file mode 100644 index 0000000000000..35d4e9b6ab02c --- /dev/null +++ b/clang-ast-mapper/tmpv0u841km_ast.json @@ -0,0 +1,1541 @@ +{ + "id": "0x1dd245f6c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x1dd245f7510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x1dd245f75c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1dd245f7748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x1dd245f7260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x1dd245f77b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x1dd245f7280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x1dd245f7b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x1dd245f78a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x1dd245f7810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x1dd245f7bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x1dd2464d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x1dd2464d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x1dd245f6e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x1dd245f7668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1dd245f7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1dd245f6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1dd245f76d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1dd245f7620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x1dd245f6d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x1dd2464d9e8", + "kind": "FunctionDecl", + "loc": { + "offset": 33, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpv0u841km.cpp", + "line": 5, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 28, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x1dd2464dc90", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 44, + "line": 5, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd2464dc80", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 52, + "line": 7, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x1dd2464dad8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 59, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x1dd2464e148", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 100, + "line": 15, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x1dd2464dca8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 119, + "line": 15, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 110, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 119, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x1dd2464dd30", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 131, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 122, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 131, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x1dd2464e0a0", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x1dd2464de18", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x1dd2464de98", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x1dd24677568", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd24677558", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd24677538", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1dd246774f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd2464de18", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x1dd24677518", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd2464de98", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1dd24677160", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x1dd245f6da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x1dd245f6ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x1dd24676eb0", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x1dd24676f60", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x1dd24677638", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd24677628", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd24677608", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1dd246775f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x1dd246775c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1dd24677580", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd24676eb0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x1dd246775d8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1dd246775a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd24676f60", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1dd2464e240", + "kind": "FunctionDecl", + "loc": { + "offset": 209, + "line": 25, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 205, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x1dd246774c0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 216, + "line": 25, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd2464e590", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 260, + "line": 29, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 279, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd2464e338", + "kind": "VarDecl", + "loc": { + "offset": 265, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 260, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x1dd2464e488", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1dd2464e470", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x1dd2464e3e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd2464d9e8", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1dd2464e740", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 287, + "line": 31, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 300, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd2464e5c0", + "kind": "VarDecl", + "loc": { + "offset": 292, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 287, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x1dd2464e628", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 296, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x1dd24676ca8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 339, + "line": 37, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 361, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd2464e7c0", + "kind": "VarDecl", + "loc": { + "offset": 351, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 339, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x1dd24676c88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x1dd2464e870", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1dd2464e828", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd2464e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1dd2464e848", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 359, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x1dd24677470", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 409, + "line": 43, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 432, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd24676cd8", + "kind": "VarDecl", + "loc": { + "offset": 414, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 409, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x1dd24677328", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x1dd24677310", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x1dd24677280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd24677160", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x1dd2464e148", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x1dd24677358", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1dd24676d88", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd2464e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x1dd24677370", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x1dd24676da8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x1dd2464e5c0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x1dd246774b0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 447, + "line": 47, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x1dd24677488", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 454, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/tmpvd0pqiky_ast.json b/clang-ast-mapper/tmpvd0pqiky_ast.json new file mode 100644 index 0000000000000..5ab4b57801b3e --- /dev/null +++ b/clang-ast-mapper/tmpvd0pqiky_ast.json @@ -0,0 +1,1541 @@ +{ + "id": "0x2c0bdb36c90", + "kind": "TranslationUnitDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "inner": [ + { + "id": "0x2c0bdb37510", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "_GUID", + "tagUsed": "struct", + "inner": [ + { + "id": "0x2c0bdb375c0", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2c0bdb37748", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__int128_t", + "type": { + "qualType": "__int128" + }, + "inner": [ + { + "id": "0x2c0bdb37260", + "kind": "BuiltinType", + "type": { + "qualType": "__int128" + } + } + ] + }, + { + "id": "0x2c0bdb377b8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__uint128_t", + "type": { + "qualType": "unsigned __int128" + }, + "inner": [ + { + "id": "0x2c0bdb37280", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned __int128" + } + } + ] + }, + { + "id": "0x2c0bdb37b60", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__NSConstantString", + "type": { + "qualType": "__NSConstantString_tag" + }, + "inner": [ + { + "id": "0x2c0bdb378a0", + "kind": "RecordType", + "type": { + "qualType": "__NSConstantString_tag" + }, + "decl": { + "id": "0x2c0bdb37810", + "kind": "CXXRecordDecl", + "name": "__NSConstantString_tag" + } + } + ] + }, + { + "id": "0x2c0bdb37bb8", + "kind": "CXXRecordDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "type_info", + "tagUsed": "class", + "inner": [ + { + "id": "0x2c0bdb8d888", + "kind": "TypeVisibilityAttr", + "range": { + "begin": {}, + "end": {} + }, + "implicit": true + } + ] + }, + { + "id": "0x2c0bdb8d900", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "size_t", + "type": { + "qualType": "unsigned long long" + }, + "inner": [ + { + "id": "0x2c0bdb36e80", + "kind": "BuiltinType", + "type": { + "qualType": "unsigned long long" + } + } + ] + }, + { + "id": "0x2c0bdb37668", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_ms_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c0bdb37620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c0bdb36d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2c0bdb376d8", + "kind": "TypedefDecl", + "loc": {}, + "range": { + "begin": {}, + "end": {} + }, + "isImplicit": true, + "name": "__builtin_va_list", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c0bdb37620", + "kind": "PointerType", + "type": { + "qualType": "char *" + }, + "inner": [ + { + "id": "0x2c0bdb36d40", + "kind": "BuiltinType", + "type": { + "qualType": "char" + } + } + ] + } + ] + }, + { + "id": "0x2c0bdb8d9e8", + "kind": "FunctionDecl", + "loc": { + "offset": 33, + "file": "D:\\EL_projects\\llvm-project-main\\llvm-project-main\\clang-ast-mapper\\web_app\\temp\\tmpvd0pqiky.cpp", + "line": 5, + "col": 6, + "tokLen": 8 + }, + "range": { + "begin": { + "offset": 28, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "getValue", + "mangledName": "?getValue@@YA@XZ", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2c0bdb8dc90", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 44, + "line": 5, + "col": 17, + "tokLen": 1 + }, + "end": { + "offset": 65, + "line": 9, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdb8dc80", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 52, + "line": 7, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "inner": [ + { + "id": "0x2c0bdb8dad8", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 59, + "col": 12, + "tokLen": 2 + }, + "end": { + "offset": 59, + "col": 12, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "id": "0x2c0bdb8e148", + "kind": "FunctionTemplateDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 100, + "line": 15, + "col": 1, + "tokLen": 8 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "inner": [ + { + "id": "0x2c0bdb8dca8", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 119, + "line": 15, + "col": 20, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 110, + "col": 11, + "tokLen": 8 + }, + "end": { + "offset": 119, + "col": 20, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "T", + "tagUsed": "typename", + "depth": 0, + "index": 0 + }, + { + "id": "0x2c0bdb8dd30", + "kind": "TemplateTypeParmDecl", + "loc": { + "offset": 131, + "col": 32, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 122, + "col": 23, + "tokLen": 8 + }, + "end": { + "offset": 131, + "col": 32, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "U", + "tagUsed": "typename", + "depth": 0, + "index": 1 + }, + { + "id": "0x2c0bdb8e0a0", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "name": "add", + "type": { + "qualType": "auto (T, U) -> decltype(a + b)" + }, + "inner": [ + { + "id": "0x2c0bdb8de18", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "a", + "type": { + "qualType": "T" + } + }, + { + "id": "0x2c0bdb8de98", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isReferenced": true, + "name": "b", + "type": { + "qualType": "U" + } + }, + { + "id": "0x2c0bdbb7568", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdbb7558", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdbb7538", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2c0bdbb74f8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "T" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdb8de18", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "T" + } + } + }, + { + "id": "0x2c0bdbb7518", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "U" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdb8de98", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "U" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c0bdbb7160", + "kind": "FunctionDecl", + "loc": { + "offset": 141, + "line": 17, + "col": 6, + "tokLen": 3 + }, + "range": { + "begin": { + "offset": 136, + "col": 1, + "tokLen": 4 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "add", + "mangledName": "??$add@HN@@YANHN@Z", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "inner": [ + { + "kind": "TemplateArgument", + "type": { + "qualType": "int" + }, + "inner": [ + { + "id": "0x2c0bdb36da0", + "kind": "BuiltinType", + "type": { + "qualType": "int" + } + } + ] + }, + { + "kind": "TemplateArgument", + "type": { + "qualType": "double" + }, + "inner": [ + { + "id": "0x2c0bdb36ec0", + "kind": "BuiltinType", + "type": { + "qualType": "double" + } + } + ] + }, + { + "id": "0x2c0bdbb6eb0", + "kind": "ParmVarDecl", + "loc": { + "offset": 147, + "line": 17, + "col": 12, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 145, + "col": 10, + "tokLen": 1 + }, + "end": { + "offset": 147, + "col": 12, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "a", + "type": { + "qualType": "int" + } + }, + { + "id": "0x2c0bdbb6f60", + "kind": "ParmVarDecl", + "loc": { + "offset": 152, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 150, + "col": 15, + "tokLen": 1 + }, + "end": { + "offset": 152, + "col": 17, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "b", + "type": { + "qualType": "double" + } + }, + { + "id": "0x2c0bdbb7638", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 174, + "col": 39, + "tokLen": 1 + }, + "end": { + "offset": 198, + "line": 21, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdbb7628", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 182, + "line": 19, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdbb7608", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2c0bdbb75f0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "IntegralToFloating", + "inner": [ + { + "id": "0x2c0bdbb75c0", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c0bdbb7580", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 189, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 189, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdbb6eb0", + "kind": "ParmVarDecl", + "name": "a", + "type": { + "qualType": "int" + } + } + } + ] + } + ] + }, + { + "id": "0x2c0bdbb75d8", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c0bdbb75a0", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 193, + "col": 16, + "tokLen": 1 + }, + "end": { + "offset": 193, + "col": 16, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdbb6f60", + "kind": "ParmVarDecl", + "name": "b", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c0bdb8e240", + "kind": "FunctionDecl", + "loc": { + "offset": 209, + "line": 25, + "col": 5, + "tokLen": 4 + }, + "range": { + "begin": { + "offset": 205, + "col": 1, + "tokLen": 3 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "name": "main", + "mangledName": "main", + "type": { + "qualType": "int ()" + }, + "inner": [ + { + "id": "0x2c0bdbb74c0", + "kind": "CompoundStmt", + "range": { + "begin": { + "offset": 216, + "line": 25, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 459, + "line": 49, + "col": 1, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdb8e590", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 260, + "line": 29, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 279, + "col": 24, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdb8e338", + "kind": "VarDecl", + "loc": { + "offset": 265, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 260, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "isUsed": true, + "name": "x", + "type": { + "qualType": "int" + }, + "init": "c", + "inner": [ + { + "id": "0x2c0bdb8e488", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 278, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2c0bdb8e470", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int (*)()" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2c0bdb8e3e8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 269, + "col": 14, + "tokLen": 8 + }, + "end": { + "offset": 269, + "col": 14, + "tokLen": 8 + } + }, + "type": { + "qualType": "int ()" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdb8d9e8", + "kind": "FunctionDecl", + "name": "getValue", + "type": { + "qualType": "int ()" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c0bdb8e740", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 287, + "line": 31, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 300, + "col": 18, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdb8e5c0", + "kind": "VarDecl", + "loc": { + "offset": 292, + "col": 10, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 287, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "isUsed": true, + "name": "y", + "type": { + "qualType": "double" + }, + "init": "c", + "inner": [ + { + "id": "0x2c0bdb8e628", + "kind": "FloatingLiteral", + "range": { + "begin": { + "offset": 296, + "col": 14, + "tokLen": 4 + }, + "end": { + "offset": 296, + "col": 14, + "tokLen": 4 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "value": "3.1400000000000001" + } + ] + } + ] + }, + { + "id": "0x2c0bdbb6ca8", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 339, + "line": 37, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 361, + "col": 27, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdb8e7c0", + "kind": "VarDecl", + "loc": { + "offset": 351, + "col": 17, + "tokLen": 1 + }, + "range": { + "begin": { + "offset": 339, + "col": 5, + "tokLen": 8 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "name": "z", + "type": { + "desugaredQualType": "int", + "qualType": "decltype(x)" + }, + "init": "c", + "inner": [ + { + "id": "0x2c0bdbb6c88", + "kind": "BinaryOperator", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "opcode": "+", + "inner": [ + { + "id": "0x2c0bdb8e870", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c0bdb8e828", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 355, + "col": 21, + "tokLen": 1 + }, + "end": { + "offset": 355, + "col": 21, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdb8e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2c0bdb8e848", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 359, + "col": 25, + "tokLen": 2 + }, + "end": { + "offset": 359, + "col": 25, + "tokLen": 2 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "10" + } + ] + } + ] + } + ] + }, + { + "id": "0x2c0bdbb7470", + "kind": "DeclStmt", + "range": { + "begin": { + "offset": 409, + "line": 43, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 432, + "col": 28, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdbb6cd8", + "kind": "VarDecl", + "loc": { + "offset": 414, + "col": 10, + "tokLen": 6 + }, + "range": { + "begin": { + "offset": 409, + "col": 5, + "tokLen": 4 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "name": "result", + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "init": "c", + "inner": [ + { + "id": "0x2c0bdbb7328", + "kind": "CallExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 431, + "col": 27, + "tokLen": 1 + } + }, + "type": { + "desugaredQualType": "double", + "qualType": "decltype(a + b)" + }, + "valueCategory": "prvalue", + "inner": [ + { + "id": "0x2c0bdbb7310", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (*)(int, double) -> decltype(a + b)" + }, + "valueCategory": "prvalue", + "castKind": "FunctionToPointerDecay", + "inner": [ + { + "id": "0x2c0bdbb7280", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 423, + "col": 19, + "tokLen": 3 + }, + "end": { + "offset": 423, + "col": 19, + "tokLen": 3 + } + }, + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdbb7160", + "kind": "FunctionDecl", + "name": "add", + "type": { + "qualType": "auto (int, double) -> decltype(a + b)" + } + }, + "foundReferencedDecl": { + "id": "0x2c0bdb8e148", + "kind": "FunctionTemplateDecl", + "name": "add" + } + } + ] + }, + { + "id": "0x2c0bdbb7358", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c0bdbb6d88", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 427, + "col": 23, + "tokLen": 1 + }, + "end": { + "offset": 427, + "col": 23, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdb8e338", + "kind": "VarDecl", + "name": "x", + "type": { + "qualType": "int" + } + } + } + ] + }, + { + "id": "0x2c0bdbb7370", + "kind": "ImplicitCastExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "prvalue", + "castKind": "LValueToRValue", + "inner": [ + { + "id": "0x2c0bdbb6da8", + "kind": "DeclRefExpr", + "range": { + "begin": { + "offset": 430, + "col": 26, + "tokLen": 1 + }, + "end": { + "offset": 430, + "col": 26, + "tokLen": 1 + } + }, + "type": { + "qualType": "double" + }, + "valueCategory": "lvalue", + "referencedDecl": { + "id": "0x2c0bdb8e5c0", + "kind": "VarDecl", + "name": "y", + "type": { + "qualType": "double" + } + } + } + ] + } + ] + } + ] + } + ] + }, + { + "id": "0x2c0bdbb74b0", + "kind": "ReturnStmt", + "range": { + "begin": { + "offset": 447, + "line": 47, + "col": 5, + "tokLen": 6 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "inner": [ + { + "id": "0x2c0bdbb7488", + "kind": "IntegerLiteral", + "range": { + "begin": { + "offset": 454, + "col": 12, + "tokLen": 1 + }, + "end": { + "offset": 454, + "col": 12, + "tokLen": 1 + } + }, + "type": { + "qualType": "int" + }, + "valueCategory": "prvalue", + "value": "0" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/README.md b/clang-ast-mapper/web_app/README.md new file mode 100644 index 0000000000000..3a01576d7ca71 --- /dev/null +++ b/clang-ast-mapper/web_app/README.md @@ -0,0 +1,67 @@ +# Clang AST Line Mapper Web Application + +This is a Flask web application that provides a user interface for the Clang AST Line Mapper tool. The application allows users to input C++ code and visualize the AST (Abstract Syntax Tree) nodes alongside the source code with AI-powered interpretations. + +## Features + +- Input C++ code via a syntax-highlighted editor +- Visualize source code with corresponding AST nodes in a side-by-side view +- Get AI-powered interpretation of code structure with detailed explanations +- Load example code snippets for quick exploration +- Responsive web interface with Bootstrap styling + +## Installation + +1. Make sure you have Python 3.8+ installed +2. Clone the repository +3. Install dependencies: + +```bash +cd clang-ast-mapper/web_app +pip install -r requirements.txt +``` + +## Running the Application + +From the `web_app` directory, run: + +```bash +python app.py +``` + +The application will be available at http://localhost:5000 + +## Directory Structure + +``` +web_app/ +โ”œโ”€โ”€ app.py # Main Flask application +โ”œโ”€โ”€ requirements.txt # Python dependencies +โ”œโ”€โ”€ static/ # Static assets +โ”‚ โ”œโ”€โ”€ css/ # CSS stylesheets +โ”‚ โ””โ”€โ”€ js/ # JavaScript files +โ”œโ”€โ”€ templates/ # HTML templates +โ”‚ โ”œโ”€โ”€ base.html # Base template with common structure +โ”‚ โ””โ”€โ”€ index.html # Main page template +โ””โ”€โ”€ temp/ # Temporary files (created at runtime) +``` + +## Using the Application + +1. Enter or paste C++ code in the editor +2. Click "Analyze Code" to process the input +3. View the side-by-side representation of code and AST nodes +4. Check the AI interpretation tab for detailed analysis + +## Development + +To contribute to the development: + +1. Fork the repository +2. Create a new branch for your feature +3. Make your changes +4. Submit a pull request + +## License + +This project is licensed under the same terms as the main Clang AST Line Mapper project. diff --git a/clang-ast-mapper/web_app/__init__.py b/clang-ast-mapper/web_app/__init__.py new file mode 100644 index 0000000000000..32c7c778570ac --- /dev/null +++ b/clang-ast-mapper/web_app/__init__.py @@ -0,0 +1,5 @@ +""" +Package initialization for Clang AST Line Mapper web application +""" + +# Empty init file to make the directory a Python package diff --git a/clang-ast-mapper/web_app/app.py b/clang-ast-mapper/web_app/app.py new file mode 100644 index 0000000000000..3f7d42f6b0dfb --- /dev/null +++ b/clang-ast-mapper/web_app/app.py @@ -0,0 +1,316 @@ +""" +Flask web application for Clang AST Line Mapper +Provides a user interface for analyzing C++ code with AST visualization +""" + +import os +import sys +import tempfile +import uuid +import markdown +import bleach +from flask import Flask, render_template, request, jsonify, session +from flask_session import Session + +# Add the parent directory to sys.path to import the AST mapper modules +sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) +from src.ast_parser import ASTParser +from src.source_annotator import SourceAnnotator +from src.ai_interpreter import AIInterpreter +from src.utils import check_environment + +app = Flask(__name__) +app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', str(uuid.uuid4())) +app.config['SESSION_TYPE'] = 'filesystem' +app.config['SESSION_FILE_DIR'] = os.path.join(os.path.dirname(__file__), 'flask_session') +Session(app) + +# Create necessary directories +os.makedirs(app.config['SESSION_FILE_DIR'], exist_ok=True) +os.makedirs(os.path.join(os.path.dirname(__file__), 'temp'), exist_ok=True) + +@app.route('/') +def index(): + """Render the main page.""" + return render_template('index.html') + +@app.route('/analyze', methods=['POST']) +def analyze(): + """Analyze C++ code and return the results.""" + try: + # Get code from the request + code = request.form.get('code', '') + include_ai = request.form.get('include_ai', 'true') == 'true' + custom_prompt = request.form.get('custom_prompt', '') + + # Save code to a temporary file + temp_dir = os.path.join(os.path.dirname(__file__), 'temp') + os.makedirs(temp_dir, exist_ok=True) + + temp_file = tempfile.NamedTemporaryFile( + mode='w', + suffix='.cpp', + delete=False, + dir=temp_dir + ) + temp_file.write(code) + temp_file.close() + + # Parse AST + parser = ASTParser() + ast_file = parser.generate_ast_json(temp_file.name) + + if not ast_file or not os.path.exists(ast_file): + return jsonify({ + 'success': False, + 'error': "Failed to generate AST JSON. Make sure Clang is installed and properly configured." + }) + + # Validate the AST file is valid JSON + try: + with open(ast_file, 'r', encoding='utf-8') as f: + import json + json.load(f) + except json.JSONDecodeError: + return jsonify({ + 'success': False, + 'error': "Generated AST file is not valid JSON. Clang may not have generated a complete AST dump." + }) + except Exception as e: + return jsonify({ + 'success': False, + 'error': f"Error reading AST file: {str(e)}" + }) + + line_mappings = parser.parse_ast_file(ast_file, temp_file.name) + + if not line_mappings: + return jsonify({ + 'success': False, + 'error': "Failed to parse AST file. The generated AST might be incomplete or invalid." + }) + + # Generate CSV output for AI interpretation + annotator = SourceAnnotator() + csv_output = annotator.generate_csv_output( + temp_file.name, + line_mappings + ) + + # Validate CSV output + if not csv_output or csv_output.strip() == "": + return jsonify({ + 'success': False, + 'error': "Failed to generate CSV output. The AST data might be empty or invalid." + }) + + # Save CSV to a temporary file + csv_file = os.path.join(temp_dir, f"{os.path.basename(temp_file.name)}.csv") + with open(csv_file, 'w') as f: + f.write(csv_output) + + # Generate the side-by-side view + side_by_side = [] + with open(temp_file.name, 'r') as f: + lines = f.readlines() + + for i, line in enumerate(lines, 1): + line_num = i + code_line = line.rstrip() + nodes = line_mappings.get(line_num, []) + node_str = "; ".join(nodes) if nodes else "" + + # Get explanation for the primary node + explanation = "" + if nodes: + primary_node = nodes[0] + explanation = get_node_explanation(primary_node) + + side_by_side.append({ + 'line_num': line_num, + 'code': code_line, + 'nodes': node_str, + 'explanation': explanation + }) + + # Generate AI interpretation if requested + ai_interpretation = "" + if include_ai: + interpreter = AIInterpreter() + ai_interpretation = interpreter.interpret_csv(csv_file) + + # Convert markdown to HTML with sanitization + ai_interpretation = markdown.markdown(ai_interpretation) + ai_interpretation = bleach.clean( + ai_interpretation, + tags=['h1', 'h2', 'h3', 'h4', 'p', 'a', 'ul', 'ol', 'li', + 'strong', 'em', 'code', 'pre', 'br', 'table', 'thead', + 'tbody', 'tr', 'th', 'td'], + attributes={'a': ['href', 'title'], 'th': ['colspan'], 'td': ['colspan']}, + strip=True + ) + + # Clean up temporary files + if os.path.exists(temp_file.name): + os.unlink(temp_file.name) + if os.path.exists(csv_file): + os.unlink(csv_file) + + # Return the results + return jsonify({ + 'success': True, + 'side_by_side': side_by_side, + 'ai_interpretation': ai_interpretation + }) + + except Exception as e: + import traceback + error_details = traceback.format_exc() + print(f"Error analyzing code: {str(e)}") + print(f"Error details:\n{error_details}") + return jsonify({ + 'success': False, + 'error': str(e), + 'details': error_details + }) + +def get_node_explanation(node_type): + """Get a simple explanation for an AST node type.""" + # Use a comprehensive dictionary of node explanations + explanations = { + "FunctionDecl": "Function declaration - defines a function with its return type, name, and parameters", + "CXXMethodDecl": "C++ method declaration - a function that belongs to a class or struct", + "CXXConstructorDecl": "C++ constructor declaration - special method that initializes objects of a class", + "CXXDestructorDecl": "C++ destructor declaration - special method that cleans up resources when object is destroyed", + "ParmVarDecl": "Parameter variable declaration - variables that receive values passed to functions", + "VarDecl": "Variable declaration - defines a variable with its type and name", + "FieldDecl": "Field declaration - member variables of a class or struct", + "DeclStmt": "Declaration statement - contains one or more variable declarations", + "ReturnStmt": "Return statement - specifies the value to be returned from a function", + "CompoundStmt": "Compound statement - a block of code enclosed in braces {}", + "CallExpr": "Function call expression - invokes a function with arguments", + "CXXRecordDecl": "C++ class/struct definition - declares a user-defined type", + "IfStmt": "If statement - conditional execution of code", + "ForStmt": "For loop - executes code repeatedly with a loop counter", + "WhileStmt": "While loop - executes code as long as a condition is true", + "SwitchStmt": "Switch statement - selects code to execute based on a value", + "CaseStmt": "Case statement - a branch in a switch statement", + "DefaultStmt": "Default statement - default branch in a switch statement", + "BinaryOperator": "Binary operator expression - combines two values (e.g., +, -, *, /)", + "UnaryOperator": "Unary operator expression - applies to a single value (e.g., -, !, ~)", + "MemberExpr": "Member expression - accesses a member of a class/struct", + "IntegerLiteral": "Integer literal - a numeric constant (e.g., 42)", + "FloatingLiteral": "Floating-point literal - a decimal constant (e.g., 3.14)", + "StringLiteral": "String literal - a text constant (e.g., \"hello\")", + "CharacterLiteral": "Character literal - a single character constant (e.g., 'a')", + "BoolLiteral": "Boolean literal - true or false", + "NullStmt": "Null statement - an empty statement (semicolon with no effect)", + "BreakStmt": "Break statement - exits from a loop or switch", + "ContinueStmt": "Continue statement - skips to the next iteration of a loop", + "AccessSpecDecl": "Access specifier - public, protected, or private in a class", + "CXXThisExpr": "C++ 'this' expression - refers to the current object", + "LambdaExpr": "Lambda expression - defines an anonymous function", + "CXXNewExpr": "C++ 'new' expression - dynamically allocates memory", + "CXXDeleteExpr": "C++ 'delete' expression - frees dynamically allocated memory", + "TypedefDecl": "Typedef declaration - creates an alias for a type", + "NamespaceDecl": "Namespace declaration - defines a scope for identifiers", + "UsingDirective": "Using directive - imports names from a namespace", + "UsingDecl": "Using declaration - imports a specific name", + "TemplateDecl": "Template declaration - defines a generic class or function", + "ClassTemplateDecl": "Class template declaration - defines a generic class", + "FunctionTemplateDecl": "Function template declaration - defines a generic function", + "DeclRefExpr": "Declaration reference expression - refers to a declared variable or function" + } + + return explanations.get(node_type, node_type) + +@app.route('/examples') +def examples(): + """Return a list of example C++ codes.""" + examples = [ + { + 'name': 'Simple Function', + 'code': '''int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +}''' + }, + { + 'name': 'Simple Class', + 'code': '''class Calculator { +private: + int value; + +public: + Calculator(int initial) : value(initial) {} + + int add(int x) { + value += x; + return value; + } + + int getValue() const { + return value; + } +}; + +int main() { + Calculator calc(10); + calc.add(5); + return calc.getValue(); +}''' + }, + { + 'name': 'Modern C++ Features', + 'code': '''#include +#include + +// Auto type deduction +auto getValue() { + return 42; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with function call + auto result = add(x, y); + + return 0; +}''' + } + ] + return jsonify(examples) + +@app.route('/check-environment') +def check_env(): + """Check the environment for all required dependencies.""" + try: + env_info = check_environment() + return jsonify({ + 'success': True, + 'environment': env_info + }) + except Exception as e: + return jsonify({ + 'success': False, + 'error': str(e) + }) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/clang-ast-mapper/web_app/flask_session/2029240f6d1128be89ddc32729463129 b/clang-ast-mapper/web_app/flask_session/2029240f6d1128be89ddc32729463129 new file mode 100644 index 0000000000000..8b04914a5e6ad Binary files /dev/null and b/clang-ast-mapper/web_app/flask_session/2029240f6d1128be89ddc32729463129 differ diff --git a/clang-ast-mapper/web_app/flask_session/934104bdb39b9919a59e61d1c89dcf7f b/clang-ast-mapper/web_app/flask_session/934104bdb39b9919a59e61d1c89dcf7f new file mode 100644 index 0000000000000..3ac341bd595fb Binary files /dev/null and b/clang-ast-mapper/web_app/flask_session/934104bdb39b9919a59e61d1c89dcf7f differ diff --git a/clang-ast-mapper/web_app/requirements.txt b/clang-ast-mapper/web_app/requirements.txt new file mode 100644 index 0000000000000..9cbb008721e13 --- /dev/null +++ b/clang-ast-mapper/web_app/requirements.txt @@ -0,0 +1,6 @@ +flask==2.0.1 +werkzeug==2.0.1 +flask-session==0.4.0 +markdown==3.4.1 +bleach==5.0.1 +pandas==1.5.3 diff --git a/clang-ast-mapper/web_app/static/css/styles.css b/clang-ast-mapper/web_app/static/css/styles.css new file mode 100644 index 0000000000000..68ddea77111ba --- /dev/null +++ b/clang-ast-mapper/web_app/static/css/styles.css @@ -0,0 +1,137 @@ +/* Custom styles for the AST Line Mapper web application */ + +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + padding-top: 20px; + padding-bottom: 40px; +} + +.navbar-brand img { + height: 30px; + margin-right: 10px; +} + +.jumbotron { + background-color: #f8f9fa; + padding: 2rem; + margin-bottom: 2rem; + border-radius: 0.3rem; +} + +/* CodeMirror customization */ +.CodeMirror { + font-family: 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace; + height: 400px; + border-radius: 4px; +} + +/* Results styles */ +.result-card { + margin-bottom: 20px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.result-card .card-header { + background-color: #f1f8ff; + font-weight: 600; +} + +/* Side-by-side table styles */ +#side-by-side-table { + font-family: 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace; +} + +#side-by-side-table th { + position: sticky; + top: 0; + background-color: #f8f9fa; + z-index: 1; +} + +#side-by-side-table code { + display: block; + white-space: pre; + overflow-x: auto; + background-color: transparent; + padding: 0; + color: #333; +} + +.ast-node { + color: #5a5a5a; + font-style: italic; +} + +.ast-explanation { + color: #0275d8; +} + +/* AI interpretation styles */ +#ai-interpretation { + line-height: 1.6; +} + +#ai-interpretation h1, +#ai-interpretation h2, +#ai-interpretation h3 { + margin-top: 1.5rem; + margin-bottom: 1rem; +} + +#ai-interpretation table { + width: 100%; + max-width: 100%; + margin-bottom: 1rem; + background-color: transparent; + border-collapse: collapse; +} + +#ai-interpretation table th, +#ai-interpretation table td { + padding: 0.75rem; + vertical-align: top; + border-top: 1px solid #dee2e6; +} + +#ai-interpretation table thead th { + vertical-align: bottom; + border-bottom: 2px solid #dee2e6; + background-color: #f8f9fa; +} + +#ai-interpretation code { + color: #e83e8c; + font-family: 'Source Code Pro', Consolas, Monaco, 'Courier New', monospace; +} + +/* Loading overlay */ +#loading-overlay { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.7); + z-index: 9999; + justify-content: center; + align-items: center; +} + +.spinner-container { + text-align: center; + color: white; +} + +/* Responsive adjustments */ +@media (max-width: 768px) { + .card-header .btn-sm { + display: block; + width: 100%; + margin-bottom: 0.5rem; + } + + #side-by-side-table { + font-size: 0.85rem; + } +} diff --git a/clang-ast-mapper/web_app/static/js/app.js b/clang-ast-mapper/web_app/static/js/app.js new file mode 100644 index 0000000000000..7eacfd9e0affe --- /dev/null +++ b/clang-ast-mapper/web_app/static/js/app.js @@ -0,0 +1,88 @@ +// Main JavaScript for AST Line Mapper web application + +document.addEventListener('DOMContentLoaded', function() { + // Initialize tooltips + var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); + var tooltipList = tooltipTriggerList.map(function(tooltipTriggerEl) { + return new bootstrap.Tooltip(tooltipTriggerEl); + }); + + // Initialize popovers + var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]')); + var popoverList = popoverTriggerList.map(function(popoverTriggerEl) { + return new bootstrap.Popover(popoverTriggerEl); + }); + + // Example loading functions + function loadExampleCode(exampleName) { + // Example predefined code snippets + const examples = { + 'simple': `#include \n\nint main() {\n int x = 42;\n std::cout << "Hello, world! x = " << x << std::endl;\n return 0;\n}`, + + 'variable_declarations': `#include \n\nint main() {\n // Basic types\n int a = 5;\n float b = 3.14f;\n double c = 2.71828;\n bool d = true;\n char e = 'A';\n \n // Reference and pointer\n int& ref = a;\n int* ptr = &a;\n \n // Auto type deduction\n auto f = 100;\n auto g = 1.5;\n \n // String\n std::string h = "Hello, AST!";\n \n return 0;\n}`, + + 'control_flow': `#include \n\nint main() {\n // If-else statement\n int x = 10;\n \n if (x > 5) {\n std::cout << "x is greater than 5" << std::endl;\n } else if (x == 5) {\n std::cout << "x equals 5" << std::endl;\n } else {\n std::cout << "x is less than 5" << std::endl;\n }\n \n // For loop\n for (int i = 0; i < 3; i++) {\n std::cout << "Loop iteration " << i << std::endl;\n }\n \n // While loop\n int j = 0;\n while (j < 3) {\n std::cout << "While iteration " << j << std::endl;\n j++;\n }\n \n // Switch statement\n char grade = 'B';\n switch (grade) {\n case 'A':\n std::cout << "Excellent!" << std::endl;\n break;\n case 'B':\n std::cout << "Good job!" << std::endl;\n break;\n default:\n std::cout << "Invalid grade" << std::endl;\n }\n \n return 0;\n}`, + + 'functions': `#include \n\n// Function declaration\nint add(int a, int b);\n\n// Function with default parameter\nvoid greet(const std::string& name = "World");\n\n// Function template\ntemplate \nT maximum(T a, T b) {\n return (a > b) ? a : b;\n}\n\nint main() {\n // Function calls\n int sum = add(5, 3);\n std::cout << "Sum: " << sum << std::endl;\n \n greet();\n greet("C++ Developer");\n \n // Template function calls\n std::cout << "Max (int): " << maximum(10, 15) << std::endl;\n std::cout << "Max (double): " << maximum(3.14, 2.71) << std::endl;\n \n // Lambda function\n auto multiply = [](int x, int y) -> int { return x * y; };\n std::cout << "Product: " << multiply(4, 7) << std::endl;\n \n return 0;\n}\n\n// Function definition\nint add(int a, int b) {\n return a + b;\n}\n\nvoid greet(const std::string& name) {\n std::cout << "Hello, " << name << "!" << std::endl;\n}` + }; + + // Get the CodeMirror instance + const cmInstance = document.querySelector('.CodeMirror').CodeMirror; + + // Set the example code + if (examples[exampleName]) { + cmInstance.setValue(examples[exampleName]); + } + } + + // Add event listeners to example buttons if they exist + document.querySelectorAll('.example-btn').forEach(button => { + button.addEventListener('click', function() { + loadExampleCode(this.dataset.example); + }); + }); + + // Copy to clipboard functionality + document.querySelectorAll('.copy-btn').forEach(button => { + button.addEventListener('click', function() { + const targetId = this.dataset.target; + const textToCopy = document.getElementById(targetId).textContent; + + navigator.clipboard.writeText(textToCopy).then(() => { + // Change button text temporarily + const originalText = this.textContent; + this.textContent = 'Copied!'; + setTimeout(() => { + this.textContent = originalText; + }, 2000); + }).catch(err => { + console.error('Failed to copy text: ', err); + }); + }); + }); + + // Tab switching + document.querySelectorAll('.nav-tabs .nav-link').forEach(tab => { + tab.addEventListener('click', function(event) { + event.preventDefault(); + + // Remove active class from all tabs and tab panes + document.querySelectorAll('.nav-tabs .nav-link').forEach(t => { + t.classList.remove('active'); + }); + + document.querySelectorAll('.tab-pane').forEach(p => { + p.classList.remove('show', 'active'); + }); + + // Add active class to clicked tab + this.classList.add('active'); + + // Show corresponding tab content + const target = document.querySelector(this.dataset.bsTarget); + if (target) { + target.classList.add('show', 'active'); + } + }); + }); +}); diff --git a/clang-ast-mapper/web_app/temp/tmpgc0sme0f.cpp b/clang-ast-mapper/web_app/temp/tmpgc0sme0f.cpp new file mode 100644 index 0000000000000..572072b0cf19d --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpgc0sme0f.cpp @@ -0,0 +1,8 @@ +int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpgfgrhn36.cpp b/clang-ast-mapper/web_app/temp/tmpgfgrhn36.cpp new file mode 100644 index 0000000000000..9d2ccfd60bf27 --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpgfgrhn36.cpp @@ -0,0 +1,27 @@ + +#include + +// Auto type deduction +auto getValue() { + return 42; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with function call + auto result = add(x, y); + + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpmr5max4f.cpp b/clang-ast-mapper/web_app/temp/tmpmr5max4f.cpp new file mode 100644 index 0000000000000..e3f92b46ce7b4 --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpmr5max4f.cpp @@ -0,0 +1,25 @@ + +// Auto type deduction +auto getValue() { + return 42; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with function call + auto result = add(x, y); + + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpmr5max4f.cpp.csv b/clang-ast-mapper/web_app/temp/tmpmr5max4f.cpp.csv new file mode 100644 index 0000000000000..0e08fe0e37182 --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpmr5max4f.cpp.csv @@ -0,0 +1,50 @@ +Line,Source Code,AST Nodes,Explanations +1,,, +2,,, +3,// Auto type deduction,, +4,,, +5,auto getValue() {,CompoundStmt; FunctionDecl, +6,,, +7, return 42;,ReturnStmt, +8,,, +9,},, +10,,, +11,,, +12,,, +13,// Function with decltype,, +14,,, +15,"template ",TemplateTypeParmDecl, +16,,, +17,"auto add(T a, U b) -> decltype(a + b) {",FunctionTemplateDecl; FunctionDecl; ParmVarDecl, +18,,, +19, return a + b;,ReturnStmt, +20,,, +21,},, +22,,, +23,,, +24,,, +25,int main() {,CompoundStmt; FunctionDecl, +26,,, +27, // Auto variable declarations,, +28,,, +29, auto x = getValue();,DeclStmt, +30,,, +31, auto y = 3.14;,DeclStmt, +32,,, +33,,, +34,,, +35, // decltype usage,, +36,,, +37, decltype(x) z = x + 10;,DeclStmt, +38,,, +39,,, +40,,, +41, // Auto with function call,, +42,,, +43," auto result = add(x, y);",DeclStmt, +44,,, +45,,, +46,,, +47, return 0;,ReturnStmt, +48,,, +49,},, diff --git a/clang-ast-mapper/web_app/temp/tmpn7dm998z.cpp b/clang-ast-mapper/web_app/temp/tmpn7dm998z.cpp new file mode 100644 index 0000000000000..4064eb6c3d9da --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpn7dm998z.cpp @@ -0,0 +1,27 @@ +#include +#include + +// Auto type deduction +auto getValue() { + return 42; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with function call + auto result = add(x, y); + + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpnv9q0rre.cpp b/clang-ast-mapper/web_app/temp/tmpnv9q0rre.cpp new file mode 100644 index 0000000000000..572072b0cf19d --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpnv9q0rre.cpp @@ -0,0 +1,8 @@ +int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpnv9q0rre.cpp.csv b/clang-ast-mapper/web_app/temp/tmpnv9q0rre.cpp.csv new file mode 100644 index 0000000000000..3bff957ec99ec --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpnv9q0rre.cpp.csv @@ -0,0 +1,16 @@ +Line,Source Code,AST Nodes,Explanations +1,"int add(int a, int b) {",ParmVarDecl; FunctionDecl, +2,,, +3, return a + b;,ReturnStmt, +4,,, +5,},, +6,,, +7,,, +8,,, +9,int main() {,CompoundStmt; FunctionDecl, +10,,, +11," int result = add(5, 3);",DeclStmt, +12,,, +13, return 0;,ReturnStmt, +14,,, +15,},, diff --git a/clang-ast-mapper/web_app/temp/tmpqb8xfdqx.cpp b/clang-ast-mapper/web_app/temp/tmpqb8xfdqx.cpp new file mode 100644 index 0000000000000..572072b0cf19d --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpqb8xfdqx.cpp @@ -0,0 +1,8 @@ +int add(int a, int b) { + return a + b; +} + +int main() { + int result = add(5, 3); + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpr0cvxwr2.cpp b/clang-ast-mapper/web_app/temp/tmpr0cvxwr2.cpp new file mode 100644 index 0000000000000..7a0e6b6cf1a45 --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpr0cvxwr2.cpp @@ -0,0 +1,46 @@ +// Complex C++ example with classes and methods +class Calculator { +private: + int value; + +public: + Calculator(int initial) : value(initial) {} + + int add(int a, int b) { + return a + b; + } + + int multiply(int a, int b) { + return a * b; + } + + void setValue(int newValue) { + value = newValue; + } + + int getValue() const { + return value; + } +}; + +int main() { + Calculator calc(10); + + int x = 5; + int y = 3; + + if (x > y) { + int result = calc.add(x, y); + calc.setValue(result); + } else { + int result = calc.multiply(x, y); + calc.setValue(result); + } + + for (int i = 0; i < 3; i++) { + int current = calc.getValue(); + calc.setValue(current + 1); + } + + return calc.getValue(); +} diff --git a/clang-ast-mapper/web_app/temp/tmps9msddp3.cpp b/clang-ast-mapper/web_app/temp/tmps9msddp3.cpp new file mode 100644 index 0000000000000..4064eb6c3d9da --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmps9msddp3.cpp @@ -0,0 +1,27 @@ +#include +#include + +// Auto type deduction +auto getValue() { + return 42; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with function call + auto result = add(x, y); + + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpuwobzv73.cpp b/clang-ast-mapper/web_app/temp/tmpuwobzv73.cpp new file mode 100644 index 0000000000000..e3f92b46ce7b4 --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpuwobzv73.cpp @@ -0,0 +1,25 @@ + +// Auto type deduction +auto getValue() { + return 42; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with function call + auto result = add(x, y); + + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/temp/tmpuwobzv73.cpp.csv b/clang-ast-mapper/web_app/temp/tmpuwobzv73.cpp.csv new file mode 100644 index 0000000000000..2d5a11cb3dfcc --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpuwobzv73.cpp.csv @@ -0,0 +1,50 @@ +Line,Source Code,AST Nodes,Explanations +1,,, +2,,, +3,// Auto type deduction,, +4,,, +5,auto getValue() {,CompoundStmt; FunctionDecl, +6,,, +7, return 42;,ReturnStmt, +8,,, +9,},, +10,,, +11,,, +12,,, +13,// Function with decltype,, +14,,, +15,"template ",TemplateTypeParmDecl, +16,,, +17,"auto add(T a, U b) -> decltype(a + b) {",ParmVarDecl; FunctionDecl; FunctionTemplateDecl, +18,,, +19, return a + b;,ReturnStmt, +20,,, +21,},, +22,,, +23,,, +24,,, +25,int main() {,CompoundStmt; FunctionDecl, +26,,, +27, // Auto variable declarations,, +28,,, +29, auto x = getValue();,DeclStmt, +30,,, +31, auto y = 3.14;,DeclStmt, +32,,, +33,,, +34,,, +35, // decltype usage,, +36,,, +37, decltype(x) z = x + 10;,DeclStmt, +38,,, +39,,, +40,,, +41, // Auto with function call,, +42,,, +43," auto result = add(x, y);",DeclStmt, +44,,, +45,,, +46,,, +47, return 0;,ReturnStmt, +48,,, +49,},, diff --git a/clang-ast-mapper/web_app/temp/tmpyetqs5yi.cpp b/clang-ast-mapper/web_app/temp/tmpyetqs5yi.cpp new file mode 100644 index 0000000000000..4064eb6c3d9da --- /dev/null +++ b/clang-ast-mapper/web_app/temp/tmpyetqs5yi.cpp @@ -0,0 +1,27 @@ +#include +#include + +// Auto type deduction +auto getValue() { + return 42; +} + +// Function with decltype +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +int main() { + // Auto variable declarations + auto x = getValue(); + auto y = 3.14; + + // decltype usage + decltype(x) z = x + 10; + + // Auto with function call + auto result = add(x, y); + + return 0; +} \ No newline at end of file diff --git a/clang-ast-mapper/web_app/templates/base.html b/clang-ast-mapper/web_app/templates/base.html new file mode 100644 index 0000000000000..664921ba47eeb --- /dev/null +++ b/clang-ast-mapper/web_app/templates/base.html @@ -0,0 +1,78 @@ + + + + + + Clang AST Line Mapper + + + + + {% block head %}{% endblock %} + + + + +
+ {% block content %}{% endblock %} +
+ +
+
+ Clang AST Line Mapper ยฉ 2025 +
+
+ + + + + + + + + {% block scripts %}{% endblock %} + + diff --git a/clang-ast-mapper/web_app/templates/index.html b/clang-ast-mapper/web_app/templates/index.html new file mode 100644 index 0000000000000..12fb6756f72ff --- /dev/null +++ b/clang-ast-mapper/web_app/templates/index.html @@ -0,0 +1,552 @@ +{% extends 'base.html' %} + +{% block head %} + +{% endblock %} + +{% block content %} +
+
+
+ Loading... +
+

Analyzing code, please wait...

+
+
+ +
+
+
+
+
C++ Code Input
+
+ + +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
+
Source Code and AST Nodes
+
+
+
+ + + + + + + + + + + + +
#C++ CodeAST NodesExplanation
+
+
+
+
+ +
+
+
+
AI Interpretation
+
+
+
+ +
+
+
+
+
+
+ + + +{% endblock %} + +{% block scripts %} + +{% endblock %}