Skip to content

Commit c9a2b33

Browse files
Merge commit 'ec7f4a7c5d9794c9fdf4f894873e7edbbfddf3e2' into llvmspirv_pulldown
2 parents d9fe4db + ec7f4a7 commit c9a2b33

File tree

93 files changed

+1136
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1136
-394
lines changed

clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,3 @@ template <typename T, template <typename> class U> class Bar {};
210210
// We used to report Q unsued, because we only checked the first template
211211
// argument.
212212
Bar<int, Q> *bar;
213-
214-
namespace internal {
215-
struct S {};
216-
int operator+(S s1, S s2);
217-
}
218-
219-
// Make sure this statement is not reported as unused.
220-
using internal::operator+;
221-
using internal::S;
222-
223-
int j() { return S() + S(); }

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Improvements to Clang's diagnostics
6767
enum without a fixed underlying type is set to a value outside the range of
6868
the enumeration's values. Fixes
6969
`Issue 50055: <https://github.com/llvm/llvm-project/issues/50055>`_.
70+
- Clang will now check compile-time determinable string literals as format strings.
71+
This fixes `Issue 55805: <https://github.com/llvm/llvm-project/issues/55805>`_.
7072

7173
Non-comprehensive list of changes in this release
7274
-------------------------------------------------

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ class DataflowAnalysisContext {
9393

9494
/// Returns a new storage location appropriate for `Type`.
9595
///
96-
/// Requirements:
97-
///
98-
/// `Type` must not be null.
96+
/// A null `Type` is interpreted as the pointee type of `std::nullptr_t`.
9997
StorageLocation &createStorageLocation(QualType Type);
10098

10199
/// Returns a stable storage location for `D`.

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class ObjCCommonTypesHelper {
174174
public:
175175
llvm::IntegerType *ShortTy, *IntTy, *LongTy;
176176
llvm::PointerType *Int8PtrTy, *Int8PtrPtrTy;
177+
llvm::PointerType *Int8PtrProgramASTy;
177178
llvm::Type *IvarOffsetVarTy;
178179

179180
/// ObjectPtrTy - LLVM type for object handles (typeof(id))
@@ -5739,11 +5740,13 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
57395740
{
57405741
CodeGen::CodeGenTypes &Types = CGM.getTypes();
57415742
ASTContext &Ctx = CGM.getContext();
5743+
unsigned ProgramAS = CGM.getDataLayout().getProgramAddressSpace();
57425744

57435745
ShortTy = cast<llvm::IntegerType>(Types.ConvertType(Ctx.ShortTy));
57445746
IntTy = CGM.IntTy;
57455747
LongTy = cast<llvm::IntegerType>(Types.ConvertType(Ctx.LongTy));
57465748
Int8PtrTy = CGM.Int8PtrTy;
5749+
Int8PtrProgramASTy = llvm::PointerType::get(CGM.Int8Ty, ProgramAS);
57475750
Int8PtrPtrTy = CGM.Int8PtrPtrTy;
57485751

57495752
// arm64 targets use "int" ivar offset variables. All others,
@@ -5812,7 +5815,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
58125815
// char *_imp;
58135816
// }
58145817
MethodTy = llvm::StructType::create("struct._objc_method", SelectorPtrTy,
5815-
Int8PtrTy, Int8PtrTy);
5818+
Int8PtrTy, Int8PtrProgramASTy);
58165819

58175820
// struct _objc_cache *
58185821
CacheTy = llvm::StructType::create(VMContext, "struct._objc_cache");
@@ -6771,11 +6774,11 @@ void CGObjCNonFragileABIMac::emitMethodConstant(ConstantArrayBuilder &builder,
67716774

67726775
if (forProtocol) {
67736776
// Protocol methods have no implementation. So, this entry is always NULL.
6774-
method.addNullPointer(ObjCTypes.Int8PtrTy);
6777+
method.addNullPointer(ObjCTypes.Int8PtrProgramASTy);
67756778
} else {
67766779
llvm::Function *fn = GetMethodDefinition(MD);
67776780
assert(fn && "no definition for method?");
6778-
method.addBitCast(fn, ObjCTypes.Int8PtrTy);
6781+
method.addBitCast(fn, ObjCTypes.Int8PtrProgramASTy);
67796782
}
67806783

67816784
method.finishAndAddTo(builder);

clang/lib/CodeGen/CGObjCRuntime.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,15 @@ CGObjCRuntime::MessageSendInfo
360360
CGObjCRuntime::getMessageSendInfo(const ObjCMethodDecl *method,
361361
QualType resultType,
362362
CallArgList &callArgs) {
363+
unsigned ProgramAS = CGM.getDataLayout().getProgramAddressSpace();
364+
363365
// If there's a method, use information from that.
364366
if (method) {
365367
const CGFunctionInfo &signature =
366368
CGM.getTypes().arrangeObjCMessageSendSignature(method, callArgs[0].Ty);
367369

368370
llvm::PointerType *signatureType =
369-
CGM.getTypes().GetFunctionType(signature)->getPointerTo();
371+
CGM.getTypes().GetFunctionType(signature)->getPointerTo(ProgramAS);
370372

371373
const CGFunctionInfo &signatureForCall =
372374
CGM.getTypes().arrangeCall(signature, callArgs);
@@ -380,7 +382,7 @@ CGObjCRuntime::getMessageSendInfo(const ObjCMethodDecl *method,
380382

381383
// Derive the signature to call from that.
382384
llvm::PointerType *signatureType =
383-
CGM.getTypes().GetFunctionType(argsInfo)->getPointerTo();
385+
CGM.getTypes().GetFunctionType(argsInfo)->getPointerTo(ProgramAS);
384386
return MessageSendInfo(argsInfo, signatureType);
385387
}
386388

clang/lib/Sema/SemaChecking.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8632,6 +8632,9 @@ static void CheckFormatString(
86328632
llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
86338633
bool IgnoreStringsWithoutSpecifiers);
86348634

8635+
static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
8636+
const Expr *E);
8637+
86358638
// Determine if an expression is a string literal or constant string.
86368639
// If this function returns false on the arguments to a function expecting a
86378640
// format string, we will usually need to emit a warning.
@@ -8872,7 +8875,11 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef<const Expr *> Args,
88728875
}
88738876
}
88748877
}
8875-
8878+
if (const Expr *SLE = maybeConstEvalStringLiteral(S.Context, E))
8879+
return checkFormatStringExpr(S, SLE, Args, APK, format_idx, firstDataArg,
8880+
Type, CallType, /*InFunctionCall*/ false,
8881+
CheckedVarArgs, UncoveredArg, Offset,
8882+
IgnoreStringsWithoutSpecifiers);
88768883
return SLCT_NotALiteral;
88778884
}
88788885
case Stmt::ObjCMessageExprClass: {
@@ -8982,6 +8989,20 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef<const Expr *> Args,
89828989
}
89838990
}
89848991

