|
24 | 24 | #include "clang/Frontend/CompilerInstance.h" |
25 | 25 | #include "clang/Sema/Lookup.h" |
26 | 26 | #include "clang/Sema/Sema.h" |
| 27 | +#if CLANG_VERSION_MAJOR >= 19 |
| 28 | +#include "clang/Sema/Redeclaration.h" |
| 29 | +#endif |
27 | 30 | #include "clang/Sema/TemplateDeduction.h" |
28 | 31 |
|
29 | 32 | #include "llvm/ADT/StringRef.h" |
|
49 | 52 | #include <unistd.h> |
50 | 53 | #endif // WIN32 |
51 | 54 |
|
| 55 | +#include <stack> |
| 56 | + |
52 | 57 | namespace Cpp { |
53 | 58 |
|
54 | 59 | using namespace clang; |
@@ -805,11 +810,8 @@ namespace Cpp { |
805 | 810 | llvm::StringRef Name(name); |
806 | 811 | auto &S = getSema(); |
807 | 812 | DeclarationName DName = &getASTContext().Idents.get(name); |
808 | | - clang::LookupResult R(S, |
809 | | - DName, |
810 | | - SourceLocation(), |
811 | | - Sema::LookupOrdinaryName, |
812 | | - Sema::ForVisibleRedeclaration); |
| 813 | + clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName, |
| 814 | + For_Visible_Redeclaration); |
813 | 815 |
|
814 | 816 | Cpp_utils::Lookup::Named(&S, R, Decl::castToDeclContext(D)); |
815 | 817 |
|
@@ -962,7 +964,7 @@ namespace Cpp { |
962 | 964 | auto& S = getSema(); |
963 | 965 | DeclarationName DName = &getASTContext().Idents.get(name); |
964 | 966 | clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName, |
965 | | - Sema::ForVisibleRedeclaration); |
| 967 | + For_Visible_Redeclaration); |
966 | 968 |
|
967 | 969 | Cpp_utils::Lookup::Named(&S, R, Decl::castToDeclContext(D)); |
968 | 970 |
|
@@ -1348,36 +1350,43 @@ namespace Cpp { |
1348 | 1350 | isunsigned = true; |
1349 | 1351 | typeName = StringRef(typeName.data()+9, typeName.size()-9); |
1350 | 1352 | } |
1351 | | - if (typeName.equals("char")) { |
| 1353 | + if (typeName == "char") { |
1352 | 1354 | if (isunsigned) return Context.UnsignedCharTy; |
1353 | 1355 | return Context.SignedCharTy; |
1354 | 1356 | } |
1355 | | - if (typeName.equals("short")) { |
| 1357 | + if (typeName == "short") { |
1356 | 1358 | if (isunsigned) return Context.UnsignedShortTy; |
1357 | 1359 | return Context.ShortTy; |
1358 | 1360 | } |
1359 | | - if (typeName.equals("int")) { |
| 1361 | + if (typeName == "int") { |
1360 | 1362 | if (isunsigned) return Context.UnsignedIntTy; |
1361 | 1363 | return Context.IntTy; |
1362 | 1364 | } |
1363 | | - if (typeName.equals("long")) { |
| 1365 | + if (typeName == "long") { |
1364 | 1366 | if (isunsigned) return Context.UnsignedLongTy; |
1365 | 1367 | return Context.LongTy; |
1366 | 1368 | } |
1367 | | - if (typeName.equals("long long")) { |
| 1369 | + if (typeName == "long long") { |
1368 | 1370 | if (isunsigned) |
1369 | 1371 | return Context.UnsignedLongLongTy; |
1370 | 1372 | return Context.LongLongTy; |
1371 | 1373 | } |
1372 | 1374 | if (!issigned && !isunsigned) { |
1373 | | - if (typeName.equals("bool")) return Context.BoolTy; |
1374 | | - if (typeName.equals("float")) return Context.FloatTy; |
1375 | | - if (typeName.equals("double")) return Context.DoubleTy; |
1376 | | - if (typeName.equals("long double")) return Context.LongDoubleTy; |
1377 | | - |
1378 | | - if (typeName.equals("wchar_t")) return Context.WCharTy; |
1379 | | - if (typeName.equals("char16_t")) return Context.Char16Ty; |
1380 | | - if (typeName.equals("char32_t")) return Context.Char32Ty; |
| 1375 | + if (typeName == "bool") |
| 1376 | + return Context.BoolTy; |
| 1377 | + if (typeName == "float") |
| 1378 | + return Context.FloatTy; |
| 1379 | + if (typeName == "double") |
| 1380 | + return Context.DoubleTy; |
| 1381 | + if (typeName == "long double") |
| 1382 | + return Context.LongDoubleTy; |
| 1383 | + |
| 1384 | + if (typeName == "wchar_t") |
| 1385 | + return Context.WCharTy; |
| 1386 | + if (typeName == "char16_t") |
| 1387 | + return Context.Char16Ty; |
| 1388 | + if (typeName == "char32_t") |
| 1389 | + return Context.Char32Ty; |
1381 | 1390 | } |
1382 | 1391 | /* Missing |
1383 | 1392 | CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99. |
@@ -1747,9 +1756,11 @@ namespace Cpp { |
1747 | 1756 | if (const CXXConstructorDecl* CD = dyn_cast<CXXConstructorDecl>(FD)) { |
1748 | 1757 | if (N <= 1 && llvm::isa<UsingShadowDecl>(FD)) { |
1749 | 1758 | auto SpecMemKind = I.getCI()->getSema().getSpecialMember(CD); |
1750 | | - if ((N == 0 && SpecMemKind == clang::Sema::CXXDefaultConstructor) || |
1751 | | - (N == 1 && (SpecMemKind == clang::Sema::CXXCopyConstructor || |
1752 | | - SpecMemKind == clang::Sema::CXXMoveConstructor))) { |
| 1759 | + if ((N == 0 && |
| 1760 | + SpecMemKind == CXXSpecialMemberKindDefaultConstructor) || |
| 1761 | + (N == 1 && |
| 1762 | + (SpecMemKind == CXXSpecialMemberKindCopyConstructor || |
| 1763 | + SpecMemKind == CXXSpecialMemberKindMoveConstructor))) { |
1753 | 1764 | // Using declarations cannot inject special members; do not call |
1754 | 1765 | // them as such. This might happen by using `Base(Base&, int = 12)`, |
1755 | 1766 | // which is fine to be called as `Derived d(someBase, 42)` but not |
@@ -2866,9 +2877,10 @@ namespace Cpp { |
2866 | 2877 | if (auto* FunctionTemplate = dyn_cast<FunctionTemplateDecl>(TemplateD)) { |
2867 | 2878 | FunctionDecl* Specialization = nullptr; |
2868 | 2879 | clang::sema::TemplateDeductionInfo Info(fakeLoc); |
2869 | | - if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments( |
2870 | | - FunctionTemplate, &TLI, Specialization, Info, |
2871 | | - /*IsAddressOfFunction*/ true)) { |
| 2880 | + Template_Deduction_Result Result = S.DeduceTemplateArguments( |
| 2881 | + FunctionTemplate, &TLI, Specialization, Info, |
| 2882 | + /*IsAddressOfFunction*/ true); |
| 2883 | + if (static_cast<int>(Result)) { |
2872 | 2884 | // FIXME: Diagnose what happened. |
2873 | 2885 | (void)Result; |
2874 | 2886 | } |
|
0 commit comments