r332817 - Print the qualified name when dumping deserialized decls.

2018-05-20 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun May 20 02:38:52 2018
New Revision: 332817

URL: http://llvm.org/viewvc/llvm-project?rev=332817&view=rev
Log:
Print the qualified name when dumping deserialized decls.

This is useful to understand and debug the lazy template specializations
used in the pch and modules.

Differential Revision: https://reviews.llvm.org/D41785

Modified:
cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=332817&r1=332816&r2=332817&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Sun May 20 02:38:52 2018
@@ -88,8 +88,10 @@ public:
 
   void DeclRead(serialization::DeclID ID, const Decl *D) override {
 llvm::outs() << "PCH DECL: " << D->getDeclKindName();
-if (const NamedDecl *ND = dyn_cast(D))
-  llvm::outs() << " - " << *ND;
+if (const NamedDecl *ND = dyn_cast(D)) {
+  llvm::outs() << " - ";
+  ND->printQualifiedName(llvm::outs());
+}
 llvm::outs() << "\n";
 
 DelegatingDeserializationListener::DeclRead(ID, D);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316022 - Expose ConsumeAnyToken interface to external clients.

2017-10-17 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 17 12:38:57 2017
New Revision: 316022

URL: http://llvm.org/viewvc/llvm-project?rev=316022&view=rev
Log:
Expose ConsumeAnyToken interface to external clients.

Modified:
cfe/trunk/include/clang/Parse/Parser.h

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=316022&r1=316021&r2=316022&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Oct 17 12:38:57 2017
@@ -338,6 +338,27 @@ public:
 return true;
   }
 
+  /// ConsumeAnyToken - Dispatch to the right Consume* method based on the
+  /// current token type.  This should only be used in cases where the type of
+  /// the token really isn't known, e.g. in error recovery.
+  SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok = false) {
+if (isTokenParen())
+  return ConsumeParen();
+if (isTokenBracket())
+  return ConsumeBracket();
+if (isTokenBrace())
+  return ConsumeBrace();
+if (isTokenStringLiteral())
+  return ConsumeStringToken();
+if (Tok.is(tok::code_completion))
+  return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
+  : handleUnexpectedCodeCompletionToken();
+if (Tok.isAnnotation())
+  return ConsumeAnnotationToken();
+return ConsumeToken();
+  }
+
+
   SourceLocation getEndOfPreviousToken() {
 return PP.getLocForEndOfToken(PrevTokLocation);
   }
@@ -388,26 +409,6 @@ private:
   PP.EnterToken(Next);
   }
 
-  /// ConsumeAnyToken - Dispatch to the right Consume* method based on the
-  /// current token type.  This should only be used in cases where the type of
-  /// the token really isn't known, e.g. in error recovery.
-  SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok = false) {
-if (isTokenParen())
-  return ConsumeParen();
-if (isTokenBracket())
-  return ConsumeBracket();
-if (isTokenBrace())
-  return ConsumeBrace();
-if (isTokenStringLiteral())
-  return ConsumeStringToken();
-if (Tok.is(tok::code_completion))
-  return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
-  : handleUnexpectedCodeCompletionToken();
-if (Tok.isAnnotation())
-  return ConsumeAnnotationToken();
-return ConsumeToken();
-  }
-
   SourceLocation ConsumeAnnotationToken() {
 assert(Tok.isAnnotation() && "wrong consume method");
 SourceLocation Loc = Tok.getLocation();


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316444 - [modules] Add a regression test for merging anon decls in extern C contexts.

2017-10-24 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 24 07:52:35 2017
New Revision: 316444

URL: http://llvm.org/viewvc/llvm-project?rev=316444&view=rev
Log:
[modules] Add a regression test for merging anon decls in extern C contexts.

Added:
cfe/trunk/test/Modules/merge-anon-in-extern_c.cpp

Added: cfe/trunk/test/Modules/merge-anon-in-extern_c.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-anon-in-extern_c.cpp?rev=316444&view=auto
==
--- cfe/trunk/test/Modules/merge-anon-in-extern_c.cpp (added)
+++ cfe/trunk/test/Modules/merge-anon-in-extern_c.cpp Tue Oct 24 07:52:35 2017
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -verify %s
+// expected-no-diagnostics
+
+#pragma clang module build sys_types
+module sys_types {}
+#pragma clang module contents
+#pragma clang module begin sys_types
+extern "C" {
+  typedef union { bool b; } pthread_mutex_t;
+}
+#pragma clang module end
+#pragma clang module endbuild
+
+typedef union { bool b; } pthread_mutex_t;
+#pragma clang module import sys_types
+
+const pthread_mutex_t *m;
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305089 - Repair 2010-05-31-palignr.c test

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 11:42:26 2017
New Revision: 305089

URL: http://llvm.org/viewvc/llvm-project?rev=305089&view=rev
Log:
Repair 2010-05-31-palignr.c test

This test was silently failing since a long time because it failed to include
stdlib.h (as it's running in a freestanding environment). However, because we
 used just not clang_cc1 instead of the verify mode, this regression was never
 noticed and the test was just always passing.

This adds -ffreestanding to the invocation, so that tmmintrin.h doesn't
indirectly include mm_malloc.h, which in turns includes the unavailable 
stdlib.h.
We also run now in the -verify mode to prevent that we silently regress again.

I've also updated the test to no longer check the return value of 
_mm_alignr_epi8
as this is also causing it to fail (and it's not really the job of this test to
test this).


Patch by Raphael Isemann (D34022)

Modified:
cfe/trunk/test/Sema/2010-05-31-palignr.c

Modified: cfe/trunk/test/Sema/2010-05-31-palignr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/2010-05-31-palignr.c?rev=305089&r1=305088&r2=305089&view=diff
==
--- cfe/trunk/test/Sema/2010-05-31-palignr.c (original)
+++ cfe/trunk/test/Sema/2010-05-31-palignr.c Fri Jun  9 11:42:26 2017
@@ -1,13 +1,12 @@
-// RUN: not %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s
+// RUN: %clang_cc1  -ffreestanding -verify -fsyntax-only %s
 
 #include 
+#include 
 
 extern int i;
 
 int main ()
 {
-#if defined( __SSSE3__ )
-
   typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16)));
 
   short   dtbl[] = {1,2,3,4,5,6,7,8};
@@ -15,8 +14,7 @@ int main ()
 
   vSInt16 v0;
   v0 = *vdtbl;
-  v0 = _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to 
'__builtin_ia32_palignr128' must be a constant integer}}
+  _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to 
'__builtin_ia32_palignr128' must be a constant integer}}
 
   return 0;
-#endif
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r305103 - Bringt back -triple so the test passes on non-x86.

2017-06-09 Thread Vassil Vassilev via cfe-commits

Thanks!

Maybe we could run it on any -triple x86_64...
On 09/06/17 21:47, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Fri Jun  9 14:47:36 2017
New Revision: 305103

URL: http://llvm.org/viewvc/llvm-project?rev=305103&view=rev
Log:
Bringt back -triple so the test passes on non-x86.

Modified:
 cfe/trunk/test/Sema/2010-05-31-palignr.c

Modified: cfe/trunk/test/Sema/2010-05-31-palignr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/2010-05-31-palignr.c?rev=305103&r1=305102&r2=305103&view=diff
==
--- cfe/trunk/test/Sema/2010-05-31-palignr.c (original)
+++ cfe/trunk/test/Sema/2010-05-31-palignr.c Fri Jun  9 14:47:36 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -ffreestanding -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -ffreestanding -verify 
-fsyntax-only %s
  
  #include 

  #include 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305118 - [modules] Fix that global delete operator get's assigned to a submodule.

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 16:36:28 2017
New Revision: 305118

URL: http://llvm.org/viewvc/llvm-project?rev=305118&view=rev
Log:
[modules] Fix that global delete operator get's assigned to a submodule.

n the current local-submodule-visibility mode, as soon as we discover a virtual
destructor, we declare on demand a global delete operator. However, this causes
that this delete operator is owned by the submodule which contains said virtual
destructor. This means that other modules no longer can see the global delete
operator which is hidden inside another submodule and fail to compile.

This patch unhides those global allocation function once they're created to
prevent this issue.

Patch by Raphael Isemann (D33366)!

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=305118&r1=305117&r2=305118&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun  9 16:36:28 2017
@@ -2658,6 +2658,8 @@ void Sema::DeclareGlobalAllocationFuncti
 Context, GlobalCtx, SourceLocation(), SourceLocation(), Name,
 FnType, /*TInfo=*/nullptr, SC_None, false, true);
 Alloc->setImplicit();
