Re: r264529 - Improve the representation of CXXUuidofExpr

2016-03-27 Thread Richard Smith via cfe-commits
On Sat, Mar 26, 2016 at 9:46 PM, David Majnemer via cfe-commits
 wrote:
> Author: majnemer
> Date: Sat Mar 26 23:46:07 2016
> New Revision: 264529
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264529&view=rev
> Log:
> Improve the representation of CXXUuidofExpr
>
> Keep a pointer to the UuidAttr that the CXXUuidofExpr corresponds to.
> This makes translating from __uuidof to the underlying constant a lot
> more straightforward.
>
> Modified:
> cfe/trunk/include/clang/AST/ExprCXX.h
> cfe/trunk/lib/AST/ExprCXX.cpp
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>
> Modified: cfe/trunk/include/clang/AST/ExprCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=264529&r1=264528&r2=264529&view=diff
> ==
> --- cfe/trunk/include/clang/AST/ExprCXX.h (original)
> +++ cfe/trunk/include/clang/AST/ExprCXX.h Sat Mar 26 23:46:07 2016
> @@ -778,22 +778,23 @@ public:
>  class CXXUuidofExpr : public Expr {
>  private:
>llvm::PointerUnion Operand;
> +  const UuidAttr *UA;
>SourceRange Range;

Looks like the serialization / deserialization code for this new
member is missing? Does this correctly round-trip through AST files?

>  public:
> -  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
> -: Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
> -   false, Operand->getType()->isDependentType(),
> -   Operand->getType()->isInstantiationDependentType(),
> -   Operand->getType()->containsUnexpandedParameterPack()),
> -  Operand(Operand), Range(R) { }
> -
> -  CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R)
> -: Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
> -   false, Operand->isTypeDependent(),
> -   Operand->isInstantiationDependent(),
> -   Operand->containsUnexpandedParameterPack()),
> -  Operand(Operand), Range(R) { }
> +  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, const UuidAttr *UA,
> +SourceRange R)
> +  : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
> + Operand->getType()->isDependentType(),
> + Operand->getType()->isInstantiationDependentType(),
> + Operand->getType()->containsUnexpandedParameterPack()),
> +Operand(Operand), UA(UA), Range(R) {}
> +
> +  CXXUuidofExpr(QualType Ty, Expr *Operand, const UuidAttr *UA, SourceRange 
> R)
> +  : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
> + Operand->isTypeDependent(), Operand->isInstantiationDependent(),
> + Operand->containsUnexpandedParameterPack()),
> +Operand(Operand), UA(UA), Range(R) {}
>
>CXXUuidofExpr(EmptyShell Empty, bool isExpr)
>  : Expr(CXXUuidofExprClass, Empty) {
> @@ -830,7 +831,7 @@ public:
>  Operand = E;
>}
>
> -  StringRef getUuidAsStringRef(ASTContext &Context) const;
> +  StringRef getUuidAsStringRef() const;
>
>SourceLocation getLocStart() const LLVM_READONLY { return 
> Range.getBegin(); }
>SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
> @@ -841,11 +842,6 @@ public:
>  return T->getStmtClass() == CXXUuidofExprClass;
>}
>
> -  /// Grabs __declspec(uuid()) off a type, or returns 0 if we cannot resolve 
> to
> -  /// a single GUID.
> -  static const UuidAttr *GetUuidAttrOfType(QualType QT,
> -   bool *HasMultipleGUIDsPtr = 
> nullptr);
> -
>// Iterators
>child_range children() {
>  if (isTypeOperand())
>
> Modified: cfe/trunk/lib/AST/ExprCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=264529&r1=264528&r2=264529&view=diff
> ==
> --- cfe/trunk/lib/AST/ExprCXX.cpp (original)
> +++ cfe/trunk/lib/AST/ExprCXX.cpp Sat Mar 26 23:46:07 2016
> @@ -54,77 +54,8 @@ QualType CXXUuidofExpr::getTypeOperand(A
>Operand.get()->getType().getNonReferenceType(), 
> Quals);
>  }
>
> -// static
> -const UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT,
> - bool 
> *RDHasMultipleGUIDsPtr) {
> -  // Optionally remove one level of pointer, reference or array indirection.
> -  const Type *Ty = QT.getTypePtr();
> -  if (QT->isPointerType() || QT->isReferenceType())
> -Ty = QT->getPointeeType().getTypePtr();
> -  else if (QT->isArrayType())
> -Ty = Ty->getBaseElementTypeUnsafe();
> -
> -  const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
> -  if (!RD)
> -return nullptr;
> -
> -  if (const UuidAttr *Uuid = RD->getMostRecentDecl()->getAttr())
> -return Uuid;
> -
> -  // __uuidof can grab UUIDs from template arguments.
> -  if (const ClassTemplateSpecializationDecl *CTSD =
> -  dyn_cast(RD)) {
> -const TemplateArgumentL

r264534 - Encapsulate a couple of on-disk structures a little more.

2016-03-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Mar 27 02:28:06 2016
New Revision: 264534

URL: http://llvm.org/viewvc/llvm-project?rev=264534&view=rev
Log:
Encapsulate a couple of on-disk structures a little more.

Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=264534&r1=264533&r2=264534&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Sun Mar 27 02:28:06 2016
@@ -175,6 +175,12 @@ namespace clang {
 : Begin(R.getBegin().getRawEncoding()),
   End(R.getEnd().getRawEncoding()),
   BitOffset(BitOffset) { }
+  SourceLocation getBegin() const {
+return SourceLocation::getFromRawEncoding(Begin);
+  }
+  SourceLocation getEnd() const {
+return SourceLocation::getFromRawEncoding(End);
+  }
 };
 
 /// \brief Source range/offset of a preprocessed entity.
@@ -191,6 +197,9 @@ namespace clang {
   void setLocation(SourceLocation L) {
 Loc = L.getRawEncoding();
   }
+  SourceLocation getLocation() const {
+return SourceLocation::getFromRawEncoding(Loc);
+  }
 };
 
 /// \brief The number of predefined preprocessed entity IDs.

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=264534&r1=264533&r2=264534&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Sun Mar 27 02:28:06 2016
@@ -1175,7 +1175,7 @@ private:
   Decl *getMostRecentExistingDecl(Decl *D);
 
   RecordLocation DeclCursorForID(serialization::DeclID ID,
- unsigned &RawLocation);
+ SourceLocation &Location);
   void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D);
   void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
   void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D,
@@ -1982,7 +1982,15 @@ public:
   /// \brief Read a source location from raw form.
   SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) 
const {
 SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw);
-assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != 
ModuleFile.SLocRemap.end() &&
+return TranslateSourceLocation(ModuleFile, Loc);
+  }
+
+  /// \brief Translate a source location from another module file's source
+  /// location space into ours.
+  SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile,
+ SourceLocation Loc) const {
+assert(ModuleFile.SLocRemap.find(Loc.getOffset()) !=
+   ModuleFile.SLocRemap.end() &&
"Cannot find offset to remap.");
 int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second;
 return Loc.getLocWithOffset(Remap);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=264534&r1=264533&r2=264534&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Mar 27 02:28:06 2016
@@ -4897,8 +4897,8 @@ PreprocessedEntity *ASTReader::ReadPrepr
 return nullptr;
 
   // Read the record.
-  SourceRange Range(ReadSourceLocation(M, PPOffs.Begin),
-ReadSourceLocation(M, PPOffs.End));
+  SourceRange Range(TranslateSourceLocation(M, PPOffs.getBegin()),
+TranslateSourceLocation(M, PPOffs.getEnd()));
   PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
   StringRef Blob;
   RecordData Record;
@@ -5089,7 +5089,7 @@ Optional ASTReader::isPreprocessed
   unsigned LocalIndex = PPInfo.second;
   const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
   
-  SourceLocation Loc = ReadSourceLocation(M, PPOffs.Begin);
+  SourceLocation Loc = TranslateSourceLocation(M, PPOffs.getBegin());
   if (Loc.isInvalid())
 return false;
   
@@ -6426,9 +6426,9 @@ SourceLocation ASTReader::getSourceLocat
   if (Decl *D = DeclsLoaded[Index])
 return D->getLocation();
 
-  unsigned RawLocation = 0;
-  RecordLocation Rec = DeclCursorForID(ID, RawLocation);
-  return ReadSourceLocation(*Rec.F, RawLocation);
+  SourceLocation Loc;
+  DeclCursorForID(ID, Loc);
+  return Loc;
 }
 
 static Decl *getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID) {

Modifi

[PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus created this revision.
mspertus added reviewers: ariccio, aaron.ballman, zturner.
mspertus added a subscriber: cfe-commits.

This change uses the [[ 
https://blogs.msdn.microsoft.com/vcblog/2014/06/12/project-support-for-natvis/ 
| Project Support for Natvis ]] added in VS2015 to eliminate the need to 
manually install natvis files. I am creating a similar diff for clang. I want 
to acknowledge ariccio for extensive advice on this change.

http://reviews.llvm.org/D18497

Files:
  CMakeLists.txt
  utils/llvm.natvis

Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,14 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if( MSVC_IDE )
+  if (NOT (MSVC_VERSION LESS 1900))
+option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use 
Visual Studio native visualizers" TRUE)
+  else()
+set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For 
Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 
2013\\Visualizers" FORCE)
+  endif()
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +736,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target( LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include
@@ -764,6 +780,7 @@
   endif()
 endif()
 
+
 # This must be at the end of the LLVM root CMakeLists file because it must run
 # after all targets are created.
 if(LLVM_DISTRIBUTION_COMPONENTS)


Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,14 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if( MSVC_IDE )
+  if (NOT (MSVC_VERSION LESS 1900))
+option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
+  else()
+set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
+  endif()
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +736,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target( LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include
@@ -764,6 +780,7 @@
   endif()
 endif()
 
+
 # This must be at the end of the LLVM root CMakeLists file because it must run
 # after all targets are created.
 if(LLVM_DISTRIBUTION_COMPONENTS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus created this revision.
mspertus added reviewers: ariccio, aaron.ballman, zturner.
mspertus added a subscriber: cfe-commits.

This change uses the [[ 
https://blogs.msdn.microsoft.com/vcblog/2014/06/12/project-support-for-natvis/ 
| Project Support for Natvis ]] added in VS2015 to eliminate the need to 
manually install natvis files. D18497 is a corresponding diff for LLVM. I want 
to acknowledge ariccio for extensive advice on this change.

http://reviews.llvm.org/D18498

Files:
  CMakeLists.txt
  utils/clang.natvis
  www/hacking.html

Index: www/hacking.html
===
--- www/hacking.html
+++ www/hacking.html
@@ -103,9 +103,11 @@
 http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis";>
   utils/clang.natvis provide debugger visualizers 
   that make debugging of more complex data types much easier.
-  Put the files into 
-%USERPROFILE%\Documents\Visual Studio 2012\Visualizers or 
+  For Visual Studio 2013 only, put the files into 
+%USERPROFILE%\Documents\Visual Studio 2013\Visualizers or 
 create a symbolic link so they update automatically.
+  For later versions of Visual Studio, no installation is required.
+Note also that later versions of Visual Studio also display better 
visualizations.
 
   
   Testing
Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -2,9 +2,10 @@
 
+For Visual Studio 2013 only, put this file into 
+"%USERPROFILE%\Documents\Visual Studio 2013\Visualizers" or create a symbolic 
link so it updates automatically.
+
+For later versions of Visual Studio, no setup is required-->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
   
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -817,3 +817,11 @@
 ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target})
   endforeach()
 endif()
+
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( CLANG_VISUALIZERS utils/clang.natvis)
+  add_custom_target( ClangVisualizers SOURCES ${CLANG_VISUALIZERS})
+  set_target_properties(ClangVisualizers PROPERTIES FOLDER "Utils")
+endif()
\ No newline at end of file


Index: www/hacking.html
===
--- www/hacking.html
+++ www/hacking.html
@@ -103,9 +103,11 @@
 http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis";>
   utils/clang.natvis provide debugger visualizers 
   that make debugging of more complex data types much easier.
-  Put the files into 
-%USERPROFILE%\Documents\Visual Studio 2012\Visualizers or 
+  For Visual Studio 2013 only, put the files into 
+%USERPROFILE%\Documents\Visual Studio 2013\Visualizers or 
 create a symbolic link so they update automatically.
+  For later versions of Visual Studio, no installation is required.
+Note also that later versions of Visual Studio also display better visualizations.
 
   
   Testing
Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -2,9 +2,10 @@
 
+For Visual Studio 2013 only, put this file into 
+"%USERPROFILE%\Documents\Visual Studio 2013\Visualizers" or create a symbolic link so it updates automatically.
+
+For later versions of Visual Studio, no setup is required-->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
   
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -817,3 +817,11 @@
 ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target})
   endforeach()
 endif()
+
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( CLANG_VISUALIZERS utils/clang.natvis)
+  add_custom_target( ClangVisualizers SOURCES ${CLANG_VISUALIZERS})
+  set_target_properties(ClangVisualizers PROPERTIES FOLDER "Utils")
+endif()
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51735.
mspertus added a comment.

Correctly handle non-Visual Studio case (e.g., Linux)


http://reviews.llvm.org/D18497

Files:
  CMakeLists.txt
  utils/llvm.natvis

Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use 
Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual 
Studio 2013, manually copy natvis files to Documents\\Visual Studio 
2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +734,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target( LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include
@@ -764,6 +778,7 @@
   endif()
 endif()
 
+
 # This must be at the end of the LLVM root CMakeLists file because it must run
 # after all targets are created.
 if(LLVM_DISTRIBUTION_COMPONENTS)


Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +734,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target( LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include
@@ -764,6 +778,7 @@
   endif()
 endif()
 
+
 # This must be at the end of the LLVM root CMakeLists file because it must run
 # after all targets are created.
 if(LLVM_DISTRIBUTION_COMPONENTS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check

2016-03-27 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 51738.
LegalizeAdulthood added a comment.

Remove brace initializers from test code.


http://reviews.llvm.org/D16529

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-raw-string-literal.rst
  test/clang-tidy/modernize-raw-string-literal-delimiter.cpp
  test/clang-tidy/modernize-raw-string-literal.cpp

Index: test/clang-tidy/modernize-raw-string-literal.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-raw-string-literal.cpp
@@ -0,0 +1,123 @@
+// RUN: %check_clang_tidy %s modernize-raw-string-literal %t
+
+char const *const BackSlash("goink\\frob");
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
+// CHECK-FIXES: {{^}}char const *const BackSlash(R"(goink\frob)");{{$}}
+
+char const *const PlainLiteral("plain literal");
+
+// Non-printable ASCII characters.
+char const *const Nul("goink\\\000");
+char const *const Soh("goink\\\001");
+char const *const Stx("goink\\\002");
+char const *const Etx("goink\\\003");
+char const *const Enq("goink\\\004");
+char const *const Ack("goink\\\005");
+char const *const Bell("goink\\\afrob");
+char const *const BackSpace("goink\\\bfrob");
+char const *const HorizontalTab("goink\\\tfrob");
+char const *const NewLine("goink\nfrob");
+char const *const VerticalTab("goink\\\vfrob");
+char const *const FormFeed("goink\\\ffrob");
+char const *const CarraigeReturn("goink\\\rfrob");
+char const *const So("goink\\\016");
+char const *const Si("goink\\\017");
+char const *const Dle("goink\\\020");
+char const *const Dc1("goink\\\021");
+char const *const Dc2("goink\\\022");
+char const *const Dc3("goink\\\023");
+char const *const Dc4("goink\\\024");
+char const *const Nak("goink\\\025");
+char const *const Syn("goink\\\026");
+char const *const Etb("goink\\\027");
+char const *const Can("goink\\\030");
+char const *const Em("goink\\\031");
+char const *const Sub("goink\\\032");
+char const *const Esc("goink\\\033");
+char const *const Fs("goink\\\034");
+char const *const Gs("goink\\\035");
+char const *const Rs("goink\\\036");
+char const *const Us("goink\\\037");
+char const *const HexNonPrintable("\\\x03");
+char const *const Delete("\\\177");
+
+char const *const TrailingSpace("A line \\with space. \n");
+char const *const TrailingNewLine("A single \\line.\n");
+char const *const AlreadyRaw(R"(foobie\\bletch)");
+char const *const UTF8Literal(u8"foobie\\bletch");
+char const *const UTF8RawLiteral(u8R"(foobie\\bletch)");
+char16_t const *const UTF16Literal(u"foobie\\bletch");
+char16_t const *const UTF16RawLiteral(uR"(foobie\\bletch)");
+char32_t const *const UTF32Literal(U"foobie\\bletch");
+char32_t const *const UTF32RawLiteral(UR"(foobie\\bletch)");
+wchar_t const *const WideLiteral(L"foobie\\bletch");
+wchar_t const *const WideRawLiteral(LR"(foobie\\bletch)");
+
+char const *const SingleQuote("goink\'frob");
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal
+// CHECK-XFIXES: {{^}}char const *const SingleQuote(R"(goink'frob)");{{$}}
+
+char const *const DoubleQuote("goink\"frob");
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const *const DoubleQuote(R"(goink"frob)");{{$}}
+
+char const *const QuestionMark("goink\?frob");
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const *const QuestionMark(R"(goink?frob)");{{$}}
+
+char const *const RegEx("goink\\(one|two\\)\\?.*\\nfrob");
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const *const RegEx(R"(goink\(one|two\)\\\?.*\nfrob)");{{$}}
+
+char const *const Path("C:\\Program Files\\Vendor\\Application\\Application.exe");
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const *const Path(R"(C:\Program Files\Vendor\Application\Application.exe)");{{$}}
+
+char const *const ContainsSentinel("who\\ops)\"");
+// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const *const ContainsSentinel(R"lit(who\ops)")lit");{{$}}
+
+char const *const ContainsDelim("whoops)\")lit\"");
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const *const ContainsDelim(R"lit1(whoops)")lit")lit1");{{$}}
+
+char const *const OctalPrintable("\100\\");
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: {{.*}} can be written as a raw string literal
+// CHECK-FIXES: {{^}}char const

Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

This is fantastic! Just a few nits, but nothing substantial.



Comment at: CMakeLists.txt:739
@@ +738,3 @@
+# tries to create a corresponding executable, which we don't want
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( LLVM_VISUALIZERS utils/llvm.natvis)

I think the convention is to have a space between the if and the (.


Comment at: CMakeLists.txt:740-741
@@ +739,4 @@
+if(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set( LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target( LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")

Should remove the space after the open paren.


Comment at: CMakeLists.txt:781
@@ -766,2 +780,3 @@
 
+
 # This must be at the end of the LLVM root CMakeLists file because it must run

Spurious newline?


Comment at: utils/llvm.natvis:8
@@ -7,1 +7,3 @@
+
+For later versions of Visual Studio, no setup is required
 -->

Missing a terminating period.


http://reviews.llvm.org/D18497



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


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51739.
mspertus added a comment.

Accepting Aaron's suggestions


http://reviews.llvm.org/D18497

Files:
  CMakeLists.txt
  utils/llvm.natvis

Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use 
Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual 
Studio 2013, manually copy natvis files to Documents\\Visual Studio 
2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +734,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target(LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include


Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +734,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target(LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus marked 3 inline comments as done.
mspertus added a comment.

http://reviews.llvm.org/D18497



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


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


http://reviews.llvm.org/D18497



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


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51740.
mspertus added a comment.

Missed one (the missing period in llvm.natvis).


http://reviews.llvm.org/D18497

Files:
  CMakeLists.txt
  utils/llvm.natvis

Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use 
Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual 
Studio 2013, manually copy natvis files to Documents\\Visual Studio 
2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +734,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target(LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include


Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -728,6 +734,14 @@
 
 add_subdirectory(cmake/modules)
 
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(LLVM_VISUALIZERS utils/llvm.natvis)
+  add_custom_target(LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
+
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/llvm include/llvm-c
 DESTINATION include
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus marked an inline comment as done.
mspertus added a comment.

http://reviews.llvm.org/D18497



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51741.
mspertus added a comment.

Apply whitespace comments from http://reviews.llvm.org/D18497 mutatis mutandis 
to this change


http://reviews.llvm.org/D18498

Files:
  CMakeLists.txt
  utils/clang.natvis
  www/hacking.html

Index: www/hacking.html
===
--- www/hacking.html
+++ www/hacking.html
@@ -103,9 +103,11 @@
 http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis";>
   utils/clang.natvis provide debugger visualizers 
   that make debugging of more complex data types much easier.
-  Put the files into 
-%USERPROFILE%\Documents\Visual Studio 2012\Visualizers or 
+  For Visual Studio 2013 only, put the files into 
+%USERPROFILE%\Documents\Visual Studio 2013\Visualizers or 
 create a symbolic link so they update automatically.
+  For later versions of Visual Studio, no installation is required.
+Note also that later versions of Visual Studio also display better 
visualizations.
 
   
   Testing
Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -2,9 +2,10 @@
 
+For Visual Studio 2013 only, put this file into 
+"%USERPROFILE%\Documents\Visual Studio 2013\Visualizers" or create a symbolic 
link so it updates automatically.
+
+For later versions of Visual Studio, no setup is required-->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
   
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -817,3 +817,11 @@
 ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target})
   endforeach()
 endif()
+
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(CLANG_VISUALIZERS utils/clang.natvis)
+  add_custom_target(ClangVisualizers SOURCES ${CLANG_VISUALIZERS})
+  set_target_properties(ClangVisualizers PROPERTIES FOLDER "Utils")
+endif()
\ No newline at end of file


Index: www/hacking.html
===
--- www/hacking.html
+++ www/hacking.html
@@ -103,9 +103,11 @@
 http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis";>
   utils/clang.natvis provide debugger visualizers 
   that make debugging of more complex data types much easier.
-  Put the files into 
-%USERPROFILE%\Documents\Visual Studio 2012\Visualizers or 
+  For Visual Studio 2013 only, put the files into 
+%USERPROFILE%\Documents\Visual Studio 2013\Visualizers or 
 create a symbolic link so they update automatically.
+  For later versions of Visual Studio, no installation is required.
+Note also that later versions of Visual Studio also display better visualizations.
 
   
   Testing
Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -2,9 +2,10 @@
 
+For Visual Studio 2013 only, put this file into 
+"%USERPROFILE%\Documents\Visual Studio 2013\Visualizers" or create a symbolic link so it updates automatically.
+
+For later versions of Visual Studio, no setup is required-->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
   
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -817,3 +817,11 @@
 ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target})
   endforeach()
 endif()
+
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(CLANG_VISUALIZERS utils/clang.natvis)
+  add_custom_target(ClangVisualizers SOURCES ${CLANG_VISUALIZERS})
+  set_target_properties(ClangVisualizers PROPERTIES FOLDER "Utils")
+endif()
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18495: Check default arguments of template template parameters for compatibility.

2016-03-27 Thread Faisal Vali via cfe-commits
faisalv marked 2 inline comments as done.


Comment at: lib/Sema/SemaTemplate.cpp:793-800
@@ -792,10 +792,2 @@
   if (!Default.isInvalid()) {
-// Check only that we have a template template argument. We don't want to
-// try to check well-formedness now, because our template template 
parameter
-// might have dependent types in its template parameters, which we wouldn't
-// be able to match now.
-//
-// If none of the template template parameter's template arguments mention
-// other template parameters, we could actually perform more checking here.
-// However, it isn't worth doing.
 TemplateArgumentLoc DefaultArg = translateTemplateArgument(*this, Default);

rsmith wrote:
> You don't appear to have added any test coverage for these cases. Are there 
> existing tests for this? Something like:
> 
>   template typename A>
>   struct X {
> template typename = A> struct Y {};
>   };
> 
> Similar cases exist where the template template parameter has a parameter 
> pack and is used as a default template argument for a template template 
> parameter that takes a non-pack.
Thanks for the example - I was struggling with conjuring an example that would 
represent the concerns expressed in those comments.  Example added to test 
suite.



Comment at: test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp:73-74
@@ +72,4 @@
+struct A {
+  template //expected-note{{declared here}}
+  class UU = TT> //expected-error{{different template parameters}}
+  struct B;

rsmith wrote:
> This looks like a rejects-valid. Consider:
> 
>   template struct Q;
>   A::B b;
> 
> Here, `TT` refers to `Q`, which is valid as a template template argument for 
> parameter `UU`.
Aah yes - nice example - I agree this should work.  Please see revision patch.


http://reviews.llvm.org/D18495



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Zachary Turner via cfe-commits
For vs2015, the files still need to be in the project right? (In the
vcxproj with a  tag)
On Sun, Mar 27, 2016 at 9:09 AM Mike Spertus  wrote:

> mspertus updated this revision to Diff 51741.
> mspertus added a comment.
>
> Apply whitespace comments from http://reviews.llvm.org/D18497 mutatis
> mutandis to this change
>
>
> http://reviews.llvm.org/D18498
>
> Files:
>   CMakeLists.txt
>   utils/clang.natvis
>   www/hacking.html
>
> Index: www/hacking.html
> ===
> --- www/hacking.html
> +++ www/hacking.html
> @@ -103,9 +103,11 @@
>  http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis";>
>utils/clang.natvis provide debugger visualizers
>that make debugging of more complex data types much easier.
> -  Put the files into
> -%USERPROFILE%\Documents\Visual Studio 2012\Visualizers or
> +  For Visual Studio 2013 only, put the files into
> +%USERPROFILE%\Documents\Visual Studio 2013\Visualizers or
>  create a symbolic link so they update automatically.
> +  For later versions of Visual Studio, no installation is required.
> +Note also that later versions of Visual Studio also display better
> visualizations.
>
>
>  
>Testing
> Index: utils/clang.natvis
> ===
> --- utils/clang.natvis
> +++ utils/clang.natvis
> @@ -2,9 +2,10 @@
>  
> +For Visual Studio 2013 only, put this file into
> +"%USERPROFILE%\Documents\Visual Studio 2013\Visualizers" or create a
> symbolic link so it updates automatically.
> +
> +For later versions of Visual Studio, no setup is required-->
>  http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
>
>
> Index: CMakeLists.txt
> ===
> --- CMakeLists.txt
> +++ CMakeLists.txt
> @@ -817,3 +817,11 @@
>  ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target})
>endforeach()
>  endif()
> +
> +# Do this by hand instead of using add_llvm_utilities(), which
> +# tries to create a corresponding executable, which we don't want
> +if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
> +  set(CLANG_VISUALIZERS utils/clang.natvis)
> +  add_custom_target(ClangVisualizers SOURCES ${CLANG_VISUALIZERS})
> +  set_target_properties(ClangVisualizers PROPERTIES FOLDER "Utils")
> +endif()
> \ No newline at end of file
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus added a comment.

In http://reviews.llvm.org/D18498#384233, @zturner wrote:

> For vs2015, the files still need to be in the project right? (In the
>  vcxproj with a  tag)


This change puts the natvis files in the project for VS2015 but it appears to 
use the `none` tag

  
  http://schemas.microsoft.com/developer/msbuild/2003";>

  


  



  
  
  It does seem to work correctly though... Whaddaya think?


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18495: Check default arguments of template template parameters for compatibility.

2016-03-27 Thread Faisal Vali via cfe-commits
faisalv updated this revision to Diff 51742.
faisalv marked 2 inline comments as done.
faisalv added a comment.

Updated the patch with the following:

- while checking dependent template template arguments at template definition 
time, we must accept the more general (pack) as compatible with the more 
specific (non-pack sequence), since the instantiation time check will preserve 
the compatibility between template parameter lists (for a subset of 
pack-expansions compatible with the non-pack sequences) mandated by the 
standard.
- added Richard's examples.

Thanks!


http://reviews.llvm.org/D18495

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaTemplate.cpp
  test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
  test/CXX/temp/temp.param/p10-0x.cpp
  test/CXX/temp/temp.param/p12.cpp

Index: test/CXX/temp/temp.param/p12.cpp
===
--- test/CXX/temp/temp.param/p12.cpp
+++ test/CXX/temp/temp.param/p12.cpp
@@ -34,6 +34,6 @@
 // Check validity of default arguments
 template class // expected-note{{previous template template parameter is here}}
= Y1> // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
-  class C1 {};
+  class C1 {};  //expected-note{{template is declared here}}
 
-C1<> c1; // expected-note{{while checking a default template argument}}
+C1<> c1; // expected-error{{too few template arguments}}
Index: test/CXX/temp/temp.param/p10-0x.cpp
===
--- test/CXX/temp/temp.param/p10-0x.cpp
+++ test/CXX/temp/temp.param/p10-0x.cpp
@@ -8,7 +8,7 @@
 template using B2 = T1;
 
 template class F, template class G = Y1> using B2t = F>;
-template class F = Y2, template class G> using B2t = F>;
+template class F = Y1, template class G> using B2t = F>;
 
 template using B2n = Y2;
 template using B2n = Y2;
Index: test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
===
--- test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
+++ test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
@@ -38,3 +38,116 @@
 X1 inst_x1b;
 X1 inst_x1c;
 X1 inst_x1d; // expected-error{{template template argument has different template parameters than its corresponding template template paramete}}
+
+
+namespace ns0 {
+template using TA = int*;
+template class TT = TA> struct X;
+
+}
+
+
+namespace ns1 {
+template class TT> //expected-note{{too many template parameters}}
+struct X {
+  template //expected-note{{previous template template parameter is here}}
+  class UU = TT>  //expected-error{{different template parameters}}
+  struct Y;
+};
+} // end ns1
+namespace ns2 {
+template class TT> 
+struct A {
+  template class UU = TT> 
+  struct B;
+};
+} // end ns2
+namespace ns3 {
+template class TT> struct A {
+  template class UU = T::template X> struct B { };
+};
+} // end ns3
+namespace ns4 {
+template class TT> 
+struct A {
+  template 
+  class UU = TT> // OK
+  struct B;
+};
+template struct Q;
+A::B *b; // OK
+
+namespace ns4_0 {
+template class TT> 
+struct A {
+  template 
+  class UU = TT> // OK
+  struct B;
+};
+template struct Q;
+A::B *b;
+} // end ns4_0
+
+namespace ns4_1 {
+template class> class TT> 
+struct A {
+  template class> 
+  class UU = TT> // OK
+  struct B;
+};
+
+} // end ns4_0
+
+} // end ns4
+
+namespace ns5 {
+template class TT> 
+struct A {
+  template 
+  class UU = TT> 
+  struct B;
+};
+
+
+} // end ns5
+
+namespace ns6 {
+
+template class A>
+struct X {
+  template class = A> struct Y {};
+};
+
+} // end ns6
+
+
+namespace ns7 {
+
+template class A>
+struct X;
+
+template class A> struct X {
+  using type = char*;
+};
+template struct Q;
+X::type *pc;
+
+} // end ns6
+
+namespace ns8 {
+// NOTE: This test for partial specializations is added here to remind us
+// that these cases are somewhat similar, yet not without differences.
+// Even though for default arguments at template defintion we allow 
+// the contravariant case (a pack on argument is compatible with a non-pack 
+// on the parameter) in the partial specialization setting, we do not allow it.
+template class A> //expected-note{{declared here}}
+struct X {};
+
+template class A> //expected-note{{pack does not match}}
+struct X { //expected-error{{different template parameters than its corresponding template template parameter}}
+  using type = char*;
+};
+
+} // end ns6
+
+
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -790,14 +790,6 @@
   }
 
   if (!Default.isInvalid()) {
-// Check only that we have a template template argument. We don't want to
-// try to check well-formedness now, because our template template parameter
-// might have dependent types in its template parameters, which we wouldn't
-// be able to match

[clang-tools-extra] r264539 - clang-tidy: Add check modernize-raw-string-literal

2016-03-27 Thread Richard Thomson via cfe-commits
Author: legalize
Date: Sun Mar 27 11:43:44 2016
New Revision: 264539

URL: http://llvm.org/viewvc/llvm-project?rev=264539&view=rev
Log:
clang-tidy: Add check modernize-raw-string-literal

Added:
clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-raw-string-literal.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-delimiter.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=264539&r1=264538&r2=264539&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Sun Mar 27 
11:43:44 2016
@@ -7,6 +7,7 @@ add_clang_library(clangTidyModernizeModu
   MakeUniqueCheck.cpp
   ModernizeTidyModule.cpp
   PassByValueCheck.cpp
+  RawStringLiteralCheck.cpp
   RedundantVoidArgCheck.cpp
   ReplaceAutoPtrCheck.cpp
   ShrinkToFitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=264539&r1=264538&r2=264539&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Sun 
Mar 27 11:43:44 2016
@@ -14,6 +14,7 @@
 #include "LoopConvertCheck.h"
 #include "MakeUniqueCheck.h"
 #include "PassByValueCheck.h"
+#include "RawStringLiteralCheck.h"
 #include "RedundantVoidArgCheck.h"
 #include "ReplaceAutoPtrCheck.h"
 #include "ShrinkToFitCheck.h"
@@ -36,6 +37,8 @@ public:
 CheckFactories.registerCheck("modernize-loop-convert");
 CheckFactories.registerCheck("modernize-make-unique");
 CheckFactories.registerCheck("modernize-pass-by-value");
+CheckFactories.registerCheck(
+"modernize-raw-string-literal");
 CheckFactories.registerCheck(
 "modernize-redundant-void-arg");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp?rev=264539&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp Sun 
Mar 27 11:43:44 2016
@@ -0,0 +1,140 @@
+//===--- RawStringLiteralCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RawStringLiteralCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+namespace {
+
+bool containsEscapes(StringRef HayStack, StringRef Escapes) {
+  size_t BackSlash = HayStack.find('\\');
+  if (BackSlash == StringRef::npos)
+return false;
+
+  while (BackSlash != StringRef::npos) {
+if (Escapes.find(HayStack[BackSlash + 1]) == StringRef::npos)
+  return false;
+BackSlash = HayStack.find('\\', BackSlash + 2);
+  }
+
+  return true;
+}
+
+bool isRawStringLiteral(StringRef Text) {
+  // Already a raw string literal if R comes before ".
+  const size_t QuotePos = Text.find('"');
+  assert(QuotePos != StringRef::npos);
+  return (QuotePos > 0) && (Text[QuotePos - 1] == 'R');
+}
+
+bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
+   const StringLiteral *Literal) {
+  // FIXME: Handle L"", u8"", u"" and U"" literals.
+  if (!Literal->isAscii())
+return false;
+
+  StringRef Bytes = Literal->getBytes();
+  // Non-printing characters disqualify this literal:
+  // \007 = \a bell
+  // \010 = \b backspace
+  // \011 = \t horizontal tab
+  // \012 = \n new line
+  // \013 = \v vertical tab
+  // \014 = \f form feed
+  // \015 = \r carriage return
+  // \177 = delete
+  if (Bytes.find_first_of(String

Re: [PATCH] D18458: [CUDA] Mangle __host__ __device__ functions differently than __host__ or __device__ functions.

2016-03-27 Thread Justin Lebar via cfe-commits
jlebar added a comment.

> OK, so the question for you is, how much ABI compatibility with NVCC are you 
> prepared to give up in order to allow HD / D overloading and HD / H 
> overloading?


At the moment, getting this feature to work seems more important than 
maintaining ABI compatibility with NVCC.  But I cannot confidently assign a 
probability to how likely it will be at some point in the future that we'll 
want this ABI compatibility.  I really don't know.

So, that's one option.  Here's another:

The motivation behind this one is, we have this pie-in-the-sky notion that, 
morally, device code should be able to call anything it wants.  Only if we 
cannot codegen for device a function transitively invoked by a device function 
will we error out.  constexpr-is-implicitly-HD is a step towards this more 
ambitious goal.

Setting aside the constexpr bit, it seems to me that when we codegen an 
unattributed function for device, we should mark the function as having 
internal linkage (or whatever the thing is called such that it's not visible 
from other TUs).  The reason is, other TUs cannot rely on this function being 
present in the first object file, because the function is only generated 
on-demand.  If you want to call an HD function defined in another .cu file, 
then the header in both files needs to explicitly define it as HD.

If that is true -- that unattributed functions which we codegen for device 
can/should be made internal -- then the mangling of those names has no bearing 
on ABI compatibility.  So we could say, no explicit-HD / D or explicit-HD / H 
overloading, but *implicit*-HD / D overloading is OK, and we will mangle 
implicit-HD functions differently to allow this.

Does that sound like it might work?


http://reviews.llvm.org/D18458



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus added a comment.

Hmmm, I just tried adding ` set_source_files_properties(utils/clang.natvis 
LANGUAGE natvis)` similar to what you suggest in 
http://lists.llvm.org/pipermail/llvm-dev/2016-January/093887.html, but it still 
produces the `None` tag in the `.vcxproj` file. Any suggestion what I might be 
doing wrong?

Thanks,
Mike


http://reviews.llvm.org/D18498



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


Re: r263709 - clang-format: Slightly weaken AlignAfterOpenBracket=AlwaysBreak.

2016-03-27 Thread Jean-philippe Dufraigne via cfe-commits
Hi Daniel,

Thanks a lot for your answer and clarifications.
Sorry for the long answer, TLDR at the beginning (and end for code
examples).

To answer your 2 questions immediately:
- It happens a lot more than I thought, about 10% of the few thousands file
I checked had instances of this.
- Yes, there is a significant readability disadvantage as these functions
become a special case that needs to be read differently from all the other
functions.
  With consistent AlwaysBreak, it is obvious from the shape of the call how
to read it (horizontally or diagonally).
  Now, it is not longer obvious and it impact readability mostly for these
functions, but also a bit for the other functions since it is not clear if
they are one of the special case or not.
  (The eye needs to jump at the end and then back to parse the arguments)
  (This ls less/not of an issue for lambda and small functions)


My conclusion:
I really think an option should provide a consistent break but I'm really
not sure it should be a new option.
If I manage to convince you through the examples, that formatting all
function consistently will actually improve overall readability more
generally, I think AlwaysBreak is just fine as it was.
I'm happy to help with coding or writing tests for whatever decision you
make.


Examples:
I've pasted / attached the code examples that I saw, some many many times
(with .clang-format file).
You'll be able to see how before things were more consistent and now things
are moved to unexpected places depending on the call.
Moreover the benefit is very limited for us, because gaining 1 line does
not seem to add to our readability, and the indentation saved (most often 1
(4 spaces)) does not lead to better or different arguments formatting in
most cases. (less than 10 where arguments where improved in the hundreds of
cases I've looked at).


Methodology:
I wanted to make sure that I really understood the problem before coming
back to you:
- I've done a full reformat of 2 of our projects first with snapshot
r260967, then with snapshot r264047 (with the new change).
  That is few thousands of cpp/h files, and about 10% were modified when
running the updated format.
- I spent more hours than I should have yesterday just scrolling through
and taking notes in a 30'000 line diff of the impact of the update (using
10 lines of context), so I think I've got a good handle on the issue now.


Other comments:
- It is possible that with some other configuration you used, this change
does improves things without the same draw back, I do not know, but your
commit comment example did not look more readable for me since I am used to
the style.
- lambda break would be nice and more what we would have expected, but they
are somewhat a different thing and less of a problem.
- Very small function break occurs not that often and are weird to format
either way. They are also less of an issue because they are small so
everything is mostly where the eye is looking at (no need for the eye to
jump toward the end of the line and back).
- I also think the new option as you described could have some trickiness,
it may also impact things like 'if' if we are not careful, and it is also
another maintenance burden.



Other notes / detailed explanations:

1 - With a consistent always break, there are 2 places you have too look
for, and the one your need is obvious from the shape of the code:
 - Either it is multi-line, and 1st argument is described at the
indentation => Scan function call diagonally
 - Or it is a single line call and the 1st argument is described after the
'(' => Scan function horizontally

With this new formatting, the 1st argument may also start to be described
after the '(' and then continue at the indentation.
It is no longer possible to scan diagonally, and that really apply for any
functions as it is not obvious from the shape of the call.

2 - It may be because of our other style options, but there are very few
(less than 10 in the many hundreds) where the result could be said to be
better, on its own:
This happens, because we most often only gain a new line (not really an
improvement for us) and only one indentation (4 spaces), and the odds that
the argument is too big by between 1 and 4 spaces is not so great:
So the net result is that the argument are shifted 4 spaces to the left
without really any improvements.

3- There is one unrelated bug with unstable comment re flowing in macros
that I found as a result and will try to raise it.
 There was also some minor changes in the way few 'else if' were
formatted but this is not the main matter.
 There was also an issue with formatting a template call with explicit
types as a function argument indented strangely.

Cheers,
Jean-Philippe



NewTest.cpp (also attached, contains both code reformatted with r26096 and
with r264047):
You can see how before things were more consistent and now things are moved
to unexpected places depending on the call.

class TestClass1
{
//
 

Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Zachary Turner via cfe-commits
Yea, CMake doesn't actually support natvis files. You'd have to actually
patch CMake to make it work.

Can you make the vs2015 and vs2013 paths the same? It will still work for
2015 i think, just that 2015 also supports putting them in the project file
On Sun, Mar 27, 2016 at 10:04 AM Mike Spertus  wrote:

> mspertus added a comment.
>
> Hmmm, I just tried adding ` set_source_files_properties(utils/clang.natvis
> LANGUAGE natvis)` similar to what you suggest in
> http://lists.llvm.org/pipermail/llvm-dev/2016-January/093887.html, but it
> still produces the `None` tag in the `.vcxproj` file. Any suggestion what I
> might be doing wrong?
>
> Thanks,
> Mike
>
>
> http://reviews.llvm.org/D18498
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus added a comment.

What do you mean by "making both paths the same"?


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Zachary Turner via cfe-commits
Code paths. For vs2013 you're installing the natvis files, can we just do
that for vs2015 as well?
On Sun, Mar 27, 2016 at 11:23 AM Mike Spertus  wrote:

> mspertus added a comment.
>
> What do you mean by "making both paths the same"?
>
>
> http://reviews.llvm.org/D18498
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus added a comment.

I'm not sure I understand. I'm not installing anything for VS2013. You still 
have to manually copy into `Documents\VS2013`. The purpose of this change is to 
eliminate this manual step for VS2015 by leveraging the new Natvis project 
support. Am I missing something?


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Zachary Turner via cfe-commits
If it's not using a natvis tag in the vcxproj (which it isn't since CMake
doesn't support it during generation) then the new natvis project file
support won't work right? In which case the files would need to be copied
into documents\vs2015, otherwise it won't work, unless I'm misunderstanding
something
On Sun, Mar 27, 2016 at 11:54 AM Mike Spertus  wrote:

> mspertus added a comment.
>
> I'm not sure I understand. I'm not installing anything for VS2013. You
> still have to manually copy into `Documents\VS2013`. The purpose of this
> change is to eliminate this manual step for VS2015 by leveraging the new
> Natvis project support. Am I missing something?
>
>
> http://reviews.llvm.org/D18498
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus added a comment.

No. Testing shows that it works fine in the project with the `` tag. 
VS2015 empirically looks at the extension.


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Zachary Turner via cfe-commits
Ahh that's surprising. If it works even with the none tag, i guess my
concerns are not valid
On Sun, Mar 27, 2016 at 12:11 PM Mike Spertus  wrote:

> mspertus added a comment.
>
> No. Testing shows that it works fine in the project with the `` tag.
> VS2015 empirically looks at the extension.
>
>
> http://reviews.llvm.org/D18498
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus added a comment.

I understand your concerns, but on balance, I don't see a better course of 
action than what I've done. If I have some time, I'll submit a CMake change so 
we can eventually migrate to having CMake generate a Natvis tag, but that will 
take a long time to propagate, so I don't want to delay this operationally 
semantically equivalent change. Sound ok?


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Zachary Turner via cfe-commits
Yea sounds fine
On Sun, Mar 27, 2016 at 12:20 PM Mike Spertus  wrote:

> mspertus added a comment.
>
> I understand your concerns, but on balance, I don't see a better course of
> action than what I've done. If I have some time, I'll submit a CMake change
> so we can eventually migrate to having CMake generate a Natvis tag, but
> that will take a long time to propagate, so I don't want to delay this
> operationally semantically equivalent change. Sound ok?
>
>
> http://reviews.llvm.org/D18498
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r264540 - [modules] When encoding SourceLocations in bitcode, rotate the 'is macro' flag

2016-03-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Mar 27 15:13:24 2016
New Revision: 264540

URL: http://llvm.org/viewvc/llvm-project?rev=264540&view=rev
Log:
[modules] When encoding SourceLocations in bitcode, rotate the 'is macro' flag
bit from the top bit to the bottom bit, so that we don't need 6 VBR6 hunks for
each macro location. Reduces libstdc++ module size by about 1%.

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=264540&r1=264539&r2=264540&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Sun Mar 27 15:13:24 2016
@@ -1979,9 +1979,15 @@ public:
   /// \brief Read the contents of a CXXCtorInitializer array.
   CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) 
override;
 
+  /// \brief Read a source location from raw form and return it in its
+  /// originating module file's source location space.
+  SourceLocation ReadUntranslatedSourceLocation(uint32_t Raw) const {
+return SourceLocation::getFromRawEncoding((Raw >> 1) | (Raw << 31));
+  }
+
   /// \brief Read a source location from raw form.
-  SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) 
const {
-SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw);
+  SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) 
const {
+SourceLocation Loc = ReadUntranslatedSourceLocation(Raw);
 return TranslateSourceLocation(ModuleFile, Loc);
   }
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=264540&r1=264539&r2=264540&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Mar 27 15:13:24 2016
@@ -2341,9 +2341,9 @@ ASTReader::ReadControlBlock(ModuleFile &
 ModuleKind ImportedKind = (ModuleKind)Record[Idx++];
 // The import location will be the local one for now; we will adjust
 // all import locations of module imports after the global source
-// location info are setup.
+// location info are setup, in ReadAST.
 SourceLocation ImportLoc =
-SourceLocation::getFromRawEncoding(Record[Idx++]);
+ReadUntranslatedSourceLocation(Record[Idx++]);
 off_t StoredSize = (off_t)Record[Idx++];
 time_t StoredModTime = (time_t)Record[Idx++];
 ASTFileSignature StoredSignature = Record[Idx++];
@@ -3601,11 +3601,12 @@ ASTReader::ASTReadResult ASTReader::Read
 
 // Set the import location.
 F.DirectImportLoc = ImportLoc;
+// FIXME: We assume that locations from PCH / preamble do not need
+// any translation.
 if (!M->ImportedBy)
   F.ImportLoc = M->ImportLoc;
 else
-  F.ImportLoc = ReadSourceLocation(*M->ImportedBy,
-   M->ImportLoc.getRawEncoding());
+  F.ImportLoc = TranslateSourceLocation(*M->ImportedBy, M->ImportLoc);
   }
 
   if (!Context.getLangOpts().CPlusPlus ||
@@ -4982,7 +4983,6 @@ PreprocessedEntityID ASTReader::findNext
 
 namespace {
 
-template 
 struct PPEntityComp {
   const ASTReader &Reader;
   ModuleFile &M;
@@ -5006,7 +5006,7 @@ struct PPEntityComp {
   }
 
   SourceLocation getLoc(const PPEntityOffset &PPE) const {
-return Reader.ReadSourceLocation(M, PPE.*PPLoc);
+return Reader.TranslateSourceLocation(M, PPE.getBegin());
   }
 };
 
@@ -5037,7 +5037,7 @@ PreprocessedEntityID ASTReader::findPrep
 
   if (EndsAfter) {
 PPI = std::upper_bound(pp_begin, pp_end, Loc,
-   PPEntityComp<&PPEntityOffset::Begin>(*this, M));
+   PPEntityComp(*this, M));
   } else {
 // Do a binary search manually instead of using std::lower_bound because
 // The end locations of entities may be unordered (when a macro expansion
@@ -5047,8 +5047,8 @@ PreprocessedEntityID ASTReader::findPrep
   Half = Count / 2;
   PPI = First;
   std::advance(PPI, Half);
-  if (SourceMgr.isBeforeInTranslationUnit(ReadSourceLocation(M, PPI->End),
-  Loc)) {
+  if (SourceMgr.isBeforeInTranslationUnit(
+  TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
 First = PPI;
 ++First;
 Count = Count - Half - 1;

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=264540&r1=264539&r2=264540&view=diff
==
--- cfe/trunk/

[PATCH] D18501: Fix compilation on FreeBSD

2016-03-27 Thread Dimitry Andric via cfe-commits
dim created this revision.
dim added reviewers: mclow.lists, EricWF, emaste.
dim added subscribers: cfe-commits, bdrewery.
Herald added a subscriber: emaste.

On FreeBSD, a number of math.h functions are actually defined as macros,
such as `signbit()`, `fpclassify()` and others.  Since libc++'s 
attempts to do `using ::signbit;`, `using ::fpclassify;`, and so on,
this results in compile errors:

libcxx/include/cmath:309:9: error: '::signbit' has not been declared
 using ::signbit;
 ^
libcxx/include/cmath:310:9: error: '::fpclassify' has not been declared
 using ::fpclassify;
 ^

Here is a patch to exclude `signbit` through `isunordered`, and also
`abs`, which we don't have in math.h.

(Actually, I'm not sure that `::abs` should even be in here, since it is
a stdlib.h function?  We don't have it in math.h, in any case.)

http://reviews.llvm.org/D18501

Files:
  include/cmath

Index: include/cmath
===
--- include/cmath
+++ include/cmath
@@ -306,6 +306,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifndef __FreeBSD__
 using ::signbit;
 using ::fpclassify;
 using ::isfinite;
@@ -319,13 +320,14 @@
 using ::islessgreater;
 using ::isunordered;
 using ::isunordered;
+#endif // __FreeBSD__
 
 using ::float_t;
 using ::double_t;
 
-#ifndef _AIX
+#if !defined(_AIX) && !defined(__FreeBSD__)
 using ::abs;
-#endif
+#endif // !AIX && !__FreeBSD__
 
 #ifndef __sun__
 using ::acos;


Index: include/cmath
===
--- include/cmath
+++ include/cmath
@@ -306,6 +306,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifndef __FreeBSD__
 using ::signbit;
 using ::fpclassify;
 using ::isfinite;
@@ -319,13 +320,14 @@
 using ::islessgreater;
 using ::isunordered;
 using ::isunordered;
+#endif // __FreeBSD__
 
 using ::float_t;
 using ::double_t;
 
-#ifndef _AIX
+#if !defined(_AIX) && !defined(__FreeBSD__)
 using ::abs;
-#endif
+#endif // !AIX && !__FreeBSD__
 
 #ifndef __sun__
 using ::acos;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18501: Fix compilation on FreeBSD

2016-03-27 Thread Dimitry Andric via cfe-commits
dim added a comment.

Note that these compilation errors came up specifically because @bdrewery is 
doing cross-compilation of FreeBSD with recent versions of gcc.  Apparently 
clang does not give the same errors on these undefined identifiers, but I'm not 
entirely sure why not...


http://reviews.llvm.org/D18501



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


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51754.
mspertus added a comment.

Since this is now creating a project, we should do some housekeeping to move 
the files to different directories so that the build tree has an 
LLVMVisualizers project directory.


http://reviews.llvm.org/D18497

Files:
  CMakeLists.txt
  utils/LLVMVisualizers/CMakeLists.txt
  utils/LLVMVisualizers/llvm.natvis
  utils/llvm.natvis

Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,169 +0,0 @@
-
-
-http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
-
-  
-empty
-{{ size={($T1*)EndX - ($T1*)BeginX} }}
-
-  ($T1*)EndX - ($T1*)BeginX
-  ($T1*)CapacityX - ($T1*)BeginX
-  
-($T1*)EndX - ($T1*)BeginX
-($T1*)BeginX
-  
-
-  
-
-  
-{BeginX,s}
-BeginX,s
-
-  (char*)EndX - (char*)BeginX
-  (char*)CapacityX - (char*)BeginX
-  
-(char*)EndX - (char*)BeginX
-(char*)BeginX
-  
-
-  
-
-  
-{Data,[Length]s}
-Data,[Length]s
-
-  Length
-  
-Length
-Data
-  
-
-  
-
-  
-{IntMask}: {($T1)(Value & PointerBitMask)} [{($T3)((Value >> IntShift) & IntMask)}]
-
-  ($T1)(Value & PointerBitMask)
-  ($T3)((Value >> IntShift) & IntMask)
-
-  
-
-  
-{"$T1", s8b}: {($T1)(Val.Value & Val.PointerBitMask)}
-{"$T2", s8b}: {($T2)(Val.Value & Val.PointerBitMask)}
-
-  ($T1)(Val.Value & Val.PointerBitMask)
-  ($T2)(Val.Value & Val.PointerBitMask)
-
-  
-
-  
-{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
-
-  ($T1)((Val.Val.Value >> 2) << 2)
-  ($T2)((Val.Val.Value >> 2) << 2)
-  ($T3)((Val.Val.Value >> 2) << 2)
-
-  
-
-  
-{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
-{"$T4", s8b}: {($T4)((Val.Val.Value >> 2) << 2)}
-
-  ($T1)((Val.Val.Value >> 2) << 2)
-  ($T2)((Val.Val.Value >> 2) << 2)
-  ($T3)((Val.Val.Value >> 2) << 2)
-  ($T4)((Val.Val.Value >> 2) << 2)
-
-  
-
-  
-{{ empty }}
-{{ head={Head} }}
-
-  
-Head
-Next
-this
-  
-
-  
-
-  
-empty
-RefPtr [1 ref] {*Obj}
-RefPtr [{Obj->ref_cnt} refs] {*Obj}
-
-  Obj->ref_cnt
-  Obj
-
-  
-
-  
-{{ [Small Mode] size={NumElements}, capacity={CurArraySize} }}
-{{ [Big Mode] size={NumElements}, capacity={CurArraySize} }}
-
-  NumElements
-  CurArraySize
-  
-CurArraySize
-($T1*)CurArray
-  
-
-  
-
-  
-empty
-{{ size={NumEntries}, buckets={NumBuckets} }}
-
-  NumEntries
-  NumBuckets
-  
-NumBuckets
-Buckets
-  
-
-  
-
-  
-{{ size={NumItems}, buckets={NumBuckets} }}
-
-  NumItems
-  NumBuckets
-  
-NumBuckets
-(MapEntryTy**)TheTable
-  
-
-  
-
-  
-empty
-({this+1,s}, {second})
-
-  this+1,s
-  second
-
-  
-
-  
-{Data}
-  
-  
-  
-empty
-{*(($T1 *)(unsigned char *)storage.buffer)}
-
-  *(($T1 *)(unsigned char *)storage.buffer)
-
-  
-
Index: utils/LLVMVisualizers/llvm.natvis
===
--- utils/LLVMVisualizers/llvm.natvis
+++ utils/LLVMVisualizers/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: utils/LLVMVisualizers/CMakeLists.txt
===
--- utils/LLVMVisualizers/CMakeLists.txt
+++ utils/LLVMVisualizers/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(LLVM_VISUALIZERS llvm.natvis)
+  add_custom_target(LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
\ No newline at end of file
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -664,6 +670,11 @@
  

Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51756.
mspertus added a comment.

Add missing newline


http://reviews.llvm.org/D18497

Files:
  CMakeLists.txt
  utils/LLVMVisualizers/CMakeLists.txt
  utils/LLVMVisualizers/llvm.natvis
  utils/llvm.natvis

Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,169 +0,0 @@
-
-
-http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
-
-  
-empty
-{{ size={($T1*)EndX - ($T1*)BeginX} }}
-
-  ($T1*)EndX - ($T1*)BeginX
-  ($T1*)CapacityX - ($T1*)BeginX
-  
-($T1*)EndX - ($T1*)BeginX
-($T1*)BeginX
-  
-
-  
-
-  
-{BeginX,s}
-BeginX,s
-
-  (char*)EndX - (char*)BeginX
-  (char*)CapacityX - (char*)BeginX
-  
-(char*)EndX - (char*)BeginX
-(char*)BeginX
-  
-
-  
-
-  
-{Data,[Length]s}
-Data,[Length]s
-
-  Length
-  
-Length
-Data
-  
-
-  
-
-  
-{IntMask}: {($T1)(Value & PointerBitMask)} [{($T3)((Value >> IntShift) & IntMask)}]
-
-  ($T1)(Value & PointerBitMask)
-  ($T3)((Value >> IntShift) & IntMask)
-
-  
-
-  
-{"$T1", s8b}: {($T1)(Val.Value & Val.PointerBitMask)}
-{"$T2", s8b}: {($T2)(Val.Value & Val.PointerBitMask)}
-
-  ($T1)(Val.Value & Val.PointerBitMask)
-  ($T2)(Val.Value & Val.PointerBitMask)
-
-  
-
-  
-{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
-
-  ($T1)((Val.Val.Value >> 2) << 2)
-  ($T2)((Val.Val.Value >> 2) << 2)
-  ($T3)((Val.Val.Value >> 2) << 2)
-
-  
-
-  
-{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
-{"$T4", s8b}: {($T4)((Val.Val.Value >> 2) << 2)}
-
-  ($T1)((Val.Val.Value >> 2) << 2)
-  ($T2)((Val.Val.Value >> 2) << 2)
-  ($T3)((Val.Val.Value >> 2) << 2)
-  ($T4)((Val.Val.Value >> 2) << 2)
-
-  
-
-  
-{{ empty }}
-{{ head={Head} }}
-
-  
-Head
-Next
-this
-  
-
-  
-
-  
-empty
-RefPtr [1 ref] {*Obj}
-RefPtr [{Obj->ref_cnt} refs] {*Obj}
-
-  Obj->ref_cnt
-  Obj
-
-  
-
-  
-{{ [Small Mode] size={NumElements}, capacity={CurArraySize} }}
-{{ [Big Mode] size={NumElements}, capacity={CurArraySize} }}
-
-  NumElements
-  CurArraySize
-  
-CurArraySize
-($T1*)CurArray
-  
-
-  
-
-  
-empty
-{{ size={NumEntries}, buckets={NumBuckets} }}
-
-  NumEntries
-  NumBuckets
-  
-NumBuckets
-Buckets
-  
-
-  
-
-  
-{{ size={NumItems}, buckets={NumBuckets} }}
-
-  NumItems
-  NumBuckets
-  
-NumBuckets
-(MapEntryTy**)TheTable
-  
-
-  
-
-  
-empty
-({this+1,s}, {second})
-
-  this+1,s
-  second
-
-  
-
-  
-{Data}
-  
-  
-  
-empty
-{*(($T1 *)(unsigned char *)storage.buffer)}
-
-  *(($T1 *)(unsigned char *)storage.buffer)
-
-  
-
Index: utils/LLVMVisualizers/llvm.natvis
===
--- utils/LLVMVisualizers/llvm.natvis
+++ utils/LLVMVisualizers/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: utils/LLVMVisualizers/CMakeLists.txt
===
--- utils/LLVMVisualizers/CMakeLists.txt
+++ utils/LLVMVisualizers/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(LLVM_VISUALIZERS llvm.natvis)
+  add_custom_target(LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -664,6 +670,11 @@
   endif()
 endif()
 
+# Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  add_subdi

Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51759.
mspertus added a comment.

Now that we are generating projects for native visualizers, have it properly 
reflected in the directory structure


http://reviews.llvm.org/D18498

Files:
  CMakeLists.txt
  utils/ClangVisualizers/CMakeLists.txt
  utils/ClangVisualizers/clang.natvis
  utils/clang.natvis
  www/hacking.html

Index: www/hacking.html
===
--- www/hacking.html
+++ www/hacking.html
@@ -103,9 +103,11 @@
 http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis";>
   utils/clang.natvis provide debugger visualizers 
   that make debugging of more complex data types much easier.
-  Put the files into 
-%USERPROFILE%\Documents\Visual Studio 2012\Visualizers or 
+  For Visual Studio 2013 only, put the files into 
+%USERPROFILE%\Documents\Visual Studio 2013\Visualizers or 
 create a symbolic link so they update automatically.
+  For later versions of Visual Studio, no installation is required.
+Note also that later versions of Visual Studio also display better visualizations.
 
   
   Testing
Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -1,361 +0,0 @@
-
-
-http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
-
-  
-
-{(clang::Type::TypeClass)TypeBits.TC, en}Type
-
-{*(clang::BuiltinType *)this}
-{*(clang::PointerType *)this}
-{*(clang::LValueReferenceType *)this}
-{*(clang::RValueReferenceType *)this}
-{*(clang::AttributedType *)this}
-{*(clang::TemplateTypeParmType *)this}
-{*(clang::SubstTemplateTypeParmType *)this}
-{*(clang::RecordType *)this}
-{*(clang::RecordType *)this,view(cpp)}
-{*(clang::FunctionProtoType *)this}
-{*this,view(poly)}
-{*this,view(cmn)}" 
-{*this,view(cmn)}  {{{*this,view(poly)}}}
-
-  (clang::Type::TypeClass)TypeBits.TC
-  TypeBits
-  CanonicalType
-  *(clang::BuiltinType *)this
-  *(clang::PointerType *)this
-  *(clang::LValueReferenceType *)this
-  *(clang::RValueReferenceType *)this
-  *(clang::AttributedType *)this
-  (clang::TemplateTypeParmType *)this
-  (clang::SubstTemplateTypeParmType *)this
-  (clang::RecordType *)this
-  (clang::FunctionProtoType *)this
-
-  
-  
-{PointeeType, view(poly)} *
-
-  *(clang::Type *)this, view(cmn)
-  PointeeType
-
-  
-  
-  
-{((clang::ReferenceType *)this)->PointeeType,view(cpp)} &
-
-  *(clang::Type *)this, view(cmn)
-  PointeeType
-
-  
-  
-{((clang::ReferenceType *)this)->PointeeType,view(cpp)} &&
-
-  *(clang::Type *)this, view(cmn)
-  PointeeType
-
-  
-  
-{ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
-  
-  
-  
-  
-{(clang::Decl::Kind)DeclKind,en}Decl
-
-  (clang::Decl::Kind)DeclKind,en
-  
-
-
-  
-FirstDecl
-(clang::Decl *)(NextInContextAndBits.Value & ~3)
-*this
-  
-
-  
-
-  
-  
-Field {{{*(clang::DeclaratorDecl *)this,view(cpp)nd}}}
-  
-  
-{*(clang::FunctionDecl *)this,nd}
-Method {{{*this,view(cpp)}}}
-  
-  
-Constructor {{{Name,view(cpp)}({*(clang::FunctionDecl *)this,view(parm0)nd})}}
-  
-  
-Destructor {{~{Name,view(cpp)}()}}
-  
-  
-{Name,view(cpp)}
-{Name}
-  
-  
-implicit{" ",sb}
-
-{*this,view(implicit)}
-{*this,view(modifiers)}{Name,view(cpp)}
-{*this,view(modifiers)}struct {Name,view(cpp)}
-{*this,view(modifiers)}interface {Name,view(cpp)}
-{*this,view(modifiers)}union {Name,view(cpp)}
-{*this,view(modifiers)}class {Name,view(cpp)}
-{*this,view(modifiers)}enum {Name,view(cpp)}
-
-  (clang::DeclContext *)this
-
-  
-  
-{*decl,view(cpp)}
-{*decl}
-
-  *(clang::Type *)this, view(cmn)
-  decl
-
-  
-  
-{*(clang::TagType *)this,view(cpp)}
-{*(clang::TagType *)this}
-
-  *(clang::TagType *)this
-
-  
-  
-{*Replaced,view(cpp)} <= {CanonicalType,view(cpp)}
-
-  *(clang::Type *)this, view(cmn)
-  *Replaced
-
-  
-  
-  
-{ResultType,view(cpp)}
-
-{*(clang::QualType *)(this+1),view(cpp)}{*this,view(parm1)}
-
-, {*((clang::QualType *)(this+1)+1),view(cpp)}{*this,view(parm2)}
-
-, {*((clang::QualType *)(this+1)+2),view(cpp)}{*this,view(parm3)}
-
-, {*((clang::QualType *)(this+1)+3),view(cpp)}{*this,view(parm4)}
-
-, {*((clang::QualType *)(this+1)+4),view(cpp)}{*this,view(parm5)}
-
-, /* expand for more params */
-{*this,view(retType)}({*this,view(parm0)})
-
-  ResultType
-  
-{*this,view(parm0)}
-
-  
-NumParams
-(clang::QualType *)(this+1)
-  
-
-  
-  *(clang::Type *)this, view(cm

Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

`utils/llvm.natvis` is a duplicate of `utils/LLVMVisualizers/llvm.natvis`?

Otherwise, assuming everything builds correctly, LGTM.

Once again, thanks for doing this!


http://reviews.llvm.org/D18497



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D18498#384274, @zturner wrote:

> Ahh that's surprising. If it works even with the none tag, i guess my
>  concerns are not valid


I'm only partly surprised... It's not the first time that a Microsoft product 
behaves surprisingly :)


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

Assuming everything builds correctly, LGTM.

Your CMake is better than mine, so I'm not sure if there're better ways to do 
this ;)



Comment at: utils/ClangVisualizers/CMakeLists.txt:2
@@ +1,3 @@
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)

Obsessive nit: Use a period after the "want", like `want.`


Comment at: utils/ClangVisualizers/clang.natvis:9
@@ -8,2 +8,3 @@
+For later versions of Visual Studio, no setup is required-->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 

Is it just me, or is this a dead link?


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus added a comment.

In http://reviews.llvm.org/D18497#384351, @ariccio wrote:

> `utils/llvm.natvis` is a duplicate of `utils/LLVMVisualizers/llvm.natvis`?


The file was moved to a more appropriate directory (Otherwise, the project 
files were stepping on each other).
`svn mv utils/llvm.natvis utils/LLVMVisualizers/llvm.natvis`

> Otherwise, assuming everything builds correctly, LGTM.


There are a lot scenarios. What do all of these files in the build tree like 
`cmake_install.cmake`, `install.vcxproj`, `Package.vcxproj`? How do I test them?

> Once again, thanks for doing this!


You're welcome. Thanks for all your help. I am in India right now with a 
limited environment. I will likely due some more testing when I get home and 
check in at the end of the week.


http://reviews.llvm.org/D18497



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus marked an inline comment as done.


Comment at: utils/ClangVisualizers/CMakeLists.txt:2
@@ +1,3 @@
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)

ariccio wrote:
> Obsessive nit: Use a period after the "want", like `want.`
Will do. Note that unfortunately, the CMakeLists.txt files are already 
inconsistent on that score...


Comment at: utils/ClangVisualizers/clang.natvis:9
@@ -8,2 +8,3 @@
+For later versions of Visual Studio, no setup is required-->
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 

ariccio wrote:
> Is it just me, or is this a dead link?
It's not a link, it's an XML namespace. The idea is that you use a URL that you 
control as a namespace identifier to avoid collisions.


http://reviews.llvm.org/D18498



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus marked an inline comment as done.
mspertus added a comment.

http://reviews.llvm.org/D18498



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


Re: [PATCH] D18498: Auto-install Clang Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51762.
mspertus added a comment.

Incorporating ariccio's comments and fixing some html


http://reviews.llvm.org/D18498

Files:
  CMakeLists.txt
  utils/ClangVisualizers/CMakeLists.txt
  utils/ClangVisualizers/clang.natvis
  utils/clang.natvis
  www/hacking.html

Index: www/hacking.html
===
--- www/hacking.html
+++ www/hacking.html
@@ -98,14 +98,16 @@
   
 
   The files 
-http://llvm.org/svn/llvm-project/llvm/trunk/utils/llvm.natvis";>
-  utils/llvm.natvis and 
-http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis";>
-  utils/clang.natvis provide debugger visualizers 
+http://llvm.org/svn/llvm-project/llvm/trunk/utils/LLVMVisualizers/llvm.natvis";>
+  utils/LLVMVisualizers/llvm.natvis and 
+http://llvm.org/svn/llvm-project/cfe/trunk/utils/ClangVisualizers/clang.natvis";>
+  utils/ClangVisualizers/clang.natvis provide debugger visualizers 
   that make debugging of more complex data types much easier.
-  Put the files into 
-%USERPROFILE%\Documents\Visual Studio 2012\Visualizers or 
+  For Visual Studio 2013 only, put the files into 
+%USERPROFILE%\Documents\Visual Studio 2013\Visualizers or 
 create a symbolic link so they update automatically.
+  For later versions of Visual Studio, no installation is required.
+Note also that later versions of Visual Studio also display better visualizations.
 
   
   Testing
Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -1,361 +0,0 @@
-
-
-http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
-
-  
-
-{(clang::Type::TypeClass)TypeBits.TC, en}Type
-
-{*(clang::BuiltinType *)this}
-{*(clang::PointerType *)this}
-{*(clang::LValueReferenceType *)this}
-{*(clang::RValueReferenceType *)this}
-{*(clang::AttributedType *)this}
-{*(clang::TemplateTypeParmType *)this}
-{*(clang::SubstTemplateTypeParmType *)this}
-{*(clang::RecordType *)this}
-{*(clang::RecordType *)this,view(cpp)}
-{*(clang::FunctionProtoType *)this}
-{*this,view(poly)}
-{*this,view(cmn)}" 
-{*this,view(cmn)}  {{{*this,view(poly)}}}
-
-  (clang::Type::TypeClass)TypeBits.TC
-  TypeBits
-  CanonicalType
-  *(clang::BuiltinType *)this
-  *(clang::PointerType *)this
-  *(clang::LValueReferenceType *)this
-  *(clang::RValueReferenceType *)this
-  *(clang::AttributedType *)this
-  (clang::TemplateTypeParmType *)this
-  (clang::SubstTemplateTypeParmType *)this
-  (clang::RecordType *)this
-  (clang::FunctionProtoType *)this
-
-  
-  
-{PointeeType, view(poly)} *
-
-  *(clang::Type *)this, view(cmn)
-  PointeeType
-
-  
-  
-  
-{((clang::ReferenceType *)this)->PointeeType,view(cpp)} &
-
-  *(clang::Type *)this, view(cmn)
-  PointeeType
-
-  
-  
-{((clang::ReferenceType *)this)->PointeeType,view(cpp)} &&
-
-  *(clang::Type *)this, view(cmn)
-  PointeeType
-
-  
-  
-{ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
-  
-  
-  
-  
-{(clang::Decl::Kind)DeclKind,en}Decl
-
-  (clang::Decl::Kind)DeclKind,en
-  
-
-
-  
-FirstDecl
-(clang::Decl *)(NextInContextAndBits.Value & ~3)
-*this
-  
-
-  
-
-  
-  
-Field {{{*(clang::DeclaratorDecl *)this,view(cpp)nd}}}
-  
-  
-{*(clang::FunctionDecl *)this,nd}
-Method {{{*this,view(cpp)}}}
-  
-  
-Constructor {{{Name,view(cpp)}({*(clang::FunctionDecl *)this,view(parm0)nd})}}
-  
-  
-Destructor {{~{Name,view(cpp)}()}}
-  
-  
-{Name,view(cpp)}
-{Name}
-  
-  
-implicit{" ",sb}
-
-{*this,view(implicit)}
-{*this,view(modifiers)}{Name,view(cpp)}
-{*this,view(modifiers)}struct {Name,view(cpp)}
-{*this,view(modifiers)}interface {Name,view(cpp)}
-{*this,view(modifiers)}union {Name,view(cpp)}
-{*this,view(modifiers)}class {Name,view(cpp)}
-{*this,view(modifiers)}enum {Name,view(cpp)}
-
-  (clang::DeclContext *)this
-
-  
-  
-{*decl,view(cpp)}
-{*decl}
-
-  *(clang::Type *)this, view(cmn)
-  decl
-
-  
-  
-{*(clang::TagType *)this,view(cpp)}
-{*(clang::TagType *)this}
-
-  *(clang::TagType *)this
-
-  
-  
-{*Replaced,view(cpp)} <= {CanonicalType,view(cpp)}
-
-  *(clang::Type *)this, view(cmn)
-  *Replaced
-
-  
-  
-  
-{ResultType,view(cpp)}
-
-{*(clang::QualType *)(this+1),view(cpp)}{*this,view(parm1)}
-
-, {*((clang::QualType *)(this+1)+1),view(cpp)}{*this,view(parm2)}
-
-, {*((clang::QualType *)(this+1)+2),view(cpp)}{*this,view(parm3)}
-
-, {*((clang::QualType *)(this+1)+3),view(cpp)}{*this,view(parm4)}
-
-, {*((clang::QualTy

Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 51764.
mspertus added a comment.

Adding missing period in comment!


http://reviews.llvm.org/D18497

Files:
  CMakeLists.txt
  utils/LLVMVisualizers/CMakeLists.txt
  utils/LLVMVisualizers/llvm.natvis
  utils/llvm.natvis

Index: utils/llvm.natvis
===
--- utils/llvm.natvis
+++ utils/llvm.natvis
@@ -1,169 +0,0 @@
-
-
-http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
-
-  
-empty
-{{ size={($T1*)EndX - ($T1*)BeginX} }}
-
-  ($T1*)EndX - ($T1*)BeginX
-  ($T1*)CapacityX - ($T1*)BeginX
-  
-($T1*)EndX - ($T1*)BeginX
-($T1*)BeginX
-  
-
-  
-
-  
-{BeginX,s}
-BeginX,s
-
-  (char*)EndX - (char*)BeginX
-  (char*)CapacityX - (char*)BeginX
-  
-(char*)EndX - (char*)BeginX
-(char*)BeginX
-  
-
-  
-
-  
-{Data,[Length]s}
-Data,[Length]s
-
-  Length
-  
-Length
-Data
-  
-
-  
-
-  
-{IntMask}: {($T1)(Value & PointerBitMask)} [{($T3)((Value >> IntShift) & IntMask)}]
-
-  ($T1)(Value & PointerBitMask)
-  ($T3)((Value >> IntShift) & IntMask)
-
-  
-
-  
-{"$T1", s8b}: {($T1)(Val.Value & Val.PointerBitMask)}
-{"$T2", s8b}: {($T2)(Val.Value & Val.PointerBitMask)}
-
-  ($T1)(Val.Value & Val.PointerBitMask)
-  ($T2)(Val.Value & Val.PointerBitMask)
-
-  
-
-  
-{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
-
-  ($T1)((Val.Val.Value >> 2) << 2)
-  ($T2)((Val.Val.Value >> 2) << 2)
-  ($T3)((Val.Val.Value >> 2) << 2)
-
-  
-
-  
-{"$T1", s8b}: {($T1)((Val.Val.Value >> 2) << 2)}
-{"$T2", s8b}: {($T2)((Val.Val.Value >> 2) << 2)}
-{"$T3", s8b}: {($T3)((Val.Val.Value >> 2) << 2)}
-{"$T4", s8b}: {($T4)((Val.Val.Value >> 2) << 2)}
-
-  ($T1)((Val.Val.Value >> 2) << 2)
-  ($T2)((Val.Val.Value >> 2) << 2)
-  ($T3)((Val.Val.Value >> 2) << 2)
-  ($T4)((Val.Val.Value >> 2) << 2)
-
-  
-
-  
-{{ empty }}
-{{ head={Head} }}
-
-  
-Head
-Next
-this
-  
-
-  
-
-  
-empty
-RefPtr [1 ref] {*Obj}
-RefPtr [{Obj->ref_cnt} refs] {*Obj}
-
-  Obj->ref_cnt
-  Obj
-
-  
-
-  
-{{ [Small Mode] size={NumElements}, capacity={CurArraySize} }}
-{{ [Big Mode] size={NumElements}, capacity={CurArraySize} }}
-
-  NumElements
-  CurArraySize
-  
-CurArraySize
-($T1*)CurArray
-  
-
-  
-
-  
-empty
-{{ size={NumEntries}, buckets={NumBuckets} }}
-
-  NumEntries
-  NumBuckets
-  
-NumBuckets
-Buckets
-  
-
-  
-
-  
-{{ size={NumItems}, buckets={NumBuckets} }}
-
-  NumItems
-  NumBuckets
-  
-NumBuckets
-(MapEntryTy**)TheTable
-  
-
-  
-
-  
-empty
-({this+1,s}, {second})
-
-  this+1,s
-  second
-
-  
-
-  
-{Data}
-  
-  
-  
-empty
-{*(($T1 *)(unsigned char *)storage.buffer)}
-
-  *(($T1 *)(unsigned char *)storage.buffer)
-
-  
-
Index: utils/LLVMVisualizers/llvm.natvis
===
--- utils/LLVMVisualizers/llvm.natvis
+++ utils/LLVMVisualizers/llvm.natvis
@@ -1,9 +1,11 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
 
Index: utils/LLVMVisualizers/CMakeLists.txt
===
--- utils/LLVMVisualizers/CMakeLists.txt
+++ utils/LLVMVisualizers/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Do this by hand instead of using add_llvm_utilities(), which
+# tries to create a corresponding executable, which we don't want.
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
+  set(LLVM_VISUALIZERS llvm.natvis)
+  add_custom_target(LLVMVisualizers SOURCES ${LLVM_VISUALIZERS})
+  set_target_properties(LLVMVisualizers PROPERTIES FOLDER "Utils")
+endif()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -398,6 +398,12 @@
   set(LLVM_USE_HOST_TOOLS ON)
 endif()
 
+if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900))
+  option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
+else()
+  set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)
+endif()
+
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on
 # first cmake run
@@ -664,6 +670,11 @@
   endif()
 endif()
 
+# Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util
+if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTIO

Re: [PATCH] D18497: Auto-install LLVM Visual Studio visualizers for VS2015 and up

2016-03-27 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D18497#384362, @mspertus wrote:

> In http://reviews.llvm.org/D18497#384351, @ariccio wrote:
>
> > Otherwise, assuming everything builds correctly, LGTM.
>
>
> There are a lot scenarios. What do all of these files in the build tree like 
> `cmake_install.cmake`, `install.vcxproj`, `Package.vcxproj`? How do I test 
> them?


Do you have a clean copy of the tree? Maybe do something like the equivalent of 
`make clean` 
?
 Then try to regenerate everything?

> > Once again, thanks for doing this!

> 

> 

> You're welcome. Thanks for all your help. I am in India right now with a 
> limited environment. I will likely due some more testing when I get home and 
> check in at the end of the week.


Well that's certainly more exotic than me! I'm impressed. I assume you have a 
laptop, and you're not doing this on your smartphone.


http://reviews.llvm.org/D18497



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


r264562 - Fix serialization/deserialization for __uuidof

2016-03-27 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sun Mar 27 22:19:50 2016
New Revision: 264562

URL: http://llvm.org/viewvc/llvm-project?rev=264562&view=rev
Log:
Fix serialization/deserialization for __uuidof

I broke this back in r264529 because I forgot to serialize the UuidAttr
member.  Fix this by replacing the UuidAttr with a StringRef which is
properly serialized and deserialized.

Added:
cfe/trunk/test/PCH/uuidof.cpp
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=264562&r1=264561&r2=264562&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sun Mar 27 22:19:50 2016
@@ -778,23 +778,23 @@ public:
 class CXXUuidofExpr : public Expr {
 private:
   llvm::PointerUnion Operand;
-  const UuidAttr *UA;
+  StringRef UuidStr;
   SourceRange Range;
 
 public:
-  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, const UuidAttr *UA,
+  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, StringRef UuidStr,
 SourceRange R)
   : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
  Operand->getType()->isDependentType(),
  Operand->getType()->isInstantiationDependentType(),
  Operand->getType()->containsUnexpandedParameterPack()),
-Operand(Operand), UA(UA), Range(R) {}
+Operand(Operand), UuidStr(UuidStr), Range(R) {}
 
-  CXXUuidofExpr(QualType Ty, Expr *Operand, const UuidAttr *UA, SourceRange R)
+  CXXUuidofExpr(QualType Ty, Expr *Operand, StringRef UuidStr, SourceRange R)
   : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
  Operand->isTypeDependent(), Operand->isInstantiationDependent(),
  Operand->containsUnexpandedParameterPack()),
-Operand(Operand), UA(UA), Range(R) {}
+Operand(Operand), UuidStr(UuidStr), Range(R) {}
 
   CXXUuidofExpr(EmptyShell Empty, bool isExpr)
 : Expr(CXXUuidofExprClass, Empty) {
@@ -831,7 +831,8 @@ public:
 Operand = E;
   }
 
-  StringRef getUuidAsStringRef() const;
+  void setUuidStr(StringRef US) { UuidStr = US; }
+  StringRef getUuidStr() const { return UuidStr; }
 
   SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
   SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=264562&r1=264561&r2=264562&view=diff
==
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Sun Mar 27 22:19:50 2016
@@ -54,10 +54,6 @@ QualType CXXUuidofExpr::getTypeOperand(A
   Operand.get()->getType().getNonReferenceType(), Quals);
 }
 
-StringRef CXXUuidofExpr::getUuidAsStringRef() const {
-  return UA ? UA->getGuid() : "----";
-}
-
 // CXXScalarValueInitExpr
 SourceLocation CXXScalarValueInitExpr::getLocStart() const {
   return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc;

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=264562&r1=264561&r2=264562&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Sun Mar 27 22:19:50 2016
@@ -1186,7 +1186,7 @@ void MicrosoftCXXNameMangler::mangleExpr
 
 // This CXXUuidofExpr is mangled as-if it were actually a VarDecl from
 // const __s_GUID _GUID_{lower case UUID with underscores}
-StringRef Uuid = UE->getUuidAsStringRef();
+StringRef Uuid = UE->getUuidStr();
 std::string Name = "_GUID_" + Uuid.lower();
 std::replace(Name.begin(), Name.end(), '-', '_');
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=264562&r1=264561&r2=264562&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Mar 27 22:19:50 2016
@@ -1454,7 +1454,7 @@ ConstantAddress CodeGenModule::GetAddrOf
 const CXXUuidofExpr* E) {
   // Sema has verified that IIDSource has a __declspec(uuid()), and that its
   // well-formed.
-  StringRef Uuid = E->getUuidAsStringRef();
+  StringRef Uuid = E->getUuidStr();
   std::string Name = "_GUID_" + Uuid.lower();
   std::replace(Name.begin(), Name.end(), '

Re: r264529 - Improve the representation of CXXUuidofExpr

2016-03-27 Thread David Majnemer via cfe-commits
Good call, fixed in r264562.

On Sun, Mar 27, 2016 at 12:29 AM, Richard Smith 
wrote:

> On Sat, Mar 26, 2016 at 9:46 PM, David Majnemer via cfe-commits
>  wrote:
> > Author: majnemer
> > Date: Sat Mar 26 23:46:07 2016
> > New Revision: 264529
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=264529&view=rev
> > Log:
> > Improve the representation of CXXUuidofExpr
> >
> > Keep a pointer to the UuidAttr that the CXXUuidofExpr corresponds to.
> > This makes translating from __uuidof to the underlying constant a lot
> > more straightforward.
> >
> > Modified:
> > cfe/trunk/include/clang/AST/ExprCXX.h
> > cfe/trunk/lib/AST/ExprCXX.cpp
> > cfe/trunk/lib/AST/MicrosoftMangle.cpp
> > cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> > cfe/trunk/lib/Sema/SemaExprCXX.cpp
> >
> > Modified: cfe/trunk/include/clang/AST/ExprCXX.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=264529&r1=264528&r2=264529&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/AST/ExprCXX.h (original)
> > +++ cfe/trunk/include/clang/AST/ExprCXX.h Sat Mar 26 23:46:07 2016
> > @@ -778,22 +778,23 @@ public:
> >  class CXXUuidofExpr : public Expr {
> >  private:
> >llvm::PointerUnion Operand;
> > +  const UuidAttr *UA;
> >SourceRange Range;
>
> Looks like the serialization / deserialization code for this new
> member is missing? Does this correctly round-trip through AST files?
>
> >  public:
> > -  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R)
> > -: Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
> > -   false, Operand->getType()->isDependentType(),
> > -   Operand->getType()->isInstantiationDependentType(),
> > -   Operand->getType()->containsUnexpandedParameterPack()),
> > -  Operand(Operand), Range(R) { }
> > -
> > -  CXXUuidofExpr(QualType Ty, Expr *Operand, SourceRange R)
> > -: Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary,
> > -   false, Operand->isTypeDependent(),
> > -   Operand->isInstantiationDependent(),
> > -   Operand->containsUnexpandedParameterPack()),
> > -  Operand(Operand), Range(R) { }
> > +  CXXUuidofExpr(QualType Ty, TypeSourceInfo *Operand, const UuidAttr
> *UA,
> > +SourceRange R)
> > +  : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
> > + Operand->getType()->isDependentType(),
> > + Operand->getType()->isInstantiationDependentType(),
> > + Operand->getType()->containsUnexpandedParameterPack()),
> > +Operand(Operand), UA(UA), Range(R) {}
> > +
> > +  CXXUuidofExpr(QualType Ty, Expr *Operand, const UuidAttr *UA,
> SourceRange R)
> > +  : Expr(CXXUuidofExprClass, Ty, VK_LValue, OK_Ordinary, false,
> > + Operand->isTypeDependent(),
> Operand->isInstantiationDependent(),
> > + Operand->containsUnexpandedParameterPack()),
> > +Operand(Operand), UA(UA), Range(R) {}
> >
> >CXXUuidofExpr(EmptyShell Empty, bool isExpr)
> >  : Expr(CXXUuidofExprClass, Empty) {
> > @@ -830,7 +831,7 @@ public:
> >  Operand = E;
> >}
> >
> > -  StringRef getUuidAsStringRef(ASTContext &Context) const;
> > +  StringRef getUuidAsStringRef() const;
> >
> >SourceLocation getLocStart() const LLVM_READONLY { return
> Range.getBegin(); }
> >SourceLocation getLocEnd() const LLVM_READONLY { return
> Range.getEnd(); }
> > @@ -841,11 +842,6 @@ public:
> >  return T->getStmtClass() == CXXUuidofExprClass;
> >}
> >
> > -  /// Grabs __declspec(uuid()) off a type, or returns 0 if we cannot
> resolve to
> > -  /// a single GUID.
> > -  static const UuidAttr *GetUuidAttrOfType(QualType QT,
> > -   bool *HasMultipleGUIDsPtr =
> nullptr);
> > -
> >// Iterators
> >child_range children() {
> >  if (isTypeOperand())
> >
> > Modified: cfe/trunk/lib/AST/ExprCXX.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=264529&r1=264528&r2=264529&view=diff
> >
> ==
> > --- cfe/trunk/lib/AST/ExprCXX.cpp (original)
> > +++ cfe/trunk/lib/AST/ExprCXX.cpp Sat Mar 26 23:46:07 2016
> > @@ -54,77 +54,8 @@ QualType CXXUuidofExpr::getTypeOperand(A
> >Operand.get()->getType().getNonReferenceType(),
> Quals);
> >  }
> >
> > -// static
> > -const UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT,
> > - bool
> *RDHasMultipleGUIDsPtr) {
> > -  // Optionally remove one level of pointer, reference or array
> indirection.
> > -  const Type *Ty = QT.getTypePtr();
> > -  if (QT->isPointerType() || QT->isReferenceType())
> > -Ty = QT->getPointeeType().getTypePtr();
> > -  else if (QT->isArrayType())
> > -Ty = Ty->getBaseElementTypeUnsafe();
> > -
> > -  const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();

[clang-tools-extra] r264563 - clang-tidy: Fix broken buildbot

2016-03-27 Thread Richard Thomson via cfe-commits
Author: legalize
Date: Sun Mar 27 23:15:41 2016
New Revision: 264563

URL: http://llvm.org/viewvc/llvm-project?rev=264563&view=rev
Log:
clang-tidy: Fix broken buildbot

VS 2013 does not support char16_t or char32_t

Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp?rev=264563&r1=264562&r2=264563&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp 
Sun Mar 27 23:15:41 2016
@@ -46,10 +46,12 @@ char const *const TrailingNewLine("A sin
 char const *const AlreadyRaw(R"(foobie\\bletch)");
 char const *const UTF8Literal(u8"foobie\\bletch");
 char const *const UTF8RawLiteral(u8R"(foobie\\bletch)");
-char16_t const *const UTF16Literal(u"foobie\\bletch");
-char16_t const *const UTF16RawLiteral(uR"(foobie\\bletch)");
-char32_t const *const UTF32Literal(U"foobie\\bletch");
-char32_t const *const UTF32RawLiteral(UR"(foobie\\bletch)");
+// TODO: enable these tests once all supported compilers
+// support char16_t and char32_t (VS2013 does not)
+// char16_t const *const UTF16Literal(u"foobie\\bletch");
+// char16_t const *const UTF16RawLiteral(uR"(foobie\\bletch)");
+// char32_t const *const UTF32Literal(U"foobie\\bletch");
+// char32_t const *const UTF32RawLiteral(UR"(foobie\\bletch)");
 wchar_t const *const WideLiteral(L"foobie\\bletch");
 wchar_t const *const WideRawLiteral(LR"(foobie\\bletch)");
 


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


[PATCH] D18509: clang-tidy: add_new_check.py stubs out release notes

2016-03-27 Thread Richard via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: alexfh.
LegalizeAdulthood added a subscriber: cfe-commits.

Update `add_new_check.py` to stub out information in the release notes for the 
new check.

http://reviews.llvm.org/D18509

Files:
  clang-tidy/add_new_check.py

Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -261,6 +261,38 @@
 """ % {"check_name_dashes" : check_name_dashes,
"underline" : "=" * len(check_name_dashes)})
 
+
+# Adds the new check to the release notes for clang-tidy
+def adapt_release_notes(module_path, module, check_name):
+  check_name_dashes = module + '-' + check_name
+  filename = os.path.normpath(
+os.path.join(module_path, '../../docs/ReleaseNotes.rst'))
+  print('Updating %s...' % filename)
+  with open(filename, 'r') as release_notes:
+lines = release_notes.readlines()
+  with open(filename, 'w') as release_notes:
+clang_tidy_found = False
+clang_tidy_heading_found = False
+bullet_found = False
+
+for line in lines:
+  if not clang_tidy_found:
+if line.startswith("Improvements to ``clang-tidy``"):
+  clang_tidy_found = True
+  elif not clang_tidy_heading_found:
+if line.startswith('^^'):
+  clang_tidy_heading_found = True
+  elif not bullet_found:
+if line.startswith('- '):
+  bullet_found = True
+  release_notes.write('- New ``' + check_name_dashes + '`` check\n')
+  release_notes.write('\n')
+  release_notes.write('  FIXME: summarize the check\n')
+  release_notes.write('\n')
+  release_notes.write(line)
+  pass
+
+
 def main():
   if len(sys.argv) == 2 and sys.argv[1] == '--update-docs':
 update_checks_list(os.path.dirname(sys.argv[0]))
@@ -289,6 +321,7 @@
   adapt_module(module_path, module, check_name, check_name_camel)
   write_test(module_path, module, check_name)
   write_docs(module_path, module, check_name)
+  adapt_release_notes(module_path, module, check_name)
   update_checks_list(clang_tidy_path)
   print('Done. Now it\'s your turn!')
 


Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -261,6 +261,38 @@
 """ % {"check_name_dashes" : check_name_dashes,
"underline" : "=" * len(check_name_dashes)})
 
+
+# Adds the new check to the release notes for clang-tidy
+def adapt_release_notes(module_path, module, check_name):
+  check_name_dashes = module + '-' + check_name
+  filename = os.path.normpath(
+os.path.join(module_path, '../../docs/ReleaseNotes.rst'))
+  print('Updating %s...' % filename)
+  with open(filename, 'r') as release_notes:
+lines = release_notes.readlines()
+  with open(filename, 'w') as release_notes:
+clang_tidy_found = False
+clang_tidy_heading_found = False
+bullet_found = False
+
+for line in lines:
+  if not clang_tidy_found:
+if line.startswith("Improvements to ``clang-tidy``"):
+  clang_tidy_found = True
+  elif not clang_tidy_heading_found:
+if line.startswith('^^'):
+  clang_tidy_heading_found = True
+  elif not bullet_found:
+if line.startswith('- '):
+  bullet_found = True
+  release_notes.write('- New ``' + check_name_dashes + '`` check\n')
+  release_notes.write('\n')
+  release_notes.write('  FIXME: summarize the check\n')
+  release_notes.write('\n')
+  release_notes.write(line)
+  pass
+
+
 def main():
   if len(sys.argv) == 2 and sys.argv[1] == '--update-docs':
 update_checks_list(os.path.dirname(sys.argv[0]))
@@ -289,6 +321,7 @@
   adapt_module(module_path, module, check_name, check_name_camel)
   write_test(module_path, module, check_name)
   write_docs(module_path, module, check_name)
+  adapt_release_notes(module_path, module, check_name)
   update_checks_list(clang_tidy_path)
   print('Done. Now it\'s your turn!')
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18510: [cxx1z-constexpr-lambda] Make conversion function constexpr

2016-03-27 Thread Faisal Vali via cfe-commits
faisalv created this revision.
faisalv added a reviewer: rsmith.
faisalv added a subscriber: cfe-commits.

Mark the lambda's conversion to function-pointer as incontrovertibly constexpr. 

auto L = [](auto a) { return a; };
constexpr int* (*fp)(int*) = L; // This is now allowed.

By itself this is not terribly useful.  A subsequent patch will enable a call 
through the function pointer in a constant expression if the lambda's 
synthesized call operator is constexpr.

The more interesting/controversial aspect of the patch (and the part I really 
need feedback on) is emission of a warning if this is called in pre-c++1z 
constant expressions, and making sure such warnings are ignored when 
determining if the constant expression evaluation succeeded. Look forward to 
your feedback...







http://reviews.llvm.org/D18510

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/DiagnosticASTKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Decl.cpp
  lib/AST/ExprConstant.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Index: test/SemaCXX/cxx1z-constexpr-lambdas.cpp
===
--- test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -2,7 +2,9 @@
 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s 
 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fms-extensions %s 
 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s 
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -Wc++14-compat %s -DCHECK_COMPATIBILITY_WARNING
 
+#ifndef CHECK_COMPATIBILITY_WARNING
 namespace test_constexpr_checking {
 
 namespace ns1 {
@@ -33,4 +35,17 @@
   L(3); //expected-note{{non-constexpr function}}
 } 
 
-} // end ns test_constexpr_call
\ No newline at end of file
+} // end ns test_constexpr_call
+#endif
+
+#ifdef CHECK_COMPATIBILITY_WARNING
+//expected-warning@+6{{incompatible with C++ standards before C++1z}}
+//expected-warning@+6{{incompatible with C++ standards before C++1z}}
+#endif
+
+namespace ns4 {
+auto L = [](auto a) { return a; };
+constexpr int (*fp1)(int) = L;  
+constexpr int* (*fp2)(int*) = L; 
+
+} // end ns4
\ No newline at end of file
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1263,7 +1263,7 @@
 ConvTy, 
 ConvTSI,
 /*isInline=*/true, /*isExplicit=*/false,
-/*isConstexpr=*/false, 
+/*isConstexpr=*/true, 
 CallOperator->getBody()->getLocEnd());
   Conversion->setAccess(AS_public);
   Conversion->setImplicit(true);
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -1256,11 +1256,11 @@
   if (!Expr::isPotentialConstantExpr(Dcl, Diags)) {
 Diag(Dcl->getLocation(), diag::ext_constexpr_function_never_constant_expr)
   << isa(Dcl);
-for (size_t I = 0, N = Diags.size(); I != N; ++I)
-  Diag(Diags[I].first, Diags[I].second);
 // Don't return false here: we allow this for compatibility in
 // system headers.
   }
+  for (size_t I = 0, N = Diags.size(); I != N; ++I)
+  Diag(Diags[I].first, Diags[I].second);
 
   return true;
 }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -819,13 +819,18 @@
 return;
 
   SmallVector Diags;
-  if (!Cond->isValueDependent() &&
-  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(D),
-Diags)) {
-S.Diag(Attr.getLoc(), diag::err_enable_if_never_constant_expr);
-for (int I = 0, N = Diags.size(); I != N; ++I)
-  S.Diag(Diags[I].first, Diags[I].second);
-return;
+  if (!Cond->isValueDependent()) {
+if (!Expr::isPotentialConstantExprUnevaluated(Cond, cast(D),
+  Diags)) {
+  S.Diag(Attr.getLoc(), diag::err_enable_if_never_constant_expr);
+  for (int I = 0, N = Diags.size(); I != N; ++I)
+S.Diag(Diags[I].first, Diags[I].second);
+  return;
+} else {
+  // Emit any warnings.
+  for (int I = 0, N = Diags.size(); I != N; ++I)
+S.Diag(Diags[I].first, Diags[I].second);
+}
   }
 
   D->addAttr(::new (S.Context)
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10258,9 +10258,10 @@
 }
 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
   <

r264564 - P0138R2: Allow direct-list-initialization of an enumeration from an integral

2016-03-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar 28 01:08:37 2016
New Revision: 264564

URL: http://llvm.org/viewvc/llvm-project?rev=264564&view=rev
Log:
P0138R2: Allow direct-list-initialization of an enumeration from an integral
value that can convert to the enum's underlying type.

Added:
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
  - copied, changed from r264563, 
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
Removed:
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=264564&r1=264563&r2=264564&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Mar 28 01:08:37 2016
@@ -3862,8 +3862,48 @@ static void TryListInitialization(Sema &
   }
 
   if (S.getLangOpts().CPlusPlus && !DestType->isAggregateType() &&
-  InitList->getNumInits() == 1 &&
-  InitList->getInit(0)->getType()->isRecordType()) {
+  InitList->getNumInits() == 1) {
+Expr *E = InitList->getInit(0);
+
+//   - Otherwise, if T is an enumeration with a fixed underlying type,
+// the initializer-list has a single element v, and the initialization
+// is direct-list-initialization, the object is initialized with the
+// value T(v); if a narrowing conversion is required to convert v to
+// the underlying type of T, the program is ill-formed.
+auto *ET = DestType->getAs();
+if (S.getLangOpts().CPlusPlus1z &&
+Kind.getKind() == InitializationKind::IK_DirectList &&
+ET && ET->getDecl()->isFixed() &&
+!S.Context.hasSameUnqualifiedType(E->getType(), DestType) &&
+(E->getType()->isIntegralOrEnumerationType() ||
+ E->getType()->isFloatingType())) {
+  // There are two ways that T(v) can work when T is an enumeration type.
+  // If there is either an implicit conversion sequence from v to T or
+  // a conversion function that can convert from v to T, then we use that.
+  // Otherwise, if v is of integral, enumeration, or floating-point type,
+  // it is converted to the enumeration type via its underlying type.
+  // There is no overlap possible between these two cases (except when the
+  // source value is already of the destination type), and the first
+  // case is handled by the general case for single-element lists below.
+  ImplicitConversionSequence ICS;
+  ICS.setStandard();
+  ICS.Standard.setAsIdentityConversion();
+  // If E is of a floating-point type, then the conversion is ill-formed
+  // due to narrowing, but go through the motions in order to produce the
+  // right diagnostic.
+  ICS.Standard.Second = E->getType()->isFloatingType()
+? ICK_Floating_Integral
+: ICK_Integral_Conversion;
+  ICS.Standard.setFromType(E->getType());
+  ICS.Standard.setToType(0, E->getType());
+  ICS.Standard.setToType(1, DestType);
+  ICS.Standard.setToType(2, DestType);
+  Sequence.AddConversionSequenceStep(ICS, ICS.Standard.getToType(2),
+ /*TopLevelOfInitList*/true);
+  Sequence.RewrapReferenceInitList(Entity.getType(), InitList);
+  return;
+}
+
 //   - Otherwise, if the initializer list has a single element of type E
 // [...references are handled above...], the object or reference is
 // initialized from that element (by copy-initialization for
@@ -3877,19 +3917,21 @@ static void TryListInitialization(Sema &
 // copy-initialization. This only matters if we might use an 'explicit'
 // conversion operator, so we only need to handle the cases where the 
source
 // is of record type.
-InitializationKind SubKind =
-Kind.getKind() == InitializationKind::IK_DirectList
-? InitializationKind::CreateDirect(Kind.getLocation(),
-   InitList->getLBraceLoc(),
-   InitList->getRBraceLoc())
-: Kind;
-Expr *SubInit[1] = { InitList->getInit(0) };
-Sequence.InitializeFrom(S, Entity, SubKind, SubInit,
-/*TopLevelOfInitList*/true,
-TreatUnavailableAsInvalid);
-if (Sequence)
-  Sequence.RewrapReferenceInitList(Entity.getType(), InitList);
-return;
+if (InitList->getInit(0)->getType()->isRecordType()) {
+  InitializationKind SubKind =
+  Kind.getKind() == InitializationKind::IK_DirectList
+  ? InitializationKind::CreateDirect(Kind.getLocation(),
+ InitList->getLBraceLoc(),
+  

Re: [PATCH] D17438: [OpenCL] Add Sema checks for atomics and implicit declaration

2016-03-27 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

Hi Anastasia,
https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15603
Now we got clarify from khronos. I will continue on this patch.
BTW, https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15599 is also fixed in 
the same revision. 
Thanks
Xiuli


http://reviews.llvm.org/D17438



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