mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 23:51:56 +00:00
[clang] - Add missing builtin name to AtomicExpr JSON dump
As a side effect, introduce AtomicExpr::getOpAsString() to dump the AtomicOp string representation. This is a recommit with the target fully specified. Differential Revision: https://reviews.llvm.org/D158558
This commit is contained in:
parent
615d812696
commit
01b2554ff4
@ -6480,6 +6480,15 @@ public:
|
||||
QualType getValueType() const;
|
||||
|
||||
AtomicOp getOp() const { return Op; }
|
||||
StringRef getOpAsString() const {
|
||||
switch (Op) {
|
||||
#define BUILTIN(ID, TYPE, ATTRS)
|
||||
#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
|
||||
case AO##ID: \
|
||||
return #ID;
|
||||
#include "clang/Basic/Builtins.def"
|
||||
}
|
||||
}
|
||||
unsigned getNumSubExprs() const { return NumSubExprs; }
|
||||
|
||||
Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }
|
||||
|
@ -285,6 +285,7 @@ public:
|
||||
void VisitBinaryOperator(const BinaryOperator *BO);
|
||||
void VisitCompoundAssignOperator(const CompoundAssignOperator *CAO);
|
||||
void VisitMemberExpr(const MemberExpr *ME);
|
||||
void VisitAtomicExpr(const AtomicExpr *AE);
|
||||
void VisitCXXNewExpr(const CXXNewExpr *NE);
|
||||
void VisitCXXDeleteExpr(const CXXDeleteExpr *DE);
|
||||
void VisitCXXThisExpr(const CXXThisExpr *TE);
|
||||
|
@ -1179,6 +1179,10 @@ void JSONNodeDumper::VisitBlockDecl(const BlockDecl *D) {
|
||||
attributeOnlyIfTrue("capturesThis", D->capturesCXXThis());
|
||||
}
|
||||
|
||||
void JSONNodeDumper::VisitAtomicExpr(const AtomicExpr *AE) {
|
||||
JOS.attribute("name", AE->getOpAsString());
|
||||
}
|
||||
|
||||
void JSONNodeDumper::VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE) {
|
||||
JOS.attribute("encodedType", createQualType(OEE->getEncodedType()));
|
||||
}
|
||||
|
128
clang/test/AST/ast-dump-atomic-json.c
Normal file
128
clang/test/AST/ast-dump-atomic-json.c
Normal file
@ -0,0 +1,128 @@
|
||||
// RUN: %clang_cc1 -triple x86_64-pc-linux -Wno-unused-value -ast-dump=json %s | FileCheck %s
|
||||
|
||||
int foo(int * ptr) {
|
||||
return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
|
||||
// using --filters=AtomicExpr
|
||||
|
||||
|
||||
// CHECK-NOT: {{^}}Dumping
|
||||
// CHECK: "kind": "AtomicExpr",
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 125,
|
||||
// CHECK-NEXT: "col": 10,
|
||||
// CHECK-NEXT: "tokLen": 15
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 162,
|
||||
// CHECK-NEXT: "col": 47,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "type": {
|
||||
// CHECK-NEXT: "qualType": "int"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "valueCategory": "prvalue",
|
||||
// CHECK-NEXT: "name": "__atomic_load_n",
|
||||
// CHECK-NEXT: "inner": [
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "ImplicitCastExpr",
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 141,
|
||||
// CHECK-NEXT: "col": 26,
|
||||
// CHECK-NEXT: "tokLen": 3
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 141,
|
||||
// CHECK-NEXT: "col": 26,
|
||||
// CHECK-NEXT: "tokLen": 3
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "type": {
|
||||
// CHECK-NEXT: "qualType": "int *"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "valueCategory": "prvalue",
|
||||
// CHECK-NEXT: "castKind": "LValueToRValue",
|
||||
// CHECK-NEXT: "inner": [
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "DeclRefExpr",
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "offset": 141,
|
||||
// CHECK-NEXT: "col": 26,
|
||||
// CHECK-NEXT: "tokLen": 3
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "offset": 141,
|
||||
// CHECK-NEXT: "col": 26,
|
||||
// CHECK-NEXT: "tokLen": 3
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "type": {
|
||||
// CHECK-NEXT: "qualType": "int *"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "valueCategory": "lvalue",
|
||||
// CHECK-NEXT: "referencedDecl": {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "ParmVarDecl",
|
||||
// CHECK-NEXT: "name": "ptr",
|
||||
// CHECK-NEXT: "type": {
|
||||
// CHECK-NEXT: "qualType": "int *"
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: {
|
||||
// CHECK-NEXT: "id": "0x{{.*}}",
|
||||
// CHECK-NEXT: "kind": "IntegerLiteral",
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "begin": {
|
||||
// CHECK-NEXT: "spellingLoc": {
|
||||
// CHECK-NEXT: "offset": 417,
|
||||
// CHECK-NEXT: "file": "<built-in>",
|
||||
// CHECK-NEXT: "line": 13,
|
||||
// CHECK-NEXT: "presumedLine": 12,
|
||||
// CHECK-NEXT: "col": 26,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "expansionLoc": {
|
||||
// CHECK-NEXT: "offset": 146,
|
||||
// CHECK-NEXT: "file": "{{.*}}",
|
||||
// CHECK-NEXT: "line": 4,
|
||||
// CHECK-NEXT: "col": 31,
|
||||
// CHECK-NEXT: "tokLen": 16
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "end": {
|
||||
// CHECK-NEXT: "spellingLoc": {
|
||||
// CHECK-NEXT: "offset": 417,
|
||||
// CHECK-NEXT: "file": "<built-in>",
|
||||
// CHECK-NEXT: "line": 13,
|
||||
// CHECK-NEXT: "presumedLine": 12,
|
||||
// CHECK-NEXT: "col": 26,
|
||||
// CHECK-NEXT: "tokLen": 1
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "expansionLoc": {
|
||||
// CHECK-NEXT: "offset": 146,
|
||||
// CHECK-NEXT: "file": "{{.*}}",
|
||||
// CHECK-NEXT: "line": 4,
|
||||
// CHECK-NEXT: "col": 31,
|
||||
// CHECK-NEXT: "tokLen": 16
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "type": {
|
||||
// CHECK-NEXT: "qualType": "int"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "valueCategory": "prvalue",
|
||||
// CHECK-NEXT: "value": "5"
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: }
|
Loading…
Reference in New Issue
Block a user