+// Global allocation functions should always be visible.
+Alloc->setHidden(false);
 
 // Implicit sized deallocation functions always have default visibility.
 Alloc->addAttr(


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305120 - [modules] D29951: Load lazily the template specialization in multi-module setups.

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 16:54:18 2017
New Revision: 305120

URL: http://llvm.org/viewvc/llvm-project?rev=305120&view=rev
Log:
[modules] D29951: Load lazily the template specialization in multi-module 
setups.

Currently, we load all template specialization if we have more than one module
attached and we touch anything around the template definition.

This patch registers the template specializations as lazily-loadable entities.
In some TUs it reduces the amount of deserializations by 1%.


Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=305120&r1=305119&r2=305120&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jun  9 16:54:18 2017
@@ -216,6 +216,30 @@ namespace clang {
   TypedefNameForLinkage(nullptr), HasPendingBody(false),
   IsDeclMarkedUsed(false) {}
 
+template  static
+void AddLazySpecializations(T *D,
+SmallVectorImpl& IDs) {
+  if (IDs.empty())
+return;
+
+  // FIXME: We should avoid this pattern of getting the ASTContext.
+  ASTContext &C = D->getASTContext();
+
+  auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
+
+  if (auto &Old = LazySpecializations) {
+IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+std::sort(IDs.begin(), IDs.end());
+IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+  }
+
+  auto *Result = new (C) serialization::DeclID[1 + IDs.size()];
+  *Result = IDs.size();
+  std::copy(IDs.begin(), IDs.end(), Result + 1);
+
+  LazySpecializations = Result;
+}
+
 template 
 static Decl *getMostRecentDeclImpl(Redeclarable *D);
 static Decl *getMostRecentDeclImpl(...);
@@ -244,7 +268,7 @@ namespace clang {
 void ReadFunctionDefinition(FunctionDecl *FD);
 void Visit(Decl *D);
 
-void UpdateDecl(Decl *D);
+void UpdateDecl(Decl *D, llvm::SmallVectorImpl&);
 
 static void setNextObjCCategory(ObjCCategoryDecl *Cat,
 ObjCCategoryDecl *Next) {
@@ -1952,21 +1976,6 @@ ASTDeclReader::VisitRedeclarableTemplate
   return Redecl;
 }
 
-static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old,
- SmallVectorImpl &IDs) {
-  assert(!IDs.empty() && "no IDs to add to list");
-  if (Old) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (Context) DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-  return Result;
-}
-
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
@@ -1975,12 +1984,7 @@ void ASTDeclReader::VisitClassTemplateDe
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2007,12 +2011,7 @@ void ASTDeclReader::VisitVarTemplateDecl
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -2118,12 +2117,7 @@ void ASTDeclReader::VisitFunctionTemplat
 // This FunctionTemplateDecl owns a CommonPtr; read it.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+ASTDeclReader::AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -3667,6 +3661,9 @@ void ASTReader::loadDeclUpdateRecords(Pe
   Decl *D = Record.D;
   ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
   DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
+
+  llvm::SmallVector PendingLazySpecializationIDs;
+
   if (UpdI != DeclUpdateOffsets.end()) {
 auto UpdateOffsets = std::move(UpdI->second);
 DeclUpdateOffsets.erase(UpdI);
@@ -3691,7 +3688,7 @@ void ASTReader::loadDeclUpdateRecords(Pe
 
   ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
Sour

[clang-tools-extra] r305125 - [clang-tidy] D33930: Do not pick up by default the LLVM style if passing -format.

2017-06-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Fri Jun  9 17:23:03 2017
New Revision: 305125

URL: http://llvm.org/viewvc/llvm-project?rev=305125&view=rev
Log:
[clang-tidy] D33930: Do not pick up by default the LLVM style if passing 
-format.

This adds a new flag -style which is passed to clang-apply-replacements and
defaults to file meaning it would pick up the closest .clang-format file in 
tree.

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=305125&r1=305124&r2=305125&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Fri Jun  9 
17:23:03 2017
@@ -105,6 +105,8 @@ def apply_fixes(args, tmpdir):
   invocation = [args.clang_apply_replacements_binary]
   if args.format:
 invocation.append('-format')
+  if args.style:
+invocation.append('-style=' + args.style)
   invocation.append(tmpdir)
   subprocess.call(invocation)
 
@@ -148,6 +150,8 @@ def main():
   parser.add_argument('-fix', action='store_true', help='apply fix-its')
   parser.add_argument('-format', action='store_true', help='Reformat code '
   'after applying fixes')
+  parser.add_argument('-style', default='file', help='The style of reformat '
+  'code after applying fixes')
   parser.add_argument('-p', dest='build_path',
   help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r305460 - Revert "Load lazily the template specialization in multi-module setups."

2017-06-15 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Jun 15 06:05:32 2017
New Revision: 305460

URL: http://llvm.org/viewvc/llvm-project?rev=305460&view=rev
Log:
Revert "Load lazily the template specialization in multi-module setups."

This broke our libcxx modules builds.

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=305460&r1=305459&r2=305460&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Jun 15 06:05:32 2017
@@ -216,30 +216,6 @@ namespace clang {
   TypedefNameForLinkage(nullptr), HasPendingBody(false),
   IsDeclMarkedUsed(false) {}
 
-template  static
-void AddLazySpecializations(T *D,
-SmallVectorImpl& IDs) {
-  if (IDs.empty())
-return;
-
-  // FIXME: We should avoid this pattern of getting the ASTContext.
-  ASTContext &C = D->getASTContext();
-
-  auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations;
-
-  if (auto &Old = LazySpecializations) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (C) serialization::DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-
-  LazySpecializations = Result;
-}
-
 template 
 static Decl *getMostRecentDeclImpl(Redeclarable *D);
 static Decl *getMostRecentDeclImpl(...);
@@ -268,7 +244,7 @@ namespace clang {
 void ReadFunctionDefinition(FunctionDecl *FD);
 void Visit(Decl *D);
 
-void UpdateDecl(Decl *D, llvm::SmallVectorImpl&);
+void UpdateDecl(Decl *D);
 
 static void setNextObjCCategory(ObjCCategoryDecl *Cat,
 ObjCCategoryDecl *Next) {
@@ -1976,6 +1952,21 @@ ASTDeclReader::VisitRedeclarableTemplate
   return Redecl;
 }
 
+static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old,
+ SmallVectorImpl &IDs) {
+  assert(!IDs.empty() && "no IDs to add to list");
+  if (Old) {
+IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+std::sort(IDs.begin(), IDs.end());
+IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+  }
+
+  auto *Result = new (Context) DeclID[1 + IDs.size()];
+  *Result = IDs.size();
+  std::copy(IDs.begin(), IDs.end(), Result + 1);
+  return Result;
+}
+
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
@@ -1984,7 +1975,12 @@ void ASTDeclReader::VisitClassTemplateDe
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-ASTDeclReader::AddLazySpecializations(D, SpecIDs);
+
+if (!SpecIDs.empty()) {
+  auto *CommonPtr = D->getCommonPtr();
+  CommonPtr->LazySpecializations = newDeclIDList(
+  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
+}
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2011,7 +2007,12 @@ void ASTDeclReader::VisitVarTemplateDecl
 // the specializations.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-ASTDeclReader::AddLazySpecializations(D, SpecIDs);
+
+if (!SpecIDs.empty()) {
+  auto *CommonPtr = D->getCommonPtr();
+  CommonPtr->LazySpecializations = newDeclIDList(
+  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
+}
   }
 }
 
@@ -2117,7 +2118,12 @@ void ASTDeclReader::VisitFunctionTemplat
 // This FunctionTemplateDecl owns a CommonPtr; read it.
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
-ASTDeclReader::AddLazySpecializations(D, SpecIDs);
+
+if (!SpecIDs.empty()) {
+  auto *CommonPtr = D->getCommonPtr();
+  CommonPtr->LazySpecializations = newDeclIDList(
+  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
+}
   }
 }
 
@@ -3661,9 +3667,6 @@ void ASTReader::loadDeclUpdateRecords(Pe
   Decl *D = Record.D;
   ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
   DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID);
-
-  llvm::SmallVector PendingLazySpecializationIDs;
-
   if (UpdI != DeclUpdateOffsets.end()) {
 auto UpdateOffsets = std::move(UpdI->second);
 DeclUpdateOffsets.erase(UpdI);
@@ -3688,7 +3691,7 @@ void ASTReader::loadDeclUpdateRecords(Pe
 
   ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
SourceLocation());
-  Reader.UpdateDecl(D, PendingLazySpecializationIDs);
+  Reader.UpdateDecl(D);
 
   // We might have made this declaration interesting. If so, remember that
   // we need to hand it off to the consumer.
@@ -3700,17 +3703,6 @

r305799 - D31187: Fix removal of out-of-line definitions.

2017-06-20 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Jun 20 09:59:57 2017
New Revision: 305799

URL: http://llvm.org/viewvc/llvm-project?rev=305799&view=rev
Log:
D31187: Fix removal of out-of-line definitions.

Consider:

struct MyClass {
  void f() {}
}
MyClass::f(){} // expected error redefinition of f. #1

Some clients (eg. cling) need to call removeDecl for the redefined (#1) decl.

This patch enables us to remove the lookup entry is registered in the semantic
decl context and not in the primary decl context of the lexical decl context
where we currently are trying to remove it from.

It is not trivial to test this piece and writing a full-blown unit test seems
too much.

Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=305799&r1=305798&r2=305799&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Jun 20 09:59:57 2017
@@ -1352,7 +1352,7 @@ void DeclContext::removeDecl(Decl *D) {
 // Remove only decls that have a name
 if (!ND->getDeclName()) return;
 
-auto *DC = this;
+auto *DC = D->getDeclContext();
 do {
   StoredDeclsMap *Map = DC->getPrimaryContext()->LookupPtr;
   if (Map) {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r320763 - D40901: Refactor lazy loading of template specializations. NFC

2017-12-14 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Dec 14 15:30:18 2017
New Revision: 320763

URL: http://llvm.org/viewvc/llvm-project?rev=320763&view=rev
Log:
D40901: Refactor lazy loading of template specializations. NFC

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/DeclTemplate.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=320763&r1=320762&r2=320763&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Dec 14 15:30:18 2017
@@ -790,6 +790,8 @@ protected:
 return SpecIterator(isEnd ? Specs.end() : Specs.begin());
   }
 
+  void loadLazySpecializationsImpl() const;
+
   template  typename SpecEntryTraits::DeclType*
   findSpecializationImpl(llvm::FoldingSetVector &Specs,
  ArrayRef Args, void *&InsertPos);
@@ -808,6 +810,13 @@ protected:
 /// was explicitly specialized.
 llvm::PointerIntPair
   InstantiatedFromMember;
+
+/// \brief If non-null, points to an array of specializations (including
+/// partial specializations) known only by their external declaration IDs.
+///
+/// The first value in the array is the number of specializations/partial
+/// specializations that follow.
+uint32_t *LazySpecializations = nullptr;
   };
 
   /// \brief Pointer to the common data shared by all declarations of this
@@ -975,13 +984,6 @@ protected:
 /// require the use of this information.
 TemplateArgument *InjectedArgs = nullptr;
 
-/// \brief If non-null, points to an array of specializations known only
-/// by their external declaration IDs.
-///
-/// The first value in the array is the number of of specializations
-/// that follow.
-uint32_t *LazySpecializations = nullptr;
-
 Common() = default;
   };
 
@@ -2065,13 +2067,6 @@ protected:
 /// \brief The injected-class-name type for this class template.
 QualType InjectedClassNameType;
 
-/// \brief If non-null, points to an array of specializations (including
-/// partial specializations) known only by their external declaration IDs.
-///
-/// The first value in the array is the number of of specializations/
-/// partial specializations that follow.
-uint32_t *LazySpecializations = nullptr;
-
 Common() = default;
   };
 
@@ -2885,13 +2880,6 @@ protected:
 llvm::FoldingSetVector
 PartialSpecializations;
 
-/// \brief If non-null, points to an array of specializations (including
-/// partial specializations) known ownly by their external declaration IDs.
-///
-/// The first value in the array is the number of of specializations/
-/// partial specializations that follow.
-uint32_t *LazySpecializations = nullptr;
-
 Common() = default;
   };
 

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=320763&r1=320762&r2=320763&view=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Dec 14 15:30:18 2017
@@ -182,6 +182,19 @@ RedeclarableTemplateDecl::CommonBase *Re
   return Common;
 }
 
+void RedeclarableTemplateDecl::loadLazySpecializationsImpl() const {
+  // Grab the most recent declaration to ensure we've loaded any lazy
+  // redeclarations of this template.
+  CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr();
+  if (CommonBasePtr->LazySpecializations) {
+ASTContext &Context = getASTContext();
+uint32_t *Specs = CommonBasePtr->LazySpecializations;
+CommonBasePtr->LazySpecializations = nullptr;
+for (uint32_t I = 0, N = *Specs++; I != N; ++I)
+  (void)Context.getExternalSource()->GetExternalDecl(Specs[I]);
+  }
+}
+
 template
 typename RedeclarableTemplateDecl::SpecEntryTraits::DeclType *
 RedeclarableTemplateDecl::findSpecializationImpl(
@@ -190,7 +203,7 @@ RedeclarableTemplateDecl::findSpecializa
   using SETraits = SpecEntryTraits;
 
   llvm::FoldingSetNodeID ID;
-  EntryType::Profile(ID,Args, getASTContext());
+  EntryType::Profile(ID, Args, getASTContext());
   EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
   return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr;
 }
@@ -251,18 +264,7 @@ FunctionTemplateDecl::newCommon(ASTConte
 }
 
 void FunctionTemplateDecl::LoadLazySpecializations() const {
-  // Grab the most recent declaration to ensure we've loaded any lazy
-  // redeclarations of this template.
-  //
-  // FIXME: Avoid walking the entire redeclaration chain here.
-  Common *CommonPtr = getMostRecentDecl()->getCommonPtr();
-  if (CommonPtr->LazySpecializations) {
-ASTContext &Context = getASTContext();
-uint32_t *Specs = CommonPtr->LazySpecializations;
-CommonPtr->LazyS

r347304 - Allow force updating the NumCreatedFIDsForFileID.

2018-11-20 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Nov 20 05:53:20 2018
New Revision: 347304

URL: http://llvm.org/viewvc/llvm-project?rev=347304&view=rev
Log:
Allow force updating the NumCreatedFIDsForFileID.

Our internal clients implement parsing cache based on FileID. In order for the
Preprocessor to reenter the cached FileID it needs to reset its
NumCreatedFIDsForFileID.

Differential Revision: https://reviews.llvm.org/D51295

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=347304&r1=347303&r2=347304&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Nov 20 05:53:20 2018
@@ -1024,13 +1024,14 @@ public:
 
   /// Set the number of FileIDs (files and macros) that were created
   /// during preprocessing of \p FID, including it.
-  void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs) const {
+  void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs,
+  bool Force = false) const {
 bool Invalid = false;
 const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid);
 if (Invalid || !Entry.isFile())
   return;
 
-assert(Entry.getFile().NumCreatedFIDs == 0 && "Already set!");
+assert((Force || Entry.getFile().NumCreatedFIDs == 0) && "Already set!");
 const_cast(Entry.getFile()).NumCreatedFIDs = NumFIDs;
   }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311843 - D34444: Teach codegen to work in incremental processing mode.

2017-08-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Aug 27 03:58:03 2017
New Revision: 311843

URL: http://llvm.org/viewvc/llvm-project?rev=311843&view=rev
Log:
D3: Teach codegen to work in incremental processing mode.

When isIncrementalProcessingEnabled is on we might want to produce multiple
llvm::Modules. This patch allows the clients to start a new llvm::Module,
allowing CodeGen to continue working after a HandleEndOfTranslationUnit call.

This should give the necessary facilities to write a unittest for D34059.

As discussed in the review this is meant to give us a way to proceed forward
in our efforts to upstream our interpreter-related patches. The design of this
will likely change soon.

Modified:
cfe/trunk/include/clang/CodeGen/ModuleBuilder.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp

Modified: cfe/trunk/include/clang/CodeGen/ModuleBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ModuleBuilder.h?rev=311843&r1=311842&r2=311843&view=diff
==
--- cfe/trunk/include/clang/CodeGen/ModuleBuilder.h (original)
+++ cfe/trunk/include/clang/CodeGen/ModuleBuilder.h Sun Aug 27 03:58:03 2017
@@ -84,6 +84,10 @@ public:
   ///   code generator will schedule the entity for emission if a
   ///   definition has been registered with this code generator.
   llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition);
+
+  /// Create a new \c llvm::Module after calling HandleTranslationUnit. This
+  /// enable codegen in interactive processing environments.
+  llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C);
 };
 
 /// CreateLLVMCodeGen - Create a CodeGenerator instance.

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=311843&r1=311842&r2=311843&view=diff
==
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Sun Aug 27 03:58:03 2017
@@ -119,6 +119,14 @@ namespace {
   return Builder->GetAddrOfGlobal(global, 
ForDefinition_t(isForDefinition));
 }
 
+llvm::Module *StartModule(llvm::StringRef ModuleName,
+  llvm::LLVMContext &C) {
+  assert(!M && "Replacing existing Module?");
+  M.reset(new llvm::Module(ModuleName, C));
+  Initialize(*Ctx);
+  return M.get();
+}
+
 void Initialize(ASTContext &Context) override {
   Ctx = &Context;
 
@@ -317,6 +325,11 @@ llvm::Constant *CodeGenerator::GetAddrOf
->GetAddrOfGlobal(global, isForDefinition);
 }
 
+llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName,
+ llvm::LLVMContext &C) {
+  return static_cast(this)->StartModule(ModuleName, C);
+}
+
 CodeGenerator *clang::CreateLLVMCodeGen(
 DiagnosticsEngine &Diags, llvm::StringRef ModuleName,
 const HeaderSearchOptions &HeaderSearchOpts,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311844 - D34059: Get the file name for the symbol from the Module, not the SourceManager.

2017-08-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Aug 27 04:27:30 2017
New Revision: 311844

URL: http://llvm.org/viewvc/llvm-project?rev=311844&view=rev
Log:
D34059: Get the file name for the symbol from the Module, not the SourceManager.

This allows multi-module / incremental compilation environments to have unique
initializer symbols.

Patch by Axel Naumann with minor modifications by me!

Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/unittests/CodeGen/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=311844&r1=311843&r2=311844&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Aug 27 04:27:30 2017
@@ -487,16 +487,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
 PrioritizedCXXGlobalInits.clear();
   }
 
