diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-09-29 13:46:27 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-10-27 14:21:13 +0000 |
commit | 6de3eb7a1a441e529549c9097431c2fc16fca90b (patch) | |
tree | 92c84f8c7fabcd005a742e29a510139258eddeb4 /dist | |
parent | 3d5731c1d6e10e26b098274f6358e07165c9b01b (diff) |
Clang: Update patches for clang 5.0
Remove a bunch of on-top patches that are already part of llvm/clang 5.
Rebase the remaining ones and add backported ones.
Add also a README providing more information about the patches.
Task-number: QTCREATORBUG-18824
Task-number: QTCREATORBUG-17769
Change-Id: I9f6904b2e6d7c83de175e7b8c194e1a494cd2571
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'dist')
12 files changed, 251 insertions, 876 deletions
diff --git a/dist/clang/patches/D15994_Allow-for-unfinished-if-blocks-in-preambles.patch b/dist/clang/patches/D15994_Allow-for-unfinished-if-blocks-in-preambles.patch deleted file mode 100644 index 180d52238d..0000000000 --- a/dist/clang/patches/D15994_Allow-for-unfinished-if-blocks-in-preambles.patch +++ /dev/null @@ -1,417 +0,0 @@ -diff --git a/tools/clang/include/clang/Lex/Preprocessor.h b/tools/clang/include/clang/Lex/Preprocessor.h -index 30cc37f6f8..3d1d9a86e0 100644 ---- a/tools/clang/include/clang/Lex/Preprocessor.h -+++ b/tools/clang/include/clang/Lex/Preprocessor.h -@@ -277,6 +277,44 @@ class Preprocessor : public RefCountedBase<Preprocessor> { - /// This is used when loading a precompiled preamble. - std::pair<int, bool> SkipMainFilePreamble; - -+ class PreambleConditionalStackStore { -+ enum State { -+ Off = 0, -+ Recording = 1, -+ Replaying = 2, -+ }; -+ -+ public: -+ PreambleConditionalStackStore() : ConditionalStackState(Off) {} -+ -+ void startRecording() { ConditionalStackState = Recording; } -+ void startReplaying() { ConditionalStackState = Replaying; } -+ bool isRecording() const { return ConditionalStackState == Recording; } -+ bool isReplaying() const { return ConditionalStackState == Replaying; } -+ -+ ArrayRef<PPConditionalInfo> getStack() const { -+ return ConditionalStack; -+ } -+ -+ void doneReplaying() { -+ ConditionalStack.clear(); -+ ConditionalStackState = Off; -+ } -+ -+ void setStack(ArrayRef<PPConditionalInfo> s) { -+ if (!isRecording() && !isReplaying()) -+ return; -+ ConditionalStack.clear(); -+ ConditionalStack.append(s.begin(), s.end()); -+ } -+ -+ bool hasRecordedPreamble() const { return !ConditionalStack.empty(); } -+ -+ private: -+ SmallVector<PPConditionalInfo, 4> ConditionalStack; -+ State ConditionalStackState; -+ } PreambleConditionalStack; -+ - /// \brief The current top of the stack that we're lexing from if - /// not expanding a macro and we are lexing directly from source code. - /// -@@ -1662,6 +1700,11 @@ public: - /// \brief Return true if we're in the top-level file, not in a \#include. - bool isInPrimaryFile() const; - -+ /// \brief Return true if we're in the main file (specifically, if we are 0 -+ /// (zero) levels deep \#include. This is used by the lexer to determine if -+ /// it needs to generate errors about unterminated \#if directives. -+ bool isInMainFile() const; -+ - /// \brief Handle cases where the \#include name is expanded - /// from a macro as multiple tokens, which need to be glued together. - /// -@@ -1904,6 +1947,27 @@ public: - const FileEntry *getModuleHeaderToIncludeForDiagnostics(SourceLocation IncLoc, - SourceLocation MLoc); - -+ bool isRecordingPreamble() const { -+ return PreambleConditionalStack.isRecording(); -+ } -+ -+ bool hasRecordedPreamble() const { -+ return PreambleConditionalStack.hasRecordedPreamble(); -+ } -+ -+ ArrayRef<PPConditionalInfo> getPreambleConditionalStack() const { -+ return PreambleConditionalStack.getStack(); -+ } -+ -+ void setRecordedPreambleConditionalStack(ArrayRef<PPConditionalInfo> s) { -+ PreambleConditionalStack.setStack(s); -+ } -+ -+ void setReplayablePreambleConditionalStack(ArrayRef<PPConditionalInfo> s) { -+ PreambleConditionalStack.startReplaying(); -+ PreambleConditionalStack.setStack(s); -+ } -+ - private: - // Macro handling. - void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterTopLevelIfndef); -diff --git a/tools/clang/include/clang/Lex/PreprocessorLexer.h b/tools/clang/include/clang/Lex/PreprocessorLexer.h -index 6d6cf05a96..5c2e4d4145 100644 ---- a/tools/clang/include/clang/Lex/PreprocessorLexer.h -+++ b/tools/clang/include/clang/Lex/PreprocessorLexer.h -@@ -17,6 +17,7 @@ - - #include "clang/Lex/MultipleIncludeOpt.h" - #include "clang/Lex/Token.h" -+#include "llvm/ADT/ArrayRef.h" - #include "llvm/ADT/SmallVector.h" - - namespace clang { -@@ -176,6 +177,11 @@ public: - conditional_iterator conditional_end() const { - return ConditionalStack.end(); - } -+ -+ void setConditionalLevels(ArrayRef<PPConditionalInfo> CL) { -+ ConditionalStack.clear(); -+ ConditionalStack.append(CL.begin(), CL.end()); -+ } - }; - - } // end namespace clang -diff --git a/tools/clang/include/clang/Lex/PreprocessorOptions.h b/tools/clang/include/clang/Lex/PreprocessorOptions.h -index 963d95d7f1..47673aa730 100644 ---- a/tools/clang/include/clang/Lex/PreprocessorOptions.h -+++ b/tools/clang/include/clang/Lex/PreprocessorOptions.h -@@ -81,7 +81,14 @@ public: - /// The boolean indicates whether the preamble ends at the start of a new - /// line. - std::pair<unsigned, bool> PrecompiledPreambleBytes; -- -+ -+ /// \brief True indicates that a preamble is being generated. -+ /// -+ /// When the lexer is done, one of the things that need to be preserved is the -+ /// conditional #if stack, so the ASTWriter/ASTReader can save/restore it when -+ /// processing the rest of the file. -+ bool GeneratePreamble; -+ - /// The implicit PTH input included at the start of the translation unit, or - /// empty. - std::string ImplicitPTHInclude; -@@ -145,6 +152,7 @@ public: - AllowPCHWithCompilerErrors(false), - DumpDeserializedPCHDecls(false), - PrecompiledPreambleBytes(0, true), -+ GeneratePreamble(false), - RemappedFilesKeepOriginalName(true), - RetainRemappedFileBuffers(false), - ObjCXXARCStandardLibrary(ARCXX_nolib) { } -diff --git a/tools/clang/include/clang/Serialization/ASTBitCodes.h b/tools/clang/include/clang/Serialization/ASTBitCodes.h -index 79c6a06222..40c63a4ce5 100644 ---- a/tools/clang/include/clang/Serialization/ASTBitCodes.h -+++ b/tools/clang/include/clang/Serialization/ASTBitCodes.h -@@ -580,7 +580,10 @@ namespace clang { - MSSTRUCT_PRAGMA_OPTIONS = 55, - - /// \brief Record code for \#pragma ms_struct options. -- POINTERS_TO_MEMBERS_PRAGMA_OPTIONS = 56 -+ POINTERS_TO_MEMBERS_PRAGMA_OPTIONS = 56, -+ -+ /// \brief The stack of open #ifs/#ifdefs recorded in a preamble. -+ PP_CONDITIONAL_STACK = 57, - }; - - /// \brief Record types used within a source manager block. -diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp -index c1c2680dcd..b446b53fa4 100644 ---- a/tools/clang/lib/Frontend/ASTUnit.cpp -+++ b/tools/clang/lib/Frontend/ASTUnit.cpp -@@ -1975,6 +1975,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( - PreprocessorOptions &PPOpts = CI->getPreprocessorOpts(); - PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName; - PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors; -+ PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0; - - // Override the resources path. - CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath; -diff --git a/tools/clang/lib/Lex/Lexer.cpp b/tools/clang/lib/Lex/Lexer.cpp -index 9c2a0163ac..72f7011d4f 100644 ---- a/tools/clang/lib/Lex/Lexer.cpp -+++ b/tools/clang/lib/Lex/Lexer.cpp -@@ -528,8 +528,6 @@ SourceLocation Lexer::GetBeginningOfToken(SourceLocation Loc, - namespace { - enum PreambleDirectiveKind { - PDK_Skipped, -- PDK_StartIf, -- PDK_EndIf, - PDK_Unknown - }; - } -@@ -551,8 +549,6 @@ std::pair<unsigned, bool> Lexer::ComputePreamble(StringRef Buffer, - - bool InPreprocessorDirective = false; - Token TheTok; -- Token IfStartTok; -- unsigned IfCount = 0; - SourceLocation ActiveCommentLoc; - - unsigned MaxLineOffset = 0; -@@ -635,33 +631,18 @@ std::pair<unsigned, bool> Lexer::ComputePreamble(StringRef Buffer, - .Case("sccs", PDK_Skipped) - .Case("assert", PDK_Skipped) - .Case("unassert", PDK_Skipped) -- .Case("if", PDK_StartIf) -- .Case("ifdef", PDK_StartIf) -- .Case("ifndef", PDK_StartIf) -+ .Case("if", PDK_Skipped) -+ .Case("ifdef", PDK_Skipped) -+ .Case("ifndef", PDK_Skipped) - .Case("elif", PDK_Skipped) - .Case("else", PDK_Skipped) -- .Case("endif", PDK_EndIf) -+ .Case("endif", PDK_Skipped) - .Default(PDK_Unknown); - - switch (PDK) { - case PDK_Skipped: - continue; - -- case PDK_StartIf: -- if (IfCount == 0) -- IfStartTok = HashTok; -- -- ++IfCount; -- continue; -- -- case PDK_EndIf: -- // Mismatched #endif. The preamble ends here. -- if (IfCount == 0) -- break; -- -- --IfCount; -- continue; -- - case PDK_Unknown: - // We don't know what this directive is; stop at the '#'. - break; -@@ -682,16 +663,13 @@ std::pair<unsigned, bool> Lexer::ComputePreamble(StringRef Buffer, - } while (true); - - SourceLocation End; -- if (IfCount) -- End = IfStartTok.getLocation(); -- else if (ActiveCommentLoc.isValid()) -+ if (ActiveCommentLoc.isValid()) - End = ActiveCommentLoc; // don't truncate a decl comment. - else - End = TheTok.getLocation(); - - return std::make_pair(End.getRawEncoding() - StartLoc.getRawEncoding(), -- IfCount? IfStartTok.isAtStartOfLine() -- : TheTok.isAtStartOfLine()); -+ TheTok.isAtStartOfLine()); - } - - -@@ -2528,6 +2506,11 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { - return true; - } - -+ if (PP->isRecordingPreamble() && !PP->isInMainFile()) { -+ PP->setRecordedPreambleConditionalStack(ConditionalStack); -+ ConditionalStack.clear(); -+ } -+ - // Issue diagnostics for unterminated #if and missing newline. - - // If we are in a #if directive, emit an error. -diff --git a/tools/clang/lib/Lex/PPLexerChange.cpp b/tools/clang/lib/Lex/PPLexerChange.cpp -index e2eceafd98..849a703671 100644 ---- a/tools/clang/lib/Lex/PPLexerChange.cpp -+++ b/tools/clang/lib/Lex/PPLexerChange.cpp -@@ -46,6 +46,12 @@ bool Preprocessor::isInPrimaryFile() const { - return true; - } - -+bool Preprocessor::isInMainFile() const { -+ if (IsFileLexer()) -+ return IncludeMacroStack.size() == 0; -+ return true; -+} -+ - /// getCurrentLexer - Return the current file lexer being lexed from. Note - /// that this ignores any potentially active macro expansions and _Pragma - /// expansions going on at the time. -diff --git a/tools/clang/lib/Lex/Preprocessor.cpp b/tools/clang/lib/Lex/Preprocessor.cpp -index 78179dd798..1da60961a8 100644 ---- a/tools/clang/lib/Lex/Preprocessor.cpp -+++ b/tools/clang/lib/Lex/Preprocessor.cpp -@@ -140,6 +140,9 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr<PreprocessorOptions> PPOpts, - Ident_GetExceptionInfo = Ident_GetExceptionCode = nullptr; - Ident_AbnormalTermination = nullptr; - } -+ -+ if (this->PPOpts->GeneratePreamble) -+ PreambleConditionalStack.startRecording(); - } - - Preprocessor::~Preprocessor() { -@@ -528,6 +531,12 @@ void Preprocessor::EnterMainSourceFile() { - - // Start parsing the predefines. - EnterSourceFile(FID, nullptr, SourceLocation()); -+ -+ // Restore the conditional stack from the preamble, if there is one. -+ if (PreambleConditionalStack.isReplaying()) { -+ CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack()); -+ PreambleConditionalStack.doneReplaying(); -+ } - } - - void Preprocessor::EndSourceFile() { -diff --git a/tools/clang/lib/Serialization/ASTReader.cpp b/tools/clang/lib/Serialization/ASTReader.cpp -index 9d1554a826..861e867341 100644 ---- a/tools/clang/lib/Serialization/ASTReader.cpp -+++ b/tools/clang/lib/Serialization/ASTReader.cpp -@@ -2799,6 +2799,21 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { - } - break; - -+ case PP_CONDITIONAL_STACK: -+ if (!Record.empty()) { -+ SmallVector<PPConditionalInfo, 4> ConditionalStack; -+ for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) { -+ auto Loc = ReadSourceLocation(F, Record, Idx); -+ bool WasSkipping = Record[Idx++]; -+ bool FoundNonSkip = Record[Idx++]; -+ bool FoundElse = Record[Idx++]; -+ ConditionalStack.push_back( -+ {Loc, WasSkipping, FoundNonSkip, FoundElse}); -+ } -+ PP.setReplayablePreambleConditionalStack(ConditionalStack); -+ } -+ break; -+ - case PP_COUNTER_VALUE: - if (!Record.empty() && Listener) - Listener->ReadCounter(F, Record[0]); -diff --git a/tools/clang/lib/Serialization/ASTWriter.cpp b/tools/clang/lib/Serialization/ASTWriter.cpp -index 7589b0c5dd..dc9bb92dea 100644 ---- a/tools/clang/lib/Serialization/ASTWriter.cpp -+++ b/tools/clang/lib/Serialization/ASTWriter.cpp -@@ -983,6 +983,8 @@ void ASTWriter::WriteBlockInfoBlock() { - RECORD(POINTERS_TO_MEMBERS_PRAGMA_OPTIONS); - RECORD(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES); - RECORD(DELETE_EXPRS_TO_ANALYZE); -+ RECORD(PP_CONDITIONAL_STACK); -+ - - // SourceManager Block. - BLOCK(SOURCE_MANAGER_BLOCK); -@@ -2140,6 +2142,18 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { - Stream.EmitRecord(PP_COUNTER_VALUE, Record); - } - -+ if (PP.isRecordingPreamble() && PP.hasRecordedPreamble()) { -+ assert(!IsModule); -+ for (const auto &Cond : PP.getPreambleConditionalStack()) { -+ AddSourceLocation(Cond.IfLoc, Record); -+ Record.push_back(Cond.WasSkipping); -+ Record.push_back(Cond.FoundNonSkip); -+ Record.push_back(Cond.FoundElse); -+ } -+ Stream.EmitRecord(PP_CONDITIONAL_STACK, Record); -+ Record.clear(); -+ } -+ - // Enter the preprocessor block. - Stream.EnterSubblock(PREPROCESSOR_BLOCK_ID, 3); - -diff --git a/tools/clang/test/Lexer/preamble.c b/tools/clang/test/Lexer/preamble.c -index 5b2739abef..762271f2e3 100644 ---- a/tools/clang/test/Lexer/preamble.c -+++ b/tools/clang/test/Lexer/preamble.c -@@ -9,15 +9,12 @@ - #pragma unknown - #endif - #ifdef WIBBLE --#include "honk" --#else --int foo(); -+#include "foo" -+int bar; - #endif - - // This test checks for detection of the preamble of a file, which --// includes all of the starting comments and #includes. Note that any --// changes to the preamble part of this file must be mirrored in --// Inputs/preamble.txt, since we diff against it. -+// includes all of the starting comments and #includes. - - // RUN: %clang_cc1 -print-preamble %s > %t - // RUN: echo END. >> %t -@@ -33,4 +30,6 @@ int foo(); - // CHECK-NEXT: #endif - // CHECK-NEXT: #pragma unknown - // CHECK-NEXT: #endif -+// CHECK-NEXT: #ifdef WIBBLE -+// CHECK-NEXT: #include "foo" - // CHECK-NEXT: END. -diff --git a/tools/clang/test/Lexer/preamble2.c b/tools/clang/test/Lexer/preamble2.c -new file mode 100644 -index 0000000000..499a9a22a5 ---- /dev/null -+++ b/tools/clang/test/Lexer/preamble2.c -@@ -0,0 +1,19 @@ -+// Preamble detection test: header with an include guard. -+#ifndef HEADER_H -+#define HEADER_H -+#include "foo" -+int bar; -+#endif -+ -+// This test checks for detection of the preamble of a file, which -+// includes all of the starting comments and #includes. -+ -+// RUN: %clang_cc1 -print-preamble %s > %t -+// RUN: echo END. >> %t -+// RUN: FileCheck < %t %s -+ -+// CHECK: // Preamble detection test: header with an include guard. -+// CHECK-NEXT: #ifndef HEADER_H -+// CHECK-NEXT: #define HEADER_H -+// CHECK-NEXT: #include "foo" -+// CHECK-NEXT: END. diff --git a/dist/clang/patches/D21176_Mark-invalid-RecordDecls-as-completed.patch b/dist/clang/patches/D21176_Mark-invalid-RecordDecls-as-completed.patch deleted file mode 100644 index a43fc88e99..0000000000 --- a/dist/clang/patches/D21176_Mark-invalid-RecordDecls-as-completed.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff --git a/tools/clang/lib/Sema/SemaDecl.cpp b/tools/clang/lib/Sema/SemaDecl.cpp -index 41719d4e7b..747a4cc0c5 100644 ---- a/tools/clang/lib/Sema/SemaDecl.cpp -+++ b/tools/clang/lib/Sema/SemaDecl.cpp -@@ -13112,7 +13112,14 @@ CreateNewDecl: - OwnedDecl = true; - // In C++, don't return an invalid declaration. We can't recover well from - // the cases where we make the type anonymous. -- return (Invalid && getLangOpts().CPlusPlus) ? nullptr : New; -+ if (Invalid && getLangOpts().CPlusPlus) { -+ if (New->isBeingDefined()) -+ if (auto RD = dyn_cast<RecordDecl>(New)) -+ RD->completeDefinition(); -+ return nullptr; -+ } else { -+ return New; -+ } - } - - void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) { -diff --git a/tools/clang/test/SemaCXX/conversion-function.cpp b/tools/clang/test/SemaCXX/conversion-function.cpp -index 3f494cce8c..c725a0d5b7 100644 ---- a/tools/clang/test/SemaCXX/conversion-function.cpp -+++ b/tools/clang/test/SemaCXX/conversion-function.cpp -@@ -434,8 +434,12 @@ namespace PR18234 { - struct A { - operator enum E { e } (); // expected-error {{'PR18234::A::E' cannot be defined in a type specifier}} - operator struct S { int n; } (); // expected-error {{'PR18234::A::S' cannot be defined in a type specifier}} -+ // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'struct A' to 'const PR18234::A::S &' for 1st argument}} -+#if __cplusplus >= 201103L -+ // expected-note@-3 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'struct A' to 'PR18234::A::S &&' for 1st argument}} -+#endif - } a; -- A::S s = a; -+ A::S s = a; // expected-error {{no viable conversion from 'struct A' to 'A::S'}} - A::E e = a; // expected-note {{here}} - bool k1 = e == A::e; // expected-error {{no member named 'e'}} - bool k2 = e.n == 0; diff --git a/dist/clang/patches/D27810_FileManager-mark-virtual-file-entries-as-valid-entries.patch b/dist/clang/patches/D27810_FileManager-mark-virtual-file-entries-as-valid-entries.patch deleted file mode 100644 index 009fa0e02a..0000000000 --- a/dist/clang/patches/D27810_FileManager-mark-virtual-file-entries-as-valid-entries.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/tools/clang/lib/Basic/FileManager.cpp b/tools/clang/lib/Basic/FileManager.cpp -index ce9b7e1bb4..6cfe1f6ebd 100644 ---- a/tools/clang/lib/Basic/FileManager.cpp -+++ b/tools/clang/lib/Basic/FileManager.cpp -@@ -383,6 +383,7 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size, - UFE->ModTime = ModificationTime; - UFE->Dir = DirInfo; - UFE->UID = NextFileUID++; -+ UFE->IsValid = true; - UFE->File.reset(); - return UFE; - } diff --git a/dist/clang/patches/D30248_Fix-crash-in-member-access-code-completion-with-implicit-base.patch b/dist/clang/patches/D30248_Fix-crash-in-member-access-code-completion-with-implicit-base.patch deleted file mode 100644 index b8e0afab2e..0000000000 --- a/dist/clang/patches/D30248_Fix-crash-in-member-access-code-completion-with-implicit-base.patch +++ /dev/null @@ -1,126 +0,0 @@ -diff --git a/tools/clang/lib/Sema/SemaCodeComplete.cpp b/tools/clang/lib/Sema/SemaCodeComplete.cpp -index f4b51a19c2..f4b35fd408 100644 ---- a/tools/clang/lib/Sema/SemaCodeComplete.cpp -+++ b/tools/clang/lib/Sema/SemaCodeComplete.cpp -@@ -4066,7 +4066,10 @@ void Sema::CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args) { - UME->copyTemplateArgumentsInto(TemplateArgsBuffer); - TemplateArgs = &TemplateArgsBuffer; - } -- SmallVector<Expr *, 12> ArgExprs(1, UME->getBase()); -+ -+ // Add the base as first argument (use a nullptr if the base is implicit). -+ SmallVector<Expr *, 12> ArgExprs( -+ 1, UME->isImplicitAccess() ? nullptr : UME->getBase()); - ArgExprs.append(Args.begin(), Args.end()); - UnresolvedSet<8> Decls; - Decls.append(UME->decls_begin(), UME->decls_end()); -diff --git a/tools/clang/lib/Sema/SemaOverload.cpp b/tools/clang/lib/Sema/SemaOverload.cpp -index 40d6e910f1..19547237ac 100644 ---- a/tools/clang/lib/Sema/SemaOverload.cpp -+++ b/tools/clang/lib/Sema/SemaOverload.cpp -@@ -6051,31 +6051,44 @@ void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns, - for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) { - NamedDecl *D = F.getDecl()->getUnderlyingDecl(); - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { -- if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) -+ if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) { -+ QualType ObjectType; -+ Expr::Classification ObjectClassification; -+ if (Expr *E = Args[0]) { -+ // Use the explit base to restrict the lookup: -+ ObjectType = E->getType(); -+ ObjectClassification = E->Classify(Context); -+ } // .. else there is an implit base. - AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(), -- cast<CXXMethodDecl>(FD)->getParent(), -- Args[0]->getType(), Args[0]->Classify(Context), -- Args.slice(1), CandidateSet, -+ cast<CXXMethodDecl>(FD)->getParent(), ObjectType, -+ ObjectClassification, Args.slice(1), CandidateSet, - SuppressUserConversions, PartialOverloading); -- else -+ } else { - AddOverloadCandidate(FD, F.getPair(), Args, CandidateSet, - SuppressUserConversions, PartialOverloading); -+ } - } else { - FunctionTemplateDecl *FunTmpl = cast<FunctionTemplateDecl>(D); - if (isa<CXXMethodDecl>(FunTmpl->getTemplatedDecl()) && -- !cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl())->isStatic()) -+ !cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl())->isStatic()) { -+ QualType ObjectType; -+ Expr::Classification ObjectClassification; -+ if (Expr *E = Args[0]) { -+ // Use the explit base to restrict the lookup: -+ ObjectType = E->getType(); -+ ObjectClassification = E->Classify(Context); -+ } // .. else there is an implit base. - AddMethodTemplateCandidate(FunTmpl, F.getPair(), -- cast<CXXRecordDecl>(FunTmpl->getDeclContext()), -- ExplicitTemplateArgs, -- Args[0]->getType(), -- Args[0]->Classify(Context), Args.slice(1), -- CandidateSet, SuppressUserConversions, -+ cast<CXXRecordDecl>(FunTmpl->getDeclContext()), -+ ExplicitTemplateArgs, ObjectType, ObjectClassification, -+ Args.slice(1), CandidateSet, SuppressUserConversions, - PartialOverloading); -- else -+ } else { - AddTemplateOverloadCandidate(FunTmpl, F.getPair(), - ExplicitTemplateArgs, Args, - CandidateSet, SuppressUserConversions, - PartialOverloading); -+ } - } - } - } -diff --git a/tools/clang/test/CodeCompletion/member-access.cpp b/tools/clang/test/CodeCompletion/member-access.cpp -index 8f772c0652..8528e18649 100644 ---- a/tools/clang/test/CodeCompletion/member-access.cpp -+++ b/tools/clang/test/CodeCompletion/member-access.cpp -@@ -27,16 +27,31 @@ public: - - void test(const Proxy &p) { - p-> -- // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s -- // CHECK-CC1: Base1 : Base1:: -- // CHECK-CC1: member1 : [#int#][#Base1::#]member1 -- // CHECK-CC1: member1 : [#int#][#Base2::#]member1 -- // CHECK-CC1: member2 : [#float#][#Base1::#]member2 -- // CHECK-CC1: member3 -- // CHECK-CC1: member4 -- // CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#float#>) -- // CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#double#>)[# const#] -- // CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>) -- // CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>) -- // CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>) -- -+} -+ -+struct Foo { -+ void foo() const; -+ static void foo(bool); -+}; -+ -+struct Bar { -+ void foo(bool param) { -+ Foo::foo( );// unresolved member expression with an implicit base -+ } -+}; -+ -+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s -+// CHECK-CC1: Base1 : Base1:: -+// CHECK-CC1: member1 : [#int#][#Base1::#]member1 -+// CHECK-CC1: member1 : [#int#][#Base2::#]member1 -+// CHECK-CC1: member2 : [#float#][#Base1::#]member2 -+// CHECK-CC1: member3 -+// CHECK-CC1: member4 -+// CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#float#>) -+// CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#double#>)[# const#] -+// CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>) -+// CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>) -+// CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>) -+ -+// Make sure this also doesn't crash -+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:39:14 %s diff --git a/dist/clang/patches/D33042_Allow-to-suspend-a-translation-unit.patch b/dist/clang/patches/D33042_Allow-to-suspend-a-translation-unit.patch deleted file mode 100644 index 312db3ace2..0000000000 --- a/dist/clang/patches/D33042_Allow-to-suspend-a-translation-unit.patch +++ /dev/null @@ -1,147 +0,0 @@ -diff --git a/tools/clang/include/clang-c/Index.h b/tools/clang/include/clang-c/Index.h -index 13db2085ba..eb6a5f14b2 100644 ---- a/tools/clang/include/clang-c/Index.h -+++ b/tools/clang/include/clang-c/Index.h -@@ -33,6 +33,7 @@ - */ - #define CINDEX_VERSION_MAJOR 0 - #define CINDEX_VERSION_MINOR 35 -+#define CINDEX_VERSION_HAS_BACKPORTED_SUSPEND - - #define CINDEX_VERSION_ENCODE(major, minor) ( \ - ((major) * 10000) \ -@@ -1404,6 +1405,15 @@ CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, - unsigned options); - - /** -+ * \brief Suspend a translation unit in order to free memory associated with it. -+ * -+ * A suspended translation unit uses significantly less memory but on the other -+ * side does not support any other calls than \c clang_reparseTranslationUnit -+ * to resume it or \c clang_disposeTranslationUnit to dispose it completely. -+ */ -+CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit); -+ -+/** - * \brief Destroy the specified CXTranslationUnit object. - */ - CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); -diff --git a/tools/clang/include/clang/Frontend/ASTUnit.h b/tools/clang/include/clang/Frontend/ASTUnit.h -index 3eaf054139..3745ec690e 100644 ---- a/tools/clang/include/clang/Frontend/ASTUnit.h -+++ b/tools/clang/include/clang/Frontend/ASTUnit.h -@@ -870,6 +870,11 @@ public: - bool Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps, - ArrayRef<RemappedFile> RemappedFiles = None); - -+ /// \brief Free data that will be re-generated on the next parse. -+ /// -+ /// Preamble-related data is not affected. -+ void ResetForParse(); -+ - /// \brief Perform code completion at the given file, line, and - /// column within this translation unit. - /// -diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp -index b446b53fa4..96437e15bb 100644 ---- a/tools/clang/lib/Frontend/ASTUnit.cpp -+++ b/tools/clang/lib/Frontend/ASTUnit.cpp -@@ -1034,8 +1034,6 @@ static void checkAndSanitizeDiags(SmallVectorImpl<StoredDiagnostic> & - /// contain any translation-unit information, false otherwise. - bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps, - std::unique_ptr<llvm::MemoryBuffer> OverrideMainBuffer) { -- SavedMainFileBuffer.reset(); -- - if (!Invocation) - return true; - -@@ -1083,16 +1081,12 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps, - Clang->createFileManager(); - FileMgr = &Clang->getFileManager(); - } -+ -+ ResetForParse(); -+ - SourceMgr = new SourceManager(getDiagnostics(), *FileMgr, - UserFilesAreVolatile); -- TheSema.reset(); -- Ctx = nullptr; -- PP = nullptr; -- Reader = nullptr; - -- // Clear out old caches and data. -- TopLevelDecls.clear(); -- clearFileLevelDecls(); - CleanTemporaryFiles(); - - if (!OverrideMainBuffer) { -@@ -2082,6 +2076,19 @@ bool ASTUnit::Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps, - return Result; - } - -+void ASTUnit::ResetForParse() { -+ SavedMainFileBuffer.reset(); -+ -+ SourceMgr.reset(); -+ TheSema.reset(); -+ Ctx.reset(); -+ PP.reset(); -+ Reader.reset(); -+ -+ TopLevelDecls.clear(); -+ clearFileLevelDecls(); -+} -+ - //----------------------------------------------------------------------------// - // Code completion - //----------------------------------------------------------------------------// -diff --git a/tools/clang/tools/c-index-test/c-index-test.c b/tools/clang/tools/c-index-test/c-index-test.c -index 007af9e252..c40bdb888d 100644 ---- a/tools/clang/tools/c-index-test/c-index-test.c -+++ b/tools/clang/tools/c-index-test/c-index-test.c -@@ -1664,6 +1664,8 @@ int perform_test_load_source(int argc, const char **argv, - return -1; - - if (Repeats > 1) { -+ clang_suspendTranslationUnit(TU); -+ - Err = clang_reparseTranslationUnit(TU, num_unsaved_files, unsaved_files, - clang_defaultReparseOptions(TU)); - if (Err != CXError_Success) { -diff --git a/tools/clang/tools/libclang/CIndex.cpp b/tools/clang/tools/libclang/CIndex.cpp -index deb4cc551b..81cb5c3778 100644 ---- a/tools/clang/tools/libclang/CIndex.cpp -+++ b/tools/clang/tools/libclang/CIndex.cpp -@@ -3778,6 +3778,20 @@ void clang_disposeTranslationUnit(CXTranslationUnit CTUnit) { - } - } - -+unsigned clang_suspendTranslationUnit(CXTranslationUnit CTUnit) { -+ if (CTUnit) { -+ ASTUnit *Unit = cxtu::getASTUnit(CTUnit); -+ -+ if (Unit && Unit->isUnsafeToFree()) -+ return false; -+ -+ Unit->ResetForParse(); -+ return true; -+ } -+ -+ return false; -+} -+ - unsigned clang_defaultReparseOptions(CXTranslationUnit TU) { - return CXReparse_None; - } -diff --git a/tools/clang/tools/libclang/libclang.exports b/tools/clang/tools/libclang/libclang.exports -index c8fe0a21d0..7a8f53d394 100644 ---- a/tools/clang/tools/libclang/libclang.exports -+++ b/tools/clang/tools/libclang/libclang.exports -@@ -298,6 +298,7 @@ clang_remap_getFilenames - clang_remap_getNumFiles - clang_reparseTranslationUnit - clang_saveTranslationUnit -+clang_suspendTranslationUnit - clang_sortCodeCompletionResults - clang_toggleCrashRecovery - clang_tokenize diff --git a/dist/clang/patches/D33493_Cache-source-locations-on-PCH-loading.patch b/dist/clang/patches/D33493_Cache-source-locations-on-PCH-loading.patch deleted file mode 100644 index 7a781ece28..0000000000 --- a/dist/clang/patches/D33493_Cache-source-locations-on-PCH-loading.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff --git a/tools/clang/include/clang/Frontend/ASTUnit.h b/tools/clang/include/clang/Frontend/ASTUnit.h -index 04e6dce511..3eaf054139 100644 ---- a/tools/clang/include/clang/Frontend/ASTUnit.h -+++ b/tools/clang/include/clang/Frontend/ASTUnit.h -@@ -184,6 +184,14 @@ private: - /// some number of calls. - unsigned PreambleRebuildCounter; - -+ /// \brief Cache pairs "filename - source location" -+ /// -+ /// Cache contains only source locations from preamble so it is -+ /// guaranteed that they stay valid when the SourceManager is recreated. -+ /// This cache is used when loading preambule to increase performance -+ /// of that loading. It must be cleared when preamble is recreated. -+ llvm::StringMap<SourceLocation> PreambleSrcLocCache; -+ - public: - class PreambleData { - const FileEntry *File; -diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp -index 76fd00a132..c1c2680dcd 100644 ---- a/tools/clang/lib/Frontend/ASTUnit.cpp -+++ b/tools/clang/lib/Frontend/ASTUnit.cpp -@@ -1142,6 +1142,8 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps, - if (SavedMainFileBuffer) - TranslateStoredDiagnostics(getFileManager(), getSourceManager(), - PreambleDiagnostics, StoredDiagnostics); -+ else -+ PreambleSrcLocCache.clear(); - - if (!Act->Execute()) - goto error; -@@ -2544,8 +2546,16 @@ void ASTUnit::TranslateStoredDiagnostics( - const FileEntry *FE = FileMgr.getFile(SD.Filename); - if (!FE) - continue; -- FileID FID = SrcMgr.translateFile(FE); -- SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID); -+ SourceLocation FileLoc; -+ auto ItFileID = PreambleSrcLocCache.find(SD.Filename); -+ if (ItFileID == PreambleSrcLocCache.end()) { -+ FileID FID = SrcMgr.translateFile(FE); -+ FileLoc = SrcMgr.getLocForStartOfFile(FID); -+ PreambleSrcLocCache[SD.Filename] = FileLoc; -+ } else { -+ FileLoc = ItFileID->getValue(); -+ } -+ - if (FileLoc.isInvalid()) - continue; - SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset); diff --git a/dist/clang/patches/D34882_Fix-invalid-warnings-for-header-guards-in-preambles.patch b/dist/clang/patches/D34882_Fix-invalid-warnings-for-header-guards-in-preambles.patch deleted file mode 100644 index d7e17fc13e..0000000000 --- a/dist/clang/patches/D34882_Fix-invalid-warnings-for-header-guards-in-preambles.patch +++ /dev/null @@ -1,82 +0,0 @@ -diff --git a/tools/clang/include/clang/Lex/Preprocessor.h b/tools/clang/include/clang/Lex/Preprocessor.h -index 3d1d9a86e0..0a02c977fc 100644 ---- a/tools/clang/include/clang/Lex/Preprocessor.h -+++ b/tools/clang/include/clang/Lex/Preprocessor.h -@@ -1034,6 +1034,8 @@ public: - /// which implicitly adds the builtin defines etc. - void EnterMainSourceFile(); - -+ void replayPreambleConditionalStack(); -+ - /// \brief Inform the preprocessor callbacks that processing is complete. - void EndSourceFile(); - -@@ -1700,11 +1702,6 @@ public: - /// \brief Return true if we're in the top-level file, not in a \#include. - bool isInPrimaryFile() const; - -- /// \brief Return true if we're in the main file (specifically, if we are 0 -- /// (zero) levels deep \#include. This is used by the lexer to determine if -- /// it needs to generate errors about unterminated \#if directives. -- bool isInMainFile() const; -- - /// \brief Handle cases where the \#include name is expanded - /// from a macro as multiple tokens, which need to be glued together. - /// -diff --git a/tools/clang/lib/Lex/Lexer.cpp b/tools/clang/lib/Lex/Lexer.cpp -index 72f7011d4f..5953412608 100644 ---- a/tools/clang/lib/Lex/Lexer.cpp -+++ b/tools/clang/lib/Lex/Lexer.cpp -@@ -2506,7 +2506,7 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { - return true; - } - -- if (PP->isRecordingPreamble() && !PP->isInMainFile()) { -+ if (PP->isRecordingPreamble() && PP->isInPrimaryFile()) { - PP->setRecordedPreambleConditionalStack(ConditionalStack); - ConditionalStack.clear(); - } -diff --git a/tools/clang/lib/Lex/PPLexerChange.cpp b/tools/clang/lib/Lex/PPLexerChange.cpp -index 849a703671..e2eceafd98 100644 ---- a/tools/clang/lib/Lex/PPLexerChange.cpp -+++ b/tools/clang/lib/Lex/PPLexerChange.cpp -@@ -46,12 +46,6 @@ bool Preprocessor::isInPrimaryFile() const { - return true; - } - --bool Preprocessor::isInMainFile() const { -- if (IsFileLexer()) -- return IncludeMacroStack.size() == 0; -- return true; --} -- - /// getCurrentLexer - Return the current file lexer being lexed from. Note - /// that this ignores any potentially active macro expansions and _Pragma - /// expansions going on at the time. -diff --git a/tools/clang/lib/Lex/Preprocessor.cpp b/tools/clang/lib/Lex/Preprocessor.cpp -index 1da60961a8..bb67b9c77a 100644 ---- a/tools/clang/lib/Lex/Preprocessor.cpp -+++ b/tools/clang/lib/Lex/Preprocessor.cpp -@@ -531,7 +531,9 @@ void Preprocessor::EnterMainSourceFile() { - - // Start parsing the predefines. - EnterSourceFile(FID, nullptr, SourceLocation()); -+} - -+void Preprocessor::replayPreambleConditionalStack() { - // Restore the conditional stack from the preamble, if there is one. - if (PreambleConditionalStack.isReplaying()) { - CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack()); -diff --git a/tools/clang/lib/Parse/Parser.cpp b/tools/clang/lib/Parse/Parser.cpp -index f968f995d5..45662e7866 100644 ---- a/tools/clang/lib/Parse/Parser.cpp -+++ b/tools/clang/lib/Parse/Parser.cpp -@@ -528,6 +528,8 @@ void Parser::Initialize() { - - // Prime the lexer look-ahead. - ConsumeToken(); -+ -+ PP.replayPreambleConditionalStack(); - } - - void Parser::LateTemplateParserCleanupCallback(void *P) { diff --git a/dist/clang/patches/D35355_Fix-templated-type-alias-completion-when-using-global-completion-cache.patch b/dist/clang/patches/D35355_Fix-templated-type-alias-completion-when-using-global-completion-cache.patch new file mode 100644 index 0000000000..a02e0da444 --- /dev/null +++ b/dist/clang/patches/D35355_Fix-templated-type-alias-completion-when-using-global-completion-cache.patch @@ -0,0 +1,71 @@ +diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp +index 1094e6d089..5a4cddbebe 100644 +--- a/tools/clang/lib/Frontend/ASTUnit.cpp ++++ b/tools/clang/lib/Frontend/ASTUnit.cpp +@@ -243,7 +243,8 @@ static unsigned getDeclShowContexts(const NamedDecl *ND, + + uint64_t Contexts = 0; + if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND) || +- isa<ClassTemplateDecl>(ND) || isa<TemplateTemplateParmDecl>(ND)) { ++ isa<ClassTemplateDecl>(ND) || isa<TemplateTemplateParmDecl>(ND) || ++ isa<TypeAliasTemplateDecl>(ND)) { + // Types can appear in these contexts. + if (LangOpts.CPlusPlus || !isa<TagDecl>(ND)) + Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel) +diff --git a/tools/clang/lib/Parse/ParseTemplate.cpp b/tools/clang/lib/Parse/ParseTemplate.cpp +index 944cd775d5..6aba10e5c7 100644 +--- a/tools/clang/lib/Parse/ParseTemplate.cpp ++++ b/tools/clang/lib/Parse/ParseTemplate.cpp +@@ -198,9 +198,11 @@ Parser::ParseSingleDeclarationAfterTemplate( + + if (Tok.is(tok::kw_using)) { + // FIXME: We should return the DeclGroup to the caller. +- ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd, +- prefixAttrs); +- return nullptr; ++ auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd, ++ prefixAttrs); ++ if (!usingDeclPtr) ++ return nullptr; ++ return usingDeclPtr.get().getSingleDecl(); + } + + // Parse the declaration specifiers, stealing any diagnostics from +@@ -1023,8 +1025,8 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK, + ? OO_None + : TemplateName.OperatorFunctionId.Operator; + +- TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( +- SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK, ++ TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( ++ SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK, + LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds); + + Tok.setAnnotationValue(TemplateId); +diff --git a/tools/clang/test/Index/code-completion.cpp b/tools/clang/test/Index/code-completion.cpp +index f52bb10a35..00f158f3d0 100644 +--- a/tools/clang/test/Index/code-completion.cpp ++++ b/tools/clang/test/Index/code-completion.cpp +@@ -37,6 +37,16 @@ Z::operator int() const { + return 0; + } + ++template <typename T> ++struct Foo { T member; }; ++ ++template<typename T> using Bar = Foo<T>; ++ ++void test_template_alias() { ++ // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s ++ ++} ++ + // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member} + // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member} + // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member} +@@ -88,3 +98,5 @@ Z::operator int() const { + // CHECK-EXPR-NEXT: Class name + // CHECK-EXPR-NEXT: Nested name specifier + // CHECK-EXPR-NEXT: Objective-C interface ++ ++// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50) diff --git a/dist/clang/patches/D37435_Dont-show-deleted-function-constructor-candidates-for-code-completion.patch b/dist/clang/patches/D37435_Dont-show-deleted-function-constructor-candidates-for-code-completion.patch new file mode 100644 index 0000000000..01a79b27db --- /dev/null +++ b/dist/clang/patches/D37435_Dont-show-deleted-function-constructor-candidates-for-code-completion.patch @@ -0,0 +1,50 @@ +diff --git a/tools/clang/lib/Sema/SemaCodeComplete.cpp b/tools/clang/lib/Sema/SemaCodeComplete.cpp +index 4de7d42207..7001849426 100644 +--- a/tools/clang/lib/Sema/SemaCodeComplete.cpp ++++ b/tools/clang/lib/Sema/SemaCodeComplete.cpp +@@ -4286,9 +4286,12 @@ static void mergeCandidatesWithResults(Sema &SemaRef, + }); + + // Add the remaining viable overload candidates as code-completion results. +- for (auto &Candidate : CandidateSet) ++ for (auto &Candidate : CandidateSet) { ++ if (Candidate.Function && Candidate.Function->isDeleted()) ++ continue; + if (Candidate.Viable) + Results.push_back(ResultCandidate(Candidate.Function)); ++ } + } + } + +diff --git a/tools/clang/test/Index/complete-constructor-params.cpp b/tools/clang/test/Index/complete-constructor-params.cpp +index 6685626a58..949077a214 100644 +--- a/tools/clang/test/Index/complete-constructor-params.cpp ++++ b/tools/clang/test/Index/complete-constructor-params.cpp +@@ -18,6 +18,20 @@ int main() { + int(42); + } + ++struct Foo { ++ Foo() = default; ++ Foo(const Foo&) = delete; ++}; ++ ++struct Bar { ++ Foo f; ++}; ++ ++void function() { ++ Bar b1; ++ Bar b2(b1); ++} ++ + // RUN: c-index-test -code-completion-at=%s:11:10 %s | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter const S<int> &}{RightParen )} (1) + // CHECK-CC1: OverloadCandidate:{Text S}{LeftParen (}{CurrentParameter int}{Comma , }{Placeholder U}{Comma , }{Placeholder U}{RightParen )} (1) +@@ -138,3 +152,6 @@ int main() { + // CHECK-CC10-NEXT: Class name + // CHECK-CC10-NEXT: Nested name specifier + // CHECK-CC10-NEXT: Objective-C interface ++ ++// RUN: c-index-test -code-completion-at=%s:32:12 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC11 %s ++// CHECK-CC11-NOT: OverloadCandidate:{Text Bar}{LeftParen (}{CurrentParameter const Bar &}{RightParen )} (1) diff --git a/dist/clang/patches/QTCREATORBUG-15449_Fix-files-lock-on-Windows.patch b/dist/clang/patches/QTCREATORBUG-15449_Fix-files-lock-on-Windows.patch index 0075d3daba..9a8c6028fd 100644 --- a/dist/clang/patches/QTCREATORBUG-15449_Fix-files-lock-on-Windows.patch +++ b/dist/clang/patches/QTCREATORBUG-15449_Fix-files-lock-on-Windows.patch @@ -1,11 +1,11 @@ diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp -index b935cbf1ae7..3c9a25062f5 100644 +index 85e782b2c04..95f10753d96 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp -@@ -286,6 +286,11 @@ static bool shouldUseMmap(int FD, +@@ -284,6 +284,11 @@ static bool shouldUseMmap(int FD, bool RequiresNullTerminator, int PageSize, - bool IsVolatileSize) { + bool IsVolatile) { +#ifdef _WIN32 + // Do not use mmap on Windows in order to avoid file locking + return false; diff --git a/dist/clang/patches/README b/dist/clang/patches/README new file mode 100644 index 0000000000..ef3828753b --- /dev/null +++ b/dist/clang/patches/README @@ -0,0 +1,39 @@ +The patches in this directory are applied to LLVM/Clang with: + + $ cd $LLVM_SOURCE_DIR + $ git apply --whitespace=fix $QT_CREATOR_SOURCE/dist/clang/patches/*.patch + +D35355_Fix-templated-type-alias-completion-when-using-global-completion-cache.patch + + https://reviews.llvm.org/D35355 + + Backported from trunk. + + Fixes completion involving templated type alias. + +D37435_Dont-show-deleted-function-constructor-candidates-for-code-completion.patch + + https://reviews.llvm.org/D37435 + https://bugs.llvm.org/show_bug.cgi?id=34402 + + Backported from trunk. + + Fixes completion involving implicitly deleted copy constructors. + +rL310905_Avoid-PointerIntPair-of-constexpr-EvalInfo-structs.patch + + https://reviews.llvm.org/rL310905 + https://bugs.llvm.org/show_bug.cgi?id=32018 + + Backported from trunk. + + Fixes build/miscompilation of LLVM/Clang with MinGW, which enables + generation of profile-guided-optimization builds for Windows. + +QTCREATORBUG-15449_Fix-files-lock-on-Windows.patch + + https://reviews.llvm.org/D35200 + https://bugreports.qt.io/browse/QTCREATORBUG-15449 + + Significantly reduces problems when saving a header file on Windows. + diff --git a/dist/clang/patches/rL310905_Avoid-PointerIntPair-of-constexpr-EvalInfo-structs.patch b/dist/clang/patches/rL310905_Avoid-PointerIntPair-of-constexpr-EvalInfo-structs.patch new file mode 100644 index 0000000000..e5c60b7f2f --- /dev/null +++ b/dist/clang/patches/rL310905_Avoid-PointerIntPair-of-constexpr-EvalInfo-structs.patch @@ -0,0 +1,88 @@ +diff --git a/tools/clang/lib/AST/ExprConstant.cpp b/tools/clang/lib/AST/ExprConstant.cpp +index a26b608082..effd72c764 100644 +--- a/tools/clang/lib/AST/ExprConstant.cpp ++++ b/tools/clang/lib/AST/ExprConstant.cpp +@@ -537,7 +537,11 @@ namespace { + /// rules. For example, the RHS of (0 && foo()) is not evaluated. We can + /// evaluate the expression regardless of what the RHS is, but C only allows + /// certain things in certain situations. ++#ifndef _WIN32 + struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) EvalInfo { ++#else ++ struct EvalInfo { ++#endif + ASTContext &Ctx; + + /// EvalStatus - Contains information about the evaluation. +@@ -575,7 +579,21 @@ namespace { + + /// The current array initialization index, if we're performing array + /// initialization. ++#ifndef _WIN32 + uint64_t ArrayInitIndex = -1; ++#else ++ /// uint64_t value is split into two uint32_t values as a workaround ++ /// to deal with mingw 32-bit miscompilation ++ uint32_t ArrayInitIndex[2] = {static_cast<uint32_t>(-1), static_cast<uint32_t>(-1)}; ++ uint64_t GetArrayInitIndex() { ++ return (static_cast<uint64_t>(ArrayInitIndex[0]) << 32) ++ + static_cast<uint64_t>(ArrayInitIndex[1]); ++ } ++ void SetArrayInitIndex(uint64_t index) { ++ ArrayInitIndex[0] = static_cast<uint32_t>(index >> 32); ++ ArrayInitIndex[1] = static_cast<uint32_t>(index); ++ } ++#endif + + /// HasActiveDiagnostic - Was the previous diagnostic stored? If so, further + /// notes attached to it will also be stored, otherwise they will not be. +@@ -922,6 +940,7 @@ namespace { + uint64_t OuterIndex; + + public: ++#ifndef _WIN32 + ArrayInitLoopIndex(EvalInfo &Info) + : Info(Info), OuterIndex(Info.ArrayInitIndex) { + Info.ArrayInitIndex = 0; +@@ -929,6 +948,19 @@ namespace { + ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; } + + operator uint64_t&() { return Info.ArrayInitIndex; } ++#else ++ ArrayInitLoopIndex(EvalInfo &Info) ++ : Info(Info), OuterIndex(Info.GetArrayInitIndex()) { ++ Info.SetArrayInitIndex(0); ++ } ++ ~ArrayInitLoopIndex() { Info.SetArrayInitIndex(OuterIndex); } ++ ++ operator uint64_t() { return Info.GetArrayInitIndex(); } ++ ArrayInitLoopIndex& operator++() { ++ Info.SetArrayInitIndex(Info.GetArrayInitIndex() + 1); ++ return *this; ++ } ++#endif + }; + }; + +@@ -6973,13 +7005,21 @@ public: + } + + bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E) { ++#ifndef _WIN32 + if (Info.ArrayInitIndex == uint64_t(-1)) { ++#else ++ if (Info.GetArrayInitIndex() == uint64_t(-1)) { ++#endif + // We were asked to evaluate this subexpression independent of the + // enclosing ArrayInitLoopExpr. We can't do that. + Info.FFDiag(E); + return false; + } ++#ifndef _WIN32 + return Success(Info.ArrayInitIndex, E); ++#else ++ return Success(Info.GetArrayInitIndex(), E); ++#endif + } + + // Note, GNU defines __null as an integer, not a pointer. |