Skip to content

Instantly share code, notes, and snippets.

@chapuni
Created March 7, 2014 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chapuni/9412576 to your computer and use it in GitHub Desktop.
Save chapuni/9412576 to your computer and use it in GitHub Desktop.
index f3481c1..37a5c8e 100644
--- a/clang/include/clang/AST/DataRecursiveASTVisitor.h
+++ b/clang/include/clang/AST/DataRecursiveASTVisitor.h
@@ -598,8 +598,8 @@ bool DataRecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) {
}
// Visit any attributes attached to this declaration.
- for (Decl::attr_iterator I=D->attr_begin(), E=D->attr_end(); I != E; ++I) {
- if (!getDerived().TraverseAttr(*I))
+ for (auto I : D->attrs()) {
+ if (!getDerived().TraverseAttr(I))
return false;
}
return true;
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 92c26c4..86537b0 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -669,8 +669,8 @@ bool RecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) {
}
// Visit any attributes attached to this declaration.
- for (Decl::attr_iterator I=D->attr_begin(), E=D->attr_end(); I != E; ++I) {
- if (!getDerived().TraverseAttr(*I))
+ for (auto I : D->attrs()) {
+ if (!getDerived().TraverseAttr(I))
return false;
}
return true;
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index c96fcbe..785aa6a 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -1940,13 +1940,11 @@ void Sema::DiagnoseMissingDesignatedInitOverrides(
static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod,
ObjCPropertyDecl *Property) {
// Should we just clone all attributes over?
- for (Decl::attr_iterator A = Property->attr_begin(),
- AEnd = Property->attr_end();
- A != AEnd; ++A) {
- if (isa<DeprecatedAttr>(*A) ||
- isa<UnavailableAttr>(*A) ||
- isa<AvailabilityAttr>(*A))
- PropertyMethod->addAttr((*A)->clone(S.Context));
+ for (auto A : Property->attrs()) {
+ if (isa<DeprecatedAttr>(A) ||
+ isa<UnavailableAttr>(A) ||
+ isa<AvailabilityAttr>(A))
+ PropertyMethod->addAttr(A->clone(S.Context));
}
}
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 69f665a..9856307 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -6040,9 +6040,8 @@ static int getCursorPlatformAvailabilityForDecl(const Decl *D,
int availability_size) {
bool HadAvailAttr = false;
int N = 0;
- for (Decl::attr_iterator A = D->attr_begin(), AEnd = D->attr_end(); A != AEnd;
- ++A) {
- if (DeprecatedAttr *Deprecated = dyn_cast<DeprecatedAttr>(*A)) {
+ for (auto A : D->attrs()) {
+ if (DeprecatedAttr *Deprecated = dyn_cast<DeprecatedAttr>(A)) {
HadAvailAttr = true;
if (always_deprecated)
*always_deprecated = 1;
@@ -6051,7 +6050,7 @@ static int getCursorPlatformAvailabilityForDecl(const Decl *D,
continue;
}
- if (UnavailableAttr *Unavailable = dyn_cast<UnavailableAttr>(*A)) {
+ if (UnavailableAttr *Unavailable = dyn_cast<UnavailableAttr>(A)) {
HadAvailAttr = true;
if (always_unavailable)
*always_unavailable = 1;
@@ -6061,7 +6060,7 @@ static int getCursorPlatformAvailabilityForDecl(const Decl *D,
continue;
}
- if (AvailabilityAttr *Avail = dyn_cast<AvailabilityAttr>(*A)) {
+ if (AvailabilityAttr *Avail = dyn_cast<AvailabilityAttr>(A)) {
HadAvailAttr = true;
if (N < availability_size) {
availability[N].Platform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment