|
26 | 26 | #include "clang/AST/Type.h"
|
27 | 27 | #include "clang/Basic/AttributeCommonInfo.h"
|
28 | 28 | #include "clang/Basic/CharInfo.h"
|
| 29 | +#include "clang/Basic/ExceptionSpecificationType.h" |
29 | 30 | #include "clang/Basic/OperatorKinds.h"
|
30 | 31 | #include "clang/Basic/Specifiers.h"
|
31 | 32 | #include "clang/Lex/HeaderSearch.h"
|
@@ -184,7 +185,7 @@ class ResultBuilder {
|
184 | 185 |
|
185 | 186 | /// Overloaded C++ member functions found by SemaLookup.
|
186 | 187 | /// Used to determine when one overload is dominated by another.
|
187 |
| - llvm::DenseMap<std::pair<DeclContext *, /*Name*/uintptr_t>, ShadowMapEntry> |
| 188 | + llvm::DenseMap<std::pair<DeclContext *, /*Name=*/uintptr_t>, ShadowMapEntry> |
188 | 189 | OverloadMap;
|
189 | 190 |
|
190 | 191 | /// If we're potentially referring to a C++ member function, the set
|
@@ -1432,16 +1433,16 @@ void ResultBuilder::AddResult(Result R, DeclContext *CurContext,
|
1432 | 1433 | }
|
1433 | 1434 | // Detect cases where a ref-qualified method cannot be invoked.
|
1434 | 1435 | switch (Method->getRefQualifier()) {
|
1435 |
| - case RQ_LValue: |
1436 |
| - if (ObjectKind != VK_LValue && !MethodQuals.hasConst()) |
1437 |
| - return; |
1438 |
| - break; |
1439 |
| - case RQ_RValue: |
1440 |
| - if (ObjectKind == VK_LValue) |
1441 |
| - return; |
1442 |
| - break; |
1443 |
| - case RQ_None: |
1444 |
| - break; |
| 1436 | + case RQ_LValue: |
| 1437 | + if (ObjectKind != VK_LValue && !MethodQuals.hasConst()) |
| 1438 | + return; |
| 1439 | + break; |
| 1440 | + case RQ_RValue: |
| 1441 | + if (ObjectKind == VK_LValue) |
| 1442 | + return; |
| 1443 | + break; |
| 1444 | + case RQ_None: |
| 1445 | + break; |
1445 | 1446 | }
|
1446 | 1447 |
|
1447 | 1448 | /// Check whether this dominates another overloaded method, which should
|
@@ -1490,9 +1491,7 @@ void ResultBuilder::AddResult(Result R) {
|
1490 | 1491 | void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
|
1491 | 1492 |
|
1492 | 1493 | /// Exit from the current scope.
|
1493 |
| -void ResultBuilder::ExitScope() { |
1494 |
| - ShadowMaps.pop_back(); |
1495 |
| -} |
| 1494 | +void ResultBuilder::ExitScope() { ShadowMaps.pop_back(); } |
1496 | 1495 |
|
1497 | 1496 | /// Determines whether this given declaration will be found by
|
1498 | 1497 | /// ordinary name lookup.
|
@@ -2557,7 +2556,8 @@ AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
|
2557 | 2556 | ReturnType = Method->getReturnType();
|
2558 | 2557 | else if (SemaRef.getCurBlock() &&
|
2559 | 2558 | !SemaRef.getCurBlock()->ReturnType.isNull())
|
2560 |
| - ReturnType = SemaRef.getCurBlock()->ReturnType;; |
| 2559 | + ReturnType = SemaRef.getCurBlock()->ReturnType; |
| 2560 | + ; |
2561 | 2561 | if (ReturnType.isNull() || ReturnType->isVoidType()) {
|
2562 | 2562 | Builder.AddTypedTextChunk("return");
|
2563 | 2563 | Builder.AddChunk(CodeCompletionString::CK_SemiColon);
|
@@ -3427,6 +3427,25 @@ AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result,
|
3427 | 3427 | Result.AddInformativeChunk(Result.getAllocator().CopyString(QualsStr));
|
3428 | 3428 | }
|
3429 | 3429 |
|
| 3430 | +static void |
| 3431 | +AddFunctionExceptSpecToCompletionString(std::string &NameAndSignature, |
| 3432 | + const FunctionDecl *Function) { |
| 3433 | + const auto *Proto = Function->getType()->getAs<FunctionProtoType>(); |
| 3434 | + if (!Proto) |
| 3435 | + return; |
| 3436 | + |
| 3437 | + auto ExceptInfo = Proto->getExceptionSpecInfo(); |
| 3438 | + switch (ExceptInfo.Type) { |
| 3439 | + case EST_BasicNoexcept: |
| 3440 | + case EST_NoexceptTrue: |
| 3441 | + NameAndSignature += " noexcept"; |
| 3442 | + break; |
| 3443 | + |
| 3444 | + default: |
| 3445 | + break; |
| 3446 | + } |
| 3447 | +} |
| 3448 | + |
3430 | 3449 | /// Add the name of the given declaration
|
3431 | 3450 | static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy,
|
3432 | 3451 | const NamedDecl *ND,
|
@@ -3642,6 +3661,13 @@ CodeCompletionResult::createCodeCompletionStringForOverride(
|
3642 | 3661 | std::string NameAndSignature;
|
3643 | 3662 | // For overrides all chunks go into the result, none are informative.
|
3644 | 3663 | printOverrideString(*CCS, BeforeName, NameAndSignature);
|
| 3664 | + |
| 3665 | + // If the virtual function is declared with "noexcept", add it in the result |
| 3666 | + // code completion string. |
| 3667 | + const auto *VirtualFunc = dyn_cast<FunctionDecl>(Declaration); |
| 3668 | + assert(VirtualFunc && "overridden decl must be a function"); |
| 3669 | + AddFunctionExceptSpecToCompletionString(NameAndSignature, VirtualFunc); |
| 3670 | + |
3645 | 3671 | NameAndSignature += " override";
|
3646 | 3672 |
|
3647 | 3673 | Result.AddTextChunk(Result.getAllocator().CopyString(BeforeName));
|
@@ -4886,7 +4912,8 @@ static void AddEnumerators(ResultBuilder &Results, ASTContext &Context,
|
4886 | 4912 | EnumDecl *Enum, DeclContext *CurContext,
|
4887 | 4913 | const CoveredEnumerators &Enumerators) {
|
4888 | 4914 | NestedNameSpecifier *Qualifier = Enumerators.SuggestedQualifier;
|
4889 |
| - if (Context.getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) { |
| 4915 | + if (Context.getLangOpts().CPlusPlus && !Qualifier && |
| 4916 | + Enumerators.Seen.empty()) { |
4890 | 4917 | // If there are no prior enumerators in C++, check whether we have to
|
4891 | 4918 | // qualify the names of the enumerators that we suggest, because they
|
4892 | 4919 | // may not be visible in this scope.
|
@@ -5292,8 +5319,7 @@ AddObjCProperties(const CodeCompletionContext &CCContext,
|
5292 | 5319 | AllowNullaryMethods, CurContext, AddedProperties,
|
5293 | 5320 | Results, IsBaseExprStatement, IsClassProperty,
|
5294 | 5321 | /*InOriginalClass*/ false);
|
5295 |
| - } else if (const auto *Category = |
5296 |
| - dyn_cast<ObjCCategoryDecl>(Container)) { |
| 5322 | + } else if (const auto *Category = dyn_cast<ObjCCategoryDecl>(Container)) { |
5297 | 5323 | // Look through protocols.
|
5298 | 5324 | for (auto *P : Category->protocols())
|
5299 | 5325 | AddObjCProperties(CCContext, P, AllowCategories, AllowNullaryMethods,
|
@@ -6159,8 +6185,7 @@ void SemaCodeCompletion::CodeCompleteCase(Scope *S) {
|
6159 | 6185 |
|
6160 | 6186 | Expr *CaseVal = Case->getLHS()->IgnoreParenCasts();
|
6161 | 6187 | if (auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
|
6162 |
| - if (auto *Enumerator = |
6163 |
| - dyn_cast<EnumConstantDecl>(DRE->getDecl())) { |
| 6188 | + if (auto *Enumerator = dyn_cast<EnumConstantDecl>(DRE->getDecl())) { |
6164 | 6189 | // We look into the AST of the case statement to determine which
|
6165 | 6190 | // enumerator was named. Alternatively, we could compute the value of
|
6166 | 6191 | // the integral constant expression, then compare it against the
|
@@ -8480,11 +8505,10 @@ void SemaCodeCompletion::CodeCompleteObjCInstanceMessage(
|
8480 | 8505 | return;
|
8481 | 8506 | RecExpr = Conv.get();
|
8482 | 8507 | }
|
8483 |
| - QualType ReceiverType = RecExpr |
8484 |
| - ? RecExpr->getType() |
8485 |
| - : Super ? Context.getObjCObjectPointerType( |
8486 |
| - Context.getObjCInterfaceType(Super)) |
8487 |
| - : Context.getObjCIdType(); |
| 8508 | + QualType ReceiverType = RecExpr ? RecExpr->getType() |
| 8509 | + : Super ? Context.getObjCObjectPointerType( |
| 8510 | + Context.getObjCInterfaceType(Super)) |
| 8511 | + : Context.getObjCIdType(); |
8488 | 8512 |
|
8489 | 8513 | // If we're messaging an expression with type "id" or "Class", check
|
8490 | 8514 | // whether we know something special about the receiver that allows
|
@@ -10356,8 +10380,7 @@ void SemaCodeCompletion::CodeCompleteIncludedFile(llvm::StringRef Dir,
|
10356 | 10380 | };
|
10357 | 10381 |
|
10358 | 10382 | // Helper: scans IncludeDir for nice files, and adds results for each.
|
10359 |
| - auto AddFilesFromIncludeDir = [&](StringRef IncludeDir, |
10360 |
| - bool IsSystem, |
| 10383 | + auto AddFilesFromIncludeDir = [&](StringRef IncludeDir, bool IsSystem, |
10361 | 10384 | DirectoryLookup::LookupType_t LookupType) {
|
10362 | 10385 | llvm::SmallString<128> Dir = IncludeDir;
|
10363 | 10386 | if (!NativeRelDir.empty()) {
|
|
0 commit comments