|
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"
|
@@ -3427,6 +3428,25 @@ AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result,
|
3427 | 3428 | Result.AddInformativeChunk(Result.getAllocator().CopyString(QualsStr));
|
3428 | 3429 | }
|
3429 | 3430 |
|
| 3431 | +static void |
| 3432 | +AddFunctionExceptSpecToCompletionString(std::string &NameAndSignature, |
| 3433 | + const FunctionDecl *Function) { |
| 3434 | + const auto *Proto = Function->getType()->getAs<FunctionProtoType>(); |
| 3435 | + if (!Proto) |
| 3436 | + return; |
| 3437 | + |
| 3438 | + auto ExceptInfo = Proto->getExceptionSpecInfo(); |
| 3439 | + switch (ExceptInfo.Type) { |
| 3440 | + case EST_BasicNoexcept: |
| 3441 | + case EST_NoexceptTrue: |
| 3442 | + NameAndSignature += " noexcept"; |
| 3443 | + break; |
| 3444 | + |
| 3445 | + default: |
| 3446 | + break; |
| 3447 | + } |
| 3448 | +} |
| 3449 | + |
3430 | 3450 | /// Add the name of the given declaration
|
3431 | 3451 | static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy,
|
3432 | 3452 | const NamedDecl *ND,
|
@@ -3642,6 +3662,13 @@ CodeCompletionResult::createCodeCompletionStringForOverride(
|
3642 | 3662 | std::string NameAndSignature;
|
3643 | 3663 | // For overrides all chunks go into the result, none are informative.
|
3644 | 3664 | printOverrideString(*CCS, BeforeName, NameAndSignature);
|
| 3665 | + |
| 3666 | + // If the virtual function is declared with "noexcept", add it in the result |
| 3667 | + // code completion string. |
| 3668 | + const auto *VirtualFunc = dyn_cast<FunctionDecl>(Declaration); |
| 3669 | + assert(VirtualFunc && "overridden decl must be a function"); |
| 3670 | + AddFunctionExceptSpecToCompletionString(NameAndSignature, VirtualFunc); |
| 3671 | + |
3645 | 3672 | NameAndSignature += " override";
|
3646 | 3673 |
|
3647 | 3674 | Result.AddTextChunk(Result.getAllocator().CopyString(BeforeName));
|
|
0 commit comments