8992+
// If this expression can be evaluated at compile-time,
8993+
// check if the result is a StringLiteral and return it
8994+
// otherwise return nullptr
8995+
static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
8996+
const Expr *E) {
8997+
Expr::EvalResult Result;
8998+
if (E->EvaluateAsRValue(Result, Context) && Result.Val.isLValue()) {
8999+
const auto *LVE = Result.Val.getLValueBase().dyn_cast<const Expr *>();
9000+
if (isa_and_nonnull<StringLiteral>(LVE))
9001+
return LVE;
9002+
}
9003+
return nullptr;
9004+
}
9005+
89859006
Sema::FormatStringType Sema::GetFormatStringType(const FormatAttr *Format) {
89869007
return llvm::StringSwitch<FormatStringType>(Format->getType()->getName())
89879008
.Case("scanf", FST_Scanf)

clang/lib/Sema/SemaOverload.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ static ExprResult CreateFunctionRefExpr(
6363
// being used.
6464
if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
6565
return ExprError();
66-
DeclRefExpr *DRE =
67-
DeclRefExpr::Create(S.Context, Fn->getQualifierLoc(), SourceLocation(),
68-
Fn, false, Loc, Fn->getType(), VK_LValue, FoundDecl);
66+
DeclRefExpr *DRE = new (S.Context)
67+
DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, LocInfo);
6968
if (HadMultipleCandidates)
7069
DRE->setHadMultipleCandidates(true);
7170

clang/test/AST/ast-dump-overloaded-operators.cpp

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,21 @@ void test() {
2424
// CHECK-NEXT: |-FunctionDecl {{.*}} <line:12:1, col:19> col:6{{( imported)?}} used operator, 'void (E, E)'
2525
// CHECK-NEXT: | |-ParmVarDecl {{.*}} <col:16> col:17{{( imported)?}} 'E'
2626
// CHECK-NEXT: | `-ParmVarDecl {{.*}} <col:18> col:19{{( imported)?}} 'E'
27-
// CHECK-NEXT: |-FunctionDecl {{.*}} <line:14:1, line:18:1> line:14:6{{( imported)?}} test 'void ()'
28-
// CHECK-NEXT: | `-CompoundStmt {{.*}} <col:13, line:18:1>
29-
// CHECK-NEXT: | |-DeclStmt {{.*}} <line:15:3, col:6>
30-
// CHECK-NEXT: | | `-VarDecl {{.*}} <col:3, col:5> col:5{{( imported)?}} used e 'E'
31-
// CHECK-NEXT: | |-CXXOperatorCallExpr {{.*}} <line:16:3, col:7> 'void' '+'
32-
// CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} <col:5> 'void (*)(E, E)' <FunctionToPointerDecay>
33-
// CHECK-NEXT: | | | `-DeclRefExpr {{.*}} <col:5> 'void (E, E)' lvalue Function {{.*}} 'operator+' 'void (E, E)'
34-
// CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} <col:3> 'E':'E' <LValueToRValue>
35-
// CHECK-NEXT: | | | `-DeclRefExpr {{.*}} <col:3> 'E':'E' lvalue Var {{.*}} 'e' 'E':'E'
36-
// CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} <col:7> 'E':'E' <LValueToRValue>
37-
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <col:7> 'E':'E' lvalue Var {{.*}} 'e' 'E':'E'
38-
// CHECK-NEXT: | `-CXXOperatorCallExpr {{.*}} <line:17:3, col:7> 'void' ','
39-
// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} <col:5> 'void (*)(E, E)' <FunctionToPointerDecay>
40-
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <col:5> 'void (E, E)' lvalue Function {{.*}} 'operator,' 'void (E, E)'
41-
// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} <col:3> 'E':'E' <LValueToRValue>
42-
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <col:3> 'E':'E' lvalue Var {{.*}} 'e' 'E':'E'
43-
// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:7> 'E':'E' <LValueToRValue>
44-
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:7> 'E':'E' lvalue Var {{.*}} 'e' 'E':'E'
45-
46-
namespace a {
47-
void operator-(E, E);
48-
}
49-
50-
using a::operator-;
51-
52-
void f() {
53-
E() - E();
54-
}
55-
// CHECK: |-NamespaceDecl {{.*}} <line:46:1, line:48:1> line:46:11{{( imported <undeserialized declarations>)?}} a
56-
// CHECK-NEXT: | `-FunctionDecl {{.*}} <line:47:3, col:22> col:8{{( imported)?}} used operator- 'void (E, E)'
57-
// CHECK-NEXT: | |-ParmVarDecl {{.*}} <col:18> col:19{{( imported)?}} 'E'
58-
// CHECK-NEXT: | `-ParmVarDecl {{.*}} <col:21> col:22{{( imported)?}} 'E'
59-
// CHECK-NEXT: |-UsingDecl {{.*}} <line:50:1, col:18> col:10{{( imported)?}} a::operator-
60-
// CHECK-NEXT: |-UsingShadowDecl {{.*}} <col:10> col:10{{( imported)?}} implicit Function {{.*}} 'operator-' 'void (E, E)'
61-
// CHECK-NEXT: `-FunctionDecl {{.*}} <line:52:1, line:54:1> line:52:6{{( imported)?}} f 'void ()'
62-
// CHECK-NEXT: `-CompoundStmt {{.*}} <col:10, line:54:1>
63-
// CHECK-NEXT: `-CXXOperatorCallExpr {{.*}} <line:53:3, col:11> 'void' '-'
64-
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:7> 'void (*)(E, E)' <FunctionToPointerDecay>
65-
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:7> 'void (E, E)' lvalue Function {{.*}} 'operator-' 'void (E, E)' (UsingShadow {{.*}} 'operator-')
66-
// CHECK-NEXT: |-CXXScalarValueInitExpr {{.*}} <col:3, col:5> 'E'
67-
// CHECK-NEXT: `-CXXScalarValueInitExpr {{.*}} <col:9, col:11> 'E'
27+
// CHECK-NEXT: `-FunctionDecl {{.*}} <line:14:1, line:18:1> line:14:6{{( imported)?}} test 'void ()'
28+
// CHECK-NEXT: `-CompoundStmt {{.*}} <col:13, line:18:1>
29+
// CHECK-NEXT: |-DeclStmt {{.*}} <line:15:3, col:6>
30+
// CHECK-NEXT: | `-VarDecl {{.*}} <col:3, col:5> col:5{{( imported)?}} used e 'E'
31+
// CHECK-NEXT: |-CXXOperatorCallExpr {{.*}} <line:16:3, col:7> 'void' '+'
32+
// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} <col:5> 'void (*)(E, E)' <FunctionToPointerDecay>
33+
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <col:5> 'void (E, E)' lvalue Function {{.*}} 'operator+' 'void (E, E)'
34+
// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} <col:3> 'E':'E' <LValueToRValue>
35+
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <col:3> 'E':'E' lvalue Var {{.*}} 'e' 'E'
36+
// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:7> 'E':'E' <LValueToRValue>
37+
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:7> 'E':'E' lvalue Var {{.*}} 'e' 'E'
38+
// CHECK-NEXT: `-CXXOperatorCallExpr {{.*}} <line:17:3, col:7> 'void' ','
39+
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:5> 'void (*)(E, E)' <FunctionToPointerDecay>
40+
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:5> 'void (E, E)' lvalue Function {{.*}} 'operator,' 'void (E, E)'
41+
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:3> 'E':'E' <LValueToRValue>
42+
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:3> 'E':'E' lvalue Var {{.*}} 'e' 'E'
43+
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <col:7> 'E':'E' <LValueToRValue>
44+
// CHECK-NEXT: `-DeclRefExpr {{.*}} <col:7> 'E':'E' lvalue Var {{.*}} 'e' 'E'

clang/test/CodeGen/avr/objc-method.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_cc1 -triple avr -emit-llvm -fobjc-runtime=macosx %s -o /dev/null
2+
3+
__attribute__((objc_root_class))
4+
@interface Foo
5+
6+
- (id)foo;
7+
- (id)bar;
8+
9+
@end
10+
11+
@implementation Foo
12+
13+
- (id)foo {
14+
return self;
15+
}
16+
17+
- (id)bar {
18+
return [self foo];
19+
}
20+
21+
@end

clang/test/Index/annotate-operator-call-expr.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,68 +17,68 @@ void testFoo(Foo foo, int index) {
1717

1818
// RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1
1919
// CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18
20-
// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
21-
// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
20+
// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
21+
// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
2222
// CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=
2323

2424
// RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2
25-
// CHECK2: Punctuation: "(" [8:6 - 8:7] CallExpr=operator():3:7
25+
// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
2626
// CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
27-
// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
27+
// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
2828
// CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt=
2929

3030
// RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3
3131
// CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18
32-
// CHECK3: Punctuation: "[" [10:6 - 10:7] CallExpr=operator[]:2:7
32+
// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
3333
// CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
34-
// CHECK3: Punctuation: "]" [10:12 - 10:13] CallExpr=operator[]:2:7
34+
// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
3535
// CHECK3: Punctuation: ";" [10:13 - 10:14] CompoundStmt=
3636

3737
// RUN: c-index-test -test-annotate-tokens=%s:11:1:11:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK4
3838
// CHECK4: Identifier: "foo" [11:3 - 11:6] DeclRefExpr=foo:6:18
39-
// CHECK4: Punctuation: "[" [11:6 - 11:7] CallExpr=operator[]:2:7
39+
// CHECK4: Punctuation: "[" [11:6 - 11:7] DeclRefExpr=operator[]:2:7 RefName=[11:6 - 11:7] RefName=[11:20 - 11:21]
4040
// CHECK4: Identifier: "index" [11:7 - 11:12] DeclRefExpr=index:6:27
4141
// CHECK4: Punctuation: "+" [11:13 - 11:14] BinaryOperator=
4242
// CHECK4: Identifier: "index" [11:15 - 11:20] DeclRefExpr=index:6:27
43-
// CHECK4: Punctuation: "]" [11:20 - 11:21] CallExpr=operator[]:2:7
43+
// CHECK4: Punctuation: "]" [11:20 - 11:21] DeclRefExpr=operator[]:2:7 RefName=[11:6 - 11:7] RefName=[11:20 - 11:21]
4444
// CHECK4: Punctuation: ";" [11:21 - 11:22] CompoundStmt=
4545

4646
// RUN: c-index-test -test-annotate-tokens=%s:13:1:13:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK5
4747
// CHECK5: Identifier: "foo" [13:3 - 13:6] DeclRefExpr=foo:6:18
48-
// CHECK5: Punctuation: "[" [13:6 - 13:7] CallExpr=operator[]:2:7
48+
// CHECK5: Punctuation: "[" [13:6 - 13:7] DeclRefExpr=operator[]:2:7 RefName=[13:6 - 13:7] RefName=[13:17 - 13:18]
4949
// CHECK5: Identifier: "foo" [13:7 - 13:10] DeclRefExpr=foo:6:18
50-
// CHECK5: Punctuation: "[" [13:10 - 13:11] CallExpr=operator[]:2:7
50+
// CHECK5: Punctuation: "[" [13:10 - 13:11] DeclRefExpr=operator[]:2:7 RefName=[13:10 - 13:11] RefName=[13:16 - 13:17]
5151
// CHECK5: Identifier: "index" [13:11 - 13:16] DeclRefExpr=index:6:27
52-
// CHECK5: Punctuation: "]" [13:16 - 13:17] CallExpr=operator[]:2:7
53-
// CHECK5: Punctuation: "]" [13:17 - 13:18] CallExpr=operator[]:2:7
52+
// CHECK5: Punctuation: "]" [13:16 - 13:17] DeclRefExpr=operator[]:2:7 RefName=[13:10 - 13:11] RefName=[13:16 - 13:17]
53+
// CHECK5: Punctuation: "]" [13:17 - 13:18] DeclRefExpr=operator[]:2:7 RefName=[13:6 - 13:7] RefName=[13:17 - 13:18]
5454
// CHECK5: Punctuation: ";" [13:18 - 13:19] CompoundStmt=
5555

5656
// RUN: c-index-test -test-annotate-tokens=%s:14:1:14:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK6
5757
// CHECK6: Identifier: "foo" [14:3 - 14:6] DeclRefExpr=foo:6:18
58-
// CHECK6: Punctuation: "[" [14:6 - 14:7] CallExpr=operator[]:2:7
58+
// CHECK6: Punctuation: "[" [14:6 - 14:7] DeclRefExpr=operator[]:2:7 RefName=[14:6 - 14:7] RefName=[14:25 - 14:26]
5959
// CHECK6: Identifier: "foo" [14:7 - 14:10] DeclRefExpr=foo:6:18
60-
// CHECK6: Punctuation: "(" [14:10 - 14:11] CallExpr=operator():3:7
61-
// CHECK6: Punctuation: ")" [14:11 - 14:12] CallExpr=operator():3:7
60+
// CHECK6: Punctuation: "(" [14:10 - 14:11] DeclRefExpr=operator():3:7 RefName=[14:10 - 14:11] RefName=[14:11 - 14:12]
61+
// CHECK6: Punctuation: ")" [14:11 - 14:12] DeclRefExpr=operator():3:7 RefName=[14:10 - 14:11] RefName=[14:11 - 14:12]
6262
// CHECK6: Punctuation: "+" [14:13 - 14:14] BinaryOperator=
6363
// CHECK6: Identifier: "foo" [14:15 - 14:18] DeclRefExpr=foo:6:18
64-
// CHECK6: Punctuation: "[" [14:18 - 14:19] CallExpr=operator[]:2:7
65-
// CHECK6: Identifier: "index" [14:19 - 14:24] DeclRefExpr=index:6:27
66-
// CHECK6: Punctuation: "]" [14:24 - 14:25] CallExpr=operator[]:2:7
67-
// CHECK6: Punctuation: "]" [14:25 - 14:26] CallExpr=operator[]:2:7
64+
// CHECK6: Punctuation: "[" [14:18 - 14:19] DeclRefExpr=operator[]:2:7 RefName=[14:18 - 14:19] RefName=[14:24 - 14:25]
65+
// CHECK6: Identifier: "index" [14:19 - 14:24] DeclRefExpr=operator[]:2:7 RefName=[14:6 - 14:7] RefName=[14:25 - 14:26]
66+
// CHECK6: Punctuation: "]" [14:24 - 14:25] DeclRefExpr=operator[]:2:7 RefName=[14:18 - 14:19] RefName=[14:24 - 14:25]
67+
// CHECK6: Punctuation: "]" [14:25 - 14:26] DeclRefExpr=operator[]:2:7 RefName=[14:6 - 14:7] RefName=[14:25 - 14:26]
6868
// CHECK6: Punctuation: ";" [14:26 - 14:27] CompoundStmt=
6969

7070
// RUN: c-index-test -test-annotate-tokens=%s:15:1:15:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK7
7171
// CHECK7: Identifier: "foo" [15:3 - 15:6] DeclRefExpr=foo:6:18
72-
// CHECK7: Punctuation: "[" [15:6 - 15:7] CallExpr=operator[]:2:7
72+
// CHECK7: Punctuation: "[" [15:6 - 15:7] DeclRefExpr=operator[]:2:7 RefName=[15:6 - 15:7] RefName=[15:30 - 15:31]
7373
// CHECK7: Identifier: "foo" [15:7 - 15:10] DeclRefExpr=foo:6:18
74-
// CHECK7: Punctuation: "(" [15:10 - 15:11] CallExpr=operator():3:7
74+
// CHECK7: Punctuation: "(" [15:10 - 15:11] DeclRefExpr=operator():3:7 RefName=[15:10 - 15:11] RefName=[15:16 - 15:17]
7575
// CHECK7: Identifier: "index" [15:11 - 15:16] DeclRefExpr=index:6:27
76-
// CHECK7: Punctuation: ")" [15:16 - 15:17] CallExpr=operator():3:7
76+
// CHECK7: Punctuation: ")" [15:16 - 15:17] DeclRefExpr=operator():3:7 RefName=[15:10 - 15:11] RefName=[15:16 - 15:17]
7777
// CHECK7: Punctuation: "+" [15:18 - 15:19] BinaryOperator=
7878
// CHECK7: Identifier: "foo" [15:20 - 15:23] DeclRefExpr=foo:6:18
79-
// CHECK7: Punctuation: "[" [15:23 - 15:24] CallExpr=operator[]:2:7
79+
// CHECK7: Punctuation: "[" [15:23 - 15:24] DeclRefExpr=operator[]:2:7 RefName=[15:23 - 15:24] RefName=[15:29 - 15:30]
8080
// CHECK7: Identifier: "index" [15:24 - 15:29] DeclRefExpr=index:6:27
81-
// CHECK7: Punctuation: "]" [15:29 - 15:30] CallExpr=operator[]:2:7
82-
// CHECK7: Punctuation: "]" [15:30 - 15:31] CallExpr=operator[]:2:7
81+
// CHECK7: Punctuation: "]" [15:29 - 15:30] DeclRefExpr=operator[]:2:7 RefName=[15:23 - 15:24] RefName=[15:29 - 15:30]
82+
// CHECK7: Punctuation: "]" [15:30 - 15:31] DeclRefExpr=operator[]:2:7 RefName=[15:6 - 15:7] RefName=[15:30 - 15:31]
8383
// CHECK7: Punctuation: ";" [15:31 - 15:32] CompoundStmt=
8484

0 commit comments

Comments
 (0)