OLD | NEW |
1 //===--- MacroExpansion.cpp - Top level Macro Expansion -------------------===// | 1 //===--- MacroExpansion.cpp - Top level Macro Expansion -------------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the top level handling of macro expasion for the | 10 // This file implements the top level handling of macro expasion for the |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 .Case("cxx_rvalue_references", LangOpts.CPlusPlus11) | 785 .Case("cxx_rvalue_references", LangOpts.CPlusPlus11) |
786 .Case("cxx_strong_enums", LangOpts.CPlusPlus11) | 786 .Case("cxx_strong_enums", LangOpts.CPlusPlus11) |
787 .Case("cxx_static_assert", LangOpts.CPlusPlus11) | 787 .Case("cxx_static_assert", LangOpts.CPlusPlus11) |
788 .Case("cxx_thread_local", | 788 .Case("cxx_thread_local", |
789 LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported()) | 789 LangOpts.CPlusPlus11 && PP.getTargetInfo().isTLSSupported()) |
790 .Case("cxx_trailing_return", LangOpts.CPlusPlus11) | 790 .Case("cxx_trailing_return", LangOpts.CPlusPlus11) |
791 .Case("cxx_unicode_literals", LangOpts.CPlusPlus11) | 791 .Case("cxx_unicode_literals", LangOpts.CPlusPlus11) |
792 .Case("cxx_unrestricted_unions", LangOpts.CPlusPlus11) | 792 .Case("cxx_unrestricted_unions", LangOpts.CPlusPlus11) |
793 .Case("cxx_user_literals", LangOpts.CPlusPlus11) | 793 .Case("cxx_user_literals", LangOpts.CPlusPlus11) |
794 .Case("cxx_variadic_templates", LangOpts.CPlusPlus11) | 794 .Case("cxx_variadic_templates", LangOpts.CPlusPlus11) |
795 // C++1y features | |
796 .Case("cxx_binary_literals", LangOpts.CPlusPlus1y) | |
797 //.Case("cxx_contextual_conversions", LangOpts.CPlusPlus1y) | |
798 //.Case("cxx_generalized_capture", LangOpts.CPlusPlus1y) | |
799 //.Case("cxx_generic_lambda", LangOpts.CPlusPlus1y) | |
800 //.Case("cxx_relaxed_constexpr", LangOpts.CPlusPlus1y) | |
801 //.Case("cxx_return_type_deduction", LangOpts.CPlusPlus1y) | |
802 //.Case("cxx_runtime_array", LangOpts.CPlusPlus1y) | |
803 .Case("cxx_aggregate_nsdmi", LangOpts.CPlusPlus1y) | |
804 //.Case("cxx_variable_templates", LangOpts.CPlusPlus1y) | |
805 // Type traits | 795 // Type traits |
806 .Case("has_nothrow_assign", LangOpts.CPlusPlus) | 796 .Case("has_nothrow_assign", LangOpts.CPlusPlus) |
807 .Case("has_nothrow_copy", LangOpts.CPlusPlus) | 797 .Case("has_nothrow_copy", LangOpts.CPlusPlus) |
808 .Case("has_nothrow_constructor", LangOpts.CPlusPlus) | 798 .Case("has_nothrow_constructor", LangOpts.CPlusPlus) |
809 .Case("has_trivial_assign", LangOpts.CPlusPlus) | 799 .Case("has_trivial_assign", LangOpts.CPlusPlus) |
810 .Case("has_trivial_copy", LangOpts.CPlusPlus) | 800 .Case("has_trivial_copy", LangOpts.CPlusPlus) |
811 .Case("has_trivial_constructor", LangOpts.CPlusPlus) | 801 .Case("has_trivial_constructor", LangOpts.CPlusPlus) |
812 .Case("has_trivial_destructor", LangOpts.CPlusPlus) | 802 .Case("has_trivial_destructor", LangOpts.CPlusPlus) |
813 .Case("has_virtual_destructor", LangOpts.CPlusPlus) | 803 .Case("has_virtual_destructor", LangOpts.CPlusPlus) |
814 .Case("is_abstract", LangOpts.CPlusPlus) | 804 .Case("is_abstract", LangOpts.CPlusPlus) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 Extension = Extension.substr(2, Extension.size() - 4); | 845 Extension = Extension.substr(2, Extension.size() - 4); |
856 | 846 |
857 // Because we inherit the feature list from HasFeature, this string switch | 847 // Because we inherit the feature list from HasFeature, this string switch |
858 // must be less restrictive than HasFeature's. | 848 // must be less restrictive than HasFeature's. |
859 return llvm::StringSwitch<bool>(Extension) | 849 return llvm::StringSwitch<bool>(Extension) |
860 // C11 features supported by other languages as extensions. | 850 // C11 features supported by other languages as extensions. |
861 .Case("c_alignas", true) | 851 .Case("c_alignas", true) |
862 .Case("c_atomic", true) | 852 .Case("c_atomic", true) |
863 .Case("c_generic_selections", true) | 853 .Case("c_generic_selections", true) |
864 .Case("c_static_assert", true) | 854 .Case("c_static_assert", true) |
865 // C++11 features supported by other languages as extensions. | 855 // C++0x features supported by other languages as extensions. |
866 .Case("cxx_atomic", LangOpts.CPlusPlus) | 856 .Case("cxx_atomic", LangOpts.CPlusPlus) |
867 .Case("cxx_deleted_functions", LangOpts.CPlusPlus) | 857 .Case("cxx_deleted_functions", LangOpts.CPlusPlus) |
868 .Case("cxx_explicit_conversions", LangOpts.CPlusPlus) | 858 .Case("cxx_explicit_conversions", LangOpts.CPlusPlus) |
869 .Case("cxx_inline_namespaces", LangOpts.CPlusPlus) | 859 .Case("cxx_inline_namespaces", LangOpts.CPlusPlus) |
870 .Case("cxx_local_type_template_args", LangOpts.CPlusPlus) | 860 .Case("cxx_local_type_template_args", LangOpts.CPlusPlus) |
871 .Case("cxx_nonstatic_member_init", LangOpts.CPlusPlus) | 861 .Case("cxx_nonstatic_member_init", LangOpts.CPlusPlus) |
872 .Case("cxx_override_control", LangOpts.CPlusPlus) | 862 .Case("cxx_override_control", LangOpts.CPlusPlus) |
873 .Case("cxx_range_for", LangOpts.CPlusPlus) | 863 .Case("cxx_range_for", LangOpts.CPlusPlus) |
874 .Case("cxx_reference_qualified_functions", LangOpts.CPlusPlus) | 864 .Case("cxx_reference_qualified_functions", LangOpts.CPlusPlus) |
875 .Case("cxx_rvalue_references", LangOpts.CPlusPlus) | 865 .Case("cxx_rvalue_references", LangOpts.CPlusPlus) |
876 // C++1y features supported by other languages as extensions. | |
877 .Case("cxx_binary_literals", true) | |
878 .Default(false); | 866 .Default(false); |
879 } | 867 } |
880 | 868 |
881 /// HasAttribute - Return true if we recognize and implement the attribute | 869 /// HasAttribute - Return true if we recognize and implement the attribute |
882 /// specified by the given identifier. | 870 /// specified by the given identifier. |
883 static bool HasAttribute(const IdentifierInfo *II) { | 871 static bool HasAttribute(const IdentifierInfo *II) { |
884 StringRef Name = II->getName(); | 872 StringRef Name = II->getName(); |
885 // Normalize the attribute name, __foo__ becomes foo. | 873 // Normalize the attribute name, __foo__ becomes foo. |
886 if (Name.startswith("__") && Name.endswith("__") && Name.size() >= 4) | 874 if (Name.startswith("__") && Name.endswith("__") && Name.size() >= 4) |
887 Name = Name.substr(2, Name.size() - 4); | 875 Name = Name.substr(2, Name.size() - 4); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 CreateString(OS.str(), Tok, Tok.getLocation(), Tok.getLocation()); | 1309 CreateString(OS.str(), Tok, Tok.getLocation(), Tok.getLocation()); |
1322 } | 1310 } |
1323 | 1311 |
1324 void Preprocessor::markMacroAsUsed(MacroInfo *MI) { | 1312 void Preprocessor::markMacroAsUsed(MacroInfo *MI) { |
1325 // If the 'used' status changed, and the macro requires 'unused' warning, | 1313 // If the 'used' status changed, and the macro requires 'unused' warning, |
1326 // remove its SourceLocation from the warn-for-unused-macro locations. | 1314 // remove its SourceLocation from the warn-for-unused-macro locations. |
1327 if (MI->isWarnIfUnused() && !MI->isUsed()) | 1315 if (MI->isWarnIfUnused() && !MI->isUsed()) |
1328 WarnUnusedMacroLocs.erase(MI->getDefinitionLoc()); | 1316 WarnUnusedMacroLocs.erase(MI->getDefinitionLoc()); |
1329 MI->setIsUsed(true); | 1317 MI->setIsUsed(true); |
1330 } | 1318 } |
OLD | NEW |