-  SmallString<128> FileName;
-  SourceManager &SM = Context.getSourceManager();
-  if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-// Include the filename in the symbol name. Including "sub_" matches gcc 
and
-// makes sure these symbols appear lexicographically behind the symbols 
with
-// priority emitted above.
-FileName = llvm::sys::path::filename(MainFile->getName());
-  } else {
+  // Include the filename in the symbol name. Including "sub_" matches gcc and
+  // makes sure these symbols appear lexicographically behind the symbols with
+  // priority emitted above.
+  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
+  if (FileName.empty())
 FileName = "";
-  }
 
   for (size_t i = 0; i < FileName.size(); ++i) {
 // Replace everything that's not [a-zA-Z0-9._] with a _. This set happens

Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=311844&r1=311843&r2=311844&view=diff
==
--- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Sun Aug 27 04:27:30 2017
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(ClangCodeGenTests
   BufferSourceTest.cpp
+  IncrementalProcessingTest.cpp
   )
 
 target_link_libraries(ClangCodeGenTests


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311845 - Add forgotten file in r311844.

2017-08-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Sun Aug 27 04:31:01 2017
New Revision: 311845

URL: http://llvm.org/viewvc/llvm-project?rev=311845&view=rev
Log:
Add forgotten file in r311844.

Added:
cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp

Added: cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp?rev=311845&view=auto
==
--- cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp (added)
+++ cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp Sun Aug 27 
04:31:01 2017
@@ -0,0 +1,174 @@
+//=== unittests/CodeGen/IncrementalProcessingTest.cpp - IncrementalCodeGen 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/Parser.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+
+#include 
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+// Incremental processing produces several modules, all using the same "main
+// file". Make sure CodeGen can cope with that, e.g. for static initializers.
+const char TestProgram1[] =
+"extern \"C\" int funcForProg1() { return 17; }\n"
+"struct EmitCXXGlobalInitFunc1 {\n"
+"   EmitCXXGlobalInitFunc1() {}\n"
+"} test1;";
+
+const char TestProgram2[] =
+"extern \"C\" int funcForProg2() { return 42; }\n"
+"struct EmitCXXGlobalInitFunc2 {\n"
+"   EmitCXXGlobalInitFunc2() {}\n"
+"} test2;";
+
+
+/// An incremental version of ParseAST().
+static std::unique_ptr
+IncrementalParseAST(CompilerInstance& CI, Parser& P,
+CodeGenerator& CG, const char* code) {
+  static int counter = 0;
+  struct IncreaseCounterOnRet {
+~IncreaseCounterOnRet() {
+  ++counter;
+}
+  } ICOR;
+
+  Sema& S = CI.getSema();
+  clang::SourceManager &SM = S.getSourceManager();
+  if (!code) {
+// Main file
+SM.setMainFileID(SM.createFileID(
+llvm::MemoryBuffer::getMemBuffer(""), clang::SrcMgr::C_User));
+
+S.getPreprocessor().EnterMainSourceFile();
+P.Initialize();
+  } else {
+FileID FID = SM.createFileID(
+llvm::MemoryBuffer::getMemBuffer(code), clang::SrcMgr::C_User);
+SourceLocation MainStartLoc = SM.getLocForStartOfFile(SM.getMainFileID());
+SourceLocation InclLoc = MainStartLoc.getLocWithOffset(counter);
+S.getPreprocessor().EnterSourceFile(FID, 0, InclLoc);
+  }
+
+  ExternalASTSource *External = S.getASTContext().getExternalSource();
+  if (External)
+External->StartTranslationUnit(&CG);
+
+  Parser::DeclGroupPtrTy ADecl;
+  for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl); !AtEOF;
+   AtEOF = P.ParseTopLevelDecl(ADecl)) {
+// If we got a null return and something *was* parsed, ignore it.  This
+// is due to a top-level semicolon, an action override, or a parse error
+// skipping something.
+if (ADecl && !CG.HandleTopLevelDecl(ADecl.get()))
+  return nullptr;
+  }
+
+  // Process any TopLevelDecls generated by #pragma weak.
+  for (Decl *D : S.WeakTopLevelDecls())
+CG.HandleTopLevelDecl(DeclGroupRef(D));
+
+  CG.HandleTranslationUnit(S.getASTContext());
+
+  std::unique_ptr M(CG.ReleaseModule());
+  // Switch to next module.
+  CG.StartModule("incremental-module-" + std::to_string(counter),
+ M->getContext());
+  return M;
+}
+
+const Function* getGlobalInit(llvm::Module& M) {
+  for (const auto& Func: M)
+if (Func.hasName() && Func.getName().startswith("_GLOBAL__sub_I_"))
+  return &Func;
+
+  return nullptr;
+}
+
+TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) {
+LLVMContext Context;
+CompilerInstance compiler;
+
+compiler.createDiagnostics();
+compiler.getLangOpts().CPlusPlus = 1;
+compiler.getLangOpts().CPlusPlus11 = 1;
+
+compiler.getTargetOpts().Triple = llvm::Triple::normalize(
+llvm::sys::getProcessTriple());
+compiler.setTarget(clang::TargetInfo::CreateTargetInfo(
+  compiler.getDiagnostics(),
+  std::make_shared(
+compiler.getTargetOpts(;
+
+compiler.createFileManager();
+compiler.createSourceManager(compiler.getFileManager());
+compiler.createPreprocessor(clang::TU_Prefix);
+compiler.getPreprocessor().enableIncrementalProcessing();
+
+compiler.createASTContext();
+

r365153 - [modules] Add PP callbacks for entering and leaving a submodule.

2019-07-04 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Jul  4 12:06:52 2019
New Revision: 365153

URL: http://llvm.org/viewvc/llvm-project?rev=365153&view=rev
Log:
[modules] Add PP callbacks for entering and leaving a submodule.


Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=365153&r1=365152&r2=365153&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Thu Jul  4 12:06:52 2019
@@ -132,6 +132,28 @@ public:
   SrcMgr::CharacteristicKind FileType) {
   }
 
+  /// Callback invoked whenever a submodule was entered.
+  ///
+  /// \param M The submodule we have entered.
+  ///
+  /// \param ImportLoc The location of import directive token.
+  ///
+  /// \param ForPragma If entering from pragma directive.
+  ///
+  virtual void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
+bool ForPragma) { }
+
+  /// Callback invoked whenever a submodule was left.
+  ///
+  /// \param M The submodule we have left.
+  ///
+  /// \param ImportLoc The location of import directive token.
+  ///
+  /// \param ForPragma If entering from pragma directive.
+  ///
+  virtual void LeftSubmodule(Module *M, SourceLocation ImportLoc,
+ bool ForPragma) { }
+
   /// Callback invoked whenever there was an explicit module-import
   /// syntax.
   ///
@@ -395,6 +417,18 @@ public:
Imported, FileType);
   }
 
+  void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
+bool ForPragma) override {
+First->EnteredSubmodule(M, ImportLoc, ForPragma);
+Second->EnteredSubmodule(M, ImportLoc, ForPragma);
+  }
+
+  void LeftSubmodule(Module *M, SourceLocation ImportLoc,
+ bool ForPragma) override {
+First->LeftSubmodule(M, ImportLoc, ForPragma);
+Second->LeftSubmodule(M, ImportLoc, ForPragma);
+  }
+
   void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path,
 const Module *Imported) override {
 First->moduleImport(ImportLoc, Path, Imported);

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=365153&r1=365152&r2=365153&view=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Jul  4 12:06:52 2019
@@ -647,6 +647,8 @@ void Preprocessor::EnterSubmodule(Module
 BuildingSubmoduleStack.push_back(
 BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
   PendingModuleMacroNames.size()));
+if (Callbacks)
+  Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
 return;
   }
 
@@ -691,6 +693,9 @@ void Preprocessor::EnterSubmodule(Module
   BuildingSubmoduleInfo(M, ImportLoc, ForPragma, CurSubmoduleState,
 PendingModuleMacroNames.size()));
 
+  if (Callbacks)
+Callbacks->EnteredSubmodule(M, ImportLoc, ForPragma);
+
   // Switch to this submodule as the current submodule.
   CurSubmoduleState = &State;
 
@@ -731,6 +736,10 @@ Module *Preprocessor::LeaveSubmodule(boo
 // are tracking macro visibility, don't build any, and preserve the list
 // of pending names for the surrounding submodule.
 BuildingSubmoduleStack.pop_back();
+
+if (Callbacks)
+  Callbacks->LeftSubmodule(LeavingMod, ImportLoc, ForPragma);
+
 makeModuleVisible(LeavingMod, ImportLoc);
 return LeavingMod;
   }
