[libcxxabi] r302981 - [libcxxabi] Do not align field unwindHeader when building for ARM EHABI.

2017-05-12 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Sat May 13 01:28:17 2017
New Revision: 302981

URL: http://llvm.org/viewvc/llvm-project?rev=302981&view=rev
Log:
[libcxxabi] Do not align field unwindHeader when building for ARM EHABI.

For ARM EHABI, _Unwind_Exception is an alias of _Unwind_Control_Block,
which is not aligned, so we shouldn't align unwindHeader either.

rdar://problem/25364625

Modified:
libcxxabi/trunk/src/cxa_exception.hpp

Modified: libcxxabi/trunk/src/cxa_exception.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.hpp?rev=302981&r1=302980&r2=302981&view=diff
==
--- libcxxabi/trunk/src/cxa_exception.hpp (original)
+++ libcxxabi/trunk/src/cxa_exception.hpp Sat May 13 01:28:17 2017
@@ -64,10 +64,18 @@ struct _LIBCXXABI_HIDDEN __cxa_exception
 // This field is annotated with attribute aligned so that the exception
 // object following the field is sufficiently aligned and there is no
 // gap between the field and the exception object. r276215 made a change to
-// annotate _Unwind_Exception with __attribute__((aligned)), but we cannot
-// incorporate the fix on Darwin since it is an ABI-breaking change, which
-// is why we need the attribute on this field.
+// annotate _Unwind_Exception in unwind.h with __attribute__((aligned)), 
but
+// we cannot incorporate the fix on Darwin since it is an ABI-breaking
+// change, which is why we need the attribute on this field.
+//
+// For ARM EHABI, we do not align this field since _Unwind_Exception is an
+// alias of _Unwind_Control_Block, which is not annotated with
+// __attribute__((aligned).
+#if defined(_LIBCXXABI_ARM_EHABI)
+_Unwind_Exception unwindHeader;
+#else
 _Unwind_Exception unwindHeader __attribute__((aligned));
+#endif
 };
 
 // http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html
@@ -104,7 +112,11 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent
 
 // See the comment in __cxa_exception as to why this field has attribute
 // aligned.
+#if defined(_LIBCXXABI_ARM_EHABI)
+_Unwind_Exception unwindHeader;
+#else
 _Unwind_Exception unwindHeader __attribute__((aligned));
+#endif
 };
 
 struct _LIBCXXABI_HIDDEN __cxa_eh_globals {


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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-12 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Probably all of the examples from the original patch description and later 
comments should be turned into unit tests.




Comment at: docs/ClangFormatStyleOptions.rst:953
 
+**DanglingParenthesis** (``bool``)
+  If there is a break after the opening parenthesis, also break before the 
closing parenthesis

Have you auto-generated this with docs/tools/dump_format_style.py? There seem 
to be subtle differences.



Comment at: include/clang/Format/Format.h:793
+  /// \endcode
+  bool DanglingParenthesis;
+

I don't think this is a name that anyone will intuitively understand. I 
understand that the naming is hard here. One thing I am wondering is whether 
this might ever make sense unless AlignAfterOpenBracket is set to AlwaysBreak?

Unless that option is set, we could have both in the same file:

  someFunction(,
   );

and

  someFunction(
  , 
  );

Is that intended, i.e. are you actively using that? Answering this is 
important, because it influence whether or not we actually need to add another 
style option and even how to implement this.



Comment at: lib/Format/TokenAnnotator.cpp:2655
 
-  if (Right.is(tok::r_paren) || Right.is(TT_TemplateCloser))
+  if (Right.is(tok::r_paren)) {
+return Style.DanglingParenthesis;

No braces


https://reviews.llvm.org/D33029



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


[libcxxabi] r302978 - [libcxxabi] Align unwindHeader on a double-word boundary.

2017-05-12 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri May 12 22:14:49 2017
New Revision: 302978

URL: http://llvm.org/viewvc/llvm-project?rev=302978&view=rev
Log:
[libcxxabi] Align unwindHeader on a double-word boundary.

r276215 made a change to annotate _Unwind_Exception with attribute
"aligned" so that an exception object following field __cxa_exception
is sufficiently aligned. This fix hasn't been incorporated to unwind.h
on Darwin since it is an ABI breaking change.

Instead of annotating struct _Unwind_Exception with the attribute, this
commit annotates field unwindHeader of __cxa_exception. This ensures the
exception object is sufficiently aligned without breaking the ABI.

This recommits r302763 with fixes to RUN lines in the test case.

rdar://problem/25364625

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

Added:
libcxxabi/trunk/test/exception_object_alignment.sh.cpp
Modified:
libcxxabi/trunk/src/cxa_exception.hpp

Modified: libcxxabi/trunk/src/cxa_exception.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.hpp?rev=302978&r1=302977&r2=302978&view=diff
==
--- libcxxabi/trunk/src/cxa_exception.hpp (original)
+++ libcxxabi/trunk/src/cxa_exception.hpp Fri May 12 22:14:49 2017
@@ -61,7 +61,13 @@ struct _LIBCXXABI_HIDDEN __cxa_exception
 size_t referenceCount;
 #endif
 
-_Unwind_Exception unwindHeader;
+// This field is annotated with attribute aligned so that the exception
+// object following the field is sufficiently aligned and there is no
+// gap between the field and the exception object. r276215 made a change to
+// annotate _Unwind_Exception with __attribute__((aligned)), but we cannot
+// incorporate the fix on Darwin since it is an ABI-breaking change, which
+// is why we need the attribute on this field.
+_Unwind_Exception unwindHeader __attribute__((aligned));
 };
 
 // http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html
@@ -96,7 +102,9 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent
 void* primaryException;
 #endif
 
-_Unwind_Exception unwindHeader;
+// See the comment in __cxa_exception as to why this field has attribute
+// aligned.
+_Unwind_Exception unwindHeader __attribute__((aligned));
 };
 
 struct _LIBCXXABI_HIDDEN __cxa_eh_globals {

Added: libcxxabi/trunk/test/exception_object_alignment.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/exception_object_alignment.sh.cpp?rev=302978&view=auto
==
--- libcxxabi/trunk/test/exception_object_alignment.sh.cpp (added)
+++ libcxxabi/trunk/test/exception_object_alignment.sh.cpp Fri May 12 22:14:49 
2017
@@ -0,0 +1,48 @@
+//=== exception_object_alignment.sh.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: libcxxabi-no-exceptions
+
+// RUN: %build -O1
+// RUN: %run
+
+// This test used to fail on Darwin because field unwindHeader of struct
+// __cxa_exception and the exception object that immediately followed were not
+// 16B aligned. It would segfault in class derived's constructor when a movaps
+// tried to write to a memory operand that was not 16B aligned.
+
+namespace {
+
+struct S {
+  int a;
+  int __attribute__((aligned(16))) b;
+};
+
+class base1 {
+protected:
+  virtual ~base1() throw() {}
+};
+
+class derived: public base1 {
+public:
+  derived() : member() {}
+private:
+  S member;
+};
+
+}
+
+int main() {
+  try {
+throw derived();
+  }
+  catch(...) {
+  }
+  return 0;
+}


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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-12 Thread Ryan Stringham via Phabricator via cfe-commits
stringham updated this revision to Diff 98873.

https://reviews.llvm.org/D33029

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8757,6 +8757,7 @@
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(BreakBeforeInheritanceComma)
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
+  CHECK_PARSE_BOOL(DanglingParenthesis);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2652,7 +2652,10 @@
   if (Right.is(TT_ImplicitStringLiteral))
 return false;
 
-  if (Right.is(tok::r_paren) || Right.is(TT_TemplateCloser))
+  if (Right.is(tok::r_paren)) {
+return Style.DanglingParenthesis;
+  }
+  if (Right.is(TT_TemplateCloser))
 return false;
   if (Right.is(tok::r_square) && Right.MatchingParen &&
   Right.MatchingParen->is(TT_LambdaLSquare))
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -315,6 +315,7 @@
Style.BreakBeforeInheritanceComma);
 IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine",
Style.ConstructorInitializerAllOnOneLineOrOnePerLine);
+IO.mapOptional("DanglingParenthesis", Style.DanglingParenthesis);
 IO.mapOptional("ConstructorInitializerIndentWidth",
Style.ConstructorInitializerIndentWidth);
 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
@@ -541,6 +542,7 @@
   LLVMStyle.ColumnLimit = 80;
   LLVMStyle.CommentPragmas = "^ IWYU pragma:";
   LLVMStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = false;
+  LLVMStyle.DanglingParenthesis = false;
   LLVMStyle.ConstructorInitializerIndentWidth = 4;
   LLVMStyle.ContinuationIndentWidth = 4;
   LLVMStyle.Cpp11BracedListStyle = true;
@@ -606,6 +608,7 @@
   GoogleStyle.AlwaysBreakBeforeMultilineStrings = true;
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  GoogleStyle.DanglingParenthesis = false;
   GoogleStyle.DerivePointerAlignment = true;
   GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -149,12 +149,13 @@
   ParenState(unsigned Indent, unsigned LastSpace, bool AvoidBinPacking,
  bool NoLineBreak)
   : Indent(Indent), LastSpace(LastSpace), NestedBlockIndent(Indent),
-BreakBeforeClosingBrace(false), AvoidBinPacking(AvoidBinPacking),
-BreakBeforeParameter(false), NoLineBreak(NoLineBreak),
-NoLineBreakInOperand(false), LastOperatorWrapped(true),
-ContainsLineBreak(false), ContainsUnwrappedBuilder(false),
-AlignColons(true), ObjCSelectorNameFound(false),
-HasMultipleNestedBlocks(false), NestedBlockInlined(false) {}
+BreakBeforeClosingBrace(false), BreakBeforeClosingParen(false),
+AvoidBinPacking(AvoidBinPacking), BreakBeforeParameter(false),
+NoLineBreak(NoLineBreak), NoLineBreakInOperand(false),
+LastOperatorWrapped(true), ContainsLineBreak(false),
+ContainsUnwrappedBuilder(false), AlignColons(true),
+ObjCSelectorNameFound(false), HasMultipleNestedBlocks(false),
+NestedBlockInlined(false) {}
 
   /// \brief The position to which a specific parenthesis level needs to be
   /// indented.
@@ -210,6 +211,13 @@
   /// was a newline after the beginning left brace.
   bool BreakBeforeClosingBrace : 1;
 
+  /// \brief Whether a newline needs to be inserted before the block's closing
+  /// paren.
+  ///
+  /// We only want to insert a newline before the closing paren if there also
+  /// was a newline after the beginning left paren.
+  bool BreakBeforeClosingParen : 1;
+
   /// \brief Avoid bin packing, i.e. multiple parameters/elements on multiple
   /// lines, in this context.
   bool AvoidBinPacking : 1;
@@ -275,6 +283,8 @@
   return FirstLessLess < Other.FirstLessLess;
 if (BreakBeforeClosingBrace != Other.BreakBeforeClosingBrace)
   return BreakBeforeClosingBrace;
+if (BreakBeforeClosingParen != Other.BreakBeforeClosingParen)
+  return BreakBeforeClosingParen;
 if (Q

r302975 - [ASTImporter] Improve handling of incomplete types

2017-05-12 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Fri May 12 19:46:33 2017
New Revision: 302975

URL: http://llvm.org/viewvc/llvm-project?rev=302975&view=rev
Log:
[ASTImporter] Improve handling of incomplete types

ASTImporter has some bugs when it's importing types 
that themselves come from an ExternalASTSource. This 
is exposed particularly in the behavior when 
comparing complete TagDecls with forward 
declarations. This patch does several things:

- Adds a test case making sure that conflicting 
  forward-declarations are resolved correctly;
- Extends the clang-import-test harness to test 
  two-level importing, so that we make sure we 
  complete types when necessary; and
- Fixes a few bugs I found this way. Failure to 
  complete types was one; however, I also discovered 
  that complete RecordDecls aren't properly added to 
  the redecls chain for existing forward 
  declarations.

Added:
cfe/trunk/test/Import/conflicting-struct/
cfe/trunk/test/Import/conflicting-struct/Inputs/
cfe/trunk/test/Import/conflicting-struct/Inputs/S1.cpp
cfe/trunk/test/Import/conflicting-struct/Inputs/S2.cpp
cfe/trunk/test/Import/conflicting-struct/test.cpp
Modified:
cfe/trunk/include/clang/AST/ExternalASTMerger.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/AST/ExternalASTMerger.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=302975&r1=302974&r2=302975&view=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Fri May 12 19:46:33 2017
@@ -44,6 +44,8 @@ public:
   FindExternalLexicalDecls(const DeclContext *DC,
llvm::function_ref IsKindWeWant,
SmallVectorImpl &Result) override;
+
+   void CompleteType(TagDecl *Tag) override;
 };
 
 } // end namespace clang

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=302975&r1=302974&r2=302975&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri May 12 19:46:33 2017
@@ -1622,10 +1622,18 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
 
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *AdoptDecl = nullptr;
+  RecordDecl *PrevDecl = nullptr;
   if (!DC->isFunctionOrMethod()) {
 SmallVector ConflictingDecls;
 SmallVector FoundDecls;
 DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
+
+if (!FoundDecls.empty()) {
+  // We're going to have to compare D against potentially conflicting 
Decls, so complete it.
+  if (D->hasExternalLexicalStorage() && !D->isCompleteDefinition())
+D->getASTContext().getExternalSource()->CompleteType(D);
+}
+
 for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
   if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
 continue;
@@ -1652,6 +1660,8 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   }
 }
 
