@@ -1798,54 +1798,55 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
17981798 return II && HasExtension (*this , II->getName ());
17991799 });
18001800 } else if (II == Ident__has_builtin) {
1801- EvaluateFeatureLikeBuiltinMacro (OS, Tok, II, *this , false ,
1802- [this ](Token &Tok, bool &HasLexedNextToken) -> int {
1803- IdentifierInfo *II = ExpectFeatureIdentifierInfo (Tok, *this ,
1804- diag::err_feature_check_malformed);
1805- if (!II)
1806- return false ;
1807- else if (II->getBuiltinID () != 0 ) {
1808- switch (II->getBuiltinID ()) {
1809- case Builtin::BI__builtin_cpu_is:
1810- return getTargetInfo ().supportsCpuIs ();
1811- case Builtin::BI__builtin_cpu_init:
1812- return getTargetInfo ().supportsCpuInit ();
1813- case Builtin::BI__builtin_cpu_supports:
1814- return getTargetInfo ().supportsCpuSupports ();
1815- case Builtin::BI__builtin_operator_new:
1816- case Builtin::BI__builtin_operator_delete:
1817- // denotes date of behavior change to support calling arbitrary
1818- // usual allocation and deallocation functions. Required by libc++
1819- return 201802 ;
1820- default :
1821- return Builtin::evaluateRequiredTargetFeatures (
1822- getBuiltinInfo ().getRequiredFeatures (II->getBuiltinID ()),
1823- getTargetInfo ().getTargetOpts ().FeatureMap );
1801+ EvaluateFeatureLikeBuiltinMacro (
1802+ OS, Tok, II, *this , false ,
1803+ [this ](Token &Tok, bool &HasLexedNextToken) -> int {
1804+ IdentifierInfo *II = ExpectFeatureIdentifierInfo (
1805+ Tok, *this , diag::err_feature_check_malformed);
1806+ if (!II)
1807+ return false ;
1808+ else if (II->getBuiltinID () != 0 ) {
1809+ switch (II->getBuiltinID ()) {
1810+ case Builtin::BI__builtin_cpu_is:
1811+ return getTargetInfo ().supportsCpuIs ();
1812+ case Builtin::BI__builtin_cpu_init:
1813+ return getTargetInfo ().supportsCpuInit ();
1814+ case Builtin::BI__builtin_cpu_supports:
1815+ return getTargetInfo ().supportsCpuSupports ();
1816+ case Builtin::BI__builtin_operator_new:
1817+ case Builtin::BI__builtin_operator_delete:
1818+ // denotes date of behavior change to support calling arbitrary
1819+ // usual allocation and deallocation functions. Required by libc++
1820+ return 201802 ;
1821+ default :
1822+ return Builtin::evaluateRequiredTargetFeatures (
1823+ getBuiltinInfo ().getRequiredFeatures (II->getBuiltinID ()),
1824+ getTargetInfo ().getTargetOpts ().FeatureMap );
1825+ }
1826+ return true ;
1827+ } else if (IsBuiltinTrait (Tok)) {
1828+ return true ;
1829+ } else if (II->getTokenID () != tok::identifier &&
1830+ II->getName ().starts_with (" __builtin_" )) {
1831+ return true ;
1832+ } else {
1833+ return llvm::StringSwitch<bool >(II->getName ())
1834+ // Report builtin templates as being builtins.
1835+ .Case (" __make_integer_seq" , getLangOpts ().CPlusPlus )
1836+ .Case (" __type_pack_element" , getLangOpts ().CPlusPlus )
1837+ .Case (" __builtin_common_type" , getLangOpts ().CPlusPlus )
1838+ // Likewise for some builtin preprocessor macros.
1839+ // FIXME: This is inconsistent; we usually suggest detecting
1840+ // builtin macros via #ifdef. Don't add more cases here.
1841+ .Case (" __is_target_arch" , true )
1842+ .Case (" __is_target_vendor" , true )
1843+ .Case (" __is_target_os" , true )
1844+ .Case (" __is_target_environment" , true )
1845+ .Case (" __is_target_variant_os" , true )
1846+ .Case (" __is_target_variant_environment" , true )
1847+ .Default (false );
18241848 }
1825- return true ;
1826- } else if (IsBuiltinTrait (Tok)) {
1827- return true ;
1828- } else if (II->getTokenID () != tok::identifier &&
1829- II->getName ().starts_with (" __builtin_" )) {
1830- return true ;
1831- } else {
1832- return llvm::StringSwitch<bool >(II->getName ())
1833- // Report builtin templates as being builtins.
1834- .Case (" __make_integer_seq" , getLangOpts ().CPlusPlus )
1835- .Case (" __type_pack_element" , getLangOpts ().CPlusPlus )
1836- .Case (" __builtin_common_type" , getLangOpts ().CPlusPlus )
1837- // Likewise for some builtin preprocessor macros.
1838- // FIXME: This is inconsistent; we usually suggest detecting
1839- // builtin macros via #ifdef. Don't add more cases here.
1840- .Case (" __is_target_arch" , true )
1841- .Case (" __is_target_vendor" , true )
1842- .Case (" __is_target_os" , true )
1843- .Case (" __is_target_environment" , true )
1844- .Case (" __is_target_variant_os" , true )
1845- .Case (" __is_target_variant_environment" , true )
1846- .Default (false );
1847- }
1848- });
1849+ });
18491850 } else if (II == Ident__has_constexpr_builtin) {
18501851 EvaluateFeatureLikeBuiltinMacro (
18511852 OS, Tok, II, *this , false ,
0 commit comments