[PATCH] D112367: [Clang][AST] Temporarily undefine IBAction/IBOutlet ObjC macros in attribute headers

Alf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 23 09:36:29 PDT 2021


gAlfonso-bit created this revision.
gAlfonso-bit requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Taken from a downstream fork: https://github.com/apple/llvm-project/pull/3461/files.

IBAction and IBOutlet are defined when compiling with ObjC/ObjC++ enabled. This can cause issues due to macro expansion when we look through these header files while compiling in ObjC++ mode. This patch temporarily undefs these macros so that the compiler doesn't try to expand them when looking through these attribute headers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112367

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/AST/RecursiveASTVisitor.h


Index: clang/include/clang/AST/RecursiveASTVisitor.h
===================================================================
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -13,18 +13,23 @@
 #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
 #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
 
+#pragma push_macro("IBAction")
+#pragma push_macro("IBOutlet")
+#undef IBAction
+#undef IBOutlet
+
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclOpenMP.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
 #include "clang/AST/LambdaCapture.h"
@@ -3702,4 +3707,7 @@
 
 } // end namespace clang
 
+#pragma pop_macro("IBAction")
+#pragma pop_macro("IBOutlet")
+
 #endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
Index: clang/include/clang/AST/Attr.h
===================================================================
--- clang/include/clang/AST/Attr.h
+++ clang/include/clang/AST/Attr.h
@@ -13,14 +13,19 @@
 #ifndef LLVM_CLANG_AST_ATTR_H
 #define LLVM_CLANG_AST_ATTR_H
 
+#pragma push_macro("IBAction")
+#pragma push_macro("IBOutlet")
+#undef IBAction
+#undef IBOutlet
+
 #include "clang/AST/ASTFwd.h"
 #include "clang/AST/AttrIterator.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/AttrKinds.h"
 #include "clang/Basic/AttributeCommonInfo.h"
-#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/Sanitizers.h"
 #include "clang/Basic/SourceLocation.h"
@@ -379,4 +384,7 @@
 }
 }  // end namespace clang
 
+#pragma pop_macro("IBAction")
+#pragma pop_macro("IBOutlet")
+
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112367.381749.patch
Type: text/x-patch
Size: 2098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211023/fc508dcc/attachment.bin>


More information about the cfe-commits mailing list