+PrevDecl = FoundRecord;
+
 if (RecordDecl *FoundDef = FoundRecord->getDefinition()) {
   if ((SearchName && !D->isCompleteDefinition())
   || (D->isCompleteDefinition() &&
@@ -1744,6 +1754,10 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
 LexicalDC->addDeclInternal(D2);
 if (D->isAnonymousStructOrUnion())
   D2->setAnonymousStructOrUnion(true);
+if (PrevDecl) {
+  // FIXME: do this for all Redeclarables, not just RecordDecls.
+  D2->setPreviousDecl(PrevDecl);
+}
   }
   
   Importer.Imported(D, D2);

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=302975&r1=302974&r2=302975&view=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Fri May 12 19:46:33 2017
@@ -855,6 +855,11 @@ static bool IsStructurallyEquivalent(Str
 
   if (CXXRecordDecl *D1CXX = dyn_cast(D1)) {
 if (CXXRecordDecl *D2CXX = dyn_cast(D2)) {
+  if (D1CXX->hasExternalLexicalStorage() &&
+  !D1CXX->isCompleteDefinition()) {
+D1CXX->getASTContext().getExternalSource()->CompleteType(D1CXX);
+  }
+
   if (D1CXX->getNumBases() != D2CXX->getNumBases()) {
 if (Context.Complain) {
   Context.Diag2(D2->getLocation(), 
diag::warn_odr_tag_type_inconsistent)

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=302975&r1=302974&r2=30297

LLVM lab will be unavailable tomorrow for few hours

2017-05-12 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster and LLVM lab will be unavailable tomorrow Saturday May 13
for about 4 hours (hopefully less) starting 10 AM Pacific time due to
network works.
Thank you for understanding.

Thanks

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


r302969 - Add LangOptions method to query whether we are tracking the owning module for a local declaration.

2017-05-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 12 19:00:16 2017
New Revision: 302969

URL: http://llvm.org/viewvc/llvm-project?rev=302969&view=rev
Log:
Add LangOptions method to query whether we are tracking the owning module for a 
local declaration.

In preparation for expanding this behavior to cover additional cases.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=302969&r1=302968&r2=302969&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Fri May 12 19:00:16 2017
@@ -166,6 +166,11 @@ public:
 return getCompilingModule() != CMK_None;
   }
 
+  /// Do we need to track the owning module for a local declaration?
+  bool trackLocalOwningModule() const {
+return ModulesLocalVisibility;
+  }
+
   bool isSignedOverflowDefined() const {
 return getSignedOverflowBehavior() == SOB_Defined;
   }

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=302969&r1=302968&r2=302969&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri May 12 19:00:16 2017
@@ -75,7 +75,7 @@ void *Decl::operator new(std::size_t Siz
   assert(!Parent || &Parent->getParentASTContext() == &Ctx);
   // With local visibility enabled, we track the owning module even for local
   // declarations.
-  if (Ctx.getLangOpts().ModulesLocalVisibility) {
+  if (Ctx.getLangOpts().trackLocalOwningModule()) {
 // Ensure required alignment of the resulting object by adding extra
 // padding at the start if required.
 size_t ExtraAlign =
@@ -96,7 +96,7 @@ Module *Decl::getOwningModuleSlow() cons
 }
 
 bool Decl::hasLocalOwningModuleStorage() const {
-  return getASTContext().getLangOpts().ModulesLocalVisibility;
+  return getASTContext().getLangOpts().trackLocalOwningModule();
 }
 
 const char *Decl::getDeclKindName() const {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=302969&r1=302968&r2=302969&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri May 12 19:00:16 2017
@@ -16038,7 +16038,7 @@ void Sema::ActOnModuleBegin(SourceLocati
   // The enclosing context is now part of this module.
   // FIXME: Consider creating a child DeclContext to hold the entities
   // lexically within the module.
-  if (getLangOpts().ModulesLocalVisibility) {
+  if (getLangOpts().trackLocalOwningModule()) {
 cast(CurContext)->setHidden(true);
 cast(CurContext)->setLocalOwningModule(Mod);
   }
@@ -16072,7 +16072,7 @@ void Sema::ActOnModuleEnd(SourceLocation
   BuildModuleInclude(DirectiveLoc, Mod);
 
   // Any further declarations are in whatever module we returned to.
-  if (getLangOpts().ModulesLocalVisibility) {
+  if (getLangOpts().trackLocalOwningModule()) {
 cast(CurContext)->setLocalOwningModule(getCurrentModule());
 if (!getCurrentModule())
   cast(CurContext)->setHidden(false);


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


[PATCH] D25051: Fix PR 10758: Infinite recursion when dealing with copy-initialization

2017-05-12 Thread ~paul via Phabricator via cfe-commits
cynecx added a comment.

Gentle ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D25051



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


r302966 - Remove unused tracking of owning module for MacroInfo objects.

2017-05-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 12 18:40:52 2017
New Revision: 302966

URL: http://llvm.org/viewvc/llvm-project?rev=302966&view=rev
Log:
Remove unused tracking of owning module for MacroInfo objects.

Modified:
cfe/trunk/include/clang/Lex/MacroInfo.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/MacroInfo.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=302966&r1=302965&r2=302966&view=diff
==
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Fri May 12 18:40:52 2017
@@ -105,9 +105,6 @@ class MacroInfo {
   /// \brief Must warn if the macro is unused at the end of translation unit.
   bool IsWarnIfUnused : 1;
 
-  /// \brief Whether this macro info was loaded from an AST file.
-  bool FromASTFile : 1;
-
   /// \brief Whether this macro was used as header guard.
   bool UsedForHeaderGuard : 1;
 
@@ -264,34 +261,16 @@ public:
 IsDisabled = true;
   }
 
-  /// \brief Determine whether this macro info came from an AST file (such as
-  /// a precompiled header or module) rather than having been parsed.
-  bool isFromASTFile() const { return FromASTFile; }
-
   /// \brief Determine whether this macro was used for a header guard.
   bool isUsedForHeaderGuard() const { return UsedForHeaderGuard; }
 
   void setUsedForHeaderGuard(bool Val) { UsedForHeaderGuard = Val; }
 
-  /// \brief Retrieve the global ID of the module that owns this particular
-  /// macro info.
-  unsigned getOwningModuleID() const {
-if (isFromASTFile())
-  return *(const unsigned *)(this + 1);
-
-return 0;
-  }
-
   void dump() const;
 
 private:
   unsigned getDefinitionLengthSlow(const SourceManager &SM) const;
 
-  void setOwningModuleID(unsigned ID) {
-assert(isFromASTFile());
-*(unsigned *)(this + 1) = ID;
-  }
-
   friend class Preprocessor;
 };
 

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=302966&r1=302965&r2=302966&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri May 12 18:40:52 2017
@@ -644,14 +644,6 @@ class Preprocessor {
   /// of that list.
   MacroInfoChain *MIChainHead;
 
-  struct DeserializedMacroInfoChain {
-MacroInfo MI;
-unsigned OwningModuleID; // MUST be immediately after the MacroInfo object
- // so it can be accessed by 
MacroInfo::getOwningModuleID().
-DeserializedMacroInfoChain *Next;
-  };
-  DeserializedMacroInfoChain *DeserialMIChainHead;
-
   void updateOutOfDateIdentifier(IdentifierInfo &II) const;
 
 public:
@@ -1669,10 +1661,6 @@ public:
   /// \brief Allocate a new MacroInfo object with the provided SourceLocation.
   MacroInfo *AllocateMacroInfo(SourceLocation L);
 
-  /// \brief Allocate a new MacroInfo object loaded from an AST file.
-  MacroInfo *AllocateDeserializedMacroInfo(SourceLocation L,
-   unsigned SubModuleID);
-
   /// \brief Turn the specified lexer token into a fully checked and spelled
   /// filename, e.g. as an operand of \#include. 
   ///
@@ -1764,9 +1752,6 @@ private:
   /// macro name.
   void updateModuleMacroInfo(const IdentifierInfo *II, ModuleMacroInfo &Info);
 
-  /// \brief Allocate a new MacroInfo object.
-  MacroInfo *AllocateMacroInfo();
-
   DefMacroDirective *AllocateDefMacroDirective(MacroInfo *MI,
SourceLocation Loc);
   UndefMacroDirective *AllocateUndefMacroDirective(SourceLocation UndefLoc);

Modified: cfe/trunk/lib/Lex/MacroInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroInfo.cpp?rev=302966&r1=302965&r2=302966&view=diff
==
--- cfe/trunk/lib/Lex/MacroInfo.cpp (original)
+++ cfe/trunk/lib/Lex/MacroInfo.cpp Fri May 12 18:40:52 2017
@@ -29,7 +29,6 @@ MacroInfo::MacroInfo(SourceLocation DefL
 IsUsed(false),
 IsAllowRedefinitionsWithoutWarning(false),
 IsWarnIfUnused(false),
-FromASTFile(false),
 UsedForHeaderGuard(false) {
 }
 
@@ -137,7 +136,6 @@ LLVM_DUMP_METHOD void MacroInfo::dump()
   if (IsAllowRedefinitionsWithoutWarning)
 Out << " allow_redefinitions_without_warning";
   if (IsWarnIfUnused) Out << " warn_if_unused";
-  if (FromASTFile) Out << " imported";
   if (UsedForHeaderGuard) Out << " header_guard";
 
   Out << "\n#define ";

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?r

r302965 - [modules] When creating a declaration, cache its owning module immediately

2017-05-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 12 18:27:00 2017
New Revision: 302965

URL: http://llvm.org/viewvc/llvm-project?rev=302965&view=rev
Log:
[modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.

Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=302965&r1=302964&r2=302965&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri May 12 18:27:00 2017
@@ -301,16 +301,6 @@ public:
   using Decl::isModulePrivate;
   using Decl::setModulePrivate;
 
-  /// \brief Determine whether this declaration is hidden from name lookup.
-  bool isHidden() const { return Hidden; }
-
-  /// \brief Set whether this declaration is hidden from name lookup.
-  void setHidden(bool Hide) {
-assert((!Hide || isFromASTFile() || hasLocalOwningModuleStorage()) &&
-   "declaration with no owning module can't be hidden");
-Hidden = Hide;
-  }
-
   /// \brief Determine whether this declaration is a C++ class member.
   bool isCXXClassMember() const {
 const DeclContext *DC = getDeclContext();

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=302965&r1=302964&r2=302965&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri May 12 18:27:00 2017
@@ -706,6 +706,20 @@ public:
 reinterpret_cast(this)[-1] = M;
   }
 
+  Module *getOwningModule() const {
+return isFromASTFile() ? getImportedOwningModule() : 
getLocalOwningModule();
+  }
+
+  /// \brief Determine whether this declaration is hidden from name lookup.
+  bool isHidden() const { return Hidden; }
+
+  /// \brief Set whether this declaration is hidden from name lookup.
+  void setHidden(bool Hide) {
+assert((!Hide || isFromASTFile() || hasLocalOwningModuleStorage()) &&
+   "declaration with no owning module can't be hidden");
+Hidden = Hide;
+  }
+
   unsigned getIdentifierNamespace() const {
 return IdentifierNamespace;
   }

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302965&r1=302964&r2=302965&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 12 18:27:00 2017
@@ -1463,11 +1463,9 @@ private:
 
   VisibleModuleSet VisibleModules;
 
-  Module *CachedFakeTopLevelModule;
-
 public:
   /// \brief Get the module owning an entity.
-  Module *getOwningModule(Decl *Entity);
+  Module *getOwningModule(Decl *Entity) { return Entity->getOwningModule(); }
 
   /// \brief Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=302965&r1=302964&r2=302965&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri May 12 18:27:00 2017
@@ -1038,10 +1038,10 @@ void ASTDumper::dumpDecl(const Decl *D)
 dumpSourceRange(D->getSourceRange());
 OS << ' ';
 dumpLocation(D->getLocation());
-if (Module *M = D->getImportedOwningModule())
+if (D->isFromASTFile())
+  OS << " imported";
+if (Module *M = D->getOwningModule())
   OS << " in " << M->getFullModuleName();
-else if (Module *M = D->getLocalOwningModule())
-  OS << " in (local) " << M->getFullModuleName();
 if (auto *ND = dyn_cast(D))
   for (Module *M : D->getASTContext().getModulesWithMergedDefinition(
const_cast(ND)))

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=302965&r1=302964&r2=302965&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri May 12 18:27:00 2017
@@ -47,9 +47,7 @@ bool Decl::isOutOfLine() const {
 
 TranslationUnitDecl::TranslationUnitDecl(ASTContext &ctx)
 : Decl(TranslationUnit, null

[PATCH] D31383: [inline asm] "=i" output constraint support - gcc compatiblity

2017-05-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D31383



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


[PATCH] D32981: [ASTImporter] Improve handling of incomplete types

2017-05-12 Thread Sean Callanan via Phabricator via cfe-commits
spyffe marked 2 inline comments as done.
spyffe added inline comments.



Comment at: tools/clang-import-test/clang-import-test.cpp:263
+AddExternalSource(*CI, Imports);
+  }
 

bruno wrote:
> No need for the curly braces here
Okay.


https://reviews.llvm.org/D32981



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


Re: r302932 - [modules] Simplify module macro handling in non-local-submodule-visibility mode.

2017-05-12 Thread Richard Smith via cfe-commits
On 12 May 2017 at 14:19, Juergen Ributzka  wrote:

> Hi Richard,
>
> I think this broke modules.
>
> If I try to compile a simple test program (@import Foundation;) I get the
> following error:
> ./bin/clang test.m -fmodules -c -isysroot /Applications/Xcode.app/
> Contents/Developer/Platforms/MacOSX.platform/Developer/
> SDKs/MacOSX10.12.sdk
> While building module 'Foundation' imported from test.m:1:
> While building module 'CoreGraphics' imported from /Applications/Xcode.app/
> Contents/Developer/Platforms/MacOSX.platform/Developer/
> SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Foundation.
> framework/Headers/NSGeometry.h:12:
> While building module 'IOKit' imported from /Applications/Xcode.app/
> Contents/Developer/Platforms/MacOSX.platform/Developer/
> SDKs/MacOSX10.12.sdk/System/Library/Frameworks/CoreGraphics.framework/
> Headers/CGDisplayConfiguration.h:12:
> In file included from :40:
> In file included from /Applications/Xcode.app/
> Contents/Developer/Platforms/MacOSX.platform/Developer/
> SDKs/MacOSX10.12.sdk/System/Library/Frameworks/IOKit.
> framework/Headers/hid/IOHIDDevicePlugIn.h:39:
> /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/
> Library/Frameworks/IOKit.framework/Headers/hid/IOHIDLibObsolete.h:41:8:
> error: redefinition of
>   'IOHIDEventStruct'
> struct IOHIDEventStruct
>

Already reverted, I'm investigating.


> Cheers,
> Juergen
>
>
> On Fri, May 12, 2017 at 11:56 AM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Fri May 12 13:56:03 2017
>> New Revision: 302932
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=302932&view=rev
>> Log:
>> [modules] Simplify module macro handling in
>> non-local-submodule-visibility mode.
>>
>> When reaching the end of a module, we used to convert its macros to
>> ModuleMacros but also leave them in the MacroDirective chain for the
>> identifier. This meant that every lookup of such a macro would find two
>> (identical) definitions. It also made it difficult to determine the
>> correct
>> owner for a macro when reaching the end of a module: the most recent
>> MacroDirective in the chain could be from an #included submodule rather
>> than
>> the current module.
>>
>> Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
>> leaving a module, clear out the MacroDirective chain for that identifier,
>> and
>> just rely on the ModuleMacro to provide the macro definition information.
>>
>> (We don't want to do this for local submodule visibility mode, because in
>> that
>> mode we maintain a distinct MacroDirective chain for each submodule, and
>> we
>> need to keep around the prior MacroDirective in case we re-enter the
>> submodule
>> -- for instance, if its header is #included more than once in a module
>> build,
>> we need the include guard directive to stick around. But the problem
>> doesn't
>> arise in this case for the same reason: each submodule has its own
>> MacroDirective chain, so the macros don't leak out of submodules in the
>> first
>> place.)
>>
>> Modified:
>> cfe/trunk/lib/Lex/PPLexerChange.cpp
>>
>> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexe
>> rChange.cpp?rev=302932&r1=302931&r2=302932&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri May 12 13:56:03 2017
>> @@ -731,7 +731,7 @@ Module *Preprocessor::LeaveSubmodule(boo
>>Module *LeavingMod = Info.M;
>>SourceLocation ImportLoc = Info.ImportLoc;
>>
>> -  if (!needModuleMacros() ||
>> +  if (!needModuleMacros() ||
>>(!getLangOpts().ModulesLocalVisibility &&
>> LeavingMod->getTopLevelModuleName() !=
>> getLangOpts().CurrentModule)) {
>>  // If we don't need module macros, or this is not a module for which
>> we
>> @@ -777,17 +777,6 @@ Module *Preprocessor::LeaveSubmodule(boo
>>  for (auto *MD = Macro.getLatest(); MD != OldMD; MD =
>> MD->getPrevious()) {
>>assert(MD && "broken macro directive chain");
>>
>> -  // Stop on macros defined in other submodules of this module that
>> we
>> -  // #included along the way. There's no point doing this if we're
>> -  // tracking local submodule visibility, since there can be no such
>> -  // directives in our list.
>> -  if (!getLangOpts().ModulesLocalVisibility) {
>> -Module *Mod = getModuleContainingLocation(MD->getLocation());
>> -if (Mod != LeavingMod &&
>> -Mod->getTopLevelModule() == LeavingMod->getTopLevelModule())
>> -  break;
>> -  }
>> -
>>if (auto *VisMD = dyn_cast(MD)) {
>>  // The latest visibility directive for a name in a submodule
>> affects
>>  // all the directives that come before it.
>> @@ -809,6 +798,12 @@ Module *Preprocessor::LeaveSubmodule(boo
>>  

Re: r302932 - [modules] Simplify module macro handling in non-local-submodule-visibility mode.

2017-05-12 Thread Juergen Ributzka via cfe-commits
Hi Richard,

I think this broke modules.

If I try to compile a simple test program (@import Foundation;) I get the
following error:
./bin/clang test.m -fmodules -c -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
While building module 'Foundation' imported from test.m:1:
While building module 'CoreGraphics' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSGeometry.h:12:
While building module 'IOKit' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayConfiguration.h:12:
In file included from :40:
In file included from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/IOKit.framework/Headers/hid/IOHIDDevicePlugIn.h:39:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/IOKit.framework/Headers/hid/IOHIDLibObsolete.h:41:8:
error: redefinition of
  'IOHIDEventStruct'
struct IOHIDEventStruct

Cheers,
Juergen


On Fri, May 12, 2017 at 11:56 AM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Fri May 12 13:56:03 2017
> New Revision: 302932
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302932&view=rev
> Log:
> [modules] Simplify module macro handling in non-local-submodule-visibility
> mode.
>
> When reaching the end of a module, we used to convert its macros to
> ModuleMacros but also leave them in the MacroDirective chain for the
> identifier. This meant that every lookup of such a macro would find two
> (identical) definitions. It also made it difficult to determine the correct
> owner for a macro when reaching the end of a module: the most recent
> MacroDirective in the chain could be from an #included submodule rather
> than
> the current module.
>
> Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
> leaving a module, clear out the MacroDirective chain for that identifier,
> and
> just rely on the ModuleMacro to provide the macro definition information.
>
> (We don't want to do this for local submodule visibility mode, because in
> that
> mode we maintain a distinct MacroDirective chain for each submodule, and we
> need to keep around the prior MacroDirective in case we re-enter the
> submodule
> -- for instance, if its header is #included more than once in a module
> build,
> we need the include guard directive to stick around. But the problem
> doesn't
> arise in this case for the same reason: each submodule has its own
> MacroDirective chain, so the macros don't leak out of submodules in the
> first
> place.)
>
> Modified:
> cfe/trunk/lib/Lex/PPLexerChange.cpp
>
> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> PPLexerChange.cpp?rev=302932&r1=302931&r2=302932&view=diff
> 
> ==
> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri May 12 13:56:03 2017
> @@ -731,7 +731,7 @@ Module *Preprocessor::LeaveSubmodule(boo
>Module *LeavingMod = Info.M;
>SourceLocation ImportLoc = Info.ImportLoc;
>
> -  if (!needModuleMacros() ||
> +  if (!needModuleMacros() ||
>(!getLangOpts().ModulesLocalVisibility &&
> LeavingMod->getTopLevelModuleName() !=
> getLangOpts().CurrentModule)) {
>  // If we don't need module macros, or this is not a module for which
> we
> @@ -777,17 +777,6 @@ Module *Preprocessor::LeaveSubmodule(boo
>  for (auto *MD = Macro.getLatest(); MD != OldMD; MD =
> MD->getPrevious()) {
>assert(MD && "broken macro directive chain");
>
> -  // Stop on macros defined in other submodules of this module that we
> -  // #included along the way. There's no point doing this if we're
> -  // tracking local submodule visibility, since there can be no such
> -  // directives in our list.
> -  if (!getLangOpts().ModulesLocalVisibility) {
> -Module *Mod = getModuleContainingLocation(MD->getLocation());
> -if (Mod != LeavingMod &&
> -Mod->getTopLevelModule() == LeavingMod->getTopLevelModule())
> -  break;
> -  }
> -
>if (auto *VisMD = dyn_cast(MD)) {
>  // The latest visibility directive for a name in a submodule
> affects
>  // all the directives that come before it.
> @@ -809,6 +798,12 @@ Module *Preprocessor::LeaveSubmodule(boo
>  if (Def || !Macro.getOverriddenMacros().empty())
>addModuleMacro(LeavingMod, II, Def,
>   Macro.getOverriddenMacros(), IsNew);
> +
> +if (!getLangOpts().ModulesLocalVisibility) {
> +  // This macro is 

Re: r302750 - PR22877: When constructing an array via a constructor with a default argument

2017-05-12 Thread Galina Kistanova via cfe-commits
I will look at this.

Thanks

Galina

On Fri, May 12, 2017 at 2:00 PM, Richard Smith 
wrote:

> On 12 May 2017 at 13:24, Renato Golin  wrote:
>
>> On 12 May 2017 at 20:46, Diana Picus  wrote:
>> > On 11 May 2017 at 21:14, Richard Smith  wrote:
>> >> Thanks for the revert, fixed up and recommitted in r302817.
>> >>
>> >> Any idea why not a single buildbot sent me any email about this? :( (A
>> >> couple of them were red at the previous change too, but some of them
>> were
>> >> not (eg. clang-cmake-armv7-a15).
>> >
>> > Hm, I have no idea... @Renato, thoughts?
>>
>> This seems to be the one:
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/6961
>>
>> First red in a long line of greens.
>>
>> I have received breakage emails this week, so if you didn't get the
>> email it could be some outage in the bots (Galina?) or some filters?
>>
>> I really have no better idea. :(
>
>
> Looks like I've been receiving the expected build failure mails from
> llvm.greendra...@gmail.com, but have only received one build failure
> email from llvm.buildmas...@lab.llvm.org since January 12th (on March
> 9th, for http://lab.llvm.org:8011/builders/clang-ppc64le-linux-ln
> t/builds/3791).
>
> Could this be a DMARC / DKIM issue?
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r302750 - PR22877: When constructing an array via a constructor with a default argument

2017-05-12 Thread Richard Smith via cfe-commits
On 12 May 2017 at 13:24, Renato Golin  wrote:

> On 12 May 2017 at 20:46, Diana Picus  wrote:
> > On 11 May 2017 at 21:14, Richard Smith  wrote:
> >> Thanks for the revert, fixed up and recommitted in r302817.
> >>
> >> Any idea why not a single buildbot sent me any email about this? :( (A
> >> couple of them were red at the previous change too, but some of them
> were
> >> not (eg. clang-cmake-armv7-a15).
> >
> > Hm, I have no idea... @Renato, thoughts?
>
> This seems to be the one:
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/6961
>
> First red in a long line of greens.
>
> I have received breakage emails this week, so if you didn't get the
> email it could be some outage in the bots (Galina?) or some filters?
>
> I really have no better idea. :(


Looks like I've been receiving the expected build failure mails from
llvm.greendra...@gmail.com, but have only received one build failure email
from llvm.buildmas...@lab.llvm.org since January 12th (on March 9th, for
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/3791).

Could this be a DMARC / DKIM issue?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302947 - Revert r302932, as it appears to be breaking stage2 for some of our modules-enabled buildbots.

2017-05-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 12 15:42:54 2017
New Revision: 302947

URL: http://llvm.org/viewvc/llvm-project?rev=302947&view=rev
Log:
Revert r302932, as it appears to be breaking stage2 for some of our 
modules-enabled buildbots.

Modified:
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=302947&r1=302946&r2=302947&view=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri May 12 15:42:54 2017
@@ -731,7 +731,7 @@ Module *Preprocessor::LeaveSubmodule(boo
   Module *LeavingMod = Info.M;
   SourceLocation ImportLoc = Info.ImportLoc;
 
-  if (!needModuleMacros() ||
+  if (!needModuleMacros() || 
   (!getLangOpts().ModulesLocalVisibility &&
LeavingMod->getTopLevelModuleName() != getLangOpts().CurrentModule)) {
 // If we don't need module macros, or this is not a module for which we
@@ -777,6 +777,17 @@ Module *Preprocessor::LeaveSubmodule(boo
 for (auto *MD = Macro.getLatest(); MD != OldMD; MD = MD->getPrevious()) {
   assert(MD && "broken macro directive chain");
 
+  // Stop on macros defined in other submodules of this module that we
+  // #included along the way. There's no point doing this if we're
+  // tracking local submodule visibility, since there can be no such
+  // directives in our list.
+  if (!getLangOpts().ModulesLocalVisibility) {
+Module *Mod = getModuleContainingLocation(MD->getLocation());
+if (Mod != LeavingMod &&
+Mod->getTopLevelModule() == LeavingMod->getTopLevelModule())
+  break;
+  }
+
   if (auto *VisMD = dyn_cast(MD)) {
 // The latest visibility directive for a name in a submodule affects
 // all the directives that come before it.
@@ -798,12 +809,6 @@ Module *Preprocessor::LeaveSubmodule(boo
 if (Def || !Macro.getOverriddenMacros().empty())
   addModuleMacro(LeavingMod, II, Def,
  Macro.getOverriddenMacros(), IsNew);
-
-if (!getLangOpts().ModulesLocalVisibility) {
-  // This macro is exposed to the rest of this compilation as a
-  // ModuleMacro; we don't need to track its MacroDirective any more.
-  Macro.setLatest(nullptr);
-}
 break;
   }
 }


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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:10286
+  // these variables must be a compile time constant.
+  VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
 CheckForConstantInitializer(Init, DclT);

Anastasia wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > yaxunl wrote:
> > > > rjmccall wrote:
> > > > > Should this rule apply even in C++ mode?  I can't remember if there 
> > > > > are any OpenCL/C++ hybrids.
> > > > No. This rule (static local variable needs to be initialised with 
> > > > compile-time constant) only applies to C and OpenCL. 
> > > > In C++ static local variable can be initialised with non-compile-time 
> > > > constant, in which case Clang will emit atomic instructions to make 
> > > > sure it is only initialised once.
> > > > 
> > > > Currently OpenCL 2.2 defines OpenCL C++ but clang does not support it.
> > > Yes, I understand that C++ generally allows static locals to be lazily 
> > > initialized, and that that rule would (probably) still apply to ordinary 
> > > static locals in OpenCL C++.  However, I would expect that OpenCL C++ 
> > > rule is that __constant local variables still need to be statically 
> > > initialized, because there's no plausible way in the OpenCL 
> > > implementation model to actually put lazily-initialized variables in the 
> > > constant address space.  Assuming that's correct, then I would recommend 
> > > reworking this whole chain of conditions to:
> > > 
> > >   // Don't check the initializer if the declaration is malformed.
> > >   if (VDecl->isInvalidDecl()) {
> > > // do nothing
> > > 
> > >   // OpenCL __constant locals must be constant-initialized, even in 
> > > OpenCL C++.
> > >   } else if (VDecl->getType().getAddressSpace() == 
> > > LangAS::opencl_constant) {
> > > CheckForConstantInitializer(Init, DclT);
> > > 
> > >   // Otherwise, C++ does not restrict the initializer.
> > >   } else if (getLangOpts().CPlusPlus) {
> > > // do nothing
> > > 
> > >   // C99 6.7.8p4: All the expressions in an initializer for an object 
> > > that has
> > >   // static storage duration shall be constant expressions or string 
> > > literals.
> > >   } else if (VDecl->getStorageClass() == SC_Static) {
> > > CheckForConstantInitializer(Init, DclT);
> > > 
> > >   // C89 is stricter than C99 for aggregate initializers.
> > >   // C89 6.5.7p3: All the expressions [...] in an initializer list
> > >   // for an object that has aggregate or union type shall be
> > >   // constant expressions.
> > >   } else if (!getLangOpts().C99 && VDecl->getType()->isAggregateType() && 
> > > isa(Init)) {
> > > Expr *Culprit;
> > > if (!Init->isConstantInitializer(Context, false, &Culprit)) {
> > >   ...
> > > }
> > >   }
> > Agree that even OpenCL C++ is unable to lazy initialise function-scope var 
> > in constant addr space. Will do.
> I think the original way would be much simpler to read and understand though.
> 
> To be honest I wouldn't complicate things now for the feature we don't 
> support. I feel OpenCL C++ should be represented as a separate LangOpt since 
> there are some places that will require special handling due to deviation 
> from C++. I would rather extend things later in more systematic way.
I will delete the comment about OpenCL C++ when committing.


https://reviews.llvm.org/D32977



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


[libcxx] r302944 - [test] Avoid P0138R2, direct-list-init of fixed enums from integers, part 1/3.

2017-05-12 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Fri May 12 15:33:32 2017
New Revision: 302944

URL: http://llvm.org/viewvc/llvm-project?rev=302944&view=rev
Log:
[test] Avoid P0138R2, direct-list-init of fixed enums from integers, part 1/3.

This C++17 Core Language feature isn't necessary when testing std::byte.
It's a minor convenience, but it limits test coverage to very new compilers.

This part changes the code.

Fixes D32386.

Modified:

libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
 Fri May 12 15:33:32 2017
@@ -26,9 +26,9 @@ constexpr std::byte test(std::byte b1, s
 
 int main () {
std::byte b;  // not constexpr, just used in noexcept check
-   constexpr std::byte b1{1};
-   constexpr std::byte b8{8};
-   constexpr std::byte b9{9};
+   constexpr std::byte b1{static_cast(1)};
+   constexpr std::byte b8{static_cast(8)};
+   constexpr std::byte b9{static_cast(9)};
 
static_assert(noexcept(b &= b), "" );
 

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==
--- libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp 
Fri May 12 15:33:32 2017
@@ -18,9 +18,9 @@
 // constexpr byte operator&(byte l, byte r) noexcept;
 
 int main () {
-   constexpr std::byte b1{1};
-   constexpr std::byte b8{8};
-   constexpr std::byte b9{9};
+   constexpr std::byte b1{static_cast(1)};
+   constexpr std::byte b8{static_cast(8)};
+   constexpr std::byte b9{static_cast(9)};
 
static_assert(noexcept(b1 & b8), "" );
 

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp?rev=302944&r1=302943&r2=302944&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
 Fri May 12 15:33:32 2017
@@ -28,8 +28,8 @@ constexpr std::byte test(std::byte b) {
 
 int main () {
std::byte b;  // not constexpr, just used in noexcept check
-   constexpr std::byte b2{2};
-   constexpr std::byte b3{3};
+   constexpr std::byte b2{static_cast(2)};
+   constexpr std::byte b3{static_cast(3)};
 
static_assert(noexcept(b <<= 2), "" );
 

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp?rev=302944&r1=302943&r2=302944&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp 
(original)
+++ 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp 
Fri May 12 15:3

[libcxx] r302946 - [test] Add specific test for P0138R2, direct-list-init of fixed enums from integers, part 3/3.

2017-05-12 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Fri May 12 15:33:46 2017
New Revision: 302946

URL: http://llvm.org/viewvc/llvm-project?rev=302946&view=rev
Log:
[test] Add specific test for P0138R2, direct-list-init of fixed enums from 
integers, part 3/3.

Test the C++17 Core Language feature independently from other std::byte tests.

Added:

libcxx/trunk/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp

Added: 
libcxx/trunk/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp?rev=302946&view=auto
==
--- 
libcxx/trunk/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/language.support/support.types/byteops/enum_direct_init.pass.cpp
 Fri May 12 15:33:46 2017
@@ -0,0 +1,21 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+#include 
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// The following compilers don't like "std::byte b1{1}"
+// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
+// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0
+
+int main () {
+  constexpr std::byte b{42};
+  static_assert(std::to_integer(b) == 42, "");
+}


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


[libcxx] r302945 - [test] Avoid P0138R2, direct-list-init of fixed enums from integers, part 2/3.

2017-05-12 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Fri May 12 15:33:41 2017
New Revision: 302945

URL: http://llvm.org/viewvc/llvm-project?rev=302945&view=rev
Log:
[test] Avoid P0138R2, direct-list-init of fixed enums from integers, part 2/3.

This C++17 Core Language feature isn't necessary when testing std::byte.
It's a minor convenience, but it limits test coverage to very new compilers.

This part activates the tests for more compilers.

Modified:

libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/not.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/or.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/or.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/rshift.fail.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/rshift.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.fail.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/to_integer.pass.cpp

libcxx/trunk/test/std/language.support/support.types/byteops/xor.assign.pass.cpp
libcxx/trunk/test/std/language.support/support.types/byteops/xor.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp?rev=302945&r1=302944&r2=302945&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.types/byteops/and.assign.pass.cpp
 Fri May 12 15:33:41 2017
@@ -11,9 +11,6 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
 
 // constexpr byte& operator &=(byte l, byte r) noexcept;
 

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp?rev=302945&r1=302944&r2=302945&view=diff
==
--- libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.types/byteops/and.pass.cpp 
Fri May 12 15:33:41 2017
@@ -11,9 +11,6 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
 
 // constexpr byte operator&(byte l, byte r) noexcept;
 

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp?rev=302945&r1=302944&r2=302945&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
 Fri May 12 15:33:41 2017
@@ -11,9 +11,6 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
 
 // template 
 //   constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept;

Modified: 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp?rev=302945&r1=302944&r2=302945&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp 
(original)
+++ 
libcxx/trunk/test/std/language.support/support.types/byteops/lshift.fail.cpp 
Fri May 12 15:33:41 2017
@@ -11,9 +11,6 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPP

Re: [clang-tools-extra] r302934 - [include-fixer] Don't throw exception when parsing unknown arguments in

2017-05-12 Thread Benjamin Kramer via cfe-commits
On Fri, May 12, 2017 at 9:01 PM, Haojian Wu via cfe-commits
 wrote:
> Author: hokein
> Date: Fri May 12 14:01:02 2017
> New Revision: 302934
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302934&view=rev
> Log:
> [include-fixer] Don't throw exception when parsing unknown arguments in
> vim script.

run-find-all-symbols.py is never being called from vim.

>
> Modified:
> 
> clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
>
> Modified: 
> clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py?rev=302934&r1=302933&r2=302934&view=diff
> ==
> --- 
> clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
>  (original)
> +++ 
> clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
>  Fri May 12 14:01:02 2017
> @@ -75,7 +75,7 @@ def main():
>help='path used to read a compilation database.')
>parser.add_argument('-saving-path', default='./find_all_symbols_db.yaml',
>help='result saving path')
> -  args = parser.parse_args()
> +  args, _ = parser.parse_known_args()
>
>db_path = 'compile_commands.json'
>
>
>
> ___
> 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: r302750 - PR22877: When constructing an array via a constructor with a default argument

2017-05-12 Thread Renato Golin via cfe-commits
On 12 May 2017 at 20:46, Diana Picus  wrote:
> On 11 May 2017 at 21:14, Richard Smith  wrote:
>> Thanks for the revert, fixed up and recommitted in r302817.
>>
>> Any idea why not a single buildbot sent me any email about this? :( (A
>> couple of them were red at the previous change too, but some of them were
>> not (eg. clang-cmake-armv7-a15).
>
> Hm, I have no idea... @Renato, thoughts?

This seems to be the one:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/6961

First red in a long line of greens.

I have received breakage emails this week, so if you didn't get the
email it could be some outage in the bots (Galina?) or some filters?

I really have no better idea. :(

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


r302941 - [Sema] Silence buildbot failures introduced by r302935

2017-05-12 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Fri May 12 14:55:32 2017
New Revision: 302941

URL: http://llvm.org/viewvc/llvm-project?rev=302941&view=rev
Log:
[Sema] Silence buildbot failures introduced by r302935

Attempt to silence buildbot failures by pinning the test to a given
triple rather than the host's triple.


Modified:
cfe/trunk/test/Sema/vector-gcc-compat.c
cfe/trunk/test/Sema/vector-gcc-compat.cpp

Modified: cfe/trunk/test/Sema/vector-gcc-compat.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-gcc-compat.c?rev=302941&r1=302940&r2=302941&view=diff
==
--- cfe/trunk/test/Sema/vector-gcc-compat.c (original)
+++ cfe/trunk/test/Sema/vector-gcc-compat.c Fri May 12 14:55:32 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything -triple 
x86_64-apple-darwin10
 
 // Test the compatibility of clang's vector extensions with gcc's vector
 // extensions for C. Notably &&, ||, ?: and ! are not available.

Modified: cfe/trunk/test/Sema/vector-gcc-compat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-gcc-compat.cpp?rev=302941&r1=302940&r2=302941&view=diff
==
--- cfe/trunk/test/Sema/vector-gcc-compat.cpp (original)
+++ cfe/trunk/test/Sema/vector-gcc-compat.cpp Fri May 12 14:55:32 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything -std=c++11
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything -std=c++11 -triple 
x86_64-apple-darwin10
 
 // Test the compatibility of clang++'s vector extensions with g++'s vector
 // extensions. In comparison to the extensions available in C, the !, ?:, && 
and


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


Re: r302750 - PR22877: When constructing an array via a constructor with a default argument

2017-05-12 Thread Diana Picus via cfe-commits
On 11 May 2017 at 21:14, Richard Smith  wrote:
> Thanks for the revert, fixed up and recommitted in r302817.
>
> Any idea why not a single buildbot sent me any email about this? :( (A
> couple of them were red at the previous change too, but some of them were
> not (eg. clang-cmake-armv7-a15).

Hm, I have no idea... @Renato, thoughts?

>
> On 11 May 2017 at 01:28, Diana Picus  wrote:
>>
>> Hexagon too:
>> http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/7916
>>
>> On 11 May 2017 at 10:27, Diana Picus  wrote:
>> > Hi Richard,
>> >
>> > I reverted this and its fixup in r302776 since some of the ARM bots
>> > were still broken:
>> > http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/6969
>> > http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/6959
>> > http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/6717
>> >
>> > http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/1518
>> >
>> > Sorry,
>> > Diana
>> >
>> > On 11 May 2017 at 02:17, Richard Smith via cfe-commits
>> >  wrote:
>> >> Author: rsmith
>> >> Date: Wed May 10 19:17:17 2017
>> >> New Revision: 302750
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=302750&view=rev
>> >> Log:
>> >> PR22877: When constructing an array via a constructor with a default
>> >> argument
>> >> in list-initialization, run cleanups for the default argument after
>> >> each
>> >> iteration of the initialization loop.
>> >>
>> >> We previously only ran the destructor for any temporary once, at the
>> >> end of the
>> >> complete loop, rather than once per iteration!
>> >>
>> >> Added:
>> >> cfe/trunk/test/CodeGenCXX/array-default-argument.cpp
>> >> Modified:
>> >> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>> >>
>> >> Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=302750&r1=302749&r2=302750&view=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
>> >> +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Wed May 10 19:17:17 2017
>> >> @@ -512,12 +512,20 @@ void AggExprEmitter::EmitArrayInit(Addre
>> >>  currentElement->addIncoming(element, entryBB);
>> >>
>> >>  // Emit the actual filler expression.
>> >> -LValue elementLV =
>> >> -  CGF.MakeAddrLValue(Address(currentElement, elementAlign),
>> >> elementType);
>> >> -if (filler)
>> >> -  EmitInitializationToLValue(filler, elementLV);
>> >> -else
>> >> -  EmitNullInitializationToLValue(elementLV);
>> >> +{
>> >> +  // C++1z [class.temporary]p5:
>> >> +  //   when a default constructor is called to initialize an
>> >> element of
>> >> +  //   an array with no corresponding initializer [...] the
>> >> destruction of
>> >> +  //   every temporary created in a default argument is sequenced
>> >> before
>> >> +  //   the construction of the next array element, if any
>> >> +  CodeGenFunction::RunCleanupsScope CleanupsScope(CGF);
>> >> +  LValue elementLV =
>> >> +CGF.MakeAddrLValue(Address(currentElement, elementAlign),
>> >> elementType);
>> >> +  if (filler)
>> >> +EmitInitializationToLValue(filler, elementLV);
>> >> +  else
>> >> +EmitNullInitializationToLValue(elementLV);
>> >> +}
>> >>
>> >>  // Move on to the next element.
>> >>  llvm::Value *nextElement =
>> >>
>> >> Added: cfe/trunk/test/CodeGenCXX/array-default-argument.cpp
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/array-default-argument.cpp?rev=302750&view=auto
>> >>
>> >> ==
>> >> --- cfe/trunk/test/CodeGenCXX/array-default-argument.cpp (added)
>> >> +++ cfe/trunk/test/CodeGenCXX/array-default-argument.cpp Wed May 10
>> >> 19:17:17 2017
>> >> @@ -0,0 +1,36 @@
>> >> +// RUN: %clang_cc1 -emit-llvm -o - %s -triple %itanium_abi_triple |
>> >> FileCheck %s
>> >> +// RUN: %clang_cc1 -emit-llvm -o - %s -triple %itanium_abi_triple
>> >> -fexceptions -fcxx-exceptions | FileCheck %s --check-prefix=CHECK
>> >> --check-prefix=CHECK-EH
>> >> +
>> >> +struct A {
>> >> +  A();
>> >> +  ~A();
>> >> +};
>> >> +
>> >> +struct B {
>> >> +  B(A = A());
>> >> +  ~B();
>> >> +};
>> >> +
>> >> +void f();
>> >> +// CHECK-LABEL: define void @_Z1gv()
>> >> +void g() {
>> >> +  // CHECK: br label %[[LOOP:.*]]
>> >> +
>> >> +  // [[LOOP]]:
>> >> +  // CHECK: {{call|invoke}} void @_ZN1AC1Ev([[TEMPORARY:.*]])
>> >> +  // CHECK-EH:  unwind label %[[PARTIAL_ARRAY_LPAD:.*]]
>> >> +  // CHECK: {{call|invoke}} void @_ZN1BC1E1A({{.*}}, [[TEMPORARY]])
>> >> +  // CHECK-EH:  unwind label %[[A_AND_PARTIAL_ARRAY_LPAD:.*]]
>> >> +  // CHECK: {{call|invoke}} void @_ZN1AD1Ev([[TEMPORARY]])
>> >> +  // CHECK-EH:  unwind label %[[PARTIAL_ARRAY_LPAD]]
>> >> +  // CHECK: getelementptr {{.*}}, i{{[0-9]*}} 1
>> >> +  // CHECK: icmp eq
>> >> +  //

r302940 - Remove ignore-empty-index-file option

2017-05-12 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri May 12 14:32:17 2017
New Revision: 302940

URL: http://llvm.org/viewvc/llvm-project?rev=302940&view=rev
Log:
Remove ignore-empty-index-file option

Summary:
Clang changes to remove this option and replace with a parameter
always set in the context of a ThinLTO distributed backend.

Depends on D33133.

Reviewers: pcc

Subscribers: mehdi_amini, eraman, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=302940&r1=302939&r2=302940&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri May 12 14:32:17 2017
@@ -1073,7 +1073,8 @@ void clang::EmitBackendOutput(Diagnostic
 // into memory and pass it into runThinLTOBackend, which will run the
 // function importer and invoke LTO passes.
 Expected> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
+llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile,
+   
/*IgnoreEmptyThinLTOIndexFile*/true);
 if (!IndexOrErr) {
   logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
 "Error loading index file '" +

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=302940&r1=302939&r2=302940&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Fri May 12 14:32:17 2017
@@ -12,10 +12,10 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
-; Ensure we ignore empty index file under -ignore-empty-index-file, and run
-; non-ThinLTO compilation which would not import f2
+; Ensure we ignore empty index file, and run non-ThinLTO compilation which
+; would not import f2
 ; RUN: touch %t4.thinlto.bc
-; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c 
-fthinlto-index=%t4.thinlto.bc -mllvm -ignore-empty-index-file
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c 
-fthinlto-index=%t4.thinlto.bc
 ; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
 ; CHECK-OBJ-IGNORE-EMPTY: T f1
 ; CHECK-OBJ-IGNORE-EMPTY: U f2


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


[PATCH] D33134: Remove ignore-empty-index-file option

2017-05-12 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302940: Remove ignore-empty-index-file option (authored by 
tejohnson).

Changed prior to commit:
  https://reviews.llvm.org/D33134?vs=98779&id=98821#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33134

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/thinlto_backend.ll


Index: cfe/trunk/test/CodeGen/thinlto_backend.ll
===
--- cfe/trunk/test/CodeGen/thinlto_backend.ll
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll
@@ -12,10 +12,10 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
-; Ensure we ignore empty index file under -ignore-empty-index-file, and run
-; non-ThinLTO compilation which would not import f2
+; Ensure we ignore empty index file, and run non-ThinLTO compilation which
+; would not import f2
 ; RUN: touch %t4.thinlto.bc
-; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c 
-fthinlto-index=%t4.thinlto.bc -mllvm -ignore-empty-index-file
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c 
-fthinlto-index=%t4.thinlto.bc
 ; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
 ; CHECK-OBJ-IGNORE-EMPTY: T f1
 ; CHECK-OBJ-IGNORE-EMPTY: U f2
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1073,7 +1073,8 @@
 // into memory and pass it into runThinLTOBackend, which will run the
 // function importer and invoke LTO passes.
 Expected> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
+llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile,
+   
/*IgnoreEmptyThinLTOIndexFile*/true);
 if (!IndexOrErr) {
   logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
 "Error loading index file '" +


Index: cfe/trunk/test/CodeGen/thinlto_backend.ll
===
--- cfe/trunk/test/CodeGen/thinlto_backend.ll
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll
@@ -12,10 +12,10 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
-; Ensure we ignore empty index file under -ignore-empty-index-file, and run
-; non-ThinLTO compilation which would not import f2
+; Ensure we ignore empty index file, and run non-ThinLTO compilation which
+; would not import f2
 ; RUN: touch %t4.thinlto.bc
-; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc -mllvm -ignore-empty-index-file
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc
 ; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
 ; CHECK-OBJ-IGNORE-EMPTY: T f1
 ; CHECK-OBJ-IGNORE-EMPTY: U f2
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1073,7 +1073,8 @@
 // into memory and pass it into runThinLTOBackend, which will run the
 // function importer and invoke LTO passes.
 Expected> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
+llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile,
+   /*IgnoreEmptyThinLTOIndexFile*/true);
 if (!IndexOrErr) {
   logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
 "Error loading index file '" +
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-05-12 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302935: [Sema] Support implicit scalar to vector conversions 
(authored by sdardis).

Changed prior to commit:
  https://reviews.llvm.org/D25866?vs=98783&id=98815#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25866

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/Sema/vector-cast.c
  cfe/trunk/test/Sema/vector-gcc-compat.c
  cfe/trunk/test/Sema/vector-gcc-compat.cpp
  cfe/trunk/test/Sema/vector-ops.c
  cfe/trunk/test/Sema/zvector.c
  cfe/trunk/test/SemaCXX/vector-no-lax.cpp

Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -8031,6 +8031,33 @@
   return QualType();
 }
 
+// Diagnose cases where a scalar was implicitly converted to a vector and
+// diagnose the underlying types. Otherwise, diagnose the error
+// as invalid vector logical operands for non-C++ cases.
+QualType Sema::InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
+ExprResult &RHS) {
+  QualType LHSType = LHS.get()->IgnoreImpCasts()->getType();
+  QualType RHSType = RHS.get()->IgnoreImpCasts()->getType();
+
+  bool LHSNatVec = LHSType->isVectorType();
+  bool RHSNatVec = RHSType->isVectorType();
+
+  if (!(LHSNatVec && RHSNatVec)) {
+Expr *Vector = LHSNatVec ? LHS.get() : RHS.get();
+Expr *NonVector = !LHSNatVec ? LHS.get() : RHS.get();
+Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
+<< 0 << Vector->getType() << NonVector->IgnoreImpCasts()->getType()
+<< Vector->getSourceRange();
+return QualType();
+  }
+
+  Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
+  << 1 << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+
+  return QualType();
+}
+
 /// Try to convert a value of non-vector type to a vector type by converting
 /// the type to the element type of the vector and then performing a splat.
 /// If the language is OpenCL, we only use conversions that promote scalar
@@ -8078,6 +8105,162 @@
   return false;
 }
 
+/// Test if a (constant) integer Int can be casted to another integer type
+/// IntTy without losing precision.
+static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int,
+  QualType OtherIntTy) {
+  QualType IntTy = Int->get()->getType().getUnqualifiedType();
+
+  // Reject cases where the value of the Int is unknown as that would
+  // possibly cause truncation, but accept cases where the scalar can be
+  // demoted without loss of precision.
+  llvm::APSInt Result;
+  bool CstInt = Int->get()->EvaluateAsInt(Result, S.Context);
+  int Order = S.Context.getIntegerTypeOrder(OtherIntTy, IntTy);
+  bool IntSigned = IntTy->hasSignedIntegerRepresentation();
+  bool OtherIntSigned = OtherIntTy->hasSignedIntegerRepresentation();
+
+  if (CstInt) {
+// If the scalar is constant and is of a higher order and has more active
+// bits that the vector element type, reject it.
+unsigned NumBits = IntSigned
+   ? (Result.isNegative() ? Result.getMinSignedBits()
+  : Result.getActiveBits())
+   : Result.getActiveBits();
+if (Order < 0 && S.Context.getIntWidth(OtherIntTy) < NumBits)
+  return true;
+
+// If the signedness of the scalar type and the vector element type
+// differs and the number of bits is greater than that of the vector
+// element reject it.
+return (IntSigned != OtherIntSigned &&
+NumBits > S.Context.getIntWidth(OtherIntTy));
+  }
+
+  // Reject cases where the value of the scalar is not constant and it's
+  // order is greater than that of the vector element type.
+  return (Order < 0);
+}
+
+/// Test if a (constant) integer Int can be casted to floating point type
+/// FloatTy without losing precision.
+static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int,
+ QualType FloatTy) {
+  QualType IntTy = Int->get()->getType().getUnqualifiedType();
+
+  // Determine if the integer constant can be expressed as a floating point
+  // number of the appropiate type.
+  llvm::APSInt Result;
+  bool CstInt = Int->get()->EvaluateAsInt(Result, S.Context);
+  uint64_t Bits = 0;
+  if (CstInt) {
+// Reject constants that would be truncated if they were converted to
+// the floating point type. Test by simple to/from conversion.
+// FIXME: Ideally the conversion to an APFloat and from an APFloat
+//could be avoided if there was a convertFromAPInt method
+//which could signal back if implicit truncation occurred.
+llvm::APFloat Float(S.Co

r302935 - [Sema] Support implicit scalar to vector conversions

2017-05-12 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Fri May 12 14:11:06 2017
New Revision: 302935

URL: http://llvm.org/viewvc/llvm-project?rev=302935&view=rev
Log:
[Sema] Support implicit scalar to vector conversions

This patch teaches clang to perform implicit scalar to vector conversions
when one of the operands of a binary vector expression is a scalar which
can be converted to the element type of the vector without truncation
following GCC's implementation.

If the (constant) scalar is can be casted safely, it is implicitly casted to the
vector elements type and splatted to produce a vector of the same type.

Contributions from: Petar Jovanovic

Reviewers: bruno, vkalintiris

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


Added:
cfe/trunk/test/Sema/vector-gcc-compat.c
cfe/trunk/test/Sema/vector-gcc-compat.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/Sema/vector-cast.c
cfe/trunk/test/Sema/vector-ops.c
cfe/trunk/test/Sema/zvector.c
cfe/trunk/test/SemaCXX/vector-no-lax.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302935&r1=302934&r2=302935&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 12 14:11:06 
2017
@@ -2465,6 +2465,9 @@ def err_attribute_invalid_size : Error<
   "vector size not an integral multiple of component size">;
 def err_attribute_zero_size : Error<"zero vector size">;
 def err_attribute_size_too_large : Error<"vector size too large">;
+def err_typecheck_vector_not_convertable_implict_truncation : Error<
+   "cannot convert between %select{scalar|vector}0 type %1 and vector type"
+   " %2 as implicit conversion would cause truncation">;
 def err_typecheck_vector_not_convertable : Error<
   "cannot convert between vector values of different size (%0 and %1)">;
 def err_typecheck_vector_not_convertable_non_scalar : Error<
@@ -5779,6 +5782,9 @@ def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;
 def err_typecheck_invalid_operands : Error<
   "invalid operands to binary expression (%0 and %1)">;
+def err_typecheck_logical_vector_expr_gnu_cpp_restrict : Error<
+  "logical expression with vector %select{type %1 and non-vector type %2|types"
+  " %1 and %2}0 is only supported in C++">;
 def err_typecheck_sub_ptr_compatible : Error<
   "%diff{$ and $ are not pointers to compatible types|"
   "pointers to incompatible types}0,1">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302935&r1=302934&r2=302935&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 12 14:11:06 2017
@@ -9285,6 +9285,8 @@ public:
   /// type checking binary operators (subroutines of CreateBuiltinBinOp).
   QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS,
ExprResult &RHS);
+  QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
+ ExprResult &RHS);
   QualType CheckPointerToMemberOperands( // C++ 5.5
 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
 SourceLocation OpLoc, bool isIndirect);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=302935&r1=302934&r2=302935&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 12 14:11:06 2017
@@ -8031,6 +8031,33 @@ QualType Sema::InvalidOperands(SourceLoc
   return QualType();
 }
 
+// Diagnose cases where a scalar was implicitly converted to a vector and
+// diagnose the underlying types. Otherwise, diagnose the error
+// as invalid vector logical operands for non-C++ cases.
+QualType Sema::InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult 
&LHS,
+ExprResult &RHS) {
+  QualType LHSType = LHS.get()->IgnoreImpCasts()->getType();
+  QualType RHSType = RHS.get()->IgnoreImpCasts()->getType();
+
+  bool LHSNatVec = LHSType->isVectorType();
+  bool RHSNatVec = RHSType->isVectorType();
+
+  if (!(LHSNatVec && RHSNatVec)) {
+Expr *Vector = LHSNatVec ? LHS.get() : RHS.get();
+Expr *NonVector = !LHSNatVec ? LHS.get() : RHS.get();
+Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
+<< 0 << Vector->getType() << NonVector->IgnoreImpCasts()->getType()
+<< Vector->getSourceRange();
+return QualType();
+

[clang-tools-extra] r302934 - [include-fixer] Don't throw exception when parsing unknown arguments in

2017-05-12 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 12 14:01:02 2017
New Revision: 302934

URL: http://llvm.org/viewvc/llvm-project?rev=302934&view=rev
Log:
[include-fixer] Don't throw exception when parsing unknown arguments in
vim script.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py?rev=302934&r1=302933&r2=302934&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 (original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 Fri May 12 14:01:02 2017
@@ -75,7 +75,7 @@ def main():
   help='path used to read a compilation database.')
   parser.add_argument('-saving-path', default='./find_all_symbols_db.yaml',
   help='result saving path')
-  args = parser.parse_args()
+  args, _ = parser.parse_known_args()
 
   db_path = 'compile_commands.json'
 


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


r302932 - [modules] Simplify module macro handling in non-local-submodule-visibility mode.

2017-05-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 12 13:56:03 2017
New Revision: 302932

URL: http://llvm.org/viewvc/llvm-project?rev=302932&view=rev
Log:
[modules] Simplify module macro handling in non-local-submodule-visibility mode.

When reaching the end of a module, we used to convert its macros to
ModuleMacros but also leave them in the MacroDirective chain for the
identifier. This meant that every lookup of such a macro would find two
(identical) definitions. It also made it difficult to determine the correct
owner for a macro when reaching the end of a module: the most recent
MacroDirective in the chain could be from an #included submodule rather than
the current module.

Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
leaving a module, clear out the MacroDirective chain for that identifier, and
just rely on the ModuleMacro to provide the macro definition information.

(We don't want to do this for local submodule visibility mode, because in that
mode we maintain a distinct MacroDirective chain for each submodule, and we
need to keep around the prior MacroDirective in case we re-enter the submodule
-- for instance, if its header is #included more than once in a module build,
we need the include guard directive to stick around. But the problem doesn't
arise in this case for the same reason: each submodule has its own
MacroDirective chain, so the macros don't leak out of submodules in the first
place.)

Modified:
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=302932&r1=302931&r2=302932&view=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Fri May 12 13:56:03 2017
@@ -731,7 +731,7 @@ Module *Preprocessor::LeaveSubmodule(boo
   Module *LeavingMod = Info.M;
   SourceLocation ImportLoc = Info.ImportLoc;
 
-  if (!needModuleMacros() || 
+  if (!needModuleMacros() ||
   (!getLangOpts().ModulesLocalVisibility &&
LeavingMod->getTopLevelModuleName() != getLangOpts().CurrentModule)) {
 // If we don't need module macros, or this is not a module for which we
@@ -777,17 +777,6 @@ Module *Preprocessor::LeaveSubmodule(boo
 for (auto *MD = Macro.getLatest(); MD != OldMD; MD = MD->getPrevious()) {
   assert(MD && "broken macro directive chain");
 
-  // Stop on macros defined in other submodules of this module that we
-  // #included along the way. There's no point doing this if we're
-  // tracking local submodule visibility, since there can be no such
-  // directives in our list.
-  if (!getLangOpts().ModulesLocalVisibility) {
-Module *Mod = getModuleContainingLocation(MD->getLocation());
-if (Mod != LeavingMod &&
-Mod->getTopLevelModule() == LeavingMod->getTopLevelModule())
-  break;
-  }
-
   if (auto *VisMD = dyn_cast(MD)) {
 // The latest visibility directive for a name in a submodule affects
 // all the directives that come before it.
@@ -809,6 +798,12 @@ Module *Preprocessor::LeaveSubmodule(boo
 if (Def || !Macro.getOverriddenMacros().empty())
   addModuleMacro(LeavingMod, II, Def,
  Macro.getOverriddenMacros(), IsNew);
+
+if (!getLangOpts().ModulesLocalVisibility) {
+  // This macro is exposed to the rest of this compilation as a
+  // ModuleMacro; we don't need to track its MacroDirective any more.
+  Macro.setLatest(nullptr);
+}
 break;
   }
 }


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


[PATCH] D33134: Remove ignore-empty-index-file option

2017-05-12 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D33134



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


[PATCH] D33135: [ASTMatchers] Add support for floatLiterals

2017-05-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/ASTMatchers/Dynamic/Parser.h:25
 ///:= true | false
+/// := 1.0 | 2e-3 | 3.45e67
 ///   := [0-9]+

It'd be good to list the actual grammar rather than a few examples.



Comment at: include/clang/ASTMatchers/Dynamic/VariantValue.h:335
 unsigned Unsigned;
+double Double;
 bool Boolean;

This may or may not be a good idea, but do we want to put the values into an 
APFloat rather than a double? My concern with double is that (0) it may be 
subtly different if the user wants a 16- or 32-bit float explicitly, (1) it 
won't be able to represent long double values, or quad double.

I'm thinking this value could be passed directly from the C++ API as an 
APFloat, float, or double, or provided using a StringRef for the dynamic API.



Comment at: lib/ASTMatchers/Dynamic/Parser.cpp:180
   /// \brief Consume an unsigned literal.
   void consumeUnsignedLiteral(TokenInfo *Result) {
+bool isFloatingLiteral = false;

This function should be renamed and the comment updated.


https://reviews.llvm.org/D33135



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


[PATCH] D32046: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments

2017-05-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Bump :)


https://reviews.llvm.org/D32046



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


[PATCH] D32842: Specify which sanitizers are covered by a sanitizer blacklist

2017-05-12 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Ping.


https://reviews.llvm.org/D32842



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


r302918 - [index] Index template specialization arguments for function templats

2017-05-12 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri May 12 11:32:26 2017
New Revision: 302918

URL: http://llvm.org/viewvc/llvm-project?rev=302918&view=rev
Log:
[index] Index template specialization arguments for function templats

Also ensure that class template specialization arguments are covered

rdar://31812032

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=302918&r1=302917&r2=302918&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Fri May 12 11:32:26 2017
@@ -52,6 +52,22 @@ public:
 return MD && !MD->isImplicit() && MD->isThisDeclarationADefinition();
   }
 
+  void handleTemplateArgumentLoc(const TemplateArgumentLoc &TALoc,
+ const NamedDecl *Parent,
+ const DeclContext *DC) {
+const TemplateArgumentLocInfo &LocInfo = TALoc.getLocInfo();
+switch (TALoc.getArgument().getKind()) {
+case TemplateArgument::Expression:
+  IndexCtx.indexBody(LocInfo.getAsExpr(), Parent, DC);
+  break;
+case TemplateArgument::Type:
+  IndexCtx.indexTypeSourceInfo(LocInfo.getAsTypeSourceInfo(), Parent, DC);
+  break;
+default:
+  break;
+}
+  }
+
   void handleDeclarator(const DeclaratorDecl *D,
 const NamedDecl *Parent = nullptr,
 bool isIBType = false) {
@@ -233,6 +249,12 @@ public:
  Dtor->getParent(), Dtor->getDeclContext());
   }
 }
+// Template specialization arguments.
+if (const ASTTemplateArgumentListInfo *TemplateArgInfo =
+D->getTemplateSpecializationArgsAsWritten()) {
+  for (const auto &Arg : TemplateArgInfo->arguments())
+handleTemplateArgumentLoc(Arg, D, D->getLexicalDeclContext());
+}
 
 if (D->isThisDeclarationADefinition()) {
   const Stmt *Body = D->getBody();

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=302918&r1=302917&r2=302918&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Fri May 12 11:32:26 2017
@@ -287,3 +287,30 @@ class PartialSpecilizationClass2#T#T@PartialSpecilizationClass |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-6]]:33 | class/C++ | Cls | c:@S@Cls |  | Ref 
| rel: 0
 // CHECK-NEXT: [[@LINE-7]]:38 | class/C++ | Cls | c:@S@Cls |  | Ref 
| rel: 0
+
+template
+void functionSp() { }
+
+struct Record {
+  constexpr static int C = 2;
+};
+
+template<>
+void functionSp, Record::C>() {
+// CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | 
c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | 
__Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | 
rel: 1
+// CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
+// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | 
Ref,RelCont | rel: 1
+// CHECK: [[@LINE-5]]:50 | static-property/C++ | C | c:@S@Record@C | 
__ZN6Record1CE | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-6]]:42 | struct/C++ | Record | c:@S@Record |  | 
Ref,RelCont | rel: 1
+}
+
+template
+class ClassWithCorrectSpecialization { };
+
+template<>
+class ClassWithCorrectSpecialization, Record::C> { };
+// CHECK: [[@LINE-1]]:38 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls |  | Ref | 
rel: 0
+// CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | 
__ZN6Record1CE | Ref,Read | rel: 0
+// CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record |  | 
Ref | rel: 0


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


Re: r302840 - Module Debug Info: Emit namespaced C++ forward decls in the correct module.

2017-05-12 Thread Adrian Prantl via cfe-commits

> On May 11, 2017, at 5:05 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
>> 
>> On May 11, 2017, at 4:43 PM, Richard Smith  wrote:
>> 
>> I don't think that's quite right; the AST doesn't merge NamespaceDecls. It 
>> looks like the issue is that we're mapping to the semantic DeclContext 
>> (which will be the canonical declaration of the namespace and could be from 
>> a different module) rather than the lexical DeclContext (the enclosing one, 
>> in the same module)... and then getOrCreateNameSpace is again mapping to the 
>> canonical declaration before calling getDeclContextDescriptor.
> 
> Thanks for pointing this out! It looks like I can simplify the code a lot if 
> I can pass the lexical DeclContext to getOrCreateNamespace and then delegate 
> the uniquing of the DINamespaces to DIBuilder (or rather MDNode), which will 
> work now that DINamespaces don't carry line and file any more.
> 
> I see that there is Decl::getLexicalContext(), so this should be doable.

Done in r302915. Looking much cleaner now. Thanks!

-- adrian

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


r302915 - Simplify DINamespace caching in CGDebugInfo

2017-05-12 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri May 12 11:23:53 2017
New Revision: 302915

URL: http://llvm.org/viewvc/llvm-project?rev=302915&view=rev
Log:
Simplify DINamespace caching in CGDebugInfo

This addresses review feedback from r302840.

By not canonicalizing namespace decls and using lexical decl context
instead of lookuing up the semantic decl context we can take advantage
of the fact that DINamespaces a reuniqued. This way non-module debug
info is unchanged and module debug info still gets distinct namespace
declarations when they ocur in different modules.

Thanks to Richard Smith for pointing this out!

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=302915&r1=302914&r2=302915&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri May 12 11:23:53 2017
@@ -208,10 +208,8 @@ llvm::DIScope *CGDebugInfo::getContextDe
   }
 
   // Check namespace.
-  if (const auto *NSDecl = dyn_cast(Context)) {
-auto *ParentModule = dyn_cast(Default);
-return getOrCreateNamespace(NSDecl, ParentModule);
-  }
+  if (const auto *NSDecl = dyn_cast(Context))
+return getOrCreateNamespace(NSDecl);
 
   if (const auto *RDecl = dyn_cast(Context))
 if (!RDecl->isDependentType())
@@ -2862,8 +2860,8 @@ void CGDebugInfo::collectFunctionDeclPro
 
   if (DebugKind >= codegenoptions::LimitedDebugInfo) {
 if (const NamespaceDecl *NSDecl =
-dyn_cast_or_null(FD->getDeclContext()))
-FDContext = getOrCreateNamespace(NSDecl, getParentModuleOrNull(FD));
+dyn_cast_or_null(FD->getLexicalDeclContext()))
+  FDContext = getOrCreateNamespace(NSDecl);
 else if (const RecordDecl *RDecl =
  dyn_cast_or_null(FD->getDeclContext())) {
   llvm::DIScope *Mod = getParentModuleOrNull(RDecl);
@@ -3963,7 +3961,7 @@ void CGDebugInfo::EmitUsingDirective(con
   CGM.getCodeGenOpts().DebugExplicitImport) {
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
-getOrCreateNamespace(NSDecl, getParentModuleOrNull(&UD)),
+getOrCreateNamespace(NSDecl),
 getLineNumber(UD.getLocation()));
   }
 }
@@ -4023,32 +4021,26 @@ CGDebugInfo::EmitNamespaceAlias(const Na
   else
 R = DBuilder.createImportedDeclaration(
 getCurrentContextDescriptor(cast(NA.getDeclContext())),
-getOrCreateNamespace(cast(NA.getAliasedNamespace()),
- getParentModuleOrNull(&NA)),
+getOrCreateNamespace(cast(NA.getAliasedNamespace())),
 getLineNumber(NA.getLocation()), NA.getName());
   VH.reset(R);
   return R;
 }
 
 llvm::DINamespace *
-CGDebugInfo::getOrCreateNamespace(const NamespaceDecl *NSDecl,
-  llvm::DIModule *ParentModule) {
-  NSDecl = NSDecl->getCanonicalDecl();
-  // The AST merges NamespaceDecls, but for module debug info it is important 
to
-  // put a namespace decl (or rather its children) into the correct
-  // (sub-)module, so use the parent module of the decl that triggered this
-  // namespace to be serialized as a second key.
-  NamespaceKey Key = {NSDecl, ParentModule};
-  auto I = NamespaceCache.find(Key);
+CGDebugInfo::getOrCreateNamespace(const NamespaceDecl *NSDecl) {
+  // Don't canonicalize the NamespaceDecl here: The DINamespace will be uniqued
+  // if necessary, and this way multiple declarations of the same namespace in
+  // different parent modules stay distinct.
+  auto I = NamespaceCache.find(NSDecl);
   if (I != NamespaceCache.end())
 return cast(I->second);
 
   llvm::DIScope *Context = getDeclContextDescriptor(NSDecl);
   // Don't trust the context if it is a DIModule (see comment above).
-  llvm::DINamespace *NS = DBuilder.createNameSpace(
-  isa(Context) ? ParentModule : Context, NSDecl->getName(),
-  NSDecl->isInline());
-  NamespaceCache[Key].reset(NS);
+  llvm::DINamespace *NS =
+  DBuilder.createNameSpace(Context, NSDecl->getName(), NSDecl->isInline());
+  NamespaceCache[NSDecl].reset(NS);
   return NS;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=302915&r1=302914&r2=302915&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri May 12 11:23:53 2017
@@ -125,8 +125,7 @@ class CGDebugInfo {
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
-  typedef std::pair 
NamespaceKey;
-  llvm::DenseMap NamespaceCache;
+  llvm::DenseMap NamespaceCache;
   llvm::DenseMap
   NamespaceAliasCache;
  

[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-05-12 Thread Simon Dardis via Phabricator via cfe-commits
sdardis updated this revision to Diff 98783.
sdardis marked an inline comment as done.
sdardis edited the summary of this revision.
sdardis added a comment.

Updated error message for logical operations where one operand is a vector and 
the other isn't.

Updated summary.

I'll commit this shortly.


https://reviews.llvm.org/D25866

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/Sema/vector-cast.c
  test/Sema/vector-gcc-compat.c
  test/Sema/vector-gcc-compat.cpp
  test/Sema/vector-ops.c
  test/Sema/zvector.c
  test/SemaCXX/vector-no-lax.cpp

Index: test/SemaCXX/vector-no-lax.cpp
===
--- test/SemaCXX/vector-no-lax.cpp
+++ test/SemaCXX/vector-no-lax.cpp
@@ -4,6 +4,6 @@
 
 vSInt32 foo (vUInt32 a) {
   vSInt32 b = { 0, 0, 0, 0 };
-  b += a; // expected-error{{cannot convert between vector values}}
+  b += a; // expected-error{{cannot convert between vector type 'vUInt32' (vector of 4 'unsigned int' values) and vector type 'vSInt32' (vector of 4 'int' values) as implicit conversion would cause truncation}}
   return b;
 }
Index: test/Sema/zvector.c
===
--- test/Sema/zvector.c
+++ test/Sema/zvector.c
@@ -326,14 +326,14 @@
   bc = bc + sc2; // expected-error {{incompatible type}}
   bc = sc + bc2; // expected-error {{incompatible type}}
 
-  sc = sc + sc_scalar; // expected-error {{cannot convert}}
-  sc = sc + uc_scalar; // expected-error {{cannot convert}}
-  sc = sc_scalar + sc; // expected-error {{cannot convert}}
-  sc = uc_scalar + sc; // expected-error {{cannot convert}}
-  uc = uc + sc_scalar; // expected-error {{cannot convert}}
-  uc = uc + uc_scalar; // expected-error {{cannot convert}}
-  uc = sc_scalar + uc; // expected-error {{cannot convert}}
-  uc = uc_scalar + uc; // expected-error {{cannot convert}}
+  sc = sc + sc_scalar;
+  sc = sc + uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  sc = sc_scalar + sc;
+  sc = uc_scalar + sc; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc + uc_scalar;
+  uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc_scalar + uc;
 
   ss = ss + ss2;
   us = us + us2;
@@ -368,10 +368,10 @@
   sc += sl2; // expected-error {{cannot convert}}
   sc += fd2; // expected-error {{cannot convert}}
 
-  sc += sc_scalar; // expected-error {{cannot convert}}
-  sc += uc_scalar; // expected-error {{cannot convert}}
-  uc += sc_scalar; // expected-error {{cannot convert}}
-  uc += uc_scalar; // expected-error {{cannot convert}}
+  sc += sc_scalar;
+  sc += uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc += uc_scalar;
 
   ss += ss2;
   us += us2;
Index: test/Sema/vector-ops.c
===
--- test/Sema/vector-ops.c
+++ test/Sema/vector-ops.c
@@ -13,11 +13,11 @@
   (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}}
 
   // Comparison operators
-  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}}
+  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values}}
   v2sa = (v2ua==v2sa);
 
   // Arrays
-  int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values)}}
+  int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values}}
   int array2[17];
   // FIXME: error message below needs type!
   (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}}
@@ -28,108 +28,108 @@
 }
 
 void testLogicalVecVec(v2u v2ua, v2s v2sa, v2f v2fa) {
-
   // Logical operators
-  v2ua = v2ua && v2ua; // expected-warning {{incompatible vector types 

[PATCH] D33135: [ASTMatchers] Add support for floatLiterals

2017-05-12 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn created this revision.

Needed to support something like "floatLiteral(equals(1.0))". The
parser for floating point numbers is kept simple, so instead of ".1" you
have to use "0.1".


https://reviews.llvm.org/D33135

Files:
  include/clang/ASTMatchers/Dynamic/Diagnostics.h
  include/clang/ASTMatchers/Dynamic/Parser.h
  include/clang/ASTMatchers/Dynamic/VariantValue.h
  lib/ASTMatchers/Dynamic/Diagnostics.cpp
  lib/ASTMatchers/Dynamic/Marshallers.h
  lib/ASTMatchers/Dynamic/Parser.cpp
  lib/ASTMatchers/Dynamic/VariantValue.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp
  unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Index: unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
===
--- unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
+++ unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
@@ -76,13 +76,15 @@
   EXPECT_EQ("A", Value.getString());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_EQ("String", Value.getTypeAsString());
 
   Value = VariantMatcher::SingleMatcher(recordDecl());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_TRUE(Value.isMatcher());
@@ -98,17 +100,28 @@
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_FALSE(Value.isString());
 
+  Value = 3.14;
+  EXPECT_TRUE(Value.isDouble());
+  EXPECT_EQ(3.14, Value.getDouble());
+  EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isUnsigned());
+  EXPECT_FALSE(Value.isMatcher());
+  EXPECT_FALSE(Value.isString());
+
   Value = 17;
   EXPECT_TRUE(Value.isUnsigned());
   EXPECT_EQ(17U, Value.getUnsigned());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_FALSE(Value.isString());
 
   Value = VariantValue();
   EXPECT_FALSE(Value.hasValue());
   EXPECT_FALSE(Value.isBoolean());
+  EXPECT_FALSE(Value.isDouble());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_FALSE(Value.isMatcher());
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -84,6 +84,21 @@
   EXPECT_EQ(false, Sema.Values[1].getBoolean());
 }
 
+TEST(ParserTest, ParseDouble) {
+  MockSema Sema;
+  Sema.parse("1.0");
+  Sema.parse("2.0f");
+  Sema.parse("34.56e-78");
+  Sema.parse("4.E+6");
+  Sema.parse("1");
+  EXPECT_EQ(5U, Sema.Values.size());
+  EXPECT_EQ(1.0, Sema.Values[0].getDouble());
+  EXPECT_EQ("1:1: Error parsing numeric literal: <2.0f>", Sema.Errors[1]);
+  EXPECT_EQ(34.56e-78, Sema.Values[2].getDouble());
+  EXPECT_EQ(4e+6, Sema.Values[3].getDouble());
+  EXPECT_FALSE(Sema.Values[4].isDouble());
+}
+
 TEST(ParserTest, ParseUnsigned) {
   MockSema Sema;
   Sema.parse("0");
@@ -95,8 +110,8 @@
   EXPECT_EQ(0U, Sema.Values[0].getUnsigned());
   EXPECT_EQ(123U, Sema.Values[1].getUnsigned());
   EXPECT_EQ(31U, Sema.Values[2].getUnsigned());
-  EXPECT_EQ("1:1: Error parsing unsigned token: <12345678901>", Sema.Errors[3]);
-  EXPECT_EQ("1:1: Error parsing unsigned token: <1a1>", Sema.Errors[4]);
+  EXPECT_EQ("1:1: Error parsing numeric literal: <12345678901>", Sema.Errors[3]);
+  EXPECT_EQ("1:1: Error parsing numeric literal: <1a1>", Sema.Errors[4]);
 }
 
 TEST(ParserTest, ParseString) {
Index: lib/ASTMatchers/Dynamic/VariantValue.cpp
===
--- lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -26,6 +26,8 @@
 return (Twine("Matcher<") + MatcherKind.asStringRef() + ">").str();
   case AK_Boolean:
 return "boolean";
+  case AK_Double:
+return "double";
   case AK_Unsigned:
 return "unsigned";
   case AK_String:
@@ -253,6 +255,10 @@
   setBoolean(Boolean);
 }
 
+VariantValue::VariantValue(double Double) : Type(VT_Nothing) {
+  setDouble(Double);
+}
+
 VariantValue::VariantValue(unsigned Unsigned) : Type(VT_Nothing) {
   setUnsigned(Unsigned);
 }
@@ -274,6 +280,9 @@
   case VT_Boolean:
 setBoolean(Other.getBoolean());
 break;
+  case VT_Double:
+setDouble(Other.getDouble());
+break;
   case VT_Unsigned:
 setUnsigned(Other.getUnsigned());
 break;
@@ -300,6 +309,7 @@
 break;
   // Cases that do nothing.
   case VT_Boolean:
+  case VT_Double:
   case VT_Unsigned:
   case VT_Nothing:
 break;
@@ -322,6 +332,21 @@
   Value.Boolean = NewValue;
 }
 
+bool VariantValue::isDouble() const {
+  return Type == VT_Double;
+}
+
+double VariantValue::getDouble() const {
+  assert(isDouble());
+  return Value.Double;
+}
+
+void VariantValue::setDouble(double NewVal

[PATCH] D33093: [ASTMatchers] Add support for boolean literals

2017-05-12 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn updated this revision to Diff 98781.
Lekensteyn edited the summary of this revision.
Lekensteyn added a comment.

v2: Minor updates (fixed comment: `//  ...` to `/// https://reviews.llvm.org/D33093

Files:
  include/clang/ASTMatchers/Dynamic/Parser.h
  include/clang/ASTMatchers/Dynamic/VariantValue.h
  lib/ASTMatchers/Dynamic/Marshallers.h
  lib/ASTMatchers/Dynamic/Parser.cpp
  lib/ASTMatchers/Dynamic/VariantValue.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp
  unittests/ASTMatchers/Dynamic/VariantValueTest.cpp

Index: unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
===
--- unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
+++ unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
@@ -75,28 +75,40 @@
   EXPECT_TRUE(Value.isString());
   EXPECT_EQ("A", Value.getString());
   EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_EQ("String", Value.getTypeAsString());
 
   Value = VariantMatcher::SingleMatcher(recordDecl());
   EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_TRUE(Value.isMatcher());
   EXPECT_TRUE(Value.getMatcher().hasTypedMatcher());
   EXPECT_FALSE(Value.getMatcher().hasTypedMatcher());
   EXPECT_EQ("Matcher", Value.getTypeAsString());
 
+  Value = true;
+  EXPECT_TRUE(Value.isBoolean());
+  EXPECT_EQ(true, Value.getBoolean());
+  EXPECT_TRUE(Value.hasValue());
+  EXPECT_FALSE(Value.isUnsigned());
+  EXPECT_FALSE(Value.isMatcher());
+  EXPECT_FALSE(Value.isString());
+
   Value = 17;
   EXPECT_TRUE(Value.isUnsigned());
   EXPECT_EQ(17U, Value.getUnsigned());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_TRUE(Value.hasValue());
   EXPECT_FALSE(Value.isMatcher());
   EXPECT_FALSE(Value.isString());
 
   Value = VariantValue();
   EXPECT_FALSE(Value.hasValue());
+  EXPECT_FALSE(Value.isBoolean());
   EXPECT_FALSE(Value.isUnsigned());
   EXPECT_FALSE(Value.isString());
   EXPECT_FALSE(Value.isMatcher());
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -75,6 +75,15 @@
   ExpectedMatchersTy ExpectedMatchers;
 };
 
+TEST(ParserTest, ParseBoolean) {
+  MockSema Sema;
+  Sema.parse("true");
+  Sema.parse("false");
+  EXPECT_EQ(2U, Sema.Values.size());
+  EXPECT_EQ(true, Sema.Values[0].getBoolean());
+  EXPECT_EQ(false, Sema.Values[1].getBoolean());
+}
+
 TEST(ParserTest, ParseUnsigned) {
   MockSema Sema;
   Sema.parse("0");
Index: lib/ASTMatchers/Dynamic/VariantValue.cpp
===
--- lib/ASTMatchers/Dynamic/VariantValue.cpp
+++ lib/ASTMatchers/Dynamic/VariantValue.cpp
@@ -24,6 +24,8 @@
   switch (getArgKind()) {
   case AK_Matcher:
 return (Twine("Matcher<") + MatcherKind.asStringRef() + ">").str();
+  case AK_Boolean:
+return "boolean";
   case AK_Unsigned:
 return "unsigned";
   case AK_String:
@@ -247,6 +249,10 @@
   *this = Other;
 }
 
+VariantValue::VariantValue(bool Boolean) : Type(VT_Nothing) {
+  setBoolean(Boolean);
+}
+
 VariantValue::VariantValue(unsigned Unsigned) : Type(VT_Nothing) {
   setUnsigned(Unsigned);
 }
@@ -265,6 +271,9 @@
   if (this == &Other) return *this;
   reset();
   switch (Other.Type) {
+  case VT_Boolean:
+setBoolean(Other.getBoolean());
+break;
   case VT_Unsigned:
 setUnsigned(Other.getUnsigned());
 break;
@@ -290,13 +299,29 @@
 delete Value.Matcher;
 break;
   // Cases that do nothing.
+  case VT_Boolean:
   case VT_Unsigned:
   case VT_Nothing:
 break;
   }
   Type = VT_Nothing;
 }
 
+bool VariantValue::isBoolean() const {
+  return Type == VT_Boolean;
+}
+
+bool VariantValue::getBoolean() const {
+  assert(isBoolean());
+  return Value.Boolean;
+}
+
+void VariantValue::setBoolean(bool NewValue) {
+  reset();
+  Type = VT_Boolean;
+  Value.Boolean = NewValue;
+}
+
 bool VariantValue::isUnsigned() const {
   return Type == VT_Unsigned;
 }
@@ -344,6 +369,12 @@
 
 bool VariantValue::isConvertibleTo(ArgKind Kind, unsigned *Specificity) const {
   switch (Kind.getArgKind()) {
+  case ArgKind::AK_Boolean:
+if (!isBoolean())
+  return false;
+*Specificity = 1;
+return true;
+
   case ArgKind::AK_Unsigned:
 if (!isUnsigned())
   return false;
@@ -383,6 +414,7 @@
   switch (Type) {
   case VT_String: return "String";
   case VT_Matcher: return getMatcher().getTypeAsString();
+  case VT_Boolean: return "Boolean";
   case VT_Unsigned: return "Unsigned";
   case VT_Nothing: return "Nothing";
   }
Index: lib/ASTMatchers/Dynamic/Parser.cpp
===
--- lib/ASTMatchers/Dynamic/Parser.cpp
+++ lib/ASTMatchers/Dynamic/Parser.cpp
@@ -153,8 +153,16 @@
  

[PATCH] D29117: SPARC: allow usage of floating-point registers in inline ASM

2017-05-12 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302913: [SPARC] Support 'f' and 'e' inline asm constraints. 
(authored by jyknight).

Changed prior to commit:
  https://reviews.llvm.org/D29117?vs=85708&id=98782#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29117

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/sparcv8-inline-asm.c


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6862,6 +6862,11 @@
 case 'N': // Same as 'K' but zext (required for SIMode)
 case 'O': // The constant 4096
   return true;
+
+case 'f':
+case 'e':
+  info.setAllowsRegister();
+  return true;
 }
 return false;
   }
Index: cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
===
--- cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
+++ cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s
+
+// CHECK: define float @fabsf(float %a)
+// CHECK: %{{.*}} = call float asm sideeffect "fabss $1, $0;", "=e,f"(float 
%{{.*}}) #1
+float fabsf(float a) {
+  float res;
+  __asm __volatile__("fabss  %1, %0;"
+ : /* reg out*/ "=e"(res)
+ : /* reg in */ "f"(a));
+  return res;
+}


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6862,6 +6862,11 @@
 case 'N': // Same as 'K' but zext (required for SIMode)
 case 'O': // The constant 4096
   return true;
+
+case 'f':
+case 'e':
+  info.setAllowsRegister();
+  return true;
 }
 return false;
   }
Index: cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
===
--- cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
+++ cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: define float @fabsf(float %a)
+// CHECK: %{{.*}} = call float asm sideeffect "fabss $1, $0;", "=e,f"(float %{{.*}}) #1
+float fabsf(float a) {
+  float res;
+  __asm __volatile__("fabss  %1, %0;"
+ : /* reg out*/ "=e"(res)
+ : /* reg in */ "f"(a));
+  return res;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302913 - [SPARC] Support 'f' and 'e' inline asm constraints.

2017-05-12 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Fri May 12 11:01:23 2017
New Revision: 302913

URL: http://llvm.org/viewvc/llvm-project?rev=302913&view=rev
Log:
[SPARC] Support 'f' and 'e' inline asm constraints.

Patch by Patrick Boettcher.

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

Added:
cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=302913&r1=302912&r2=302913&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May 12 11:01:23 2017
@@ -6862,6 +6862,11 @@ public:
 case 'N': // Same as 'K' but zext (required for SIMode)
 case 'O': // The constant 4096
   return true;
+
+case 'f':
+case 'e':
+  info.setAllowsRegister();
+  return true;
 }
 return false;
   }

Added: cfe/trunk/test/CodeGen/sparcv8-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sparcv8-inline-asm.c?rev=302913&view=auto
==
--- cfe/trunk/test/CodeGen/sparcv8-inline-asm.c (added)
+++ cfe/trunk/test/CodeGen/sparcv8-inline-asm.c Fri May 12 11:01:23 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s
+
+// CHECK: define float @fabsf(float %a)
+// CHECK: %{{.*}} = call float asm sideeffect "fabss $1, $0;", "=e,f"(float 
%{{.*}}) #1
+float fabsf(float a) {
+  float res;
+  __asm __volatile__("fabss  %1, %0;"
+ : /* reg out*/ "=e"(res)
+ : /* reg in */ "f"(a));
+  return res;
+}


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


[PATCH] D33134: Remove ignore-empty-index-file option

2017-05-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
Herald added subscribers: eraman, mehdi_amini.

Clang changes to remove this option and replace with a parameter
always set in the context of a ThinLTO distributed backend.

Depends on https://reviews.llvm.org/D33133.


https://reviews.llvm.org/D33134

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/thinlto_backend.ll


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -12,10 +12,10 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
-; Ensure we ignore empty index file under -ignore-empty-index-file, and run
-; non-ThinLTO compilation which would not import f2
+; Ensure we ignore empty index file, and run non-ThinLTO compilation which
+; would not import f2
 ; RUN: touch %t4.thinlto.bc
-; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c 
-fthinlto-index=%t4.thinlto.bc -mllvm -ignore-empty-index-file
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c 
-fthinlto-index=%t4.thinlto.bc
 ; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
 ; CHECK-OBJ-IGNORE-EMPTY: T f1
 ; CHECK-OBJ-IGNORE-EMPTY: U f2
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1073,7 +1073,8 @@
 // into memory and pass it into runThinLTOBackend, which will run the
 // function importer and invoke LTO passes.
 Expected> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
+llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile,
+   
/*IgnoreEmptyThinLTOIndexFile*/true);
 if (!IndexOrErr) {
   logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
 "Error loading index file '" +


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -12,10 +12,10 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
-; Ensure we ignore empty index file under -ignore-empty-index-file, and run
-; non-ThinLTO compilation which would not import f2
+; Ensure we ignore empty index file, and run non-ThinLTO compilation which
+; would not import f2
 ; RUN: touch %t4.thinlto.bc
-; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc -mllvm -ignore-empty-index-file
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc
 ; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
 ; CHECK-OBJ-IGNORE-EMPTY: T f1
 ; CHECK-OBJ-IGNORE-EMPTY: U f2
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -1073,7 +1073,8 @@
 // into memory and pass it into runThinLTOBackend, which will run the
 // function importer and invoke LTO passes.
 Expected> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
+llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile,
+   /*IgnoreEmptyThinLTOIndexFile*/true);
 if (!IndexOrErr) {
   logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
 "Error loading index file '" +
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32178: Delete unstable integration tests

2017-05-12 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Sure. That'd be needed whether they stay, or get moved to test-suite.


https://reviews.llvm.org/D32178



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-05-12 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 98766.
gtbercea added a comment.

Address comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D29654

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -590,6 +590,28 @@
 
 /// ###
 
+/// Check cubin file generation and usage by nvlink
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN %s
+
+// CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" "{{.*}}-openmp-nvptx64-nvidia-cuda.cubin" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} "openmp-offload-openmp-nvptx64-nvidia-cuda.cubin"
+
+/// ###
+
+/// Check cubin file generation and usage by nvlink
+// RUN:   touch %t1.o
+// RUN:   touch %t2.o
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %t1.o %t2.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
+
+// CHK-TWOCUBIN: clang-offload-bundler" "-type=o" "{{.*}}inputs={{.*}}tmp1.o" "-outputs={{.*}}.o,{{.*}}tmp1-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
+// CHK-TWOCUBIN-NEXT: clang-offload-bundler" "-type=o" "{{.*}}inputs={{.*}}tmp2.o" "-outputs={{.*}}.o,{{.*}}tmp2-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
+// CHK-TWOCUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} "openmp-offload.c.tmp1-openmp-nvptx64-nvidia-cuda.cubin" "openmp-offload.c.tmp2-openmp-nvptx64-nvidia-cuda.cubin"
+
+/// ###
+
 /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -203,131 +203,6 @@
   // The types are (hopefully) good enough.
 }
 
-/// Add OpenMP linker script arguments at the end of the argument list so that
-/// the fat binary is built by embedding each of the device images into the
-/// host. The linker script also defines a few symbols required by the code
-/// generation so that the images can be easily retrieved at runtime by the
-/// offloading library. This should be used only in tool chains that support
-/// linker scripts.
-static void AddOpenMPLinkerScript(const ToolChain &TC, Compilation &C,
-  const InputInfo &Output,
-  const InputInfoList &Inputs,
-  const ArgList &Args, ArgStringList &CmdArgs,
-  const JobAction &JA) {
-
-  // If this is not an OpenMP host toolchain, we don't need to do anything.
-  if (!JA.isHostOffloading(Action::OFK_OpenMP))
-return;
-
-  // Create temporary linker script. Keep it if save-temps is enabled.
-  const char *LKS;
-  SmallString<256> Name = llvm::sys::path::filename(Output.getFilename());
-  if (C.getDriver().isSaveTempsEnabled()) {
-llvm::sys::path::replace_extension(Name, "lk");
-LKS = C.getArgs().MakeArgString(Name.c_str());
-  } else {
-llvm::sys::path::replace_extension(Name, "");
-Name = C.getDriver().GetTemporaryPath(Name, "lk");
-LKS = C.addTempFile(C.getArgs().MakeArgString(Name.c_str()));
-  }
-
-  // Add linker script option to the command.
-  CmdArgs.push_back("-T");
-  CmdArgs.push_back(LKS);
-
-  // Create a buffer to write the contents of the linker script.
-  std::string LksBuffer;
-  llvm::raw_string_ostream LksStream(LksBuffer);
-
-  // Get the OpenMP offload tool chains so that we can extract the triple
-  // associated with each device input.
-  auto OpenMPToolChains = C.getOffloadToolChains();
-  assert(OpenMPToolChains.first != OpenMPToolChains.second &&
- "No OpenMP toolchains??");
-
-  // Track the input file name and device triple in order to build the script,
-  // inserting binaries in the designated sections.
-  SmallVector, 8> InputBinaryInfo;
-
-  // Add commands to embed target binaries. We ensure that each section and
-  // image is 16-byte aligned. This is not mandatory, but increases the
-  // likelihood of data to be aligned with 

[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Looks good from my side.
> > > 
> > > @yaxunl , since you originally committed this. Could you please verify 
> > > that changing from `SIZE_MAX` to `0` would be fine.
> > > 
> > > Btw, we have a similar definition for `CLK_NULL_EVENT`.
> > `__PIPE_RESERVE_ID_VALID_BIT` is implementation detail and not part of the 
> > spec. I would suggest to remove it from this header file.
> > 
> > The spec only requires CLK_NULL_RESERVE_ID to be defined but does not 
> > define its value. Naturally a valid id starts from 0 and increases. I don't 
> > see significant advantage to change CLK_NULL_RESERVE_ID from __SIZE_MAX to 
> > 0.
> > 
> > Is there any reason that this change is needed?
> I don't see issues to commit things outside of spec as soon as they prefixed 
> properly with "__".  But I agree it would be nice to see if it's any useful 
> and what the motivation is for having different implementation.
For `__PIPE_RESERVE_ID_VALID_BIT`, it assumes that the implementation uses one 
specific bit of a reserve id to indicate that the reserve id is valid. Not all 
implementations assume that. Actually I am curious why that is needed too.


https://reviews.llvm.org/D32896



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


r302901 - Enabling the /bigobj flag for SemaDeclAttr.cpp.

2017-05-12 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 12 09:30:49 2017
New Revision: 302901

URL: http://llvm.org/viewvc/llvm-project?rev=302901&view=rev
Log:
Enabling the /bigobj flag for SemaDeclAttr.cpp.

This resolves compile errors with MSVC 2015 x64 debug builds where 
SemaDeclAttr.cpp is hitting the section symbol limit.

Modified:
cfe/trunk/lib/Sema/CMakeLists.txt

Modified: cfe/trunk/lib/Sema/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=302901&r1=302900&r2=302901&view=diff
==
--- cfe/trunk/lib/Sema/CMakeLists.txt (original)
+++ cfe/trunk/lib/Sema/CMakeLists.txt Fri May 12 09:30:49 2017
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 if (MSVC)
+  set_source_files_properties(SemaDeclAttr.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
   set_source_files_properties(SemaExpr.cpp PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
 


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


[PATCH] D27334: [OpenCL] Ambiguous function call.

2017-05-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D27334#751921, @echuraev wrote:

> So, I think that we have to do some decision about this patch. @Anastasia, 
> What do you think about it? Please see my comment above. What should we do 
> with this patch?


I am still not convinced adding the diagnostics in this shape is a good way to 
go


https://reviews.llvm.org/D27334



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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

yaxunl wrote:
> Anastasia wrote:
> > Looks good from my side.
> > 
> > @yaxunl , since you originally committed this. Could you please verify that 
> > changing from `SIZE_MAX` to `0` would be fine.
> > 
> > Btw, we have a similar definition for `CLK_NULL_EVENT`.
> `__PIPE_RESERVE_ID_VALID_BIT` is implementation detail and not part of the 
> spec. I would suggest to remove it from this header file.
> 
> The spec only requires CLK_NULL_RESERVE_ID to be defined but does not define 
> its value. Naturally a valid id starts from 0 and increases. I don't see 
> significant advantage to change CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.
> 
> Is there any reason that this change is needed?
I don't see issues to commit things outside of spec as soon as they prefixed 
properly with "__".  But I agree it would be nice to see if it's any useful and 
what the motivation is for having different implementation.


https://reviews.llvm.org/D32896



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


[PATCH] D15994: Allow for unfinished #if blocks in preambles.

2017-05-12 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv updated this revision to Diff 98757.

https://reviews.llvm.org/D15994

Files:
  include/clang/Lex/Preprocessor.h
  include/clang/Lex/PreprocessorLexer.h
  include/clang/Lex/PreprocessorOptions.h
  include/clang/Serialization/ASTBitCodes.h
  lib/Frontend/ASTUnit.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/PPLexerChange.cpp
  lib/Lex/Preprocessor.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/Lexer/preamble.c
  test/Lexer/preamble2.c

Index: test/Lexer/preamble2.c
===
--- /dev/null
+++ test/Lexer/preamble2.c
@@ -0,0 +1,19 @@
+// Preamble detection test: header with an include guard.
+#ifndef HEADER_H
+#define HEADER_H
+#include "foo"
+int bar;
+#endif
+
+// This test checks for detection of the preamble of a file, which
+// includes all of the starting comments and #includes.
+
+// RUN: %clang_cc1 -print-preamble %s > %t
+// RUN: echo END. >> %t
+// RUN: FileCheck < %t %s
+
+// CHECK: // Preamble detection test: header with an include guard.
+// CHECK-NEXT: #ifndef HEADER_H
+// CHECK-NEXT: #define HEADER_H
+// CHECK-NEXT: #include "foo"
+// CHECK-NEXT: END.
Index: test/Lexer/preamble.c
===
--- test/Lexer/preamble.c
+++ test/Lexer/preamble.c
@@ -9,15 +9,12 @@
 #pragma unknown
 #endif
 #ifdef WIBBLE
-#include "honk"
-#else
-int foo();
+#include "foo"
+int bar;
 #endif
 
 // This test checks for detection of the preamble of a file, which
-// includes all of the starting comments and #includes. Note that any
-// changes to the preamble part of this file must be mirrored in
-// Inputs/preamble.txt, since we diff against it.
+// includes all of the starting comments and #includes.
 
 // RUN: %clang_cc1 -print-preamble %s > %t
 // RUN: echo END. >> %t
@@ -33,4 +30,6 @@
 // CHECK-NEXT: #endif
 // CHECK-NEXT: #pragma unknown
 // CHECK-NEXT: #endif
+// CHECK-NEXT: #ifdef WIBBLE
+// CHECK-NEXT: #include "foo"
 // CHECK-NEXT: END.
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -1093,6 +1093,7 @@
   RECORD(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES);
   RECORD(DELETE_EXPRS_TO_ANALYZE);
   RECORD(CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH);
+  RECORD(PP_CONDITIONAL_STACK);
 
   // SourceManager Block.
   BLOCK(SOURCE_MANAGER_BLOCK);
@@ -2302,6 +2303,18 @@
 Stream.EmitRecord(PP_COUNTER_VALUE, Record);
   }
 
+  if (PP.isRecordingPreamble() && PP.hasRecordedPreamble()) {
+assert(!IsModule);
+for (const auto &Cond : PP.getPreambleConditionalStack()) {
+  AddSourceLocation(Cond.IfLoc, Record);
+  Record.push_back(Cond.WasSkipping);
+  Record.push_back(Cond.FoundNonSkip);
+  Record.push_back(Cond.FoundElse);
+}
+Stream.EmitRecord(PP_CONDITIONAL_STACK, Record);
+Record.clear();
+  }
+
   // Enter the preprocessor block.
   Stream.EnterSubblock(PREPROCESSOR_BLOCK_ID, 3);
 
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2925,6 +2925,21 @@
   }
   break;
 
+case PP_CONDITIONAL_STACK:
+  if (!Record.empty()) {
+SmallVector ConditionalStack;
+for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) {
+  auto Loc = ReadSourceLocation(F, Record, Idx);
+  bool WasSkipping = Record[Idx++];
+  bool FoundNonSkip = Record[Idx++];
+  bool FoundElse = Record[Idx++];
+  ConditionalStack.push_back(
+  {Loc, WasSkipping, FoundNonSkip, FoundElse});
+}
+PP.setReplayablePreambleConditionalStack(ConditionalStack);
+  }
+  break;
+
 case PP_COUNTER_VALUE:
   if (!Record.empty() && Listener)
 Listener->ReadCounter(F, Record[0]);
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -150,6 +150,9 @@
 Ident_GetExceptionInfo = Ident_GetExceptionCode = nullptr;
 Ident_AbnormalTermination = nullptr;
   }
+
+  if (this->PPOpts->GeneratePreamble)
+PreambleConditionalStack.startRecording();
 }
 
 Preprocessor::~Preprocessor() {
@@ -537,6 +540,12 @@
 
   // Start parsing the predefines.
   EnterSourceFile(FID, nullptr, SourceLocation());
+
+  // Restore the conditional stack from the preamble, if there is one.
+  if (PreambleConditionalStack.isReplaying()) {
+CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack());
+PreambleConditionalStack.doneReplaying();
+  }
 }
 
 void Preprocessor::EndSourceFile() {
Index: lib/Lex/PPLexerChange.cpp
===
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -46,6 +46,12 @@
   });
 }
 
+bool Preprocessor::isInPreamble() const {
+  if

[PATCH] D15994: Allow for unfinished #if blocks in preambles.

2017-05-12 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv marked 8 inline comments as done.
erikjv added a comment.

Fixed with the next patch.


https://reviews.llvm.org/D15994



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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!




Comment at: lib/Sema/SemaDecl.cpp:10286
+  // these variables must be a compile time constant.
+  VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
 CheckForConstantInitializer(Init, DclT);

yaxunl wrote:
> rjmccall wrote:
> > yaxunl wrote:
> > > rjmccall wrote:
> > > > Should this rule apply even in C++ mode?  I can't remember if there are 
> > > > any OpenCL/C++ hybrids.
> > > No. This rule (static local variable needs to be initialised with 
> > > compile-time constant) only applies to C and OpenCL. 
> > > In C++ static local variable can be initialised with non-compile-time 
> > > constant, in which case Clang will emit atomic instructions to make sure 
> > > it is only initialised once.
> > > 
> > > Currently OpenCL 2.2 defines OpenCL C++ but clang does not support it.
> > Yes, I understand that C++ generally allows static locals to be lazily 
> > initialized, and that that rule would (probably) still apply to ordinary 
> > static locals in OpenCL C++.  However, I would expect that OpenCL C++ rule 
> > is that __constant local variables still need to be statically initialized, 
> > because there's no plausible way in the OpenCL implementation model to 
> > actually put lazily-initialized variables in the constant address space.  
> > Assuming that's correct, then I would recommend reworking this whole chain 
> > of conditions to:
> > 
> >   // Don't check the initializer if the declaration is malformed.
> >   if (VDecl->isInvalidDecl()) {
> > // do nothing
> > 
> >   // OpenCL __constant locals must be constant-initialized, even in OpenCL 
> > C++.
> >   } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) 
> > {
> > CheckForConstantInitializer(Init, DclT);
> > 
> >   // Otherwise, C++ does not restrict the initializer.
> >   } else if (getLangOpts().CPlusPlus) {
> > // do nothing
> > 
> >   // C99 6.7.8p4: All the expressions in an initializer for an object that 
> > has
> >   // static storage duration shall be constant expressions or string 
> > literals.
> >   } else if (VDecl->getStorageClass() == SC_Static) {
> > CheckForConstantInitializer(Init, DclT);
> > 
> >   // C89 is stricter than C99 for aggregate initializers.
> >   // C89 6.5.7p3: All the expressions [...] in an initializer list
> >   // for an object that has aggregate or union type shall be
> >   // constant expressions.
> >   } else if (!getLangOpts().C99 && VDecl->getType()->isAggregateType() && 
> > isa(Init)) {
> > Expr *Culprit;
> > if (!Init->isConstantInitializer(Context, false, &Culprit)) {
> >   ...
> > }
> >   }
> Agree that even OpenCL C++ is unable to lazy initialise function-scope var in 
> constant addr space. Will do.
I think the original way would be much simpler to read and understand though.

To be honest I wouldn't complicate things now for the feature we don't support. 
I feel OpenCL C++ should be represented as a separate LangOpt since there are 
some places that will require special handling due to deviation from C++. I 
would rather extend things later in more systematic way.


https://reviews.llvm.org/D32977



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


r302895 - [Hexagon] Make sure to pass empty struct arguments with nontrivial ctors

2017-05-12 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri May 12 08:18:07 2017
New Revision: 302895

URL: http://llvm.org/viewvc/llvm-project?rev=302895&view=rev
Log:
[Hexagon] Make sure to pass empty struct arguments with nontrivial ctors

Thanks to Richard Smith for the suggested fix.

This fixes llvm.org/PR33009

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCXX/array-default-argument.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302895&r1=302894&r2=302895&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 12 08:18:07 2017
@@ -7043,13 +7043,13 @@ ABIArgInfo HexagonABIInfo::classifyArgum
 ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
 
+  if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI()))
+return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
+
   // Ignore empty records.
   if (isEmptyRecord(getContext(), Ty, true))
 return ABIArgInfo::getIgnore();
 
-  if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI()))
-return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
-
   uint64_t Size = getContext().getTypeSize(Ty);
   if (Size > 64)
 return getNaturalAlignIndirect(Ty, /*ByVal=*/true);

Modified: cfe/trunk/test/CodeGenCXX/array-default-argument.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/array-default-argument.cpp?rev=302895&r1=302894&r2=302895&view=diff
==
--- cfe/trunk/test/CodeGenCXX/array-default-argument.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/array-default-argument.cpp Fri May 12 08:18:07 
2017
@@ -1,10 +1,6 @@
 // RUN: %clang_cc1 -emit-llvm -o - %s -triple %itanium_abi_triple | FileCheck 
%s
 // RUN: %clang_cc1 -emit-llvm -o - %s -triple %itanium_abi_triple -std=c++98 
-fexceptions -fcxx-exceptions | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-EH
 
-// Hexagon calling convention lowering is horribly broken and fails to pass A
-// object to B constructor at all!
-// XFAIL: hexagon
-
 struct A {
   A();
   ~A();


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


[PATCH] D33080: [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows

2017-05-12 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

> I noticed that the Windows STL headers have to do this dance with `new` (even 
> though they do `(foo)(...)` for `min` and `max`). If we're going to need
>  to guard against a bunch of macros I would like to use a single approach.  
> Other than updating the `#if defined(min) || defined(max)` lines it's trivial 
> to guard
>  against additional macros.

I think the guarding of 'new' is done because of user code, not because of 
headers #defining new.  There is a lot of old Windows code out there that would 
define 'new' to something else in order to get extra instrumentation.  I want 
to say this was even done in some of the MFC example 'project templates'

One of the things I don't like about push / pop macro is that it isn't the same 
as doing nothing with the macro.  If something between the push and pop 
specifically wanted to use or modify the macro, the pop macro will destroy that 
state.  Granted, in this situation, that seems both unlikely, and it would be 
evil heaped upon evil.

With push and pop macro, you also need to be very careful about how things are 
positioned.  The push and undef need to happen after all the other includes in 
the header are processed, and care needs to be taken not to include anything 
offensive within the bounds of the push and pop.  You also need to remember to 
do the pop.

push and pop macro are acceptable.  I still have a preference for the 
parenthesis approach though.




Comment at: include/shared_mutex:128-136
+_LIBCPP_PUSH_MACROS
+#if defined(min) || defined(max)
+# include <__undef_macros>
+#endif
+
+
 #if _LIBCPP_STD_VER > 11 || defined(_LIBCPP_BUILDING_SHARED_MUTEX)

Shouldn't the push macro be somewhere below this potential include?


https://reviews.llvm.org/D33080



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


r302893 - clang-format: [JS] support non-null assertions after all identifiers.

2017-05-12 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Fri May 12 08:00:33 2017
New Revision: 302893

URL: http://llvm.org/viewvc/llvm-project?rev=302893&view=rev
Log:
clang-format: [JS] support non-null assertions after all identifiers.

Summary:
Previously:
x = namespace !;

Now:
x = namespace!;

Reviewers: djasper

Subscribers: klimek

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=302893&r1=302892&r2=302893&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri May 12 08:00:33 2017
@@ -1034,7 +1034,8 @@ private:
 if (Style.Language == FormatStyle::LK_JavaScript) {
   if (Current.is(tok::exclaim)) {
 if (Current.Previous &&
-(Current.Previous->isOneOf(tok::identifier, tok::r_paren,
+(Current.Previous->Tok.getIdentifierInfo() ||
+ Current.Previous->isOneOf(tok::identifier, tok::r_paren,
tok::r_square, tok::r_brace) ||
  Current.Previous->Tok.isLiteral())) {
   Current.Type = TT_JsNonNullAssertion;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302893&r1=302892&r2=302893&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri May 12 08:00:33 2017
@@ -1799,6 +1799,7 @@ TEST_F(FormatTestJS, NonNullAssertionOpe
   ".foo()!\n"
   ".foo()!;\n",
   getGoogleJSStyleWithColumns(20));
+  verifyFormat("let x = namespace!;\n");
 }
 
 TEST_F(FormatTestJS, Conditional) {


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


[PATCH] D32332: Add support for transparent overloadable functions in clang

2017-05-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D32332#751785, @george.burgess.iv wrote:

> I'd be happy with that approach. Do you like it, Aaron?


I think that makes a lot of sense.

> FWIW, I did a bit of archaeology, and it looks like the commit that added the 
> requirement that all overloads must have `overloadable` (r64414) did so to 
> keep users from "trying to be too sneaky for their own good." The issue it 
> was trying to solve was
> 
>   double sin(double) __attribute__((overloadable));
>   #include 
>   
>   // calls to `sin` are now mangled, which probably resulted in fun linker 
> errors.
> 
> 
> If we go back to no longer requiring some spelling of `overloadable` on all 
> (re)decls of this special non-mangled function, the above problem shouldn't 
> reappear.




https://reviews.llvm.org/D32332



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


[clang-tools-extra] r302890 - [clang-tidy] Add a test for PR33020

2017-05-12 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri May 12 06:24:58 2017
New Revision: 302890

URL: http://llvm.org/viewvc/llvm-project?rev=302890&view=rev
Log:
[clang-tidy] Add a test for PR33020

Fix committed in clang as r302889.

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp?rev=302890&r1=302889&r2=302890&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp Fri May 12 
06:24:58 2017
@@ -1137,3 +1137,23 @@ void ifStmtSequencesDeclAndCondition() {
 }
   }
 }
+
+namespace PR33020 {
+class D {
+  ~D();
+};
+struct A {
+  D d;
+};
+class B {
+  A a;
+};
+template 
+class C : T, B {
+  void m_fn1() {
+int a;
+std::move(a);
+C c;
+  }
+};
+}


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


r302889 - Fix an assertion failure (PR33020).

2017-05-12 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri May 12 06:24:25 2017
New Revision: 302889

URL: http://llvm.org/viewvc/llvm-project?rev=302889&view=rev
Log:
Fix an assertion failure (PR33020).

Adding a test separately (tools/extra/test/clang-tidy/misc-use-after-move.cpp).

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

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=302889&r1=302888&r2=302889&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri May 12 06:24:25 2017
@@ -1432,8 +1432,9 @@ bool CXXRecordDecl::isAnyDestructorNoRet
 
   // Check base classes destructor for noreturn.
   for (const auto &Base : bases())
-if (Base.getType()->getAsCXXRecordDecl()->isAnyDestructorNoReturn())
-  return true;
+if (const CXXRecordDecl *RD = Base.getType()->getAsCXXRecordDecl())
+  if (RD->isAnyDestructorNoReturn())
+return true;
 
   // Check fields for noreturn.
   for (const auto *Field : fields())


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


[PATCH] D32178: Delete unstable integration tests

2017-05-12 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@jroelofs 
We'd be ok with tying the test to a specific SDK and maintaining that tie (e.g. 
bumping it upstream).
I was planning to investigate how to make the SDK version checks work, but I 
don't have the time ATM. Can I get back to you in a week?


https://reviews.llvm.org/D32178



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


[PATCH] D33047: [ClangD] Refactor clangd into separate components

2017-05-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.h:23
+
+class ClangdLSPServer {
+  class LSPDiagnosticsConsumer;

klimek wrote:
> ilya-biryukov wrote:
> > klimek wrote:
> > > I'd have expected something that's called LSP server to work on the LSP 
> > > protocol level (that is, have a server(iostream) equivalent method).
> > The idea is to have a class that wraps ClangdServer and is called by 
> > clangd's ProtocolHandlers.cpp to do all the work.
> > I.e. it's a replacement of what used to be called 'ASTManager'. Any 
> > suggestions for a better name? ClangdLSPHandler?
> > 
> > It's seems hard to implement the interface you suggest right away, lots of 
> > code will have to be moved. Happy to do that in further commits, but 
> > suggest we leave this class as is in this commit.
> I think it's fine to have an intermediate step checked in; the important part 
> is that we add comments explaining why this is the way it is, especially if 
> we plan to change it in the future :) -> I'd add a class level comment 
> explaining what this class does and why it exists.
Added comments to this class. And ClangdServer, it didn't have a comment too.



Comment at: clangd/ClangdUnit.h:43
+
+  /// Reparse with new contents
+  void reparse(StringRef Contents);

klimek wrote:
> Tiny nit: generally, use "." at the end of sentences :)
Fixed



Comment at: clangd/GlobalCompilationDatabase.h:28
+/// Provides compilation arguments used for building ClangdUnit.
+class GlobalCompilationDatabase {
+public:

klimek wrote:
> ilya-biryukov wrote:
> > klimek wrote:
> > > What's global about this?
> > The fact that it's created only once(as opposed to 
> > tooling::CompilationDatabase, which can be recreated for each file) and 
> > handles all CompileCommand-related things(i.e. the idea is to add tracking 
> > of compile flags changes to this interface).
> > I called it ClangdCompilationDatabase first, but then I thought there's too 
> > much Clangd-prefixed names :-)
> > Any suggestions for a better name?
> Why don't we just use a tooling::CompilationDatabase and pass it around?
It has getAllFiles and getAllCompileCommands which we don't need for now.
It doesn't have capabilities to track changes to flags, which we'll want to add 
at some point. (Added a comment that we'll be adding those).

Also, currently implementations of CompilationDatabase actually require us to 
recreate them for each file, this logic is currently moved into 
DirectoryBasedGlobalCompilationDatabase for convenience.


https://reviews.llvm.org/D33047



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


[PATCH] D33047: [ClangD] Refactor clangd into separate components

2017-05-12 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 98745.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

Addressed new comments


https://reviews.llvm.org/D33047

Files:
  clangd/ASTManager.cpp
  clangd/ASTManager.h
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdMain.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h
  clangd/DocumentStore.h
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Path.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h

Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -22,8 +22,8 @@
 
 namespace clang {
 namespace clangd {
-class ASTManager;
-class DocumentStore;
+class ClangdLSPServer;
+class ClangdLSPServer;
 
 struct InitializeHandler : Handler {
   InitializeHandler(JSONOutput &Output) : Handler(Output) {}
@@ -56,83 +56,83 @@
 };
 
 struct TextDocumentDidOpenHandler : Handler {
-  TextDocumentDidOpenHandler(JSONOutput &Output, DocumentStore &Store)
-  : Handler(Output), Store(Store) {}
+  TextDocumentDidOpenHandler(JSONOutput &Output, ClangdLSPServer &AST)
+  : Handler(Output), AST(AST) {}
 
   void handleNotification(llvm::yaml::MappingNode *Params) override;
 
 private:
-  DocumentStore &Store;
+  ClangdLSPServer &AST;
 };
 
 struct TextDocumentDidChangeHandler : Handler {
-  TextDocumentDidChangeHandler(JSONOutput &Output, DocumentStore &Store)
-  : Handler(Output), Store(Store) {}
+  TextDocumentDidChangeHandler(JSONOutput &Output, ClangdLSPServer &AST)
+  : Handler(Output), AST(AST) {}
 
   void handleNotification(llvm::yaml::MappingNode *Params) override;
 
 private:
-  DocumentStore &Store;
+  ClangdLSPServer &AST;
 };
 
 struct TextDocumentDidCloseHandler : Handler {
-  TextDocumentDidCloseHandler(JSONOutput &Output, DocumentStore &Store)
-  : Handler(Output), Store(Store) {}
+  TextDocumentDidCloseHandler(JSONOutput &Output, ClangdLSPServer &AST)
+  : Handler(Output), AST(AST) {}
 
   void handleNotification(llvm::yaml::MappingNode *Params) override;
 
 private:
-  DocumentStore &Store;
+  ClangdLSPServer &AST;
 };
 
 struct TextDocumentOnTypeFormattingHandler : Handler {
-  TextDocumentOnTypeFormattingHandler(JSONOutput &Output, DocumentStore &Store)
-  : Handler(Output), Store(Store) {}
+  TextDocumentOnTypeFormattingHandler(JSONOutput &Output, ClangdLSPServer &AST)
+  : Handler(Output), AST(AST) {}
 
   void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override;
 
 private:
-  DocumentStore &Store;
+  ClangdLSPServer &AST;
 };
 
 struct TextDocumentRangeFormattingHandler : Handler {
-  TextDocumentRangeFormattingHandler(JSONOutput &Output, DocumentStore &Store)
-  : Handler(Output), Store(Store) {}
+  TextDocumentRangeFormattingHandler(JSONOutput &Output, ClangdLSPServer &AST)
+  : Handler(Output), AST(AST) {}
 
   void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override;
 
 private:
-  DocumentStore &Store;
+  ClangdLSPServer &AST;
 };
 
 struct TextDocumentFormattingHandler : Handler {
-  TextDocumentFormattingHandler(JSONOutput &Output, DocumentStore &Store)
-  : Handler(Output), Store(Store) {}
+  TextDocumentFormattingHandler(JSONOutput &Output, ClangdLSPServer &AST)
+  : Handler(Output), AST(AST) {}
 
   void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override;
 
 private:
-  DocumentStore &Store;
+  ClangdLSPServer &AST;
 };
 
 struct CodeActionHandler : Handler {
-  CodeActionHandler(JSONOutput &Output, ASTManager &AST)
+  CodeActionHandler(JSONOutput &Output, ClangdLSPServer &AST)
   : Handler(Output), AST(AST) {}
 
   void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override;
 
 private:
-  ASTManager &AST;
+  ClangdLSPServer &AST;
 };
 
 struct CompletionHandler : Handler {
-  CompletionHandler(JSONOutput &Output, ASTManager &AST)
+  CompletionHandler(JSONOutput &Output, ClangdLSPServer &AST)
   : Handler(Output), AST(AST) {}
 
   void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override;
 
  private:
-  ASTManager &AST;
+  ClangdLSPServer &AST;
 };
 
 } // namespace clangd
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -8,9 +8,10 @@
 //===--===//
 
 #include "ProtocolHandlers.h"
-#include "ASTManager.h"
-#include "DocumentStore.h"
+#include "ClangdServer.h"
+#include "DraftStore.h"
 #include "clang/Format/Format.h"
+#include "ClangdLSPServer.h"
 using namespace clang;
 using namespace clangd;
 
@@ -21,7 +22,7 @@
 Output.log("Failed to decode DidOpenT

[PATCH] D33047: [ClangD] Refactor clangd into separate components

2017-05-12 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clangd/ClangdLSPServer.h:23
+
+class ClangdLSPServer {
+  class LSPDiagnosticsConsumer;

ilya-biryukov wrote:
> klimek wrote:
> > I'd have expected something that's called LSP server to work on the LSP 
> > protocol level (that is, have a server(iostream) equivalent method).
> The idea is to have a class that wraps ClangdServer and is called by clangd's 
> ProtocolHandlers.cpp to do all the work.
> I.e. it's a replacement of what used to be called 'ASTManager'. Any 
> suggestions for a better name? ClangdLSPHandler?
> 
> It's seems hard to implement the interface you suggest right away, lots of 
> code will have to be moved. Happy to do that in further commits, but suggest 
> we leave this class as is in this commit.
I think it's fine to have an intermediate step checked in; the important part 
is that we add comments explaining why this is the way it is, especially if we 
plan to change it in the future :) -> I'd add a class level comment explaining 
what this class does and why it exists.



Comment at: clangd/ClangdUnit.h:43
+
+  /// Reparse with new contents
+  void reparse(StringRef Contents);

Tiny nit: generally, use "." at the end of sentences :)



Comment at: clangd/GlobalCompilationDatabase.h:28
+/// Provides compilation arguments used for building ClangdUnit.
+class GlobalCompilationDatabase {
+public:

ilya-biryukov wrote:
> klimek wrote:
> > What's global about this?
> The fact that it's created only once(as opposed to 
> tooling::CompilationDatabase, which can be recreated for each file) and 
> handles all CompileCommand-related things(i.e. the idea is to add tracking of 
> compile flags changes to this interface).
> I called it ClangdCompilationDatabase first, but then I thought there's too 
> much Clangd-prefixed names :-)
> Any suggestions for a better name?
Why don't we just use a tooling::CompilationDatabase and pass it around?


https://reviews.llvm.org/D33047



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


[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-05-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:656-659
+  // If the SVal is a LazyCompoundVal it might only cover sub-region of a given
+  // symbol. For example, the LCV might represent a field in an uninitialized
+  // struct. In this case, the LCV encapsulates a conjured symbol and reference
+  // to the sub-region representing the struct field.

vlad.tsyrklevich wrote:
> NoQ wrote:
> > I still feel bad about producing API with very tricky pre-conditions. The 
> > LCV may have various forms - some may have empty store with no symbols at 
> > all, and others may be full of direct bindings that make the symbol 
> > essentially irrelevant. However, because the taint API is designed to be 
> > defensive to cases when taint cannot be added, and it sounds like a good 
> > thing, i guess we've taken the right approach here :)
> > 
> > I suggest commenting this more thoroughly though, something like:
> > 
> > > If the SVal represents a structure, try to mass-taint all values within 
> > > the structure. For now it only works efficiently on lazy compound values 
> > > that were conjured during a conservative evaluation of a function - 
> > > either as return values of functions that return structures or arrays by 
> > > value, or as values of structures or arrays passed into the function by 
> > > reference, directly or through pointer aliasing. Such lazy compound 
> > > values are characterized by having exactly one binding in their captured 
> > > store within their parent region, which is a conjured symbol 
> > > default-bound to the base region of the parent region.
> > 
> > Then inside `if (Sym)`:
> > 
> > > If the parent region is a base region, we add taint to the whole conjured 
> > > symbol.
> > 
> > > Otherwise, when the value represents a record-typed field within the 
> > > conjured structure, so we add partial taint for that symbol to that field.
> The pre-conditions for using the API are actually a bit simpler than what's 
> exposed here. I made it explicit to make the logic for tainting LCVs 
> explicit, but the following simpler logic works:
> ```
>   if (auto LCV = V.getAs()) {
> if (Optional binding = 
> getStateManager().StoreMgr->getDefaultBinding(*LCV)) {
>   if (SymbolRef Sym = binding->getAsSymbol()) {
> return addPartialTaint(Sym, LCV->getRegion(), Kind);
>   }
> }
>   }
> ```
> 
> This works because `addPartialTaint()` actually already performs the 
> 'getRegion() == getRegion()->getBaseRegion()` check already and taints the 
> parent symbol if the region is over the base region already. I chose to 
> replicate it here to make the logic more explicit, but now that I've written 
> this down the overhead of duplicating the logic seems unnecessary. Do you 
> agree?
> The pre-conditions for using the API are actually a bit simpler than what's 
> exposed here.

I'm talking about the situation when we add the partial taint to the 
default-bound symbol but it has no effect because there's a direct binding in 
the lazy compound value on top of it. The user should ideally understand why it 
doesn't work that way.

> I chose to replicate it here to make the logic more explicit, but now that 
> I've written this down the overhead of duplicating the logic seems 
> unnecessary. Do you agree?

The variant without the check looks easier to read, and it is kind of obvious 
that full taint is a special case of partial taint, so i'm for removing the 
check.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:701-703
+  // Ignore partial taint if the entire parent symbol is already tainted.
+  if (contains(ParentSym))
+return this;

vlad.tsyrklevich wrote:
> NoQ wrote:
> > Speaking of taint tags: right now we didn't add support for multiple taint 
> > tags per symbol (because we have only one taint tag to choose from), but 
> > `addTaint` overwrites the tag. I guess we should do the same for now.
> I believe this is the current behavior. On line 714 I presume 
> ImmutableMap::add overrides a key if it's already present in the map but I 
> couldn't trace down the Tree ADT implementation to confirm this.
> I presume ImmutableMap::add overrides a key if it's already present in the map

Yep, it does.

> I believe this is the current behavior.

No, you early-return the original state if the full-taint map already contains 
the info for the whole symbol on line 703.

Hmm. In fact, with my suggestion we'd be able to have full taint of one kind 
and partial taint of another kind. I guess it's all right.





Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:788
+  (R == I->first || R->isSubRegionOf(I->first)))
+return true;
+}

I actually have no idea why does this function accumulate things in the 
`Tainted` variable, instead of returning :)


https://reviews.llvm.org/D30909




[PATCH] D33103: [clang-tidy] TwineLocalCheck: add param # checking

2017-05-12 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good, thanks!


https://reviews.llvm.org/D33103



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


r302880 - [analyzer] Add modelling of __builtin_assume

2017-05-12 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri May 12 02:02:54 2017
New Revision: 302880

URL: http://llvm.org/viewvc/llvm-project?rev=302880&view=rev
Log:
[analyzer] Add modelling of __builtin_assume

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

Added:
cfe/trunk/test/Analysis/builtin-assume.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp?rev=302880&r1=302879&r2=302880&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp Fri May 12 
02:02:54 2017
@@ -41,6 +41,22 @@ bool BuiltinFunctionChecker::evalCall(co
   default:
 return false;
 
+  case Builtin::BI__builtin_assume: {
+assert (CE->arg_begin() != CE->arg_end());
+SVal ArgSVal = state->getSVal(CE->getArg(0), LCtx);
+if (ArgSVal.isUndef())
+  return true; // Return true to model purity.
+
+state = state->assume(ArgSVal.castAs(), true);
+// FIXME: do we want to warn here? Not right now. The most reports might
+// come from infeasible paths, thus being false positives.
+if (!state)
+  return true;
+
+C.addTransition(state);
+return true;
+  }
+
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
   case Builtin::BI__builtin_assume_aligned:

Added: cfe/trunk/test/Analysis/builtin-assume.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/builtin-assume.c?rev=302880&view=auto
==
--- cfe/trunk/test/Analysis/builtin-assume.c (added)
+++ cfe/trunk/test/Analysis/builtin-assume.c Fri May 12 02:02:54 2017
@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
+
+void clang_analyzer_eval(int);
+
+void f(int i) {
+  __builtin_assume(i < 10);
+  clang_analyzer_eval(i < 15); // expected-warning {{TRUE}}
+}


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


[PATCH] D33092: [analyzer] Add checker to model builtin functions

2017-05-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302880: [analyzer] Add modelling of __builtin_assume 
(authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D33092?vs=98609&id=98731#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33092

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  cfe/trunk/test/Analysis/builtin-assume.c


Index: cfe/trunk/test/Analysis/builtin-assume.c
===
--- cfe/trunk/test/Analysis/builtin-assume.c
+++ cfe/trunk/test/Analysis/builtin-assume.c
@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
+
+void clang_analyzer_eval(int);
+
+void f(int i) {
+  __builtin_assume(i < 10);
+  clang_analyzer_eval(i < 15); // expected-warning {{TRUE}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -41,6 +41,22 @@
   default:
 return false;
 
+  case Builtin::BI__builtin_assume: {
+assert (CE->arg_begin() != CE->arg_end());
+SVal ArgSVal = state->getSVal(CE->getArg(0), LCtx);
+if (ArgSVal.isUndef())
+  return true; // Return true to model purity.
+
+state = state->assume(ArgSVal.castAs(), true);
+// FIXME: do we want to warn here? Not right now. The most reports might
+// come from infeasible paths, thus being false positives.
+if (!state)
+  return true;
+
+C.addTransition(state);
+return true;
+  }
+
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
   case Builtin::BI__builtin_assume_aligned:


Index: cfe/trunk/test/Analysis/builtin-assume.c
===
--- cfe/trunk/test/Analysis/builtin-assume.c
+++ cfe/trunk/test/Analysis/builtin-assume.c
@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void f(int i) {
+  __builtin_assume(i < 10);
+  clang_analyzer_eval(i < 15); // expected-warning {{TRUE}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -41,6 +41,22 @@
   default:
 return false;
 
+  case Builtin::BI__builtin_assume: {
+assert (CE->arg_begin() != CE->arg_end());
+SVal ArgSVal = state->getSVal(CE->getArg(0), LCtx);
+if (ArgSVal.isUndef())
+  return true; // Return true to model purity.
+
+state = state->assume(ArgSVal.castAs(), true);
+// FIXME: do we want to warn here? Not right now. The most reports might
+// come from infeasible paths, thus being false positives.
+if (!state)
+  return true;
+
+C.addTransition(state);
+return true;
+  }
+
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
   case Builtin::BI__builtin_assume_aligned:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33095: [analyzer] Avoid allocation in Std C function modelling.

2017-05-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302879: [analyzer] Avoid an allocation in Std C function 
modelling (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D33095?vs=98610&id=98730#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33095

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -440,7 +440,10 @@
   BasicValueFactory &BVF = SVB.getBasicValueFactory();
   initFunctionSummaries(BVF);
 
-  std::string Name = FD->getQualifiedNameAsString();
+  IdentifierInfo *II = FD->getIdentifier();
+  if (!II)
+return None;
+  StringRef Name = II->getName();
   if (Name.empty() || !C.isCLibraryFunction(FD, Name))
 return None;
 


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -440,7 +440,10 @@
   BasicValueFactory &BVF = SVB.getBasicValueFactory();
   initFunctionSummaries(BVF);
 
-  std::string Name = FD->getQualifiedNameAsString();
+  IdentifierInfo *II = FD->getIdentifier();
+  if (!II)
+return None;
+  StringRef Name = II->getName();
   if (Name.empty() || !C.isCLibraryFunction(FD, Name))
 return None;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302879 - [analyzer] Avoid an allocation in Std C function modelling

2017-05-12 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri May 12 01:53:55 2017
New Revision: 302879

URL: http://llvm.org/viewvc/llvm-project?rev=302879&view=rev
Log:
[analyzer] Avoid an allocation in Std C function modelling

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp?rev=302879&r1=302878&r2=302879&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp Fri 
May 12 01:53:55 2017
@@ -440,7 +440,10 @@ StdLibraryFunctionsChecker::findFunction
   BasicValueFactory &BVF = SVB.getBasicValueFactory();
   initFunctionSummaries(BVF);
 
-  std::string Name = FD->getQualifiedNameAsString();
+  IdentifierInfo *II = FD->getIdentifier();
+  if (!II)
+return None;
+  StringRef Name = II->getName();
   if (Name.empty() || !C.isCLibraryFunction(FD, Name))
 return None;
 


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