[PATCH] D14349: [Lex] Add __has_builtin support for __make_integer_seq

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 4 17:04:08 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL252115: [Lex] Add __has_builtin support for __make_integer_seq (authored by majnemer).

Changed prior to commit:
  http://reviews.llvm.org/D14349?vs=39258&id=39294#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14349

Files:
  cfe/trunk/lib/Lex/PPMacroExpansion.cpp
  cfe/trunk/test/SemaCXX/make_integer_seq.cpp

Index: cfe/trunk/test/SemaCXX/make_integer_seq.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/make_integer_seq.cpp
+++ cfe/trunk/test/SemaCXX/make_integer_seq.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
+static_assert(__has_builtin(__make_integer_seq), "");
+
 template <class T, T... I>
 struct Seq {
   static constexpr T PackSize = sizeof...(I);
Index: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
===================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp
@@ -1636,7 +1636,15 @@
       Value = FeatureII->getTokenID() == tok::identifier;
     else if (II == Ident__has_builtin) {
       // Check for a builtin is trivial.
-      Value = FeatureII->getBuiltinID() != 0;
+      if (FeatureII->getBuiltinID() != 0) {
+        Value = true;
+      } else {
+        const LangOptions &LangOpts = PP.getLangOpts();
+        StringRef Feature = FeatureII->getName();
+        Value = llvm::StringSwitch<bool>(Feature)
+                    .Case("__make_integer_seq", LangOpts.CPlusPlus)
+                    .Default(false);
+      }
     } else if (II == Ident__has_attribute)
       Value = hasAttribute(AttrSyntax::GNU, nullptr, FeatureII,
                            getTargetInfo(), getLangOpts());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14349.39294.patch
Type: text/x-patch
Size: 1377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151105/4130186d/attachment.bin>


More information about the cfe-commits mailing list