diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -4389,7 +4389,8 @@ auto AddCompletions = [&](const ParsedAttrInfo &A) { if (A.IsTargetSpecific && !A.existsInTarget(Context.getTargetInfo())) return; - // FIXME: filter by langopts (diagLangOpts method requires a ParsedAttr) + if (!A.acceptsLangOpts(getLangOpts())) + return; for (const auto &S : A.Spellings) { if (S.Syntax != Syntax) continue; diff --git a/clang/test/CodeCompletion/attr.cpp b/clang/test/CodeCompletion/attr.cpp --- a/clang/test/CodeCompletion/attr.cpp +++ b/clang/test/CodeCompletion/attr.cpp @@ -7,11 +7,14 @@ // STD-NOT: COMPLETION: __used__ // STD: COMPLETION: _Clang::__convergent__ // STD: COMPLETION: carries_dependency +// STD-NOT: COMPLETION: clang::called_once // STD: COMPLETION: clang::convergent // STD-NOT: COMPLETION: convergent // STD-NOT: COMPLETION: gnu::__used__ // STD: COMPLETION: gnu::used // STD-NOT: COMPLETION: used +// RUN: %clang_cc1 -code-completion-at=%s:1:9 -xobjective-c++ %s | FileCheck --check-prefix=STD-OBJC %s +// STD-OBJC: COMPLETION: clang::called_once // RUN: %clang_cc1 -code-completion-at=%s:1:14 %s | FileCheck --check-prefix=STD-NS %s // STD-NS-NOT: COMPLETION: __used__ // STD-NS-NOT: COMPLETION: carries_dependency @@ -20,12 +23,12 @@ // STD-NS-NOT: COMPLETION: gnu::used // STD-NS: COMPLETION: used int b [[__gnu__::used]]; -// RUN: %clang_cc1 -code-completion-at=%s:22:18 %s | FileCheck --check-prefix=STD-NSU %s +// RUN: %clang_cc1 -code-completion-at=%s:25:18 %s | FileCheck --check-prefix=STD-NSU %s // STD-NSU: COMPLETION: __used__ // STD-NSU-NOT: COMPLETION: used int c [[using gnu: used]]; -// RUN: %clang_cc1 -code-completion-at=%s:27:15 %s | FileCheck --check-prefix=STD-USING %s +// RUN: %clang_cc1 -code-completion-at=%s:30:15 %s | FileCheck --check-prefix=STD-USING %s // STD-USING: COMPLETION: __gnu__ // STD-USING: COMPLETION: _Clang // STD-USING-NOT: COMPLETION: carries_dependency @@ -33,10 +36,10 @@ // STD-USING-NOT: COMPLETION: clang:: // STD-USING-NOT: COMPLETION: gnu:: // STD-USING: COMPLETION: gnu -// RUN: %clang_cc1 -code-completion-at=%s:27:20 %s | FileCheck --check-prefix=STD-NS %s +// RUN: %clang_cc1 -code-completion-at=%s:30:20 %s | FileCheck --check-prefix=STD-NS %s int d __attribute__((used)); -// RUN: %clang_cc1 -code-completion-at=%s:38:22 %s | FileCheck --check-prefix=GNU %s +// RUN: %clang_cc1 -code-completion-at=%s:41:22 %s | FileCheck --check-prefix=GNU %s // GNU: COMPLETION: __carries_dependency__ // GNU: COMPLETION: __convergent__ // GNU-NOT: COMPLETION: __gnu__::__used__ @@ -51,12 +54,12 @@ #pragma clang attribute push (__attribute__((internal_linkage)), apply_to=variable) int e; #pragma clang attribute pop -// RUN: %clang_cc1 -code-completion-at=%s:51:46 %s | FileCheck --check-prefix=PRAGMA %s +// RUN: %clang_cc1 -code-completion-at=%s:54:46 %s | FileCheck --check-prefix=PRAGMA %s // PRAGMA: internal_linkage #ifdef MS_EXT int __declspec(thread) f; -// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:58:16 %s | FileCheck --check-prefix=DS %s +// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:61:16 %s | FileCheck --check-prefix=DS %s // DS-NOT: COMPLETION: __convergent__ // DS-NOT: COMPLETION: __used__ // DS-NOT: COMPLETION: clang::convergent @@ -66,7 +69,7 @@ // DS: COMPLETION: uuid [uuid("123e4567-e89b-12d3-a456-426614174000")] struct g; -// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:68:2 %s | FileCheck --check-prefix=MS %s +// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:71:2 %s | FileCheck --check-prefix=MS %s // MS-NOT: COMPLETION: __uuid__ // MS-NOT: COMPLETION: clang::convergent // MS-NOT: COMPLETION: convergent @@ -80,9 +83,9 @@ {} } // FIXME: support for omp attributes would be nice. -// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:79:5 %s | FileCheck --check-prefix=OMP-NS --allow-empty %s +// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:82:5 %s | FileCheck --check-prefix=OMP-NS --allow-empty %s // OMP-NS-NOT: omp -// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:79:10 %s | FileCheck --check-prefix=OMP-ATTR --allow-empty %s +// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:82:10 %s | FileCheck --check-prefix=OMP-ATTR --allow-empty %s // OMP-ATTR-NOT: sequence -// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:79:19 %s | FileCheck --check-prefix=OMP-NESTED --allow-empty %s +// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:82:19 %s | FileCheck --check-prefix=OMP-NESTED --allow-empty %s // OMP-NESTED-NOT: directive