@@ -815,6 +824,9 @@ Module *Preprocessor::LeaveSubmodule(boo
 
   BuildingSubmoduleStack.pop_back();
 
+  if (Callbacks)
+Callbacks->LeftSubmodule(LeavingMod, ImportLoc, ForPragma);
+
   // A nested #include makes the included submodule visible.
   makeModuleVisible(LeavingMod, ImportLoc);
   return LeavingMod;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335853 - [ODRHash] Do not rely on Type* when computing the hash.

2018-06-28 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Jun 28 06:28:44 2018
New Revision: 335853

URL: http://llvm.org/viewvc/llvm-project?rev=335853&view=rev
Log:
[ODRHash] Do not rely on Type* when computing the hash.

ODRHash aims to provide Cross-TU stable hashing. Making clang::Type pointer
part of the hash connects (remotely) the ODRHash with the TU-specific
::Profile hasher.

r332281 exposed the issue by changing the way the ASTContext different
elaborated types if there is an owning tag. In that case, ODRHash stores two
 different types in its TypeMap which yields false ODR violation in modules.

The current state of implementation shouldn't need the TypeMap concept
anymore. Rip it out.

Differential Revision: https://reviews.llvm.org/D48524

Added:
cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/
cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/first.h
cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/module.modulemap
cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/second.h
cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/textual_stat.h
cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/textual_time.h
cfe/trunk/test/Modules/odr_hash-elaborated-types.cpp
Modified:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=335853&r1=335852&r2=335853&view=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Thu Jun 28 06:28:44 2018
@@ -40,7 +40,6 @@ class ODRHash {
   // Use DenseMaps to convert from DeclarationName and Type pointers
   // to an index value.
   llvm::DenseMap DeclNameMap;
-  llvm::DenseMap TypeMap;
 
   // Save space by processing bools at the end.
   llvm::SmallVector Bools;

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=335853&r1=335852&r2=335853&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jun 28 06:28:44 2018
@@ -180,7 +180,6 @@ void ODRHash::AddTemplateParameterList(c
 
 void ODRHash::clear() {
   DeclNameMap.clear();
-  TypeMap.clear();
   Bools.clear();
   ID.clear();
 }
@@ -770,14 +769,6 @@ public:
 
 void ODRHash::AddType(const Type *T) {
   assert(T && "Expecting non-null pointer.");
-  auto Result = TypeMap.insert(std::make_pair(T, TypeMap.size()));
-  ID.AddInteger(Result.first->second);
-  // On first encounter of a Type pointer, process it.  Every time afterwards,
-  // only the index value is needed.
-  if (!Result.second) {
-return;
-  }
-
   ODRTypeVisitor(ID, *this).Visit(T);
 }
 

Added: cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/first.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/first.h?rev=335853&view=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/first.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/first.h Thu Jun 28 
06:28:44 2018
@@ -0,0 +1,6 @@
+#ifndef FIRST
+#define FIRST
+
+#include "textual_time.h"
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/module.modulemap?rev=335853&view=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/module.modulemap 
(added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/module.modulemap 
Thu Jun 28 06:28:44 2018
@@ -0,0 +1,5 @@
+module M {
+  module first { header "first.h" export *}
+  module second { header "second.h" export *}
+  export *
+}

Added: cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/second.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/second.h?rev=335853&view=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/second.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/second.h Thu Jun 28 
06:28:44 2018
@@ -0,0 +1,6 @@
+#ifndef SECOND
+#define SECOND
+
+#include "textual_stat.h"
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/textual_stat.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/textual_stat.h?rev=335853&view=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-elaborated-types/textual_stat.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-elabor

r337353 - [modules] Print input files when -module-file-info file switch is passed.

2018-07-17 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Jul 17 23:49:33 2018
New Revision: 337353

URL: http://llvm.org/viewvc/llvm-project?rev=337353&view=rev
Log:
[modules] Print input files when -module-file-info file switch is passed.

This patch improves traceability of duplicated header files which end
up in multiple pcms.

Differential Revision: https://reviews.llvm.org/D47118



Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/test/Modules/module_file_info.m

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=337353&r1=337352&r2=337353&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Tue Jul 17 23:49:33 2018
@@ -560,6 +560,45 @@ namespace {
 
   Out << "\n";
 }
+
+/// Tells the \c ASTReaderListener that we want to receive the
+/// input files of the AST file via \c visitInputFile.
+bool needsInputFileVisitation() override { return true; }
+
+/// Tells the \c ASTReaderListener that we want to receive the
+/// input files of the AST file via \c visitInputFile.
+bool needsSystemInputFileVisitation() override { return true; }
+
+/// Indicates that the AST file contains particular input file.
+///
+/// \returns true to continue receiving the next input file, false to stop.
+bool visitInputFile(StringRef Filename, bool isSystem,
+bool isOverridden, bool isExplicitModule) override {
+
+  Out.indent(2) << "Input file: " << Filename;
+
+  if (isSystem || isOverridden || isExplicitModule) {
+Out << " [";
+if (isSystem) {
+  Out << "System";
+  if (isOverridden || isExplicitModule)
+Out << ", ";
+}
+if (isOverridden) {
+  Out << "Overridden";
+  if (isExplicitModule)
+Out << ", ";
+}
+if (isExplicitModule)
+  Out << "ExplicitModule";
+
+Out << "]";
+  }
+
+  Out << "\n";
+
+  return true;
+}
 #undef DUMP_BOOLEAN
   };
 }

Modified: cfe/trunk/test/Modules/module_file_info.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module_file_info.m?rev=337353&r1=337352&r2=337353&view=diff
==
--- cfe/trunk/test/Modules/module_file_info.m (original)
+++ cfe/trunk/test/Modules/module_file_info.m Tue Jul 17 23:49:33 2018
@@ -43,6 +43,16 @@
 // CHECK:   Predefined macros:
 // CHECK: -DBLARG
 // CHECK: -DWIBBLE=WOBBLE
+// CHECK: Input file: {{.*}}DependsOnModulePrivate.h
+// CHECK-NEXT: Input file: {{.*}}Other.h
+// CHECK-NEXT: Input file: {{.*}}SubFramework.h
+// CHECK-NEXT: Input file: {{.*}}not_coroutines.h
+// CHECK-NEXT: Input file: {{.*}}not_cxx.h
+// CHECK-NEXT: Input file: {{.*}}other.h
+// CHECK-NEXT: Input file: {{.*}}module.map
+// CHECK-NEXT: Input file: {{.*}}DependsOnModule.h
+// CHECK-NEXT: Input file: {{.*}}module_private.map
+// CHECK-NEXT: Input file: {{.*}}module.map
 
 // CHECK: Diagnostic options:
 // CHECK:   IgnoreWarnings: Yes


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D31702: Append -w when LLVM_ENABLE_WARNINGS is Off.

2020-06-04 Thread Vassil Vassilev via cfe-commits

On 6/4/20 6:58 AM, Sean Silva wrote:

Can we revert this?

In our downstream project we were bitten by this: 
https://github.com/google/mlir-npcomp/commit/cd7258dbd48bd9254c6741cab2d3f4e36cbd3c84


It seems that now by default anybody that depends on LLVM with CMake 
will globally get a `-w` passed to their compiler. That doesn't seem 
like good behavior.



  Wouldn't that be the case for all append clauses in that file?




-- Sean Silva

On Wed, Apr 12, 2017 at 1:56 PM Vassil Vassilev via Phabricator via 
llvm-commits > wrote:


v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r300100.


https://reviews.llvm.org/D31702



___
llvm-commits mailing list
llvm-comm...@lists.llvm.org 
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 46ea465 - Return false if the identifier is not in the global module index.

2020-06-22 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2020-06-22T08:03:11Z
New Revision: 46ea465b5b741fb0bf6e2cedd5cd6bf7026cd3c6

URL: 
https://github.com/llvm/llvm-project/commit/46ea465b5b741fb0bf6e2cedd5cd6bf7026cd3c6
DIFF: 
https://github.com/llvm/llvm-project/commit/46ea465b5b741fb0bf6e2cedd5cd6bf7026cd3c6.diff

LOG: Return false if the identifier is not in the global module index.

This allows clients to use the idiom:

if (GlobalIndex->lookupIdentifier(Name, FoundModules)) {
  // work on the FoundModules
}

This is also a minor performance improvent for clang.

Differential Revision: https://reviews.llvm.org/D81077

Added: 


Modified: 
clang/lib/Serialization/GlobalModuleIndex.cpp

Removed: 




diff  --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index 958cca734572..9192b3b476bb 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -321,7 +321,7 @@ bool GlobalModuleIndex::lookupIdentifier(StringRef Name, 
HitSet &Hits) {
 = *static_cast(IdentifierIndex);
   IdentifierIndexTable::iterator Known = Table.find(Name);
   if (Known == Table.end()) {
-return true;
+return false;
   }
 
   SmallVector ModuleIDs = *Known;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-26 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:102
@@ -95,5 +101,3 @@
 // as a note.
-DiagEngine.Report(Group.Sequences.front().getStartLoc(), WarnID);
-for (unsigned i = 1; i < Group.Sequences.size(); ++i) {
-  DiagEngine.Report(Group.Sequences[i].getStartLoc(), NoteID);
-}
+static const char *const MsgSingular = "Clone of this code was detected";
+static const char *const MsgPlural = "Clones of this code were detected";

I was thinking whether we shouldn't say `code snippet` or something that 
qualifies code, as it is too generic term.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:112
@@ +111,3 @@
+  R->addNote("Code clone here",
+  makeLocation(Group.Sequences[i], Mgr),
+  Group.Sequences[i].getSourceRange());

Is that missing an indent?


https://reviews.llvm.org/D24916



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-05 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 73688.
v.g.vassilev added a comment.

Address some comments and publish current progress.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/Inputs/merge-class-definition-visibility/a.h
  test/Modules/Inputs/merge-class-definition-visibility/c.h
  test/Modules/merge-class-definition-visibility.cpp
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/merge-class-definition-visibility.cpp
===
--- test/Modules/merge-class-definition-visibility.cpp
+++ test/Modules/merge-class-definition-visibility.cpp
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/merge-class-definition-visibility/modmap \
-// RUN:-I%S/Inputs/merge-class-definition-visibility \
+// RUN:-std=c++1z -I%S/Inputs/merge-class-definition-visibility \
 // RUN:-fmodules-cache-path=%t %s -verify \
 // RUN:-fmodules-local-submodule-visibility
 // expected-no-diagnostics
Index: test/Modules/Inputs/merge-class-definition-visibility/c.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/c.h
+++ test/Modules/Inputs/merge-class-definition-visibility/c.h
@@ -1 +1,3 @@
 struct A;
+
+inline int var_A;
Index: test/Modules/Inputs/merge-class-definition-visibility/a.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/a.h
+++ test/Modules/Inputs/merge-class-definition-visibility/a.h
@@ -1 +1,3 @@
 struct A {};
+
+inline int var_A = 2;
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+  template 
+  static
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+};
+template 
+template 
+const bool D<_Alloc>::F<_Alloc2>::value;
+
+template  class vector {
+public:
+  vector(int);
+  vector(vector &) : vector(D::_S_select((bool)0)) {}
+};
+}
+#endif // VECTOR
\ No newline at end of file
Index: test/Modules/Inputs/PR28752/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: test/Modules/Inputs/PR28752/a.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/a.h
@@ -0,0 +1 @@
+#include 
Index: test/Modules/Inputs/PR28752/Subdir1/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/module.modulemap
@@ -0,0 +1,5 @@
+module b {
+  module "b.h" { header "b.h" export * }
+  module "c.h" { header "c.h" export * }
+  export *
+}
Index: test/Modules/Inputs/PR28752/Subdir1/b.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/b.h
@@ -0,0 +1 @@
+#include 
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -893,6 +893,7 @@
   Record.push_back(D->getStorageClass());
   Record.push_back(D->getTSCSpec());
   Record.push_back(D->getInitStyle());
+  Record.push_back(D->isThisDeclarationADemotedDefinition());
   if (!isa(D))

r283444 - [modules] Allow VarDecls with initializers to use special var abbrev.

2016-10-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Oct  6 08:04:54 2016
New Revision: 283444

URL: http://llvm.org/viewvc/llvm-project?rev=283444&view=rev
Log:
[modules] Allow VarDecls with initializers to use special var abbrev.

Update storage sizes to fit the (past) changes in the VarDecl's data model.
Update some comments.

Patch partially reviewed by Richard Smith as part of 
https://reviews.llvm.org/D24508

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=283444&r1=283443&r2=283444&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Oct  6 08:04:54 2016
@@ -1236,7 +1236,7 @@ ASTDeclReader::RedeclarableResult ASTDec
 
   if (uint64_t Val = Record[Idx++]) {
 VD->setInit(Reader.ReadExpr(F));
-if (Val > 1) {
+if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3
   EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
   Eval->CheckedICE = true;
   Eval->IsICE = Val == 3;

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=283444&r1=283443&r2=283444&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Oct  6 08:04:54 2016
@@ -942,8 +942,6 @@ void ASTDeclWriter::VisitVarDecl(VarDecl
   D->getDeclName().getNameKind() == DeclarationName::Identifier &&
   !D->hasExtInfo() &&
   D->getFirstDecl() == D->getMostRecentDecl() &&
-  D->getInitStyle() == VarDecl::CInit &&
-  D->getInit() == nullptr &&
   D->getKind() == Decl::Var &&
   !D->isInline() &&
   !D->isConstexpr() &&
@@ -1880,9 +1878,9 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
   Abv->Add(BitCodeAbbrevOp(0));   // hasExtInfo
   // VarDecl
-  Abv->Add(BitCodeAbbrevOp(0));   // StorageClass
-  Abv->Add(BitCodeAbbrevOp(0));   // getTSCSpec
-  Abv->Add(BitCodeAbbrevOp(0));   // 
hasCXXDirectInitializer
+  Abv->Add(BitCodeAbbrevOp(0));   // SClass
+  Abv->Add(BitCodeAbbrevOp(0));   // TSCSpec
+  Abv->Add(BitCodeAbbrevOp(0));   // InitStyle
   Abv->Add(BitCodeAbbrevOp(0));   // Linkage
   Abv->Add(BitCodeAbbrevOp(0));   // HasInit
   Abv->Add(BitCodeAbbrevOp(0));   // 
HasMemberSpecializationInfo
@@ -1956,9 +1954,9 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
   Abv->Add(BitCodeAbbrevOp(0));   // hasExtInfo
   // VarDecl
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // StorageClass
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getTSCSpec
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // CXXDirectInitializer
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
@@ -1969,8 +1967,8 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
   Abv->Add(BitCodeAbbrevOp(0)); // 
isPrevDeclInSameScope
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasInit
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasMemberSpecInfo
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
   // Type Source Info
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283448 - Allocate after the early exit checks. NFC.

2016-10-06 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Thu Oct  6 08:18:06 2016
New Revision: 283448

URL: http://llvm.org/viewvc/llvm-project?rev=283448&view=rev
Log:
Allocate after the early exit checks. NFC.

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=283448&r1=283447&r2=283448&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Oct  6 08:18:06 2016
@@ -2320,8 +2320,6 @@ template
 void ASTDeclReader::mergeRedeclarable(Redeclarable *DBase,
   RedeclarableResult &Redecl,
   DeclID TemplatePatternID) {
-  T *D = static_cast(DBase);
-
   // If modules are not available, there is no reason to perform this merge.
   if (!Reader.getContext().getLangOpts().Modules)
 return;
@@ -2330,6 +2328,8 @@ void ASTDeclReader::mergeRedeclarable(Re
   if (!DBase->isFirstDecl())
 return;
 
+  T *D = static_cast(DBase);
+
   if (auto *Existing = Redecl.getKnownMergeTarget())
 // We already know of an existing declaration we should merge with.
 mergeRedeclarable(D, cast(Existing), Redecl, TemplatePatternID);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-06 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 73803.
v.g.vassilev marked 4 inline comments as done.
v.g.vassilev added a comment.

Rebase, comments some more fixes.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/Inputs/merge-class-definition-visibility/a.h
  test/Modules/Inputs/merge-class-definition-visibility/b.h
  test/Modules/Inputs/merge-class-definition-visibility/c.h
  test/Modules/Inputs/merge-class-definition-visibility/d.h
  test/Modules/Inputs/merge-class-definition-visibility/e.h
  test/Modules/merge-class-definition-visibility.cpp
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/merge-class-definition-visibility.cpp
===
--- test/Modules/merge-class-definition-visibility.cpp
+++ test/Modules/merge-class-definition-visibility.cpp
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/merge-class-definition-visibility/modmap \
-// RUN:-I%S/Inputs/merge-class-definition-visibility \
+// RUN:-std=c++1z -I%S/Inputs/merge-class-definition-visibility \
 // RUN:-fmodules-cache-path=%t %s -verify \
 // RUN:-fmodules-local-submodule-visibility
 // expected-no-diagnostics
@@ -10,6 +10,9 @@
 typedef X XA;
 struct B;
 
+template int n;
+
+
 #include "e.h"
 // Ensure that this triggers the import of the second definition from e.h,
 // which is necessary to make the definition of A visible in the template
@@ -21,3 +24,5 @@
 // and that definition was merged into the canonical definition from b.h,
 // so that becomes visible, and we have a visible definition.
 B b;
+
+void f (int dflt = n) {}
Index: test/Modules/Inputs/merge-class-definition-visibility/e.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/e.h
+++ test/Modules/Inputs/merge-class-definition-visibility/e.h
@@ -1,3 +1,5 @@
 #include "a.h"
 
 struct B {};
+
+template int n;
Index: test/Modules/Inputs/merge-class-definition-visibility/d.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/d.h
+++ test/Modules/Inputs/merge-class-definition-visibility/d.h
@@ -1 +1,3 @@
 struct B {};
+
+template int n;
Index: test/Modules/Inputs/merge-class-definition-visibility/c.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/c.h
+++ test/Modules/Inputs/merge-class-definition-visibility/c.h
@@ -1 +1,3 @@
 struct A;
+
+inline int var_A;
Index: test/Modules/Inputs/merge-class-definition-visibility/b.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/b.h
+++ test/Modules/Inputs/merge-class-definition-visibility/b.h
@@ -2,3 +2,6 @@
 #include "a.h"
 
 struct B {};
+
+template int n;
+int k = n;
Index: test/Modules/Inputs/merge-class-definition-visibility/a.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/a.h
+++ test/Modules/Inputs/merge-class-definition-visibility/a.h
@@ -1 +1,3 @@
 struct A {};
+
+inline int var_A = 2;
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+  template 
+  static
+  typename B:

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-06 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.


> rsmith wrote in SemaTemplate.cpp:509
> This function still appears to be able to return true (indicating to the 
> caller that a diagnostic was produced) without actually producing a 
> diagnostic.

Is it better now?

> rsmith wrote in SemaTemplate.cpp:505
> Why do we not issue a diagnostic in this case for a `VarDecl` when `Complain` 
> is true and no definition is available? It seems like we should either be 
> diagnosing this or asserting that it can't happen.

I believe it is not implemented, i.e. we didn't have this diagnostics when 
`VarDecl::getInstantiatedFromStaticDataMember` is true. I added a FIXME: for a 
future enhancement.

> rsmith wrote in ASTWriterDecl.cpp:896-897
> Sink this flag into the "not for `ParmVarDecl`" block below.

I thought we might need this for c-style `void f(struct S arg)`-like constructs 
where we might need to demote if we merge ParmVarDecls.

> rsmith wrote in ASTWriterDecl.cpp:1965
> Hmm. The width of the `InitStyle` field is definitely wrong right now, but 
> should be fixed separately from this change. It looks like we don't hit this 
> today because we don't use this abbreviation for a variable with an 
> initializer. In addition to fixing the width of this field, we should also 
> remove the `getInit() == nullptr` check when selecting the abbreviation in 
> `ASTDeclWriter::VisitVarDecl`.

Committed in r283444.

https://reviews.llvm.org/D24508



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-10 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 74129.
v.g.vassilev marked 3 inline comments as done.
v.g.vassilev added a comment.

Address comments.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+  template 
+  static
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+};
+template 
+template 
+const bool D<_Alloc>::F<_Alloc2>::value;
+
+template  class vector {
+public:
+  vector(int);
+  vector(vector &) : vector(D::_S_select((bool)0)) {}
+};
+}
+#endif // VECTOR
\ No newline at end of file
Index: test/Modules/Inputs/PR28752/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: test/Modules/Inputs/PR28752/a.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/a.h
@@ -0,0 +1 @@
+#include 
Index: test/Modules/Inputs/PR28752/Subdir1/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/module.modulemap
@@ -0,0 +1,5 @@
+module b {
+  module "b.h" { header "b.h" export * }
+  module "c.h" { header "c.h" export * }
+  export *
+}
Index: test/Modules/Inputs/PR28752/Subdir1/b.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/b.h
@@ -0,0 +1 @@
+#include 
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -894,6 +894,7 @@
   Record.push_back(D->getTSCSpec());
   Record.push_back(D->getInitStyle());
   if (!isa(D)) {
+Record.push_back(D->isThisDeclarationADemotedDefinition());
 Record.push_back(D->isExceptionVariable());
 Record.push_back(D->isNRVOVariable());
 Record.push_back(D->isCXXForRangeDecl());
@@ -998,6 +999,8 @@
   // Check things we know are true of *every* PARM_VAR_DECL, which is more than
   // just us assuming it.
   assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
+  assert(!D->isThisDeclarationADemotedDefinition()
+ && "PARM_VAR_DECL can't be demoted definition.");
   assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
   assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
   assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
@@ -1957,6 +1960,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1216,6 +1216,7 

r283882 - [modules] PR28752: Do not instantiate variable declarations which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 08:57:36 2016
New Revision: 283882

URL: http://llvm.org/viewvc/llvm-project?rev=283882&view=rev
Log:
[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283882&r1=283881&r2=283882&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 08:57:36 2016
@@ -865,6 +865,11 @@ protected:
 
 unsigned : NumVarDeclBits;
 
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,27 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1322,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283882&r1=283881&r2=283882&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 08:57:36 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
+  if (isThisDeclarationADemotedDefinition())
+return DeclarationOnly;
+
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2250,6 +2253,56 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
+VarDecl *VarDecl::getTemplateInstantiationPattern() const {
+  // If it's a variable template specialization, find the template or partial
+  // specialization from which it was instantiated.
+  if (auto *VDTemplSpec = dyn_cast(this)) {
+auto From = VDTemplSpec->getInstantiatedFrom();
+if (auto *VTD = From.dyn_cast()) {
+  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
+if (NewVTD->isMemberSpecialization())
+  break;
+VTD = NewVTD;
+  }
+  return VTD->getTemplatedDecl()->getDefinition();
+ 

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Landed in r283882.




Comment at: include/clang/AST/Decl.h:1222
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");

rsmith wrote:
> You can remove this; it's covered by the next line.
Ok. This would allow calling the method on already demoted definition. Do we 
want to allow that?



Comment at: lib/AST/Decl.cpp:2284
+  while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
+VD = NewVD;
+  return VD->getDefinition();

rsmith wrote:
> Missing a member specialization check here.
Isn't that covered by the cases above? It seems there is no API to make such 
check, here. The current state looks to me consistent with 
`CXXRecordDecl::getTemplateInstantiationPattern` and 
`FunctionDecl::getTemplateInstantiationPattern`.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3086-3090
+  if (CurD->isThisDeclarationADemotedDefinition()) {
+VD->demoteThisDefinitionToDeclaration();
+break;
+  }
+  if (CurD->isThisDeclarationADefinition()) {

rsmith wrote:
> Maybe combine these two `if`s into one, since their bodies are identical?
Good point ;)


https://reviews.llvm.org/D24508



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283887 - r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:09:26 2016
New Revision: 283887

URL: http://llvm.org/viewvc/llvm-project?rev=283887&view=rev
Log:
r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=283887&r1=283886&r2=283887&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 11 10:09:26 2016
@@ -9709,20 +9709,22 @@ void Sema::AddInitializerToDecl(Decl *Re
   // The previous definition is hidden, and multiple definitions are
   // permitted (in separate TUs). Form another definition of it.
 
-  // Demote the newly parsed definition to a fake declaration.
-  if (!VDecl->isThisDeclarationADemotedDefinition())
-VDecl->demoteThisDefinitionToDeclaration();
+  if (!isa(VDecl)) {
+// Demote the newly parsed definition to a fake declaration.
+if (!VDecl->isThisDeclarationADemotedDefinition())
+  VDecl->demoteThisDefinitionToDeclaration();
 
-  // Make the definition visible from the point of the demotion on.
-  assert (!Hidden || Def == Hidden &&
-  "We were suggested another hidden definition!");
-  makeMergedDefinitionVisible(Def, VDecl->getLocation());
+// Make the definition visible from the point of the demotion on.
+assert (!Hidden || Def == Hidden &&
+"We were suggested another hidden definition!");
+makeMergedDefinitionVisible(Def, VDecl->getLocation());
 
-  // If this is a variable template definition, make its enclosing template
-  // visible.
-  if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
-if (VarPattern->isThisDeclarationADefinition())
-  makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+// If this is a variable template definition, make its enclosing 
template
+// visible.
+if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
+  if (VarPattern->isThisDeclarationADefinition())
+makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+  }
 } else {
   Diag(VDecl->getLocation(), diag::err_redefinition)
 << VDecl->getDeclName();


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283890 - Revert r283887 and r283882, until the issue is understood and fixed.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:51:06 2016
New Revision: 283890

URL: http://llvm.org/viewvc/llvm-project?rev=283890&view=rev
Log:
Revert r283887 and r283882, until the issue is understood and fixed.

Removed:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283890&r1=283889&r2=283890&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 10:51:06 2016
@@ -865,11 +865,6 @@ protected:
 
 unsigned : NumVarDeclBits;
 
-// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
-/// \brief Whether this variable is a definition which was demoted due to
-/// module merge.
-unsigned IsThisDeclarationADemotedDefinition : 1;
-
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1203,27 +1198,12 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
+
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
-  /// \brief If this definition should pretend to be a declaration.
-  bool isThisDeclarationADemotedDefinition() const {
-return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
-  }
-
-  /// \brief This is a definition which should be demoted to a declaration.
-  ///
-  /// In some cases (mostly module merging) we can end up with two visible
-  /// definitions one of which needs to be demoted to a declaration to keep
-  /// the AST invariants.
-  void demoteThisDefinitionToDeclaration() {
-assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
-assert (isThisDeclarationADefinition() && "Not a definition!");
-NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
-  }
-
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1322,10 +1302,6 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
-  /// \brief Retrieve the variable declaration from which this variable could
-  /// be instantiated, if it is an instantiation (rather than a non-template).
-  VarDecl *getTemplateInstantiationPattern() const;
-
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283890&r1=283889&r2=283890&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 10:51:06 2016
@@ -1926,9 +1926,6 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
-  if (isThisDeclarationADemotedDefinition())
-return DeclarationOnly;
-
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2253,56 +2250,6 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
-VarDecl *VarDecl::getTemplateInstantiationPattern() const {
-  // If it's a variable template specialization, find the template or partial
-  // specialization from which it was instantiated.
-  if (auto *VDTemplSpec = dyn_cast(this)) {
-auto From = VDTemplSpec->getInstantiatedFrom();
-if (auto *VTD = From.dyn_cast()) {
-  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
-if (NewVTD->isMemberSpecialization())
-  break;
-VTD = NewVTD;
-  }
-  return VTD->getTemplatedDecl()->getDefinition();
-}
-if (auto *VTPSD =
-From.dyn_cast()) {
-  while (auto *NewVTPSD = VTPSD->getInstantiatedFromMember()) {
-if (NewVTPSD->isMemberSpecialization())
-  break;
-VTPSD = NewVTPSD;
-  }
-  return VTPSD->getDefinition();
-}
-  }
-
-  if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) {
-if (isTemplateInstantiation(MSInfo->getTemplateSpecializationKind())) {
-  VarDecl *VD = getInstantiatedFromStat

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-12 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 74353.
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

We should not access the IsThisDeclarationADemotedDefinition bits if the decl 
is ParmVarDecl.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+  template 
+  static
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+};
+template 
+template 
+const bool D<_Alloc>::F<_Alloc2>::value;
+
+template  class vector {
+public:
+  vector(int);
+  vector(vector &) : vector(D::_S_select((bool)0)) {}
+};
+}
+#endif // VECTOR
\ No newline at end of file
Index: test/Modules/Inputs/PR28752/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: test/Modules/Inputs/PR28752/a.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/a.h
@@ -0,0 +1 @@
+#include 
Index: test/Modules/Inputs/PR28752/Subdir1/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/module.modulemap
@@ -0,0 +1,5 @@
+module b {
+  module "b.h" { header "b.h" export * }
+  module "c.h" { header "c.h" export * }
+  export *
+}
Index: test/Modules/Inputs/PR28752/Subdir1/b.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/b.h
@@ -0,0 +1 @@
+#include 
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -894,6 +894,7 @@
   Record.push_back(D->getTSCSpec());
   Record.push_back(D->getInitStyle());
   if (!isa(D)) {
+Record.push_back(D->isThisDeclarationADemotedDefinition());
 Record.push_back(D->isExceptionVariable());
 Record.push_back(D->isNRVOVariable());
 Record.push_back(D->isCXXForRangeDecl());
@@ -998,6 +999,8 @@
   // Check things we know are true of *every* PARM_VAR_DECL, which is more than
   // just us assuming it.
   assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
+  assert(!D->isThisDeclarationADemotedDefinition()
+ && "PARM_VAR_DECL can't be demoted definition.");
   assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
   assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
   assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
@@ -1957,6 +1960,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/

r284008 - Reinstate r283887 and r283882.

2016-10-12 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Wed Oct 12 06:57:08 2016
New Revision: 284008

URL: http://llvm.org/viewvc/llvm-project?rev=284008&view=rev
Log:
Reinstate r283887 and r283882.

Original message:
"[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!"

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Oct 12 06:57:08 2016
@@ -865,6 +865,11 @@ protected:
 
 unsigned : NumVarDeclBits;
 
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Oct 12 06:57:08 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
+  if (isThisDeclarationADemotedDefinition())
+return DeclarationOnly;
+
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2250,6 +2253,56 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
+VarDecl *VarDecl::getTemplateInstantiationPattern() const {
+  // If it's a variable template specialization, find the template or partial
+  // specialization from which it was instantiated.
+  if (auto *VDTemplSpec = dyn_cast(this)) {
+auto From = VDTemplSpec->getInstantiatedFrom();
+if (auto *VTD = From.dyn_cast()) {
+  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
+if (NewVTD->isMemberSpecialization())
+  break;
+VTD = NewVTD;
+   

[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-12 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev marked an inline comment as done.
v.g.vassilev added a comment.

Relanded in r284008.


https://reviews.llvm.org/D24508



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284008 - Reinstate r283887 and r283882.

2016-10-12 Thread Vassil Vassilev via cfe-commits

Hi Manman,
On 12/10/16 20:28, Manman wrote:

Hi Vassil,

Any change between this commit and “r283887 + r283882”?

The only extra change is in:

+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }

The old patch failed because we read the 
IsThisDeclarationADemotedDefinition bit of ParmVarDecls. We allow 
demoting only VarDecls, which are not ParmVarDecls, and thus we 
serialize/deserialize this bit only for non ParmVarDecls. Reading the 
IsThisDeclarationADemotedDefinition of ParmVarDecls caused random behavior.


Cheers,
Vassil

And what was the issue that caused the revert?

Thanks,
Manman


On Oct 12, 2016, at 4:57 AM, Vassil Vassilev via cfe-commits 
 wrote:

Author: vvassilev
Date: Wed Oct 12 06:57:08 2016
New Revision: 284008

URL: http://llvm.org/viewvc/llvm-project?rev=284008&view=rev
Log:
Reinstate r283887 and r283882.

Original message:
"[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!"

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Oct 12 06:57:08 2016
@@ -865,6 +865,11 @@ protected:

 unsigned : NumVarDeclBits;

+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }

+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }

+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=284008&r1=284007&r2=284008&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Oct 12 06:57:08 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial sp

[PATCH] D7842: Make clang-format-diff compatible with Python 3.4

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a subscriber: djasper.
v.g.vassilev added a comment.

I think @djasper could help with this review.


https://reviews.llvm.org/D7842



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D7842: Make clang-format-diff compatible with Python 3.4

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

This patch needs rebasing.


https://reviews.llvm.org/D7842



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

The print related changes were added in in r280240 
(https://reviews.llvm.org/D23319). Could you rebase the patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Thanks I am closing it!


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25602: Do not reset TUScope when we are in incremental processing mode.

2016-10-14 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added a reviewer: rsmith.
v.g.vassilev added a subscriber: cfe-commits.

We are using this in the context of cling, where we keep the compiler instance 
alive after EOF.

The incremental processing part in clang was done mostly by me and this patch 
LGTM, but I'd like to go under a formal review procedure.


https://reviews.llvm.org/D25602

Files:
  lib/Sema/Sema.cpp


Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -710,7 +710,8 @@
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -909,7 +910,8 @@
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 


Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -710,7 +710,8 @@
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -909,7 +910,8 @@
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25604: Add support for Mageia Linux

2016-10-14 Thread Vassil Vassilev via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: chandlerc, rsmith.
v.g.vassilev added a subscriber: cfe-commits.
v.g.vassilev set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D25604

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1509,6 +1509,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu",
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1517,6 +1518,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu",
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1509,6 +1509,7 @@
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
+  "x86_64-mageia-linux-gnu",
   "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
@@ -1517,6 +1518,7 @@
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
   "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
+  "i586-mageia-linux-gnu",
   "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284284 - Reinstate r284008 reverted in r284081, with two fixes:

2016-10-15 Thread Vassil Vassilev via cfe-commits

Thanks!

When calling makeMergedDefinitionVisible shouldn't we get the template 
instantiation pattern?

On 14/10/16 23:41, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri Oct 14 16:41:24 2016
New Revision: 284284

URL: http://llvm.org/viewvc/llvm-project?rev=284284&view=rev
Log:
Reinstate r284008 reverted in r284081, with two fixes:

1) Merge and demote variable definitions when we find a redefinition in
MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach
the second case if it's the addition of the initializer itself that converts an
existing declaration into a definition).

2) When rebuilding a redeclaration chain for a variable, if we merge two
definitions together, mark the definitions as merged so the retained definition
is made visible whenever the demoted definition would have been.

Original commit message (from r283882):

[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

Original patch by Vassil Vassilev! Changes listed above are mine.

Added:
 cfe/trunk/test/Modules/Inputs/PR28752/
   - copied from r284080, cfe/trunk/test/Modules/Inputs/PR28752/
 cfe/trunk/test/Modules/pr28752.cpp
   - copied, changed from r284080, cfe/trunk/test/Modules/pr28752.cpp
Modified:
 cfe/trunk/include/clang/AST/Decl.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/Decl.cpp
 cfe/trunk/lib/Sema/SemaDecl.cpp
 cfe/trunk/lib/Sema/SemaTemplate.cpp
 cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
 cfe/trunk/lib/Sema/SemaType.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Oct 14 16:41:24 2016
@@ -865,6 +865,11 @@ protected:
  
  unsigned : NumVarDeclBits;
  
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.

+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
  /// \brief Whether this variable is the exception variable in a C++ catch
  /// or an Objective-C @catch statement.
  unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
InitializationStyle getInitStyle() const {
  return static_cast(VarDeclBits.InitStyle);
}
-
/// \brief Whether the initializer is a direct-initializer (list or call).
bool isDirectInit() const {
  return getInitStyle() != CInit;
}
  
+  /// \brief If this definition should pretend to be a declaration.

+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
/// \brief Determine whether this variable is the exception variable in a
/// C++ catch statememt or an Objective-C \@catch statement.
bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
  NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
}
  
+  /// \brief Retrieve the variable declaration from which this variable could

+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
/// \brief If this variable is an instantiated static data member of a
/// class template specialization, returns the templated static data member
/// from which it was instantiated.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Oct 14 16:41:24 2016
@@ -2286,6 +2286,7 @@ public:
void MergeVarDecl(VarDecl *New, LookupResult &Previous);
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
+  bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
bool

Re: r284284 - Reinstate r284008 reverted in r284081, with two fixes:

2016-10-15 Thread Vassil Vassilev via cfe-commits
It seems that we are still missing a piece, because this broke the 
libstdc++ selfhost: 
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/5891


On 14/10/16 23:41, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri Oct 14 16:41:24 2016
New Revision: 284284

URL: http://llvm.org/viewvc/llvm-project?rev=284284&view=rev
Log:
Reinstate r284008 reverted in r284081, with two fixes:

1) Merge and demote variable definitions when we find a redefinition in
MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach
the second case if it's the addition of the initializer itself that converts an
existing declaration into a definition).

2) When rebuilding a redeclaration chain for a variable, if we merge two
definitions together, mark the definitions as merged so the retained definition
is made visible whenever the demoted definition would have been.

Original commit message (from r283882):

[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

Original patch by Vassil Vassilev! Changes listed above are mine.

Added:
 cfe/trunk/test/Modules/Inputs/PR28752/
   - copied from r284080, cfe/trunk/test/Modules/Inputs/PR28752/
 cfe/trunk/test/Modules/pr28752.cpp
   - copied, changed from r284080, cfe/trunk/test/Modules/pr28752.cpp
Modified:
 cfe/trunk/include/clang/AST/Decl.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/Decl.cpp
 cfe/trunk/lib/Sema/SemaDecl.cpp
 cfe/trunk/lib/Sema/SemaTemplate.cpp
 cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
 cfe/trunk/lib/Sema/SemaType.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
 cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Oct 14 16:41:24 2016
@@ -865,6 +865,11 @@ protected:
  
  unsigned : NumVarDeclBits;
  
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.

+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
  /// \brief Whether this variable is the exception variable in a C++ catch
  /// or an Objective-C @catch statement.
  unsigned ExceptionVar : 1;
@@ -1198,12 +1203,28 @@ public:
InitializationStyle getInitStyle() const {
  return static_cast(VarDeclBits.InitStyle);
}
-
/// \brief Whether the initializer is a direct-initializer (list or call).
bool isDirectInit() const {
  return getInitStyle() != CInit;
}
  
+  /// \brief If this definition should pretend to be a declaration.

+  bool isThisDeclarationADemotedDefinition() const {
+return isa(this) ? false :
+  NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (isThisDeclarationADefinition() && "Not a definition!");
+assert (!isa(this) && "Cannot demote ParmVarDecls!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
/// \brief Determine whether this variable is the exception variable in a
/// C++ catch statememt or an Objective-C \@catch statement.
bool isExceptionVariable() const {
@@ -1302,6 +1323,10 @@ public:
  NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
}
  
+  /// \brief Retrieve the variable declaration from which this variable could

+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
/// \brief If this variable is an instantiated static data member of a
/// class template specialization, returns the templated static data member
/// from which it was instantiated.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284284&r1=284283&r2=284284&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Oct 14 16:41:24 2016
@@ -2286,6 +2286,7 @@ public:
void MergeVarDecl(VarDecl *New, LookupResult &Previous);
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
+  bool c

r284372 - Do not reset TUScope when we are in incremental processing mode.

2016-10-17 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Oct 17 05:15:25 2016
New Revision: 284372

URL: http://llvm.org/viewvc/llvm-project?rev=284372&view=rev
Log:
Do not reset TUScope when we are in incremental processing mode.

Patch by Axel Naumann!

Reviewed by Richard Smith and me.

Modified:
cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=284372&r1=284371&r2=284372&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon Oct 17 05:15:25 2016
@@ -708,7 +708,8 @@ void Sema::ActOnEndOfTranslationUnit() {
 
   if (TUKind == TU_Prefix) {
 // Translation unit prefixes don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 
@@ -908,7 +909,8 @@ void Sema::ActOnEndOfTranslationUnit() {
   assert(ParsingInitForAutoVars.empty() &&
  "Didn't unmark var as having its initializer parsed");
 
-  TUScope = nullptr;
+  if (!PP.isIncrementalProcessingEnabled())
+TUScope = nullptr;
 }
 
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25602: Do not reset TUScope when we are in incremental processing mode.

2016-10-17 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r284372.


https://reviews.llvm.org/D25602



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284382 - Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"

2016-10-17 Thread Vassil Vassilev via cfe-commits

I was just to commit a fix :(
On 17/10/16 15:00, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Mon Oct 17 08:00:44 2016
New Revision: 284382

URL: http://llvm.org/viewvc/llvm-project?rev=284382&view=rev
Log:
Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling 
of"

This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

Removed:
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
 cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
 cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
 cfe/trunk/include/clang/AST/ASTContext.h
 cfe/trunk/lib/AST/ASTContext.cpp
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h
 cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/d.h
 cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284382&r1=284381&r2=284382&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Oct 17 08:00:44 2016
@@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase
/// merged into.
llvm::DenseMap MergedDecls;
  
-  /// The modules into which a definition has been merged, or a map from a

-  /// merged definition to its canonical definition. This is really a union of
-  /// a NamedDecl* and a vector of Module*.
-  struct MergedModulesOrCanonicalDef {
-llvm::TinyPtrVector MergedModules;
-NamedDecl *CanonicalDef = nullptr;
-  };
-
/// \brief A mapping from a defining declaration to a list of modules (other
/// than the owning module of the declaration) that contain merged
/// definitions of that entity.
-  llvm::DenseMap MergedDefModules;
+  llvm::DenseMap> MergedDefModules;
  
/// \brief Initializers for a module, in order. Each Decl will be either

/// something that has a semantic effect on startup (such as a variable with
@@ -891,7 +883,6 @@ public:
/// and should be visible whenever \p M is visible.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
   bool NotifyListeners = true);
-  void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other);
/// \brief Clean up the merged definition list. Call this if you might have
/// added duplicates into the list.
void deduplicateMergedDefinitonsFor(NamedDecl *ND);
@@ -902,9 +893,7 @@ public:
  auto MergedIt = MergedDefModules.find(Def);
  if (MergedIt == MergedDefModules.end())
return None;
-if (auto *CanonDef = MergedIt->second.CanonicalDef)
-  return getModulesWithMergedDefinition(CanonDef);
-return MergedIt->second.MergedModules;
+return MergedIt->second;
}
  
/// Add a declaration to the list of declarations that are initialized


Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284382&r1=284381&r2=284382&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 17 08:00:44 2016
@@ -888,74 +888,18 @@ void ASTContext::mergeDefinitionIntoModu
  if (auto *Listener = getASTMutationListener())
Listener->RedefinedHiddenDefinition(ND, M);
  
-  auto *Merged = &MergedDefModules[ND];

-  if (auto *CanonDef = Merged->CanonicalDef) {
-ND = CanonDef;
-Merged = &MergedDefModules[ND];
-  }
-  assert(!Merged->CanonicalDef && "canonical def not canonical");
-
-  Merged->MergedModules.push_back(M);
-
-  if (!getLangOpts().ModulesLocalVisibility)
+  if (getLangOpts().ModulesLocalVisibility)
+MergedDefModules[ND].push_back(M);
+  else
  ND->setHidden(false);
  }
  
-void ASTContext::mergeDefinitionIntoModulesOf(NamedDecl *Def,

-  NamedDecl *Other) {
-  // We need to know the owning module of the merge source.
-  assert(Other->isFromASTFile() && "merge of non-imported decl not supported");
-  assert(Def != Other && "merging definition into itself");
-
-  if (!Other->isHidden()) {
-Def->setHidden(false);
-return;
-  }
-
-  assert(Other->getImportedOwningModule() &&
- "hidden, imported declaration has no owning module");
-
-  // Mark Def as the canonical definition of merged definition Other.
-  {
-auto &OtherMerged = MergedDefModul

r319037 - Constify. NFC.

2017-11-27 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Mon Nov 27 07:32:00 2017
New Revision: 319037

URL: http://llvm.org/viewvc/llvm-project?rev=319037&view=rev
Log:
Constify. NFC.

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=319037&r1=319036&r2=319037&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Nov 27 07:32:00 2017
@@ -1555,7 +1555,7 @@ public:
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);
 
-  bool isModuleVisible(Module *M) { return VisibleModules.isVisible(M); }
+  bool isModuleVisible(const Module *M) { return VisibleModules.isVisible(M); }
 
   /// Determine whether a declaration is visible to name lookup.
   bool isVisible(const NamedDecl *D) {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r305110 - [ODRHash] Add support for TemplateArgument types.

2017-12-08 Thread Vassil Vassilev via cfe-commits

Hi Richard,

  Is there a way to get an ODRHashing which is stable across 
translation units? I'd like to use the TemplateArgument ODRHash to 
lookup template specializations and deserialize them only if they are 
required.


Many thanks!
Vassil
On 6/9/17 11:00 PM, Richard Trieu via cfe-commits wrote:

Author: rtrieu
Date: Fri Jun  9 16:00:10 2017
New Revision: 305110

URL: http://llvm.org/viewvc/llvm-project?rev=305110&view=rev
Log:
[ODRHash] Add support for TemplateArgument types.

Recommit r304592 that was reverted in r304618.  r305104 should have fixed the
issue.

Modified:
 cfe/trunk/lib/AST/ODRHash.cpp
 cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305110&r1=305109&r2=305110&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  9 16:00:10 2017
@@ -140,7 +140,25 @@ void ODRHash::AddTemplateName(TemplateNa
}
  }
  
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {}

+void ODRHash::AddTemplateArgument(TemplateArgument TA) {
+  auto Kind = TA.getKind();
+  ID.AddInteger(Kind);
+
+  switch (Kind) {
+  case TemplateArgument::Null:
+  case TemplateArgument::Declaration:
+  case TemplateArgument::NullPtr:
+  case TemplateArgument::Integral:
+  case TemplateArgument::Template:
+  case TemplateArgument::TemplateExpansion:
+  case TemplateArgument::Expression:
+  case TemplateArgument::Pack:
+break;
+  case TemplateArgument::Type:
+AddQualType(TA.getAsType());
+break;
+  }
+}
  void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
  
  void ODRHash::clear() {


Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305110&r1=305109&r2=305110&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun  9 16:00:10 2017
@@ -900,6 +900,24 @@ S2 s2;
  #endif
  }
  
+namespace TemplateArgument {

+#if defined(FIRST)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#elif defined(SECOND)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'TemplateArgument::S1::u' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'u' does not match}}
+#endif
+}
+
  // Interesting cases that should not cause errors.  struct S should not error
  // while struct T should error at the access specifier mismatch at the end.
  namespace AllDecls {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r305110 - [ODRHash] Add support for TemplateArgument types.

2017-12-10 Thread Vassil Vassilev via cfe-commits

On 12/8/17 9:14 PM, Richard Trieu wrote:

Vassil,

It depends on which parts of the AST you want to be stable.  The 
ODRHashing is stable across TU's, but it may depend on information 
that you don't want to be part of the hash.  For instance, if you have 
"using F = float;" in you code, then the hash of TemplateArgument for 
"float" and for "F" would be different.  If the template 
specializations you are dealing with are canonicalized, then the 
TemplateArgument hashes should be the same.  Otherwise, ODRHash would 
need to be changed to suit your requirements.
  Thanks for the prompt reply! Luckily the decls I will be working with 
should be canonicalized. I will give it a try and I will ping you if I 
have more questions ;)


On Fri, Dec 8, 2017 at 8:16 AM, Vassil Vassilev 
mailto:v.g.vassi...@gmail.com>> wrote:


Hi Richard,

  Is there a way to get an ODRHashing which is stable across
translation units? I'd like to use the TemplateArgument ODRHash to
lookup template specializations and deserialize them only if they
are required.

Many thanks!
Vassil

On 6/9/17 11:00 PM, Richard Trieu via cfe-commits wrote:

Author: rtrieu
Date: Fri Jun  9 16:00:10 2017
New Revision: 305110

URL: http://llvm.org/viewvc/llvm-project?rev=305110&view=rev

Log:
[ODRHash] Add support for TemplateArgument types.

Recommit r304592 that was reverted in r304618. r305104 should
have fixed the
issue.

Modified:
     cfe/trunk/lib/AST/ODRHash.cpp
     cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305110&r1=305109&r2=305110&view=diff



==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  9 16:00:10 2017
@@ -140,7 +140,25 @@ void ODRHash::AddTemplateName(TemplateNa
    }
  }
  -void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {
+  auto Kind = TA.getKind();
+  ID.AddInteger(Kind);
+
+  switch (Kind) {
+  case TemplateArgument::Null:
+  case TemplateArgument::Declaration:
+  case TemplateArgument::NullPtr:
+  case TemplateArgument::Integral:
+  case TemplateArgument::Template:
+  case TemplateArgument::TemplateExpansion:
+  case TemplateArgument::Expression:
+  case TemplateArgument::Pack:
+    break;
+  case TemplateArgument::Type:
+    AddQualType(TA.getAsType());
+    break;
+  }
+}
  void ODRHash::AddTemplateParameterList(const
TemplateParameterList *TPL) {}
    void ODRHash::clear() {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305110&r1=305109&r2=305110&view=diff



==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun 9 16:00:10 2017
@@ -900,6 +900,24 @@ S2 s2;
  #endif
  }
  +namespace TemplateArgument {
+#if defined(FIRST)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#elif defined(SECOND)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'TemplateArgument::S1::u' from
module 'FirstModule' is not present in definition of
'TemplateArgument::S1' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'u' does not match}}
+#endif
+}
+
  // Interesting cases that should not cause errors. struct S
should not error
  // while struct T should error at the access specifier
mismatch at the end.
  namespace AllDecls {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org 
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits







___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-b

[clang] [clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (PR #71393)

2023-11-06 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

Thank you, @mstorsjo!

https://github.com/llvm/llvm-project/pull/71393
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHandler(CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+
+  // convert a Declaration completion result  to a completion string, and then 
store it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+
+  // convert a Keyword completion result  to a completion string, and then 
store it in Results.

vgvassilev wrote:

```suggestion
  /// Convert a Keyword completion result to a completion string, and then 
store it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHandler(CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+
+  // convert a Declaration completion result  to a completion string, and then 
store it in Results.

vgvassilev wrote:

```suggestion
  /// Converts a Declaration completion result to a completion string, and then 
stores it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -23,8 +23,27 @@ namespace clang {
 class CodeCompletionResult;
 class CompilerInstance;
 
-void codeComplete(CompilerInstance *InterpCI, llvm::StringRef Content,
-  unsigned Line, unsigned Col, const CompilerInstance 
*ParentCI,
-  std::vector &CCResults);
+struct ReplCodeCompleter {
+  ReplCodeCompleter() = default;
+  std::string Prefix;
+
+  /*
+@param InterpCI The compiler instance that is used to trigger code 
completion
+
+@param Content The string where code completion is triggered.
+
+@param Line The line number of the code completion point.
+
+@param Col The column number of the code completion point.
+
+@param ParentCI The running interpreter compiler instance that provides 
ASTContexts.
+
+@param CCResults [out] The completion results.
+   */

vgvassilev wrote:

```suggestion
  /// Provides code completion results given a stem.
  ///
  /// \param InterpCI [in] The compiler instance that is used to trigger code 
completion
  /// \param Content [in] The string where code completion is triggered.
  /// \param Line [in] The line number of the code completion point.
  /// \param Col [in] The column number of the code completion point.
  /// \param ParentCI [in] The running interpreter compiler instance that 
provides ASTContexts.
  /// \param CCResults [out] The completion results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -37,12 +40,22 @@ clang::CodeCompleteOptions getClangCompleteOpts() {
   return Opts;
 }
 
+class CodeCompletionSubContext {

vgvassilev wrote:

I cannot seem to find the uses of this class.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */

vgvassilev wrote:

```suggestion
  /// The abstract class CompletionContextHandler contains four interfaces, 
each of
  /// which handles one type of completion result.
  ///
  /// Its substract classes are used to create concrete handlers based on
  /// \c CodeCompletionContext.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -118,6 +256,16 @@ void IncrementalSyntaxOnlyAction::ExecuteAction() {
   CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage(
   true);
 
+  // Load all external decls into current context.  Under the hood, it calls

vgvassilev wrote:

```suggestion
  // Load all external decls into current context. Under the hood, it calls
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHandler(CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+
+  // convert a Declaration completion result  to a completion string, and then 
store it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+
+  // convert a Keyword completion result  to a completion string, and then 
store it in Results.
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+
+  // convert a Pattern completion result  to a completion string, and then 
store it in Results.

vgvassilev wrote:

```suggestion
  /// Convert a Pattern completion result to a completion string, and then 
store it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHandler(CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+
+  // convert a Declaration completion result  to a completion string, and then 
store it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+
+  // convert a Keyword completion result  to a completion string, and then 
store it in Results.
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+
+  // convert a Pattern completion result  to a completion string, and then 
store it in Results.
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+
+  // convert a Macro completion result  to a completion string, and then store 
it in Results.

vgvassilev wrote:

```suggestion
  // Converts a Macro completion result to a completion string, and then store 
it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHandler(CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+
+  // convert a Declaration completion result  to a completion string, and then 
store it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+
+  // convert a Keyword completion result  to a completion string, and then 
store it in Results.
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+
+  // convert a Pattern completion result  to a completion string, and then 
store it in Results.
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+
+  // convert a Macro completion result  to a completion string, and then store 
it in Results.
+  virtual void handleMacro(const CodeCompletionResult &Result) {}
+};
+
+class DotMemberAccessHandler : public CompletionContextHandler {
+public:
+  DotMemberAccessHandler(CodeCompletionContext CCC,
+ std::vector &Results)
+  : CompletionContextHandler(CCC, Results) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+auto *ID = Result.Declaration->getIdentifier();
+if (!ID)
+  return;
+if (!isa(Result.Declaration))
+  return;
+const auto *Fun = cast(Result.Declaration);
+if (Fun->getParent()->getCanonicalDecl() ==
+CCC.getBaseType()->getAsCXXRecordDecl()->getCanonicalDecl()) {
+  LLVM_DEBUG(llvm::dbgs() << "[In HandleCodeCompleteDOT] Name : "
+  << ID->getName() << "\n");
+  Results.push_back(ID->getName().str());
+}
+  }
+};
+
+class DefaultAccessHandler : public CompletionContextHandler {

vgvassilev wrote:

What is the benefit of having a base class? We could merge the implementations 
of `DefaultAccessHandler` and `DotMemberAccessHandler` into the base class to 
simplify things.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -159,29 +308,62 @@ void ExternalSource::completeVisibleDeclsMap(
   for (auto *DeclCtxt = ParentTUDeclCtxt; DeclCtxt != nullptr;
DeclCtxt = DeclCtxt->getPreviousDecl()) {
 for (auto &IDeclContext : DeclCtxt->decls()) {
-  if (NamedDecl *Decl = llvm::dyn_cast(IDeclContext)) {
-if (auto DeclOrErr = Importer->Import(Decl)) {
-  if (NamedDecl *importedNamedDecl =
-  llvm::dyn_cast(*DeclOrErr)) {
-SetExternalVisibleDeclsForName(ChildDeclContext,
-   importedNamedDecl->getDeclName(),
-   importedNamedDecl);
-  }
-
-} else {
-  llvm::consumeError(DeclOrErr.takeError());
-}
+  if (!llvm::isa(IDeclContext))
+continue;
+
+  NamedDecl *Decl = llvm::cast(IDeclContext);
+
+  auto DeclOrErr = Importer->Import(Decl);
+  if (!DeclOrErr) {
+llvm::consumeError(DeclOrErr.takeError());

vgvassilev wrote:

Maybe add a comment here why error is fine.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHandler(CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+
+  // convert a Declaration completion result  to a completion string, and then 
store it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+
+  // convert a Keyword completion result  to a completion string, and then 
store it in Results.
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+
+  // convert a Pattern completion result  to a completion string, and then 
store it in Results.
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+
+  // convert a Macro completion result  to a completion string, and then store 
it in Results.
+  virtual void handleMacro(const CodeCompletionResult &Result) {}
+};
+
+class DotMemberAccessHandler : public CompletionContextHandler {

vgvassilev wrote:

Maybe we can add some documentation here explaining what we do on a high-level 
as it seems the main part of this PR.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -159,29 +308,62 @@ void ExternalSource::completeVisibleDeclsMap(
   for (auto *DeclCtxt = ParentTUDeclCtxt; DeclCtxt != nullptr;
DeclCtxt = DeclCtxt->getPreviousDecl()) {
 for (auto &IDeclContext : DeclCtxt->decls()) {
-  if (NamedDecl *Decl = llvm::dyn_cast(IDeclContext)) {
-if (auto DeclOrErr = Importer->Import(Decl)) {
-  if (NamedDecl *importedNamedDecl =
-  llvm::dyn_cast(*DeclOrErr)) {
-SetExternalVisibleDeclsForName(ChildDeclContext,
-   importedNamedDecl->getDeclName(),
-   importedNamedDecl);
-  }
-
-} else {
-  llvm::consumeError(DeclOrErr.takeError());
-}
+  if (!llvm::isa(IDeclContext))
+continue;
+
+  NamedDecl *Decl = llvm::cast(IDeclContext);
+
+  auto DeclOrErr = Importer->Import(Decl);
+  if (!DeclOrErr) {
+llvm::consumeError(DeclOrErr.takeError());
+continue;
   }
+
+  if (!llvm::isa(*DeclOrErr))
+continue;
+
+  NamedDecl *importedNamedDecl = llvm::cast(*DeclOrErr);
+
+  SetExternalVisibleDeclsForName(ChildDeclContext,
+ importedNamedDecl->getDeclName(),
+ importedNamedDecl);
+
+  if (!llvm::isa(importedNamedDecl))
+continue;
+
+  auto *Record =
+llvm::cast(importedNamedDecl);
+
+  if (auto Err = Importer->ImportDefinition(Decl)) {
+consumeError(std::move(Err));

vgvassilev wrote:

Likewise.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-06 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,151 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+/*
+  The abstract class CompletionContextHandler contains four interfaces, each of
+  which handles one type of completion result.
+
+  Its substract classes are used to create concrete handlers based on
+  CodeCompletionContext.
+ */
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHandler(CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+
+  // convert a Declaration completion result  to a completion string, and then 
store it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+
+  // convert a Keyword completion result  to a completion string, and then 
store it in Results.
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+
+  // convert a Pattern completion result  to a completion string, and then 
store it in Results.
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+
+  // convert a Macro completion result  to a completion string, and then store 
it in Results.
+  virtual void handleMacro(const CodeCompletionResult &Result) {}
+};
+
+class DotMemberAccessHandler : public CompletionContextHandler {
+public:
+  DotMemberAccessHandler(CodeCompletionContext CCC,
+ std::vector &Results)
+  : CompletionContextHandler(CCC, Results) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+auto *ID = Result.Declaration->getIdentifier();
+if (!ID)
+  return;
+if (!isa(Result.Declaration))
+  return;
+const auto *Fun = cast(Result.Declaration);
+if (Fun->getParent()->getCanonicalDecl() ==
+CCC.getBaseType()->getAsCXXRecordDecl()->getCanonicalDecl()) {
+  LLVM_DEBUG(llvm::dbgs() << "[In HandleCodeCompleteDOT] Name : "
+  << ID->getName() << "\n");
+  Results.push_back(ID->getName().str());
+}
+  }
+};
+
+class DefaultAccessHandler : public CompletionContextHandler {
+private:
+  Sema &S;
+
+public:
+  DefaultAccessHandler(Sema &S, CodeCompletionContext CCC,
+   std::vector &Results)
+  : CompletionContextHandler(CCC, Results), S(S) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+auto PreferredType = CCC.getPreferredType();
+if (PreferredType.isNull()) {
+  Results.push_back(Result.Declaration->getName().str());
+  return;
+}
+
+if (auto *VD = dyn_cast(Result.Declaration)) {
+  auto ArgumentType = VD->getType();
+  if (PreferredType->isReferenceType()) {
+QualType RT = PreferredType->castAs()->getPointeeType();
+Sema::ReferenceConversions RefConv;
+Sema::ReferenceCompareResult RefRelationship =
+S.CompareReferenceRelationship(SourceLocation(), RT, ArgumentType,
+   &RefConv);
+switch (RefRelationship) {
+case Sema::Ref_Compatible:
+case Sema::Ref_Related:
+  Results.push_back(VD->getName().str());
+  break;
+case Sema::Ref_Incompatible:
+  break;
+}
+  } else if (S.Context.hasSameType(ArgumentType, PreferredType)) {
+Results.push_back(VD->getName().str());
+  }
+}
+  }
+
+  void handleKeyword(const CodeCompletionResult &Result) override {
+auto Prefix = S.getPreprocessor().getCodeCompletionFilter();
+// add keyword to the completion results only if we are in a type-aware
+// situation.

vgvassilev wrote:

```suggestion
// Add keyword to the completion results only if we are in a type-aware
// situation.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-14 Thread Vassil Vassilev via cfe-commits


@@ -37,16 +39,15 @@ static std::vector runComp(clang::Interpreter 
&MainInterp,
 
   std::vector Results;
   std::vector Comps;
-
-  codeComplete(
-  const_cast((*Interp)->getCompilerInstance()),
-  Prefix, /* Lines */ 1, Prefix.size(), MainInterp.getCompilerInstance(),
-  Results);
+  auto *MainCI =
+  const_cast((*Interp)->getCompilerInstance());

vgvassilev wrote:

```suggestion
  auto *MainCI = Interp->getCompilerInstance();
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-14 Thread Vassil Vassilev via cfe-commits


@@ -37,16 +39,15 @@ static std::vector runComp(clang::Interpreter 
&MainInterp,
 
   std::vector Results;
   std::vector Comps;
-
-  codeComplete(
-  const_cast((*Interp)->getCompilerInstance()),
-  Prefix, /* Lines */ 1, Prefix.size(), MainInterp.getCompilerInstance(),
-  Results);
+  auto *MainCI =
+  const_cast((*Interp)->getCompilerInstance());

vgvassilev wrote:

Then just drop the `const_cast` we should not need it.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-14 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +63,146 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+// The class CompletionContextHandler contains four interfaces, each of
+// which handles one type of completion result.
+// Its substract classes are used to create concrete handlers based on
+// CodeCompletionContext.

vgvassilev wrote:

```suggestion
/// The class CompletionContextHandler contains four interfaces, each of
/// which handles one type of completion result.
/// Its derived classes are used to create concrete handlers based on
/// \c CodeCompletionContext.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-14 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +63,146 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+// The class CompletionContextHandler contains four interfaces, each of
+// which handles one type of completion result.
+// Its substract classes are used to create concrete handlers based on
+// CodeCompletionContext.
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+private:
+  Sema &S;
+
+public:
+  CompletionContextHandler(Sema &S, CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results), S(S) {}
+
+  // converts a Declaration completion result to a completion string, and then
+  // stores it in Results.

vgvassilev wrote:

```suggestion
  /// Converts a Declaration completion result to a completion string, and then
  /// stores it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-14 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +63,146 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+// The class CompletionContextHandler contains four interfaces, each of
+// which handles one type of completion result.
+// Its substract classes are used to create concrete handlers based on
+// CodeCompletionContext.
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+private:
+  Sema &S;
+
+public:
+  CompletionContextHandler(Sema &S, CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results), S(S) {}
+
+  // converts a Declaration completion result to a completion string, and then
+  // stores it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {
+auto PreferredType = CCC.getPreferredType();
+if (PreferredType.isNull()) {
+  Results.push_back(Result.Declaration->getName().str());
+  return;
+}
+
+if (auto *VD = dyn_cast(Result.Declaration)) {
+  auto ArgumentType = VD->getType();
+  if (PreferredType->isReferenceType()) {
+QualType RT = PreferredType->castAs()->getPointeeType();
+Sema::ReferenceConversions RefConv;
+Sema::ReferenceCompareResult RefRelationship =
+S.CompareReferenceRelationship(SourceLocation(), RT, ArgumentType,
+   &RefConv);
+switch (RefRelationship) {
+case Sema::Ref_Compatible:
+case Sema::Ref_Related:
+  Results.push_back(VD->getName().str());
+  break;
+case Sema::Ref_Incompatible:
+  break;
+}
+  } else if (S.Context.hasSameType(ArgumentType, PreferredType)) {
+Results.push_back(VD->getName().str());
+  }
+}
+  }
+
+  // converts a Keyword completion result to a completion string, and then
+  // stores it in Results.
+  virtual void handleKeyword(const CodeCompletionResult &Result) {
+auto Prefix = S.getPreprocessor().getCodeCompletionFilter();
+// Add keyword to the completion results only if we are in a type-aware
+// situation.
+if (!CCC.getBaseType().isNull() || !CCC.getPreferredType().isNull())
+  return;
+if (StringRef(Result.Keyword).startswith(Prefix))
+  Results.push_back(Result.Keyword);
+  }
+
+  // converts a Pattern completion result to a completion string, and then
+  // stores it in Results.
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+
+  // converts a Macro completion result to a completion string, and then stores
+  // it in Results.

vgvassilev wrote:

```suggestion
  /// Converts a Macro completion result to a completion string, and then stores
  /// it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-14 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +63,146 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+// The class CompletionContextHandler contains four interfaces, each of
+// which handles one type of completion result.
+// Its substract classes are used to create concrete handlers based on
+// CodeCompletionContext.
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+private:
+  Sema &S;
+
+public:
+  CompletionContextHandler(Sema &S, CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results), S(S) {}
+
+  // converts a Declaration completion result to a completion string, and then
+  // stores it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {
+auto PreferredType = CCC.getPreferredType();
+if (PreferredType.isNull()) {
+  Results.push_back(Result.Declaration->getName().str());
+  return;
+}
+
+if (auto *VD = dyn_cast(Result.Declaration)) {
+  auto ArgumentType = VD->getType();
+  if (PreferredType->isReferenceType()) {
+QualType RT = PreferredType->castAs()->getPointeeType();
+Sema::ReferenceConversions RefConv;
+Sema::ReferenceCompareResult RefRelationship =
+S.CompareReferenceRelationship(SourceLocation(), RT, ArgumentType,
+   &RefConv);
+switch (RefRelationship) {
+case Sema::Ref_Compatible:
+case Sema::Ref_Related:
+  Results.push_back(VD->getName().str());
+  break;
+case Sema::Ref_Incompatible:
+  break;
+}
+  } else if (S.Context.hasSameType(ArgumentType, PreferredType)) {
+Results.push_back(VD->getName().str());
+  }
+}
+  }
+
+  // converts a Keyword completion result to a completion string, and then
+  // stores it in Results.

vgvassilev wrote:

```suggestion
  /// Converts a Keyword completion result to a completion string, and then
  /// stores it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-14 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +63,146 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompleter &CC;
+};
+
+// The class CompletionContextHandler contains four interfaces, each of
+// which handles one type of completion result.
+// Its substract classes are used to create concrete handlers based on
+// CodeCompletionContext.
+class CompletionContextHandler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+private:
+  Sema &S;
+
+public:
+  CompletionContextHandler(Sema &S, CodeCompletionContext CCC,
+   std::vector &Results)
+  : CCC(CCC), Results(Results), S(S) {}
+
+  // converts a Declaration completion result to a completion string, and then
+  // stores it in Results.
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {
+auto PreferredType = CCC.getPreferredType();
+if (PreferredType.isNull()) {
+  Results.push_back(Result.Declaration->getName().str());
+  return;
+}
+
+if (auto *VD = dyn_cast(Result.Declaration)) {
+  auto ArgumentType = VD->getType();
+  if (PreferredType->isReferenceType()) {
+QualType RT = PreferredType->castAs()->getPointeeType();
+Sema::ReferenceConversions RefConv;
+Sema::ReferenceCompareResult RefRelationship =
+S.CompareReferenceRelationship(SourceLocation(), RT, ArgumentType,
+   &RefConv);
+switch (RefRelationship) {
+case Sema::Ref_Compatible:
+case Sema::Ref_Related:
+  Results.push_back(VD->getName().str());
+  break;
+case Sema::Ref_Incompatible:
+  break;
+}
+  } else if (S.Context.hasSameType(ArgumentType, PreferredType)) {
+Results.push_back(VD->getName().str());
+  }
+}
+  }
+
+  // converts a Keyword completion result to a completion string, and then
+  // stores it in Results.
+  virtual void handleKeyword(const CodeCompletionResult &Result) {
+auto Prefix = S.getPreprocessor().getCodeCompletionFilter();
+// Add keyword to the completion results only if we are in a type-aware
+// situation.
+if (!CCC.getBaseType().isNull() || !CCC.getPreferredType().isNull())
+  return;
+if (StringRef(Result.Keyword).startswith(Prefix))
+  Results.push_back(Result.Keyword);
+  }
+
+  // converts a Pattern completion result to a completion string, and then
+  // stores it in Results.

vgvassilev wrote:

```suggestion
  /// Converts a Pattern completion result to a completion string, and then
  /// stores it in Results.
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-22 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

LGTM! Thank you!

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-23 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@capfredf, can you rebase the PR to trigger a rebuild - the test failure seems 
unrelated to our changes but maybe it was fixed meanwhile.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-10-30 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev edited 
https://github.com/llvm/llvm-project/pull/69287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-10-30 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev commented:

This looks pretty good modulo the comments.

@zygoloid ping.

https://github.com/llvm/llvm-project/pull/69287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-10-30 Thread Vassil Vassilev via cfe-commits


@@ -2407,6 +2407,53 @@ class ASTReader
   bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
 };
 
+/// A simple helper class to unpack an integer to bits and consuming
+/// the bits in order.
+class BitsUnpacker {
+  constexpr static uint32_t BitsIndexUpbound = 32;
+
+public:
+  BitsUnpacker(uint32_t V) { updateValue(V); }
+  BitsUnpacker(const BitsUnpacker &) = delete;
+  BitsUnpacker(BitsUnpacker &&) = delete;
+  BitsUnpacker operator=(const BitsUnpacker &) = delete;
+  BitsUnpacker operator=(BitsUnpacker &&) = delete;
+  ~BitsUnpacker() {
+#ifndef NDEBUG
+while (isValid())
+  assert(!getNextBit() && "There are bits failed to read!");
+#endif
+  }
+
+  void updateValue(uint32_t V) {
+Value = V;
+CurrentBitsIndex = 0;
+  }
+
+  bool getNextBit() {
+assert(isValid());
+return Value & (1 << CurrentBitsIndex++);
+  }
+
+  uint32_t getNextBits(uint32_t Width) {
+assert(isValid());
+assert(Width < BitsIndexUpbound);
+uint32_t Ret = (Value >> CurrentBitsIndex) & ((1 << Width) - 1);
+CurrentBitsIndex += Width;
+return Ret;
+  }
+
+  bool isValidToGetNextNBits(uint32_t Width) const {

vgvassilev wrote:

```suggestion
  bool canGetNextNBits(uint32_t Width) const {
```

https://github.com/llvm/llvm-project/pull/69287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-10-30 Thread Vassil Vassilev via cfe-commits


@@ -1689,9 +1709,10 @@ void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
   } else {
 PD->setScopeInfo(scopeDepth, scopeIndex);
   }
-  PD->ParmVarDeclBits.IsKNRPromoted = Record.readInt();
-  PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
-  if (Record.readInt()) // hasUninstantiatedDefaultArg.
+  PD->ParmVarDeclBits.IsKNRPromoted = ParmVarDeclBits.getNextBit();
+  ;

vgvassilev wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/69287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-10-30 Thread Vassil Vassilev via cfe-commits


@@ -2407,6 +2407,53 @@ class ASTReader
   bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
 };
 
+/// A simple helper class to unpack an integer to bits and consuming
+/// the bits in order.
+class BitsUnpacker {
+  constexpr static uint32_t BitsIndexUpbound = 32;
+
+public:
+  BitsUnpacker(uint32_t V) { updateValue(V); }
+  BitsUnpacker(const BitsUnpacker &) = delete;
+  BitsUnpacker(BitsUnpacker &&) = delete;
+  BitsUnpacker operator=(const BitsUnpacker &) = delete;
+  BitsUnpacker operator=(BitsUnpacker &&) = delete;
+  ~BitsUnpacker() {
+#ifndef NDEBUG
+while (isValid())
+  assert(!getNextBit() && "There are bits failed to read!");

vgvassilev wrote:

```suggestion
  assert(!getNextBit() && "There are unprocessed bits!");
```

Is that the analog of `hasUnconsumedValues`? If so, we could probably mirror it 
here, too.

https://github.com/llvm/llvm-project/pull/69287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-10-31 Thread Vassil Vassilev via cfe-commits


@@ -2005,14 +2039,7 @@ void ASTWriter::WriteDeclAbbrevs() {
   // Decl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
   Abv->Add(BitCodeAbbrevOp(0));   // LexicalDeclContext
-  Abv->Add(BitCodeAbbrevOp(0));   // isInvalidDecl
-  Abv->Add(BitCodeAbbrevOp(0));   // HasAttrs
-  Abv->Add(BitCodeAbbrevOp(0));   // isImplicit
-  Abv->Add(BitCodeAbbrevOp(0));   // isUsed
-  Abv->Add(BitCodeAbbrevOp(0));   // isReferenced
-  Abv->Add(BitCodeAbbrevOp(0));   // 
TopLevelDeclInObjCContainer
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2));  // AccessSpecifier
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));  // ModuleOwnershipKind
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // Decl Bits

vgvassilev wrote:

These sections became a little harder to read. Perhaps we could keep the 
comments and this way the reader could probably do the math why this is 11 bits 
for example.

https://github.com/llvm/llvm-project/pull/69287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev edited 
https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev commented:

Looks like this is heading in a good direction. Thank you!

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,135 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompletion &CC;
+};
+
+class CompletionContextHanndler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHanndler(CodeCompletionContext CCC,
+std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+  virtual void handleMacro(const CodeCompletionResult &Result) {}
+};
+
+class DotMemberAccessHandler : public CompletionContextHanndler {
+public:
+  DotMemberAccessHandler(CodeCompletionContext CCC,
+ std::vector &Results)
+  : CompletionContextHanndler(CCC, Results) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+if (auto *ID = Result.Declaration->getIdentifier()) {
+  if (const auto *Fun = llvm::dyn_cast(Result.Declaration)) 
{
+if (Fun->getParent()->getCanonicalDecl() ==
+CCC.getBaseType()->getAsCXXRecordDecl()->getCanonicalDecl()) {
+  LLVM_DEBUG(llvm::dbgs() << "[In HandleCodeCompleteDOT] Name : "
+  << ID->getName() << "\n");
+  Results.push_back(ID->getName().str());
+}
+  }
+}
+  }
+};
+
+class DefaultAccessHandler : public CompletionContextHanndler {
+private:
+  Sema &S;
+
+public:
+  DefaultAccessHandler(Sema &S, CodeCompletionContext CCC,
+   std::vector &Results)
+  : CompletionContextHanndler(CCC, Results), S(S) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+auto PreferredType = CCC.getPreferredType();
+if (!PreferredType.isNull()) {

vgvassilev wrote:

We could use a similar approach here:
```suggestion
if (PreferredType.isNull())
  return;
...
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits


@@ -101,6 +223,7 @@ class ExternalSource : public clang::ExternalASTSource {
  ASTContext &ParentASTCtxt, FileManager &ParentFM);
   bool FindExternalVisibleDeclsByName(const DeclContext *DC,
   DeclarationName Name) override;
+  // void CompleteType(TagDecl *Tag) override;

vgvassilev wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,135 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompletion &CC;
+};
+
+class CompletionContextHanndler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHanndler(CodeCompletionContext CCC,
+std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+  virtual void handleMacro(const CodeCompletionResult &Result) {}
+};
+
+class DotMemberAccessHandler : public CompletionContextHanndler {
+public:
+  DotMemberAccessHandler(CodeCompletionContext CCC,
+ std::vector &Results)
+  : CompletionContextHanndler(CCC, Results) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+if (auto *ID = Result.Declaration->getIdentifier()) {
+  if (const auto *Fun = llvm::dyn_cast(Result.Declaration)) 
{
+if (Fun->getParent()->getCanonicalDecl() ==
+CCC.getBaseType()->getAsCXXRecordDecl()->getCanonicalDecl()) {
+  LLVM_DEBUG(llvm::dbgs() << "[In HandleCodeCompleteDOT] Name : "
+  << ID->getName() << "\n");
+  Results.push_back(ID->getName().str());
+}
+  }
+}

vgvassilev wrote:

```suggestion
if (!Result.Declaration->getIdentifier())
  return;
if (!isa(Result.Declaration))
  return;
const auto *Fun = cast(Result.Declaration)
if (Fun->getParent()->getCanonicalDecl() ==
CCC.getBaseType()->getAsCXXRecordDecl()->getCanonicalDecl()) {
   LLVM_DEBUG(llvm::dbgs() << "[In HandleCodeCompleteDOT] Name : "
   << ID->getName() << "\n");
  Results.push_back(ID->getName().str());
  }
```

This would help with the indentation, please run clang-format on it.

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,135 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompletion &CC;
+};
+
+class CompletionContextHanndler {
+protected:
+  CodeCompletionContext CCC;
+  std::vector &Results;
+
+public:
+  CompletionContextHanndler(CodeCompletionContext CCC,
+std::vector &Results)
+  : CCC(CCC), Results(Results) {}
+  virtual void handleDeclaration(const CodeCompletionResult &Result) {}
+  virtual void handleKeyword(const CodeCompletionResult &Result) {}
+  virtual void handlePattern(const CodeCompletionResult &Result) {}
+  virtual void handleMacro(const CodeCompletionResult &Result) {}
+};
+
+class DotMemberAccessHandler : public CompletionContextHanndler {
+public:
+  DotMemberAccessHandler(CodeCompletionContext CCC,
+ std::vector &Results)
+  : CompletionContextHanndler(CCC, Results) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+if (auto *ID = Result.Declaration->getIdentifier()) {
+  if (const auto *Fun = llvm::dyn_cast(Result.Declaration)) 
{
+if (Fun->getParent()->getCanonicalDecl() ==
+CCC.getBaseType()->getAsCXXRecordDecl()->getCanonicalDecl()) {
+  LLVM_DEBUG(llvm::dbgs() << "[In HandleCodeCompleteDOT] Name : "
+  << ID->getName() << "\n");
+  Results.push_back(ID->getName().str());
+}
+  }
+}
+  }
+};
+
+class DefaultAccessHandler : public CompletionContextHanndler {
+private:
+  Sema &S;
+
+public:
+  DefaultAccessHandler(Sema &S, CodeCompletionContext CCC,
+   std::vector &Results)
+  : CompletionContextHanndler(CCC, Results), S(S) {}
+  void handleDeclaration(const CodeCompletionResult &Result) override {
+auto PreferredType = CCC.getPreferredType();
+if (!PreferredType.isNull()) {
+  if (auto *VD = dyn_cast(Result.Declaration)) {
+auto ArgumentType = VD->getType();
+if (PreferredType->isReferenceType()) {
+  QualType RT =
+  PreferredType->castAs()->getPointeeType();
+  Sema::ReferenceConversions RefConv;
+  Sema::ReferenceCompareResult RefRelationship =
+  S.CompareReferenceRelationship(SourceLocation(), RT, 
ArgumentType,
+ &RefConv);
+  switch (RefRelationship) {
+  case Sema::Ref_Compatible:
+  case Sema::Ref_Related:
+Results.push_back(VD->getName().str());
+break;
+  case Sema::Ref_Incompatible:
+break;
+  }
+} else if (S.Context.hasSameType(ArgumentType, PreferredType)) {
+  Results.push_back(VD->getName().str());
+}
+  }
+} else
+  Results.push_back(Result.Declaration->getName().str());
+  }
+
+  void handleKeyword(const CodeCompletionResult &Result) override {
+auto Prefix = S.getPreprocessor().getCodeCompletionFilter();
+// add keyword to the completion results only if we are in a type-aware
+// situation.
+if (!CCC.getBaseType().isNull() || !CCC.getPreferredType().isNull())
+  return;
+if (StringRef(Result.Keyword).startswith(Prefix))
+  Results.push_back(Result.Keyword);
+  }
 };
 
 void ReplCompletionConsumer::ProcessCodeCompleteResults(
 class Sema &S, CodeCompletionContext Context,
 CodeCompletionResult *InResults, unsigned NumResults) {
-  for (unsigned I = 0; I < NumResults; ++I) {
+
+  // auto& a = S.Context.Idents.get("f1");
+  // LLVM_DEBUG(llvm::dbgs() << "\n F11 : " << a.getName() << "\n" );

vgvassilev wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits


@@ -23,8 +23,13 @@ namespace clang {
 class CodeCompletionResult;
 class CompilerInstance;
 
-void codeComplete(CompilerInstance *InterpCI, llvm::StringRef Content,
-  unsigned Line, unsigned Col, const CompilerInstance 
*ParentCI,
-  std::vector &CCResults);
+struct ReplCodeCompletion {

vgvassilev wrote:

Can we rename that as `CodeCompleter` or similar and add some doxygen-style 
documentation?

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits


@@ -166,8 +300,37 @@ void ExternalSource::completeVisibleDeclsMap(
 SetExternalVisibleDeclsForName(ChildDeclContext,
importedNamedDecl->getDeclName(),
importedNamedDecl);
-  }
+if (auto *Record =
+llvm::dyn_cast(importedNamedDecl)) {
+  if (auto Err = Importer->ImportDefinition(Decl))
+consumeError(std::move(Err));
+  // LLVM_DEBUG(llvm::dbgs() << "\nHello :\n");
+  // Record->getTypeForDecl()->dump();
+  Record->setHasLoadedFieldsFromExternalStorage(true);
+  // auto ToOrErr = Importer->Import(->getTypeForDecl());
+  // if (!ToOrErr) {
+  //   consumeError(std::move(ToOrErr.takeError()));
+  // }
+  LLVM_DEBUG(
+  llvm::dbgs()
+  << "\nCXXRecrod : " << Record->getName() << " size(methods): 
"
+  << std::distance(Record->method_begin(), 
Record->method_end())
+  << " has def?:  " << Record->hasDefinition()
+  << " # (methods): "
+  << std::distance(Record->getDefinition()->method_begin(),
+   Record->getDefinition()->method_end())
+  << "\n");
+  for (auto *Meth : Record->methods()) {
+SetExternalVisibleDeclsForName(ChildDeclContext,
+   Meth->getDeclName(), Meth);
+// if (Meth->getDeclName().isIdentifier()) {
+// LLVM_DEBUG(llvm::dbgs() << "CXXRecrod Method: " <<
+// Meth->getName() << "\n");

vgvassilev wrote:

Can we clean up the comments and reduce the indentation levels as suggested in 
previous comments?

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

2023-11-01 Thread Vassil Vassilev via cfe-commits


@@ -56,26 +69,135 @@ class ReplCompletionConsumer : public CodeCompleteConsumer 
{
   std::shared_ptr CCAllocator;
   CodeCompletionTUInfo CCTUInfo;
   std::vector &Results;
+  ReplCodeCompletion &CC;
+};
+
+class CompletionContextHanndler {

vgvassilev wrote:

```suggestion
class CompletionContextHandler {
```

Can we add some documentation, too?

https://github.com/llvm/llvm-project/pull/67349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] [test] Make an XFAIL more precise (PR #70991)

2023-11-01 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

Thank you. Lgtm!

https://github.com/llvm/llvm-project/pull/70991
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] [Serializer] Pack information in serializer (PR #69287)

2023-11-03 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

LGTM, thank you!

https://github.com/llvm/llvm-project/pull/69287
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Always clear UndefinedButUsed (PR #73955)

2023-12-12 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

In principle we could add this test as an xfail to make sure we have this 
scenario when unloading support is up to that stage. 

https://github.com/llvm/llvm-project/pull/73955
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-15 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@capfredf, can you include the original commit message in the commit and add a 
line about what was done to resolve the reason we have reverted it earlier?

https://github.com/llvm/llvm-project/pull/75556
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;"

vgvassilev wrote:

Can you move this in the `code-undo.cpp` test?

https://github.com/llvm/llvm-project/pull/75629
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits


@@ -373,7 +373,15 @@ std::unique_ptr 
IncrementalParser::GenModule() {
 
 void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
   TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+  if (!MostRecentTU) {
+return;
+  }

vgvassilev wrote:

```suggestion
  if (!MostRecentTU)
return;
```

https://github.com/llvm/llvm-project/pull/75629
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits


@@ -373,7 +373,15 @@ std::unique_ptr 
IncrementalParser::GenModule() {
 
 void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
   TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+  if (!MostRecentTU) {
+return;
+  }
+
   TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
+  if (!FirstTU) {
+return;
+  }

vgvassilev wrote:

```suggestion
  if (!FirstTU)
return;
```

https://github.com/llvm/llvm-project/pull/75629
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-15 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;"

vgvassilev wrote:

Then we can put it in a new file called `error-recovery.cpp`.

https://github.com/llvm/llvm-project/pull/75629
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

2023-12-16 Thread Vassil Vassilev via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: clang-repl "int x = 10;" "{ int t; a::b(t); }" "int y = 10;"

vgvassilev wrote:

@p4vook ping.

https://github.com/llvm/llvm-project/pull/75629
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-18 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@capfredf ping.

https://github.com/llvm/llvm-project/pull/75556
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/75556
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev closed 
https://github.com/llvm/llvm-project/pull/75556
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-19 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@vvereschaka, thanks for the ping. Will look into this shortly. Feel free to 
revert. 

https://github.com/llvm/llvm-project/pull/75556
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   10   >