[PATCH] D41495: [clangd] Skip function bodies when building the preamble

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Those are some impressive numbers!
Excited to see this land, thanks for tracking down all the weird problems.




Comment at: clangd/ClangdUnit.cpp:536
+  // so we set SkipFunctionBodies back to false after preamble is built.
+  assert(!CI->getFrontendOpts().SkipFunctionBodies);
+  CI->getFrontendOpts().SkipFunctionBodies = true;

Nit: I think the comment/assert focus too much on the 'what' at the expense of 
the 'why' - just the first sentence here is probably enough (without the second 
and without the assert).

And below, something like:
// For the main file, we do want the AST and diagnostics for function 
bodies. 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41495



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


[PATCH] D41433: Unit tests for TBAA metadata generation.

2017-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Interesting.  Okay, LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D41433



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


[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

2017-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Type.h:1152
+NTFK_Struct,  // non-trivial C struct.
+NTFK_Array// array that has non-trivial elements.
+  };

ahatanak wrote:
> rjmccall wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > We don't actually distinguish arrays in DestructionKind.  Is it 
> > > > important here?  You can't actually do anything with that information.
> > > > 
> > > > Regarding your naming question, I wonder if it would be useful to just 
> > > > invent a new term here, something meaning "non-trivial" but without the 
> > > > C++ baggage.  Maybe just "PrimitiveCopyKind", with the understanding 
> > > > that C++ can never do a "primitive" copy?  And for consistency with 
> > > > DestructionKind, maybe you should lowercase the second words.
> > > > 
> > > > I'm not sure how isNonTrivialToCopy is supposed to be used.  Where does 
> > > > the function come from?  And why is a context required when it isn't 
> > > > required for isDestructedType?
> > > Enum NonTrivialCopyKind and isNonTrivialToCopy() are used just to 
> > > distinguish the different types of fields in a C struct. Currently, there 
> > > are four types that are handled by visitField functions in 
> > > CGNonTrivialStruct.cpp:
> > > 
> > > - struct field
> > > - array field
> > > - __strong field
> > > - trivial field that can be copied using memcpy
> > > 
> > > I thought using enums would make the code easier to read, but of course 
> > > it's possible to remove them and instead just check the field types 
> > > calling functions like getAsArrayType or getAs. ASTContext is 
> > > passed to isNonTrivialToCopy so that it can call 
> > > ASTContext::getAsArrayType to determine whether the type is an array. 
> > > Maybe there is another way to detect an array that doesn't require 
> > > ASTContext?
> > > 
> > > As for the naming, PrimitiveCopyKind seems find if we want to distinguish 
> > > it from C++ non-trivial classes (I don't have a better name). If we are 
> > > going to call non-trivial C structs primitiveCopyKind, what should we 
> > > call the C structs that are trivial (those that can be copied using 
> > > memcpy)?
> > I think "trivial" is a reasonable kind of primitive-copy semantics.  
> > Basically, we're saying that all complete object types other than 
> > non-trivial C++ types have some sort of primitive-copy semantics, and this 
> > enum tells us what those semantics are.
> > 
> > DestructionKind has to deal with arrays as well, but it does so by just 
> > reporting the appropriate value for the underlying element type without 
> > mentioning that it's specifically an *array* of the type.  I think that's a 
> > reasonable design, since most places do not need to distinguish arrays from 
> > non-arrays.  IRGen does, but only when you're actually finally emitting 
> > code; prior to that (when e.g. deciding that a field is non-trivial to 
> > copy) you can just use the enum value.
> > 
> > You can do without getAsArrayType the same way that isDestructedType() 
> > does: the more complex operation is only necessary in order to preserve 
> > qualifiers on the element type, but that's unnecessary for this operation 
> > because the array type itself is considered to have the same qualifiers as 
> > its element type.  That is, you can ask the original type whether it's 
> > __strong/__weak-qualified without having to specifically handle array 
> > types, and once you've done all of those queries, you can use the "unsafe" 
> > operations to drill down to the element type because you no longer care 
> > about qualification.
> So QualType::hasNonTrivialToDefaultInitializeStruct should be renamed to 
> QualType::hasPrimitiveDefaultInitializeStruct and 
> RecordDecl::isNonTrivialToPrimitiveDefaultInitialize to 
> RecordDecl::isPrimitiveDefaultInitialize, for example?
> 
> Also, I realized that, after I made the changes that removed the NonTrivial 
> flags from RecordDecl, CGNonTrivialStruct.cpp is the only user of enum 
> NonTrivialCopyKind and the following methods of QualType 
> (Sema::isValidVarArgType calls nonTrivialToDestroy, but it should call 
> methods like hasNonTrivialToDestroyStruct that detect non-trivial C structs 
> instead):
> 
> nonTrivialToDefaultInitialize
> nonTrivialToCopy
> nonTrivialToDestructiveMove
> nonTrivialToDestroy
> 
> Maybe we should make these enums and functions local to 
> CGNonTrivialStruct.cpp to avoid adding something that is not used outside 
> CGNonTrivialStruct.cpp?
I think the right name would be isNonTrivialToPrimitiveDefaultInitialize(), and 
like isDestructedType() it would return an enum that happens to have a zero 
value (and is thus false) for the trivial case.

I think we are likely to add more places that use these methods and enums.  For 
example, if we want to add a diagnostic that warns about memcpy'ing non-trivial 
struct types, that diagnostic should probably include a note about which field 
is 

[PATCH] D41326: [clang-tidy] Added diagnostics about incorrect usage of NOLINT comment

2017-12-21 Thread Anton via Phabricator via cfe-commits
xgsa added a comment.

Ping.


https://reviews.llvm.org/D41326



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


[PATCH] D41536: Provide public getter for OverlayFileSystem

2017-12-21 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun created this revision.
vladimir.plyashkun added a reviewer: alexfh.
vladimir.plyashkun added projects: clang, clang-tools-extra.
Herald added subscribers: cfe-commits, klimek.

This is part of review - https://reviews.llvm.org/D41535


Repository:
  rC Clang

https://reviews.llvm.org/D41536

Files:
  include/clang/Tooling/Tooling.h


Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -339,6 +339,10 @@
 
   llvm::ArrayRef getSourcePaths() const { return SourcePaths; }
 
+  vfs::OverlayFileSystem () const {
+return *OverlayFileSystem;
+  }
+
 private:
   const CompilationDatabase 
   std::vector SourcePaths;


Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -339,6 +339,10 @@
 
   llvm::ArrayRef getSourcePaths() const { return SourcePaths; }
 
+  vfs::OverlayFileSystem () const {
+return *OverlayFileSystem;
+  }
+
 private:
   const CompilationDatabase 
   std::vector SourcePaths;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41535: Add -vfsoverlay option for Clang-Tidy

2017-12-21 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

Second part of review - https://reviews.llvm.org/D41536


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41535



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


r321346 - Fix unused variable warning in SemaTemplate. NFC

2017-12-21 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Dec 21 23:09:51 2017
New Revision: 321346

URL: http://llvm.org/viewvc/llvm-project?rev=321346=rev
Log:
Fix unused variable warning in SemaTemplate. NFC

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=321346=321345=321346=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Dec 21 23:09:51 2017
@@ -950,7 +950,7 @@ Decl *Sema::ActOnNonTypeTemplateParamete
 if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified)
   EmitDiag(DS.getStorageClassSpecLoc());
 
-if (DeclSpec::TSCS TSCS = DS.getThreadStorageClassSpec())
+if (DS.getThreadStorageClassSpec() != TSCS_unspecified)
   EmitDiag(DS.getThreadStorageClassSpecLoc());
 
 // [dcl.inline]p1: 


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


[PATCH] D41535: Add -vfsoverlay option for Clang-Tidy

2017-12-21 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun created this revision.
vladimir.plyashkun added reviewers: alexfh, benlangmuir.
vladimir.plyashkun added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

These changes introduce support for -vfsoverlay option in Clang-Tidy
The main reason for it:
In IDE integration we have two different pieces of source: editor and physical 
file.
File is placed in some project directory (let's call it "A")
We want to run clang-tidy exactly in this project directory "A",  in order to 
get all .clang-tidy files in parent directories along with correct resolution 
for all relative include paths.
But in IDE, saving mechanism perfoms periodically.
So, to perform analysis of actual text on the fly, we need to save document on 
every modification  (which is inefficient) or generate file in the temporary 
directory with actual text (it also leads to skipping .clang-tidy files and 
complicates include search paths resolution)
-vfsoverlay approach allows us to analyze source file in the project directory 
"A" but with actual data placed in another directory.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41535

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp

Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -209,6 +209,12 @@
cl::init(false),
cl::cat(ClangTidyCategory));
 
+static cl::opt VfsOverlay("vfsoverlay", cl::desc(R"(
+Overlay the virtual filesystem described by file over the real file system.
+)"),
+   cl::value_desc("filename"),
+   cl::cat(ClangTidyCategory));
+
 namespace clang {
 namespace tidy {
 
@@ -295,6 +301,7 @@
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
   DefaultOptions.FormatStyle = FormatStyle;
   DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
+  DefaultOptions.VfsOverlay = VfsOverlay;
   // USERNAME is used on Windows.
   if (!DefaultOptions.User)
 DefaultOptions.User = llvm::sys::Process::GetEnv("USERNAME");
@@ -312,6 +319,8 @@
 OverrideOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
   if (FormatStyle.getNumOccurrences() > 0)
 OverrideOptions.FormatStyle = FormatStyle;
+  if (VfsOverlay.getNumOccurrences() > 0)
+OverrideOptions.VfsOverlay = VfsOverlay;
 
   if (!Config.empty()) {
 if (llvm::ErrorOr ParsedConfig =
@@ -331,7 +340,16 @@
 }
 
 static int clangTidyMain(int argc, const char **argv) {
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
+  llvm::SpecificBumpPtrAllocator ArgAllocator;
+  SmallVector Argv;
+  std::error_code EC = llvm::sys::Process::GetArgumentVector(
+  Argv, llvm::makeArrayRef(argv, argc), ArgAllocator);
+  if (EC) {
+llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
+return 1;
+  }
+
+  CommonOptionsParser OptionsParser(argc, [0], ClangTidyCategory,
 cl::ZeroOrMore);
 
   auto OwningOptionsProvider = createOptionsProvider();
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -108,6 +108,8 @@
 
   /// \brief Add extra compilation arguments to the start of the list.
   llvm::Optional ExtraArgsBefore;
+
+  llvm::Optional VfsOverlay;
 };
 
 /// \brief Abstract interface for retrieving various ClangTidy options.
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -92,6 +92,7 @@
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
 IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
+IO.mapOptional("VfsOverlay", Options.VfsOverlay);
   }
 };
 
@@ -152,6 +153,7 @@
   overrideValue(Result.User, Other.User);
   mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
   mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
+  overrideValue(Result.VfsOverlay, Other.VfsOverlay);
 
   for (const auto  : Other.CheckOptions)
 Result.CheckOptions[KeyValue.first] = KeyValue.second;
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -87,17 +87,41 @@
   ClangTidyContext 
 };
 
+void pushVfsOverlayFromFile(StringRef OverlayFile,
+vfs::OverlayFileSystem ) {
+  if (OverlayFile.empty())
+return;
+
+  llvm::ErrorOr Buffer =
+  OverlayFS.getBufferForFile(OverlayFile);
+  if (!Buffer) {
+return;
+  }
+
+  IntrusiveRefCntPtr FS = vfs::getVFSFromYAML(
+  std::move(Buffer.get()), 

[PATCH] D41514: [Index] Reduce size of SymbolInfo struct.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 127986.
sammccall added a comment.

Avoid repeating uint8_t type for SymbolProperty/SymbolPropertySet.


Repository:
  rC Clang

https://reviews.llvm.org/D41514

Files:
  include/clang/Index/IndexSymbol.h
  lib/Index/IndexSymbol.cpp
  tools/libclang/CXIndexDataConsumer.cpp

Index: tools/libclang/CXIndexDataConsumer.cpp
===
--- tools/libclang/CXIndexDataConsumer.cpp
+++ tools/libclang/CXIndexDataConsumer.cpp
@@ -1304,11 +1304,11 @@
 
 static CXIdxEntityCXXTemplateKind
 getEntityKindFromSymbolProperties(SymbolPropertySet K) {
-  if (K & (unsigned)SymbolProperty::TemplatePartialSpecialization)
+  if (K & (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization)
 return CXIdxEntity_TemplatePartialSpecialization;
-  if (K & (unsigned)SymbolProperty::TemplateSpecialization)
+  if (K & (SymbolPropertySet)SymbolProperty::TemplateSpecialization)
 return CXIdxEntity_TemplateSpecialization;
-  if (K & (unsigned)SymbolProperty::Generic)
+  if (K & (SymbolPropertySet)SymbolProperty::Generic)
 return CXIdxEntity_Template;
   return CXIdxEntity_NonTemplate;
 }
Index: lib/Index/IndexSymbol.cpp
===
--- lib/Index/IndexSymbol.cpp
+++ lib/Index/IndexSymbol.cpp
@@ -42,10 +42,10 @@
 
 static void checkForIBOutlets(const Decl *D, SymbolPropertySet ) {
   if (D->hasAttr()) {
-PropSet |= (unsigned)SymbolProperty::IBAnnotated;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
   } else if (D->hasAttr()) {
-PropSet |= (unsigned)SymbolProperty::IBAnnotated;
-PropSet |= (unsigned)SymbolProperty::IBOutletCollection;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBOutletCollection;
   }
 }
 
@@ -93,7 +93,7 @@
   Info.Lang = SymbolLanguage::C;
 
   if (isFunctionLocalSymbol(D)) {
-Info.Properties |= (unsigned)SymbolProperty::Local;
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Local;
   }
 
   if (const TagDecl *TD = dyn_cast(D)) {
@@ -118,17 +118,19 @@
   if (!CXXRec->isCLike()) {
 Info.Lang = SymbolLanguage::CXX;
 if (CXXRec->getDescribedClassTemplate()) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
 }
   }
 }
 
 if (isa(D)) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
 } else if (isa(D)) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
 }
 
   } else if (auto *VD = dyn_cast(D)) {
@@ -142,15 +144,17 @@
 
 if (isa(D)) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
 } else if (isa(D)) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
 } else if (VD->getDescribedVarTemplate()) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
 }
 
   } else {
@@ -181,7 +185,7 @@
   if (!ClsD)
 ClsD = cast(D)->getClassInterface();
   if (isUnitTestCase(ClsD))
-Info.Properties |= (unsigned)SymbolProperty::UnitTest;
+Info.Properties |= (SymbolPropertySet)SymbolProperty::UnitTest;
   break;
 }
 case Decl::ObjCProtocol:
@@ -198,7 +202,7 @@
   else
 ClsD = cast(D)->getClassInterface();
   if (isUnitTestCase(ClsD))
-Info.Properties |= (unsigned)SymbolProperty::UnitTest;
+Info.Properties |= (SymbolPropertySet)SymbolProperty::UnitTest;
   break;
 }
 case Decl::ObjCMethod: {
@@ -212,18 +216,18 @@
   }
   Info.Lang = SymbolLanguage::ObjC;
   if (isUnitTest(MD))
-Info.Properties |= (unsigned)SymbolProperty::UnitTest;
+Info.Properties |= 

[PATCH] D41534: Don't add empty InstalledDir as a candidate GCC location

2017-12-21 Thread Jack Andersen via Phabricator via cfe-commits
jackoalan created this revision.
jackoalan added a reviewer: cfe-commits.

I maintain a couple build tools based on Clang's Tooling framework. The tools 
are built and used directly out of the CMake binary directory (i.e. not 
installed in a meaningful way).

This non-installed setup causes issues when finding the GCC Toolchain and using 
the resulting system include paths. A normally-installed `clang -v` outputs the 
following:

  clang version 5.0.1 (tags/RELEASE_501/final)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /usr/bin
  Found candidate GCC installation: 
/usr/bin/../lib/gcc/x86_64-pc-linux-gnu/7.2.1
  Found candidate GCC installation: 
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1
  Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1
  Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/7.2.1
  Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1
  Candidate multilib: .;@m64
  Candidate multilib: 32;@m32
  Selected multilib: .;@m64

But my build-tree tool outputs this:

  clang version 5.0.1 (tags/RELEASE_501/final)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: 
  Found candidate GCC installation: /../lib/gcc/x86_64-pc-linux-gnu/7.2.1
  Found candidate GCC installation: /../lib64/gcc/x86_64-pc-linux-gnu/7.2.1
  Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1
  Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/7.2.1
  Selected GCC installation: /../lib64/gcc/x86_64-pc-linux-gnu/7.2.1

InstalledDir is empty, which is fine, but the resulting candidate selection is 
undesirable. The `/usr` rooted candidate strikes me as a much more stable 
option. Granted `/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1` works, but on a 
rather hackish technicality where `/../ == /` and symlink exists at `/lib64`.

This creates problems with dependency files consumed by Ninja (which is unable 
to canonicalize paths that feature a mix of `..` and multi-level symlinks as 
explained in https://reviews.llvm.org/D37954). For example: 
`/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/cstdlib` 
which ninja "canonicalizes" as `/../include/c++/7.2.1/cstdlib`, but is actually 
`/usr/include/c++/7.2.1/cstdlib` when taking symlinks into account.

If clang were to use the `/usr/lib64/gcc/x86_64-pc-linux-gnu/7.2.1` candidate 
instead, the result would be 
`/usr/lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/cstdlib`
 which Ninja can correctly canonicalize to `/usr/include/c++/7.2.1/cstdlib`.

I'm not trying to force clang to produce canonical paths as output; rather 
avoid the obviously problematic `/../` candidate in the first place.


Repository:
  rC Clang

https://reviews.llvm.org/D41534

Files:
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1617,7 +1617,8 @@
 }
 
 // Then look for gcc installed alongside clang.
-Prefixes.push_back(D.InstalledDir + "/..");
+if (!D.InstalledDir.empty())
+  Prefixes.push_back(D.InstalledDir + "/..");
 
 // Then look for distribution supplied gcc installations.
 if (D.SysRoot.empty()) {


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1617,7 +1617,8 @@
 }
 
 // Then look for gcc installed alongside clang.
-Prefixes.push_back(D.InstalledDir + "/..");
+if (!D.InstalledDir.empty())
+  Prefixes.push_back(D.InstalledDir + "/..");
 
 // Then look for distribution supplied gcc installations.
 if (D.SysRoot.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321343 - [X86] Add missing check lines for the silvermont cases in predefined-arch-macros.c test.

2017-12-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Dec 21 21:09:38 2017
New Revision: 321343

URL: http://llvm.org/viewvc/llvm-project?rev=321343=rev
Log:
[X86] Add missing check lines for the silvermont cases in 
predefined-arch-macros.c test.

Modified:
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=321343=321342=321343=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Thu Dec 21 21:09:38 
2017
@@ -1234,7 +1234,11 @@
 // RUN: %clang -march=slm -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SLM_M32
+// CHECK_SLM_M32: #define __AES__ 1
+// CHECK_SLM_M32: #define __FXSR__ 1
 // CHECK_SLM_M32: #define __MMX__ 1
+// CHECK_SLM_M32: #define __PCLMUL__ 1
+// CHECK_SLM_M32: #define __POPCNT__ 1
 // CHECK_SLM_M32: #define __PRFCHW__ 1
 // CHECK_SLM_M32: #define __SSE2__ 1
 // CHECK_SLM_M32: #define __SSE3__ 1
@@ -1251,7 +1255,11 @@
 // RUN: %clang -march=slm -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SLM_M64
+// CHECK_SLM_M64: #define __AES__ 1
+// CHECK_SLM_M64: #define __FXSR__ 1
 // CHECK_SLM_M64: #define __MMX__ 1
+// CHECK_SLM_M64: #define __PCLMUL__ 1
+// CHECK_SLM_M64: #define __POPCNT__ 1
 // CHECK_SLM_M64: #define __PRFCHW__ 1
 // CHECK_SLM_M64: #define __SSE2_MATH__ 1
 // CHECK_SLM_M64: #define __SSE2__ 1


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


r321342 - [Modules] Map missing private submodules from Foo.Private to Foo_Private

2017-12-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec 21 21:04:43 2017
New Revision: 321342

URL: http://llvm.org/viewvc/llvm-project?rev=321342=rev
Log:
[Modules] Map missing private submodules from Foo.Private to Foo_Private

In case `@import Foo.Private` fails because the submodule doesn't exist,
look for `Foo_Private` (if available) and build/load that module
instead. In that process emit a warning and tell the user about the
assumption.

The intention here is to assist all existing private modules owners
(in ObjC and Swift) to migrate to the new `Foo_Private` syntax.

rdar://problem/36023940

Added:
cfe/trunk/test/Modules/implicit-map-dot-private.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=321342=321341=321342=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Dec 21 
21:04:43 2017
@@ -198,6 +198,11 @@ def err_missing_module : Error<
 def err_no_submodule : Error<"no submodule named %0 in module '%1'">;
 def err_no_submodule_suggest : Error<
   "no submodule named %0 in module '%1'; did you mean '%2'?">;
+def warn_no_priv_submodule_use_toplevel : Warning<
+  "no submodule named %0 in module '%1'; using top level '%2'">,
+  InGroup;
+def note_private_top_level_defined : Note<
+  "module defined here">;
 def warn_missing_submodule : Warning<"missing submodule '%0'">,
   InGroup;
 def note_module_import_here : Note<"module imported here">;

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=321342=321341=321342=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Dec 21 21:04:43 2017
@@ -1854,6 +1854,7 @@ CompilerInstance::loadModule(SourceLocat
 
   // Verify that the rest of the module path actually corresponds to
   // a submodule.
+  bool MapPrivateSubModToTopLevel = false;
   if (!getLangOpts().ModulesTS && Path.size() > 1) {
 for (unsigned I = 1, N = Path.size(); I != N; ++I) {
   StringRef Name = Path[I].first->getName();
@@ -1892,7 +1893,40 @@ CompilerInstance::loadModule(SourceLocat
   Sub = Module->findSubmodule(Best[0]);
 }
   }
-  
+
+  // If the user is requesting Foo.Private and it doesn't exist, try to
+  // match Foo_Private and emit a warning asking for the user to write
+  // @import Foo_Private instead. FIXME: remove this when existing clients
+  // migrate off of Foo.Private syntax.
+  if (!Sub && PP->getLangOpts().ImplicitModules && Name == "Private" &&
+  Module == Module->getTopLevelModule()) {
+SmallString<128> PrivateModule(Module->Name);
+PrivateModule.append("_Private");
+
+SmallVector PrivPath;
+auto  = PP->getIdentifierTable().get(
+PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
+PrivPath.push_back(std::make_pair(, Path[0].second));
+
+if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
+  Sub =
+  loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
+if (Sub) {
+  MapPrivateSubModToTopLevel = true;
+  if (!getDiagnostics().isIgnored(
+  diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
+getDiagnostics().Report(Path[I].second,
+diag::warn_no_priv_submodule_use_toplevel)
+<< Path[I].first << Module->getFullModuleName() << 
PrivateModule
+<< SourceRange(Path[0].second, Path[I].second)
+<< FixItHint::CreateReplacement(SourceRange(Path[0].second),
+PrivateModule);
+getDiagnostics().Report(Sub->DefinitionLoc,
+diag::note_private_top_level_defined);
+  }
+}
+  }
+
   if (!Sub) {
 // No submodule by this name. Complain, and don't look for further
 // submodules.
@@ -1909,7 +1943,7 @@ CompilerInstance::loadModule(SourceLocat
   // Make the named module visible, if it's not already part of the module
   // we are parsing.
   if (ModuleName != getLangOpts().CurrentModule) {
-if (!Module->IsFromModuleFile) {
+if (!Module->IsFromModuleFile && !MapPrivateSubModToTopLevel) {
   // We have an umbrella header or directory that doesn't actually include
   // all of the headers within the directory it covers. Complain about
   // this missing submodule and recover by forgetting that we 

r321341 - [X86] Add 'prfchw' to the correct CPUs to match the backend.

2017-12-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Dec 21 20:51:00 2017
New Revision: 321341

URL: http://llvm.org/viewvc/llvm-project?rev=321341=rev
Log:
[X86] Add 'prfchw' to the correct CPUs to match the backend.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=321341=321340=321341=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Thu Dec 21 20:51:00 2017
@@ -159,6 +159,7 @@ bool X86TargetInfo::initFeatureMap(
   case CK_Broadwell:
 setFeatureEnabledImpl(Features, "rdseed", true);
 setFeatureEnabledImpl(Features, "adx", true);
+setFeatureEnabledImpl(Features, "prfchw", true);
 LLVM_FALLTHROUGH;
   case CK_Haswell:
 setFeatureEnabledImpl(Features, "avx2", true);
@@ -224,6 +225,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "aes", true);
 setFeatureEnabledImpl(Features, "pclmul", true);
 setFeatureEnabledImpl(Features, "sse4.2", true);
+setFeatureEnabledImpl(Features, "prfchw", true);
 LLVM_FALLTHROUGH;
   case CK_Bonnell:
 setFeatureEnabledImpl(Features, "movbe", true);
@@ -241,6 +243,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "avx512cd", true);
 setFeatureEnabledImpl(Features, "avx512er", true);
 setFeatureEnabledImpl(Features, "avx512pf", true);
+setFeatureEnabledImpl(Features, "prfchw", true);
 setFeatureEnabledImpl(Features, "prefetchwt1", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "rdseed", true);

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=321341=321340=321341=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Thu Dec 21 20:51:00 
2017
@@ -589,6 +589,7 @@
 // CHECK_BROADWELL_M32: #define __MMX__ 1
 // CHECK_BROADWELL_M32: #define __PCLMUL__ 1
 // CHECK_BROADWELL_M32: #define __POPCNT__ 1
+// CHECK_BROADWELL_M32: #define __PRFCHW__ 1
 // CHECK_BROADWELL_M32: #define __RDRND__ 1
 // CHECK_BROADWELL_M32: #define __RDSEED__ 1
 // CHECK_BROADWELL_M32: #define __SSE2__ 1
@@ -620,6 +621,7 @@
 // CHECK_BROADWELL_M64: #define __MMX__ 1
 // CHECK_BROADWELL_M64: #define __PCLMUL__ 1
 // CHECK_BROADWELL_M64: #define __POPCNT__ 1
+// CHECK_BROADWELL_M64: #define __PRFCHW__ 1
 // CHECK_BROADWELL_M64: #define __RDRND__ 1
 // CHECK_BROADWELL_M64: #define __RDSEED__ 1
 // CHECK_BROADWELL_M64: #define __SSE2_MATH__ 1
@@ -657,6 +659,7 @@
 // CHECK_SKL_M32: #define __MPX__ 1
 // CHECK_SKL_M32: #define __PCLMUL__ 1
 // CHECK_SKL_M32: #define __POPCNT__ 1
+// CHECK_SKL_M32: #define __PRFCHW__ 1
 // CHECK_SKL_M32: #define __RDRND__ 1
 // CHECK_SKL_M32: #define __RDSEED__ 1
 // CHECK_SKL_M32: #define __RTM__ 1
@@ -690,6 +693,7 @@
 // CHECK_SKL_M64: #define __MPX__ 1
 // CHECK_SKL_M64: #define __PCLMUL__ 1
 // CHECK_SKL_M64: #define __POPCNT__ 1
+// CHECK_SKL_M64: #define __PRFCHW__ 1
 // CHECK_SKL_M64: #define __RDRND__ 1
 // CHECK_SKL_M64: #define __RDSEED__ 1
 // CHECK_SKL_M64: #define __RTM__ 1
@@ -730,6 +734,7 @@
 // CHECK_KNL_M32: #define __PCLMUL__ 1
 // CHECK_KNL_M32: #define __POPCNT__ 1
 // CHECK_KNL_M32: #define __PREFETCHWT1__ 1
+// CHECK_KNL_M32: #define __PRFCHW__ 1
 // CHECK_KNL_M32: #define __RDRND__ 1
 // CHECK_KNL_M32: #define __RTM__ 1
 // CHECK_KNL_M32: #define __SSE2__ 1
@@ -766,6 +771,7 @@
 // CHECK_KNL_M64: #define __PCLMUL__ 1
 // CHECK_KNL_M64: #define __POPCNT__ 1
 // CHECK_KNL_M64: #define __PREFETCHWT1__ 1
+// CHECK_KNL_M64: #define __PRFCHW__ 1
 // CHECK_KNL_M64: #define __RDRND__ 1
 // CHECK_KNL_M64: #define __RTM__ 1
 // CHECK_KNL_M64: #define __SSE2_MATH__ 1
@@ -806,6 +812,7 @@
 // CHECK_KNM_M32: #define __PCLMUL__ 1
 // CHECK_KNM_M32: #define __POPCNT__ 1
 // CHECK_KNM_M32: #define __PREFETCHWT1__ 1
+// CHECK_KNM_M32: #define __PRFCHW__ 1
 // CHECK_KNM_M32: #define __RDRND__ 1
 // CHECK_KNM_M32: #define __RTM__ 1
 // CHECK_KNM_M32: #define __SSE2__ 1
@@ -840,6 +847,7 @@
 // CHECK_KNM_M64: #define __PCLMUL__ 1
 // CHECK_KNM_M64: #define __POPCNT__ 1
 // CHECK_KNM_M64: #define __PREFETCHWT1__ 1
+// CHECK_KNM_M64: #define __PRFCHW__ 1
 // CHECK_KNM_M64: #define __RDRND__ 1
 // CHECK_KNM_M64: #define __RTM__ 1
 // CHECK_KNM_M64: #define __SSE2_MATH__ 1
@@ -879,6 +887,7 @@
 // CHECK_SKX_M32: #define __MPX__ 1
 // CHECK_SKX_M32: #define __PCLMUL__ 1
 // CHECK_SKX_M32: #define __POPCNT__ 1
+// CHECK_SKX_M32: #define __PRFCHW__ 1
 // CHECK_SKX_M32: #define __RDRND__ 1
 // CHECK_SKX_M32: #define __RTM__ 1
 // CHECK_SKX_M32: #define __SGX__ 1
@@ -921,6 +930,7 @@
 // 

[PATCH] D40705: Diagnose invalid decl-specifiers in non-type template parameter declarations (original author miyuki!)

2017-12-21 Thread Faisal Vali via Phabricator via cfe-commits
faisalv closed this revision.
faisalv added a comment.

Added via https://reviews.llvm.org/rC321339


Repository:
  rC Clang

https://reviews.llvm.org/D40705



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


r321339 - Diagnose the various invalid decl-specifiers on nontype template parameters.

2017-12-21 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Thu Dec 21 19:50:55 2017
New Revision: 321339

URL: http://llvm.org/viewvc/llvm-project?rev=321339=rev
Log:
Diagnose the various invalid decl-specifiers on nontype template parameters.

The standard correctly forbids various decl-specifiers that dont make sense on 
non-type template parameters - such as the extern in:
template struct X;

This patch implements those restrictions (in a fashion similar to the 
corresponding checks on function parameters within ActOnParamDeclarator).

Credit goes to miyuki (Mikhail Maltsev) for drawing attention to this issue,  
authoring the initial versions of this patch, and supporting the effort to 
re-engineer it slightly.  Thank you!

For details of how this patch evolved please see: 
https://reviews.llvm.org/D40705



Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/temp/temp.param/p2.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=321339=321338=321339=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 21 19:50:55 
2017
@@ -3911,6 +3911,9 @@ def err_template_param_different_kind :
   "%select{|template parameter }0redeclaration">;
 def note_template_param_different_kind : Note<
   "template parameter has a different kind in template argument">;
+
+def err_invalid_decl_specifier_in_nontype_parm : Error<
+  "invalid declaration specifier in template non-type parameter">;
   
 def err_template_nontype_parm_different_type : Error<
   "template non-type parameter has a different type %0 in template "

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=321339=321338=321339=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Dec 21 19:50:55 2017
@@ -929,6 +929,60 @@ Decl *Sema::ActOnNonTypeTemplateParamete
   Expr *Default) {
   TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S);
 
+  // Check that we have valid decl-specifiers specified.
+  auto CheckValidDeclSpecifiers = [this, ] {
+// C++ [temp.param]
+// p1 
+//   template-parameter:
+// ...
+// parameter-declaration
+// p2 
+//   ... A storage class shall not be specified in a template-parameter
+//   declaration.
+// [dcl.typedef]p1: 
+//   The typedef specifier [...] shall not be used in the 
decl-specifier-seq
+//   of a parameter-declaration
+const DeclSpec  = D.getDeclSpec();
+auto EmitDiag = [this](SourceLocation Loc) {
+  Diag(Loc, diag::err_invalid_decl_specifier_in_nontype_parm)
+  << FixItHint::CreateRemoval(Loc);
+};
+if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified)
+  EmitDiag(DS.getStorageClassSpecLoc());
+
+if (DeclSpec::TSCS TSCS = DS.getThreadStorageClassSpec())
+  EmitDiag(DS.getThreadStorageClassSpecLoc());
+
+// [dcl.inline]p1: 
+//   The inline specifier can be applied only to the declaration or 
+//   definition of a variable or function.
+
+if (DS.isInlineSpecified())
+  EmitDiag(DS.getInlineSpecLoc());
+
+// [dcl.constexpr]p1:
+//   The constexpr specifier shall be applied only to the definition of a 
+//   variable or variable template or the declaration of a function or 
+//   function template.
+
+if (DS.isConstexprSpecified())
+  EmitDiag(DS.getConstexprSpecLoc());
+
+// [dcl.fct.spec]p1:
+//   Function-specifiers can be used only in function declarations.
+
+if (DS.isVirtualSpecified())
+  EmitDiag(DS.getVirtualSpecLoc());
+
+if (DS.isExplicitSpecified())
+  EmitDiag(DS.getExplicitSpecLoc());
+
+if (DS.isNoreturnSpecified())
+  EmitDiag(DS.getNoreturnSpecLoc());
+  };
+
+  CheckValidDeclSpecifiers();
+  
   if (TInfo->getType()->isUndeducedType()) {
 Diag(D.getIdentifierLoc(),
  diag::warn_cxx14_compat_template_nontype_parm_auto_type)

Modified: cfe/trunk/test/CXX/temp/temp.param/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.param/p2.cpp?rev=321339=321338=321339=diff
==
--- cfe/trunk/test/CXX/temp/temp.param/p2.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.param/p2.cpp Thu Dec 21 19:50:55 2017
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DCPP11
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -DCPP17
 
 

[PATCH] D41507: avxintrin.h documentation fixes and updates

2017-12-21 Thread Katya Romanova via Phabricator via cfe-commits
kromanova added inline comments.



Comment at: lib/Headers/avxintrin.h:1668
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equal (ordered, signaling)
-///0x03 : Unordered (non-signaling)
-///0x04 : Not-equal (unordered, non-signaling)
-///0x05 : Not-less-than (unordered, signaling)
-///0x06 : Not-less-than-or-equal (unordered, signaling)
-///0x07 : Ordered (non-signaling)
-///0x08 : Equal (unordered, non-signaling)
-///0x09 : Not-greater-than-or-equal (unordered, signaling)
-///0x0a : Not-greater-than (unordered, signaling)
-///0x0b : False (ordered, non-signaling)
-///0x0c : Not-equal (ordered, non-signaling)
-///0x0d : Greater-than-or-equal (ordered, signaling)
-///0x0e : Greater-than (ordered, signaling)
-///0x0f : True (unordered, non-signaling)
-///0x10 : Equal (ordered, signaling)
-///0x11 : Less-than (ordered, non-signaling)
-///0x12 : Less-than-or-equal (ordered, non-signaling)
-///0x13 : Unordered (signaling)
-///0x14 : Not-equal (unordered, signaling)
-///0x15 : Not-less-than (unordered, non-signaling)
-///0x16 : Not-less-than-or-equal (unordered, non-signaling)
-///0x17 : Ordered (signaling)
-///0x18 : Equal (unordered, signaling)
-///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
-///0x1a : Not-greater-than (unordered, non-signaling)
-///0x1b : False (ordered, signaling)
-///0x1c : Not-equal (ordered, signaling)
-///0x1d : Greater-than-or-equal (ordered, non-signaling)
-///0x1e : Greater-than (ordered, non-signaling)
-///0x1f : True (unordered, signaling)
+///00h: Equal (ordered, non-signaling) \n
+///01h: Less-than (ordered, signaling) \n

lebedev.ri wrote:
> While i'm incompetent to actually review this, i have a question.
> //Why// replace code-friendly `0x00` with `00h`?
> And, //why// is this hex in the first place? Why not decimals?
> 
>> why is this hex in the first place? Why not decimals?
There are a few reasons that I could think of: 

(1) for consistency with the defines in the header file describing these values:
#define _CMP_EQ_OQ0x00 /* Equal (ordered, non-signaling)  */
#define _CMP_LT_OS0x01 /* Less-than (ordered, signaling)  */
#define _CMP_LE_OS0x02 /* Less-than-or-equal (ordered, signaling)  */
#define _CMP_UNORD_Q  0x03 /* Unordered (non-signaling)  */
#define _CMP_NEQ_UQ   0x04 /* Not-equal (unordered, non-signaling)  */

(2) This immediate is 5 bits, so when using hex, it's much easier to tell which 
bits are set/not set/
(3) For consistency with Intel's and AMD's documentation for intrinsics and 
corresponding instructions. 


I s developers prefer to have it in 0x format, this change it was done for 
consistency. 
AMD and Intel manuals use the 'h' suffix style



Comment at: lib/Headers/avxintrin.h:1668
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equal (ordered, signaling)
-///0x03 : Unordered (non-signaling)
-///0x04 : Not-equal (unordered, non-signaling)
-///0x05 : Not-less-than (unordered, signaling)
-///0x06 : Not-less-than-or-equal (unordered, signaling)
-///0x07 : Ordered (non-signaling)
-///0x08 : Equal (unordered, non-signaling)
-///0x09 : Not-greater-than-or-equal (unordered, signaling)
-///0x0a : Not-greater-than (unordered, signaling)
-///0x0b : False (ordered, non-signaling)
-///0x0c : Not-equal (ordered, non-signaling)
-///0x0d : Greater-than-or-equal (ordered, signaling)
-///0x0e : Greater-than (ordered, signaling)
-///0x0f : True (unordered, non-signaling)
-///0x10 : Equal (ordered, signaling)
-///0x11 : Less-than (ordered, non-signaling)
-///0x12 : Less-than-or-equal (ordered, non-signaling)
-///0x13 : Unordered (signaling)
-///0x14 : Not-equal (unordered, signaling)
-///0x15 : Not-less-than (unordered, non-signaling)
-///0x16 : Not-less-than-or-equal (unordered, non-signaling)
-///0x17 : Ordered (signaling)
-///0x18 : Equal (unordered, signaling)
-///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
-///0x1a : Not-greater-than (unordered, non-signaling)
-///0x1b : False (ordered, signaling)
-///0x1c : Not-equal (ordered, signaling)
-///0x1d : Greater-than-or-equal (ordered, non-signaling)
-///0x1e : Greater-than (ordered, non-signaling)
-///0x1f : True (unordered, signaling)
+///00h: Equal (ordered, non-signaling) \n
+///01h: Less-than (ordered, signaling) \n

kromanova wrote:
> lebedev.ri wrote:
> > While i'm incompetent to actually review this, i have a question.
> > //Why// replace code-friendly `0x00` with `00h`?
> > And, //why// is this hex in the first place? Why not decimals?
> > 
> >> why is this hex 

[PATCH] D41526: [libclang] Avoid builtin trap for __debug parser_crash pragma

2017-12-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman abandoned this revision.
arphaman added a comment.

It turns out there's already something that works much better: `#pragma clang 
__debug handle_crash`. Sorry about the redundant patch!


Repository:
  rC Clang

https://reviews.llvm.org/D41526



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


[PATCH] D41528: [Sema] Don't emit the -Wstrict-prototypes warning for variadic functions.

2017-12-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you


https://reviews.llvm.org/D41528



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


[PATCH] D41528: [Sema] Don't emit the -Wstrict-prototypes warning for variadic functions.

2017-12-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: arphaman, ahatanak.

rdar://problem/33251668


https://reviews.llvm.org/D41528

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/warn-strict-prototypes.c


Index: clang/test/Sema/warn-strict-prototypes.c
===
--- clang/test/Sema/warn-strict-prototypes.c
+++ clang/test/Sema/warn-strict-prototypes.c
@@ -65,3 +65,9 @@
 void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style 
function definition is not preceded by a prototype}}
   short d;
 {}
+
+// No warnings for variadic functions. Overloadable attribute is required
+// to avoid err_ellipsis_first_param error.
+// rdar://problem/33251668
+void foo13(...) __attribute__((overloadable));
+void foo13(...) __attribute__((overloadable)) {}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4762,7 +4762,7 @@
 break;
   case DeclaratorChunk::Function: {
 const DeclaratorChunk::FunctionTypeInfo  = DeclType.Fun;
-if (FTI.NumParams == 0)
+if (FTI.NumParams == 0 && !FTI.isVariadic)
   S.Diag(DeclType.Loc, diag::warn_strict_prototypes)
   << IsBlock
   << FixItHint::CreateInsertion(FTI.getRParenLoc(), "void");


Index: clang/test/Sema/warn-strict-prototypes.c
===
--- clang/test/Sema/warn-strict-prototypes.c
+++ clang/test/Sema/warn-strict-prototypes.c
@@ -65,3 +65,9 @@
 void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}}
   short d;
 {}
+
+// No warnings for variadic functions. Overloadable attribute is required
+// to avoid err_ellipsis_first_param error.
+// rdar://problem/33251668
+void foo13(...) __attribute__((overloadable));
+void foo13(...) __attribute__((overloadable)) {}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4762,7 +4762,7 @@
 break;
   case DeclaratorChunk::Function: {
 const DeclaratorChunk::FunctionTypeInfo  = DeclType.Fun;
-if (FTI.NumParams == 0)
+if (FTI.NumParams == 0 && !FTI.isVariadic)
   S.Diag(DeclType.Loc, diag::warn_strict_prototypes)
   << IsBlock
   << FixItHint::CreateInsertion(FTI.getRParenLoc(), "void");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41521: [CUDA] fixes for __shfl_* intrinsics.

2017-12-21 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321326: [CUDA] More fixes for __shfl_* intrinsics. (authored 
by tra, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41521?vs=127950=127962#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41521

Files:
  lib/Headers/__clang_cuda_intrinsics.h

Index: lib/Headers/__clang_cuda_intrinsics.h
===
--- lib/Headers/__clang_cuda_intrinsics.h
+++ lib/Headers/__clang_cuda_intrinsics.h
@@ -34,23 +34,24 @@
 #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
 #pragma push_macro("__MAKE_SHUFFLES")
-#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)\
-  inline __device__ int __FnName(int __val, int __offset,  \
+#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask,\
+__Type)\
+  inline __device__ int __FnName(int __val, __Type __offset,   \
  int __width = warpSize) { \
 return __IntIntrinsic(__val, __offset, \
   ((warpSize - __width) << 8) | (__Mask)); \
   }\
-  inline __device__ float __FnName(float __val, int __offset,  \
+  inline __device__ float __FnName(float __val, __Type __offset,   \
int __width = warpSize) {   \
 return __FloatIntrinsic(__val, __offset,   \
 ((warpSize - __width) << 8) | (__Mask));   \
   }\
-  inline __device__ unsigned int __FnName(unsigned int __val, int __offset,\
+  inline __device__ unsigned int __FnName(unsigned int __val, __Type __offset, \
   int __width = warpSize) {\
 return static_cast(  \
 ::__FnName(static_cast(__val), __offset, __width));   \
   }\
-  inline __device__ long long __FnName(long long __val, int __offset,  \
+  inline __device__ long long __FnName(long long __val, __Type __offset,   \
int __width = warpSize) {   \
 struct __Bits {\
   int __a, __b;\
@@ -65,12 +66,29 @@
 memcpy(&__ret, &__tmp, sizeof(__tmp)); \
 return __ret;  \
   }\
+  inline __device__ long __FnName(long __val, __Type __offset, \
+  int __width = warpSize) {\
+_Static_assert(sizeof(long) == sizeof(long long) ||\
+   sizeof(long) == sizeof(int));   \
+if (sizeof(long) == sizeof(long long)) {   \
+  return static_cast(\
+  ::__FnName(static_cast(__val), __offset, __width));   \
+} else if (sizeof(long) == sizeof(int)) {  \
+  return static_cast(\
+  ::__FnName(static_cast(__val), __offset, __width)); \
+}  \
+  }\
+  inline __device__ unsigned long __FnName(\
+  unsigned long __val, __Type __offset, int __width = warpSize) {  \
+return static_cast( \
+::__FnName(static_cast(__val), __offset, __width));  \
+  }\
   inline __device__ unsigned long long __FnName(   \
-  unsigned long long __val, int __offset, int __width = warpSize) {\
+  unsigned long long __val, __Type __offset, int __width = warpSize) { \
 return static_cast(::__FnName( \
 static_cast(__val), __offset, __width));   \
   }\
-  inline __device__ double __FnName(double __val, int __offset,\
+  inline __device__ double __FnName(double __val, __Type 

r321326 - [CUDA] More fixes for __shfl_* intrinsics.

2017-12-21 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Dec 21 15:52:09 2017
New Revision: 321326

URL: http://llvm.org/viewvc/llvm-project?rev=321326=rev
Log:
[CUDA] More fixes for __shfl_* intrinsics.

* __shfl_{up,down}* uses unsigned int for the third parameter.
* added [unsigned] long overloads for non-sync shuffles.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=321326=321325=321326=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Thu Dec 21 15:52:09 2017
@@ -34,23 +34,24 @@
 #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
 #pragma push_macro("__MAKE_SHUFFLES")
-#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)
\
-  inline __device__ int __FnName(int __val, int __offset,  
\
+#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask,
\
+__Type)
\
+  inline __device__ int __FnName(int __val, __Type __offset,   
\
  int __width = warpSize) { 
\
 return __IntIntrinsic(__val, __offset, 
\
   ((warpSize - __width) << 8) | (__Mask)); 
\
   }
\
-  inline __device__ float __FnName(float __val, int __offset,  
\
+  inline __device__ float __FnName(float __val, __Type __offset,   
\
int __width = warpSize) {   
\
 return __FloatIntrinsic(__val, __offset,   
\
 ((warpSize - __width) << 8) | (__Mask));   
\
   }
\
-  inline __device__ unsigned int __FnName(unsigned int __val, int __offset,
\
+  inline __device__ unsigned int __FnName(unsigned int __val, __Type __offset, 
\
   int __width = warpSize) {
\
 return static_cast(  
\
 ::__FnName(static_cast(__val), __offset, __width));   
\
   }
\
-  inline __device__ long long __FnName(long long __val, int __offset,  
\
+  inline __device__ long long __FnName(long long __val, __Type __offset,   
\
int __width = warpSize) {   
\
 struct __Bits {
\
   int __a, __b;
\
@@ -65,12 +66,29 @@
 memcpy(&__ret, &__tmp, sizeof(__tmp)); 
\
 return __ret;  
\
   }
\
+  inline __device__ long __FnName(long __val, __Type __offset, 
\
+  int __width = warpSize) {
\
+_Static_assert(sizeof(long) == sizeof(long long) ||
\
+   sizeof(long) == sizeof(int));   
\
+if (sizeof(long) == sizeof(long long)) {   
\
+  return static_cast(
\
+  ::__FnName(static_cast(__val), __offset, __width));   
\
+} else if (sizeof(long) == sizeof(int)) {  
\
+  return static_cast(
\
+  ::__FnName(static_cast(__val), __offset, __width)); 
\
+}  
\
+  }
\
+  inline __device__ unsigned long __FnName(
\
+  unsigned long __val, __Type __offset, int __width = warpSize) {  
\
+return static_cast( 
\
+::__FnName(static_cast(__val), __offset, __width));  
\
+  }
\
   inline __device__ unsigned long long __FnName(   
\
-  unsigned long long __val, int __offset, int __width = warpSize) {
\
+  unsigned long long __val, __Type __offset, int __width = warpSize) { 
\
 return static_cast(::__FnName(

r321325 - [X86] Allow _mm_prefetch (both the header implementation and the builtin) to accept bit 2 which is supposed to indicate the prefetched addresses will be written to

2017-12-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Dec 21 15:50:22 2017
New Revision: 321325

URL: http://llvm.org/viewvc/llvm-project?rev=321325=rev
Log:
[X86] Allow _mm_prefetch (both the header implementation and the builtin) to 
accept bit 2 which is supposed to indicate the prefetched addresses will be 
written to

Add the appropriate _MM_HINT_ET0/ET1 defines to match gcc.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=321325=321324=321325=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 21 15:50:22 2017
@@ -8022,8 +8022,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   default: return nullptr;
   case X86::BI_mm_prefetch: {
 Value *Address = Ops[0];
-Value *RW = ConstantInt::get(Int32Ty, 0);
-Value *Locality = Ops[1];
+ConstantInt *C = cast(Ops[1]);
+Value *RW = ConstantInt::get(Int32Ty, (C->getZExtValue() >> 2) & 0x1);
+Value *Locality = ConstantInt::get(Int32Ty, C->getZExtValue() & 0x3);
 Value *Data = ConstantInt::get(Int32Ty, 1);
 Value *F = CGM.getIntrinsic(Intrinsic::prefetch);
 return Builder.CreateCall(F, {Address, RW, Locality, Data});

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=321325=321324=321325=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Thu Dec 21 15:50:22 2017
@@ -2035,9 +2035,11 @@ _mm_storer_ps(float *__p, __m128 __a)
   _mm_store_ps(__p, __a);
 }
 
-#define _MM_HINT_T0 3
-#define _MM_HINT_T1 2
-#define _MM_HINT_T2 1
+#define _MM_HINT_ET0 7
+#define _MM_HINT_ET1 6
+#define _MM_HINT_T0  3
+#define _MM_HINT_T1  2
+#define _MM_HINT_T2  1
 #define _MM_HINT_NTA 0
 
 #ifndef _MSC_VER
@@ -2068,7 +2070,8 @@ _mm_storer_ps(float *__p, __m128 __a)
 ///be generated. \n
 ///_MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction 
will
 ///be generated.
-#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), 0, (sel)))
+#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), \
+ ((sel) >> 2) & 1, (sel) & 
0x3))
 #endif
 
 /// \brief Stores a 64-bit integer in the specified aligned memory location. To

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=321325=321324=321325=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec 21 15:50:22 2017
@@ -2278,7 +2278,7 @@ bool Sema::CheckX86BuiltinFunctionCall(u
   default:
 return false;
   case X86::BI_mm_prefetch:
-i = 1; l = 0; u = 3;
+i = 1; l = 0; u = 7;
 break;
   case X86::BI__builtin_ia32_sha1rnds4:
   case X86::BI__builtin_ia32_shuf_f32x4_256_mask:


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


[PATCH] D41526: [libclang] Avoid builtin trap for __debug parser_crash pragma

2017-12-21 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

Did you consider just using a different pragma that triggers this behaviour 
instead of avoiding the crash?  I don't really have a strong preference but I'd 
be interested to hear what you think the pros/cons are.




Comment at: lib/Parse/ParseDecl.cpp:5657
+  else
+PP.getPreprocessorOpts().SeenParserCrashPragma = true;
+}

This should return immediately (and keep exiting until ~ParseAST) or it won't 
really behave like a trap.


Repository:
  rC Clang

https://reviews.llvm.org/D41526



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


[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

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

I'm sure most of you have taken off for the year, but if anyone had time, 
*ping* :D


https://reviews.llvm.org/D40819



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


[PATCH] D41363: [clang-tidy] Adding Fuchsia checker for overloaded operators

2017-12-21 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

> Are the Fuchsia library headers intended to also comply with this rule? I 
> notice there's mention of a unique_ptr class, and I can't imagine that 
> working without overloading more operators than just assignment. Perhaps this 
> check should not be triggered for system headers?

It would make sense for it to be run on the system headers when clang-tidy's 
-system-headers flag is included, otherwise not -- does that logic need to go 
into the checker though?


https://reviews.llvm.org/D41363



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


[PATCH] D41151: [analyzer] Adding LoopContext and improve loop modeling

2017-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Or not. Loop counter has its own whole-loop scope.

I guess `LoopContext` can be treated as a sub-class of `ScopeContext`. And i 
don't mind having `ScopeContext` be split into small distinct sub-classes. 
Because we're stuck in cornercases for covering all possible scopes, while 
we're fine with covering only simple scopes (it's better than nothing) and 
lacking a scope from time to time.


https://reviews.llvm.org/D41151



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


[PATCH] D41363: [clang-tidy] Adding Fuchsia checker for overloaded operators

2017-12-21 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 127960.
juliehockett marked 5 inline comments as done.
juliehockett added a comment.

Fixing comments


https://reviews.llvm.org/D41363

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
  clang-tidy/fuchsia/OverloadedOperatorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-overloaded-operator.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/fuchsia-overloaded-operator.cpp

Index: test/clang-tidy/fuchsia-overloaded-operator.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-overloaded-operator.cpp
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy %s fuchsia-overloaded-operator %t
+
+class A {
+public:
+  int operator+(int);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: cannot overload 'operator+' [fuchsia-overloaded-operator]
+};
+
+class B {
+public:
+  B =(const B );
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' [fuchsia-overloaded-operator]
+  B =(B &);
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' [fuchsia-overloaded-operator]
+};
+
+A operator-(const A& a, const A& b);
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' [fuchsia-overloaded-operator]
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -69,6 +69,7 @@
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
fuchsia-default-arguments
+   fuchsia-overloaded-operator
fuchsia-virtual-inheritance
google-build-explicit-make-pair
google-build-namespaces
Index: docs/clang-tidy/checks/fuchsia-overloaded-operator.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-overloaded-operator.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - fuchsia-overloaded-operator
+
+fuchsia-overloaded-operator
+===
+
+Warns if an operator is overloaded, except for the assignment (copy and move) 
+operators.
+
+For example:
+
+.. code-block:: c++
+
+  int operator+(int); // Warning
+
+  B =(const B );  // No warning
+  B =(B &) // No warning
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -134,7 +134,12 @@
   `_ check
 
   Warns if a function or method is declared or called with default arguments.
-  
+
+- New `fuchsia-overloaded-operator
+  `_ check
+
+  Warns if an operator is overloaded, except for the assignment (copy and move) operators.
+
 - New `fuchsia-virtual-inheritance
   `_ check
 
Index: clang-tidy/fuchsia/OverloadedOperatorCheck.h
===
--- /dev/null
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.h
@@ -0,0 +1,35 @@
+//===--- OverloadedOperatorCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_OVERLOADED_OPERATOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_OVERLOADED_OPERATOR_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace fuchsia {
+
+/// Overloading operators is disallowed by the Fuchsia coding standard.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/fuchsia-overloaded-operator.html
+class OverloadedOperatorCheck : public ClangTidyCheck {
+public:
+  OverloadedOperatorCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace fuchsia
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_OVERLOADED_OPERATOR_H
Index: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
===
--- /dev/null
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
@@ -0,0 +1,39 @@
+//===--- OverloadedOperatorCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file 

[PATCH] D41151: [analyzer] Adding LoopContext and improve loop modeling

2017-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

So, essentially, `LoopContext` is per-loop, while `ScopeContext` is 
per-iteration?




Comment at: lib/StaticAnalyzer/Core/LoopUnrolling.cpp:28-46
 struct LoopState {
 private:
   enum Kind { Normal, Unrolled } K;
-  const Stmt *LoopStmt;
-  const LocationContext *LCtx;
-  unsigned maxStep;
-  LoopState(Kind InK, const Stmt *S, const LocationContext *L, unsigned N)
-  : K(InK), LoopStmt(S), LCtx(L), maxStep(N) {}
+  unsigned MaxStep;
+  LoopState(Kind InK, unsigned N) : K(InK), MaxStep(N) {}
 
 public:

Should the whole `LoopState` be reduced to a field(s) in `LoopContext`? It 
seems to make sense to me, unless we're planning to modify it in the middle of 
the loop.


https://reviews.llvm.org/D41151



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


[PATCH] D41521: [CUDA] fixes for __shfl_* intrinsics.

2017-12-21 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Added to my todo list.  There are few more gaps that I want to test in order to 
make sure we don't regress on compatibility with older CUDA versions while 
changing these wrappers.


https://reviews.llvm.org/D41521



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


r321324 - Correct hasFeature/isValidFeatureName's handling of shstk/adx/mwaitx

2017-12-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Dec 21 15:27:36 2017
New Revision: 321324

URL: http://llvm.org/viewvc/llvm-project?rev=321324=rev
Log:
Correct hasFeature/isValidFeatureName's handling of shstk/adx/mwaitx

https://bugs.llvm.org/show_bug.cgi?id=35721 reports that x86intrin.h
is issuing a few warnings. This is because attribute target is using
isValidFeatureName for its source. It was also discovered that two of
these were missing from hasFeature.  

Additionally, shstk is and ibu are reordered alphabetically, as came
up during code review.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=321324=321323=321324=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Thu Dec 21 15:27:36 2017
@@ -1131,6 +1131,7 @@ bool X86TargetInfo::isValidFeatureName(S
   return llvm::StringSwitch(Name)
   .Case("3dnow", true)
   .Case("3dnowa", true)
+  .Case("adx", true)
   .Case("aes", true)
   .Case("avx", true)
   .Case("avx2", true)
@@ -1160,6 +1161,7 @@ bool X86TargetInfo::isValidFeatureName(S
   .Case("mmx", true)
   .Case("movbe", true)
   .Case("mpx", true)
+  .Case("mwaitx", true)
   .Case("pclmul", true)
   .Case("pku", true)
   .Case("popcnt", true)
@@ -1170,6 +1172,7 @@ bool X86TargetInfo::isValidFeatureName(S
   .Case("rtm", true)
   .Case("sgx", true)
   .Case("sha", true)
+  .Case("shstk", true)
   .Case("sse", true)
   .Case("sse2", true)
   .Case("sse3", true)
@@ -1190,6 +1193,7 @@ bool X86TargetInfo::isValidFeatureName(S
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
   return llvm::StringSwitch(Feature)
+  .Case("adx", HasADX)
   .Case("aes", HasAES)
   .Case("avx", SSELevel >= AVX)
   .Case("avx2", SSELevel >= AVX2)
@@ -1214,6 +1218,7 @@ bool X86TargetInfo::hasFeature(StringRef
   .Case("fma4", XOPLevel >= FMA4)
   .Case("fsgsbase", HasFSGSBASE)
   .Case("fxsr", HasFXSR)
+  .Case("ibt", HasIBT)
   .Case("lwp", HasLWP)
   .Case("lzcnt", HasLZCNT)
   .Case("mm3dnow", MMX3DNowLevel >= AMD3DNow)
@@ -1221,8 +1226,7 @@ bool X86TargetInfo::hasFeature(StringRef
   .Case("mmx", MMX3DNowLevel >= MMX)
   .Case("movbe", HasMOVBE)
   .Case("mpx", HasMPX)
-  .Case("shstk", HasSHSTK)
-  .Case("ibt", HasIBT)
+  .Case("mwaitx", HasMWAITX)
   .Case("pclmul", HasPCLMUL)
   .Case("pku", HasPKU)
   .Case("popcnt", HasPOPCNT)
@@ -1233,6 +1237,7 @@ bool X86TargetInfo::hasFeature(StringRef
   .Case("rtm", HasRTM)
   .Case("sgx", HasSGX)
   .Case("sha", HasSHA)
+  .Case("shstk", HasSHSTK)
   .Case("sse", SSELevel >= SSE1)
   .Case("sse2", SSELevel >= SSE2)
   .Case("sse3", SSELevel >= SSE3)


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


[clang-tools-extra] r321323 - Update test after r321312

2017-12-21 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Dec 21 15:19:25 2017
New Revision: 321323

URL: http://llvm.org/viewvc/llvm-project?rev=321323=rev
Log:
Update test after r321312

Modified:
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=321323=321322=321323=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Thu Dec 21 15:19:25 2017
@@ -1891,7 +1891,7 @@ TEST_F(ChangeNamespaceTest, ReferencesTo
  "  Glob g2 = G2;\n"
  "  na::X x1 = na::X::X1;\n"
  "  na::Y y1 = na::Y::Y1;\n"
- "  na::Y y2 = na::Y::Y2;\n"
+ "  na::Y y2 = na::Y2;\n"
  "}\n"
  "} // namespace y\n"
  "} // namespace x\n";
@@ -1923,8 +1923,7 @@ TEST_F(ChangeNamespaceTest, NoRedundantE
  "void f() {\n"
  "  ns::X x1 = ns::X::X1;\n"
  "  ns::Y y1 = ns::Y::Y1;\n"
- // FIXME: this is redundant
- "  ns::Y y2 = ns::Y::Y2;\n"
+ "  ns::Y y2 = ns::Y2;\n"
  "}\n"
  "} // namespace y\n"
  "} // namespace x\n";


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


[PATCH] D41526: [libclang] Avoid builtin trap for __debug parser_crash pragma

2017-12-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: benlangmuir.
Herald added a subscriber: JDevlieghere.

This patch allows libclang to report a parser crash that's caused by `#pragma 
clang __debug parser_crash` without using the `LLVM_BUILTIN_TRAP`. Instead a 
new flag in PPOpts is used to let libclang know that a simulated crash has 
occurred. This flag allows clients to test that libclang can report a parser 
crash (CXError_Crash) when libclang is ran under a debugger that breaks on 
`LLVM_BUILTIN_TRAP`.


Repository:
  rC Clang

https://reviews.llvm.org/D41526

Files:
  include/clang/Frontend/ASTUnit.h
  include/clang/Lex/PreprocessorOptions.h
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseDecl.cpp
  tools/libclang/CIndex.cpp
  unittests/libclang/LibclangTest.cpp

Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -572,3 +572,15 @@
   EXPECT_EQ(0U, clang_getNumDiagnostics(ClangTU));
   DisplayDiagnostics();
 }
+
+TEST_F(LibclangReparseTest, clang_parseTranslationUnit2FullArgv_Crash) {
+  std::string Filename = "test.cc";
+  WriteFile(Filename, "#  pragma clang __debug parser_crash\n");
+
+  const char *Argv[] = {"clang"};
+
+  EXPECT_EQ(CXError_Crashed,
+clang_parseTranslationUnit2FullArgv(Index, Filename.c_str(), Argv,
+sizeof(Argv) / sizeof(Argv[0]),
+nullptr, 0, TUFlags, ));
+}
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -37,6 +37,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Serialization/SerializationDiagnostic.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -3453,8 +3454,8 @@
   TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
   /*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
   /*UserFilesAreVolatile=*/true, ForSerialization,
-  CXXIdx->getPCHContainerOperations()->getRawReader().getFormat(),
-  ));
+  CXXIdx->getPCHContainerOperations()->getRawReader().getFormat(), ,
+  /*VFS=*/nullptr, /*AvoidTrapOnBuiltinDebugCrash=*/true));
 
   // Early failures in LoadFromCommandLine may return with ErrUnit unset.
   if (!Unit && !ErrUnit)
@@ -3469,15 +3470,17 @@
   if (isASTReadError(Unit ? Unit.get() : ErrUnit.get()))
 return CXError_ASTReadError;
 
+  bool Crash =
+  Unit->getPreprocessor().getPreprocessorOpts().SeenParserCrashPragma;
   *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(Unit));
   if (CXTranslationUnitImpl *TU = *out_TU) {
 TU->ParsingOptions = options;
 TU->Arguments.reserve(Args->size());
 for (const char *Arg : *Args)
   TU->Arguments.push_back(Arg);
-return CXError_Success;
+return Crash ? CXError_Crashed : CXError_Success;
   }
-  return CXError_Failure;
+  return Crash ? CXError_Crashed : CXError_Failure;
 }
 
 CXTranslationUnit
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/ParsedTemplate.h"
@@ -5649,8 +5650,12 @@
   Diag(PP.getLocForEndOfToken(D.getEllipsisLoc()),
diag::ext_abstract_pack_declarator_parens);
   } else {
-if (Tok.getKind() == tok::annot_pragma_parser_crash)
-  LLVM_BUILTIN_TRAP;
+if (Tok.getKind() == tok::annot_pragma_parser_crash) {
+  if (!PP.getPreprocessorOpts().AvoidTrapOnParserCrashPragma)
+LLVM_BUILTIN_TRAP;
+  else
+PP.getPreprocessorOpts().SeenParserCrashPragma = true;
+}
 if (Tok.is(tok::l_square))
   return ParseMisplacedBracketDeclarator(D);
 if (D.getContext() == Declarator::MemberContext) {
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1649,7 +1649,8 @@
 bool AllowPCHWithCompilerErrors, bool SkipFunctionBodies,
 bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization,
 llvm::Optional ModuleFormat, std::unique_ptr *ErrAST,
-IntrusiveRefCntPtr VFS) {
+IntrusiveRefCntPtr VFS,
+bool AvoidTrapOnBuiltinDebugCrash) {
   assert(Diags.get() && "no DiagnosticsEngine was provided");
 
   SmallVector StoredDiagnostics;
@@ -1676,6 +1677,7 @@
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   

[PATCH] D41521: [CUDA] fixes for __shfl_* intrinsics.

2017-12-21 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Since this is tricky and we've seen it affecting user code, do you think it's a 
bad idea to add tests to the test-suite?


https://reviews.llvm.org/D41521



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


[PATCH] D41514: [Index] Reduce size of SymbolInfo struct.

2017-12-21 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Nice one! One minor change I'd suggest is to change `SymbolProperty` to `enum 
class SymbolProperty : SymbolPropertySet`, so that if it needs to increase we 
only change the type in one place.


Repository:
  rC Clang

https://reviews.llvm.org/D41514



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


r321321 - Delete dead code.

2017-12-21 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Dec 21 15:03:05 2017
New Revision: 321321

URL: http://llvm.org/viewvc/llvm-project?rev=321321=rev
Log:
Delete dead code.

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321321=321320=321321=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 21 15:03:05 2017
@@ -2653,7 +2653,6 @@ llvm::DIModule *CGDebugInfo::getParentMo
 // file where the type's definition is located, so it might be
 // best to make this behavior a command line or debugger tuning
 // option.
-FullSourceLoc Loc(D->getLocation(), CGM.getContext().getSourceManager());
 if (Module *M = D->getOwningModule()) {
   // This is a (sub-)module.
   auto Info = ExternalASTSource::ASTSourceDescriptor(*M);


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


[PATCH] D41414: [analyzer] Add keyboard j/k navigation to HTML reports

2017-12-21 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321320: [analyzer] Add Javascript to analyzer HTML output to 
allow keyboard navigation. (authored by george.karpenkov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41414?vs=127919=127955#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41414

Files:
  cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Index: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
===
--- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
+++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
@@ -342,6 +342,7 @@
   " .CodeInsertionHint { font-weight: bold; background-color: #10dd10 }\n"
   " .CodeRemovalHint { background-color:#de1010 }\n"
   " .CodeRemovalHint { border-bottom:1px solid #6F9DBE }\n"
+  " .selected{ background-color:orange !important; }\n"
   " table.simpletable {\n"
   "   padding: 5px;\n"
   "   font-size:12pt;\n"
Index: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -91,6 +91,9 @@
   // Rewrite the file specified by FID with HTML formatting.
   void RewriteFile(Rewriter , const SourceManager& SMgr,
const PathPieces& path, FileID FID);
+
+  /// \return Javascript for navigating the HTML report using j/k keys.
+  std::string generateKeyboardNavigationJavascript();
 };
 
 } // end anonymous namespace
@@ -337,6 +340,9 @@
   int LineNumber = path.back()->getLocation().asLocation().getExpansionLineNumber();
   int ColumnNumber = path.back()->getLocation().asLocation().getExpansionColumnNumber();
 
+  R.InsertTextBefore(SMgr.getLocForStartOfFile(FID),
+ generateKeyboardNavigationJavascript());
+
   // Add the name of the file as an  tag.
   {
 std::string s;
@@ -378,8 +384,14 @@
   os << "" << html::EscapeText(*I) << "\n";
 }
 
-os << "\n\n"
-  "Annotated Source Code\n";
+os << R"<<<(
+
+
+Annotated Source Code
+[?]
+  Use j/k keys for keyboard navigation
+
+)<<<";
 
 R.InsertTextBefore(SMgr.getLocForStartOfFile(FID), os.str());
   }
@@ -777,3 +789,82 @@
 
   html::HighlightRange(R, InstantiationStart, E, HighlightStart, HighlightEnd);
 }
+
+std::string HTMLDiagnostics::generateKeyboardNavigationJavascript() {
+  return R"<<<(
+
+var digitMatcher = new RegExp("[0-9]+");
+
+document.addEventListener("DOMContentLoaded", function() {
+document.querySelectorAll(".PathNav > a").forEach(
+function(currentValue, currentIndex) {
+var hrefValue = currentValue.getAttribute("href");
+currentValue.onclick = function() {
+scrollTo(document.querySelector(hrefValue));
+return false;
+};
+});
+});
+
+var findNum = function() {
+var s = document.querySelector(".selected");
+if (!s || s.id == "EndPath") {
+return 0;
+}
+var out = parseInt(digitMatcher.exec(s.id)[0]);
+return out;
+};
+
+var scrollTo = function(el) {
+document.querySelectorAll(".selected").forEach(function(s) {
+s.classList.remove("selected");
+});
+el.classList.add("selected");
+window.scrollBy(0, el.getBoundingClientRect().top -
+(window.innerHeight / 2));
+}
+
+var move = function(num, up, numItems) {
+  if (num == 1 && up || num == numItems - 1 && !up) {
+return 0;
+  } else if (num == 0 && up) {
+return numItems - 1;
+  } else if (num == 0 && !up) {
+return 1 % numItems;
+  }
+  return up ? num - 1 : num + 1;
+}
+
+var numToId = function(num) {
+  if (num == 0) {
+return document.getElementById("EndPath")
+  }
+  return document.getElementById("Path" + num);
+};
+
+var navigateTo = function(up) {
+  var numItems = document.querySelectorAll(".line > .msg").length;
+  var currentSelected = findNum();
+  var newSelected = move(currentSelected, up, numItems);
+  var newEl = numToId(newSelected, numItems);
+
+  // Scroll element into center.
+  scrollTo(newEl);
+};
+
+window.addEventListener("keydown", function (event) {
+  if (event.defaultPrevented) {
+return;
+  }
+  if (event.key == "j") {
+navigateTo(/*up=*/false);
+  } else if (event.key == "k") {
+navigateTo(/*up=*/true);
+  } else {
+return;
+  } 
+  event.preventDefault();
+}, true);
+
+  )<<<";
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321320 - [analyzer] Add Javascript to analyzer HTML output to allow keyboard navigation.

2017-12-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Dec 21 14:57:51 2017
New Revision: 321320

URL: http://llvm.org/viewvc/llvm-project?rev=321320=rev
Log:
[analyzer] Add Javascript to analyzer HTML output to allow keyboard navigation.

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

Modified:
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Modified: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/HTMLRewrite.cpp?rev=321320=321319=321320=diff
==
--- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp (original)
+++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp Thu Dec 21 14:57:51 2017
@@ -342,6 +342,7 @@ void html::AddHeaderFooterInternalBuilti
   " .CodeInsertionHint { font-weight: bold; background-color: #10dd10 }\n"
   " .CodeRemovalHint { background-color:#de1010 }\n"
   " .CodeRemovalHint { border-bottom:1px solid #6F9DBE }\n"
+  " .selected{ background-color:orange !important; }\n"
   " table.simpletable {\n"
   "   padding: 5px;\n"
   "   font-size:12pt;\n"

Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=321320=321319=321320=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Thu Dec 21 14:57:51 
2017
@@ -91,6 +91,9 @@ public:
   // Rewrite the file specified by FID with HTML formatting.
   void RewriteFile(Rewriter , const SourceManager& SMgr,
const PathPieces& path, FileID FID);
+
+  /// \return Javascript for navigating the HTML report using j/k keys.
+  std::string generateKeyboardNavigationJavascript();
 };
 
 } // end anonymous namespace
@@ -337,6 +340,9 @@ void HTMLDiagnostics::FinalizeHTML(const
   int LineNumber = 
path.back()->getLocation().asLocation().getExpansionLineNumber();
   int ColumnNumber = 
path.back()->getLocation().asLocation().getExpansionColumnNumber();
 
+  R.InsertTextBefore(SMgr.getLocForStartOfFile(FID),
+ generateKeyboardNavigationJavascript());
+
   // Add the name of the file as an  tag.
   {
 std::string s;
@@ -378,8 +384,14 @@ void HTMLDiagnostics::FinalizeHTML(const
   os << "" << html::EscapeText(*I) << "\n";
 }
 
-os << "\n\n"
-  "Annotated Source Code\n";
+os << R"<<<(
+
+
+Annotated Source Code
+[?]
+  Use j/k keys for keyboard navigation
+
+)<<<";
 
 R.InsertTextBefore(SMgr.getLocForStartOfFile(FID), os.str());
   }
@@ -777,3 +789,82 @@ void HTMLDiagnostics::HighlightRange(Rew
 
   html::HighlightRange(R, InstantiationStart, E, HighlightStart, HighlightEnd);
 }
+
+std::string HTMLDiagnostics::generateKeyboardNavigationJavascript() {
+  return R"<<<(
+
+var digitMatcher = new RegExp("[0-9]+");
+
+document.addEventListener("DOMContentLoaded", function() {
+document.querySelectorAll(".PathNav > a").forEach(
+function(currentValue, currentIndex) {
+var hrefValue = currentValue.getAttribute("href");
+currentValue.onclick = function() {
+scrollTo(document.querySelector(hrefValue));
+return false;
+};
+});
+});
+
+var findNum = function() {
+var s = document.querySelector(".selected");
+if (!s || s.id == "EndPath") {
+return 0;
+}
+var out = parseInt(digitMatcher.exec(s.id)[0]);
+return out;
+};
+
+var scrollTo = function(el) {
+document.querySelectorAll(".selected").forEach(function(s) {
+s.classList.remove("selected");
+});
+el.classList.add("selected");
+window.scrollBy(0, el.getBoundingClientRect().top -
+(window.innerHeight / 2));
+}
+
+var move = function(num, up, numItems) {
+  if (num == 1 && up || num == numItems - 1 && !up) {
+return 0;
+  } else if (num == 0 && up) {
+return numItems - 1;
+  } else if (num == 0 && !up) {
+return 1 % numItems;
+  }
+  return up ? num - 1 : num + 1;
+}
+
+var numToId = function(num) {
+  if (num == 0) {
+return document.getElementById("EndPath")
+  }
+  return document.getElementById("Path" + num);
+};
+
+var navigateTo = function(up) {
+  var numItems = document.querySelectorAll(".line > .msg").length;
+  var currentSelected = findNum();
+  var newSelected = move(currentSelected, up, numItems);
+  var newEl = numToId(newSelected, numItems);
+
+  // Scroll element into center.
+  scrollTo(newEl);
+};
+
+window.addEventListener("keydown", function (event) {
+  if (event.defaultPrevented) {
+return;
+  }
+  if (event.key == "j") {
+navigateTo(/*up=*/false);
+  } else if (event.key == "k") {
+navigateTo(/*up=*/true);
+  } else {
+return;
+  } 
+  event.preventDefault();
+}, true);
+
+  )<<<";
+}



[PATCH] D41523: xmmintrin.h documentation fixes and updates

2017-12-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.

This is the result of several patches we made internally to update the 
documentation that we would like to have reviewed for possible submission.

The changes include:

1. Fix inaccurate instruction listings.
2. Fix small issues in _mm_getcsr and _mm_setcsr.
3. Fix description of NaN handling in comparison intrinsics.
4. Fix inaccurate description of _mm_movemask_pi8.
5. Fix inaccurate instruction mappings.
6. Fix typos.
7. Clarify wording on some descriptions.
8. Fix bit ranges in return value.
9. Fix typo in _mm_move_ms intrinsic instruction since it operates on 
singe-precision values, not double.

These patches were made by Craig Flores


https://reviews.llvm.org/D41523

Files:
  lib/Headers/xmmintrin.h

Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -1011,6 +1011,8 @@
 /// \brief Compares two 32-bit float values in the low-order bits of both
 ///operands for equality and returns the result of the comparison.
 ///
+///If either of the two lower 32-bit values is NaN, 0 is returned.
+///
 /// \headerfile 
 ///
 /// This intrinsic corresponds to the  VCOMISS / COMISS 
@@ -1022,7 +1024,8 @@
 /// \param __b
 ///A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
 ///used in the comparison.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the
+///two lower 32-bit values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comieq_ss(__m128 __a, __m128 __b)
 {
@@ -1033,6 +1036,8 @@
 ///operands to determine if the first operand is less than the second
 ///operand and returns the result of the comparison.
 ///
+///If either of the two lower 32-bit values is NaN, 0 is returned.
+///
 /// \headerfile 
 ///
 /// This intrinsic corresponds to the  VCOMISS / COMISS 
@@ -1044,7 +1049,8 @@
 /// \param __b
 ///A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
 ///used in the comparison.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the two
+/// lower 32-bit values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comilt_ss(__m128 __a, __m128 __b)
 {
@@ -1055,6 +1061,8 @@
 ///operands to determine if the first operand is less than or equal to the
 ///second operand and returns the result of the comparison.
 ///
+///If either of the two lower 32-bit values is NaN, 0 is returned.
+///
 /// \headerfile 
 ///
 /// This intrinsic corresponds to the  VCOMISS / COMISS  instructions.
@@ -1065,7 +1073,8 @@
 /// \param __b
 ///A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
 ///used in the comparison.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the two
+/// lower 32-bit values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comile_ss(__m128 __a, __m128 __b)
 {
@@ -1076,6 +1085,8 @@
 ///operands to determine if the first operand is greater than the second
 ///operand and returns the result of the comparison.
 ///
+///If either of the two lower 32-bit values is NaN, 0 is returned.
+///
 /// \headerfile 
 ///
 /// This intrinsic corresponds to the  VCOMISS / COMISS  instructions.
@@ -1086,7 +1097,8 @@
 /// \param __b
 ///A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
 ///used in the comparison.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the
+/// two lower 32-bit values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comigt_ss(__m128 __a, __m128 __b)
 {
@@ -1097,6 +1109,8 @@
 ///operands to determine if the first operand is greater than or equal to
 ///the second operand and returns the result of the comparison.
 ///
+///If either of the two lower 32-bit values is NaN, 0 is returned.
+///
 /// \headerfile 
 ///
 /// This intrinsic corresponds to the  VCOMISS / COMISS  instructions.
@@ -1107,7 +1121,8 @@
 /// \param __b
 ///A 128-bit vector of [4 x float]. The lower 32 bits of this operand are
 ///used in the comparison.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the two
+///lower 32-bit values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comige_ss(__m128 __a, __m128 __b)
 {
@@ -1118,6 +1133,8 @@
 ///operands to determine if the first operand is not equal to the second
 ///operand and returns the result of the comparison.
 ///
+///If either of the two lower 32-bit values is NaN, 1 is returned.
+///
 /// \headerfile 
 ///
 /// This intrinsic 

r321319 - [ODRHash] Canonicalize Decl's before processing.

2017-12-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Dec 21 14:38:29 2017
New Revision: 321319

URL: http://llvm.org/viewvc/llvm-project?rev=321319=rev
Log:
[ODRHash] Canonicalize Decl's before processing.

Canonicalizing the Decl before processing it as part of the hash should reduce
issues with non-canonical types showing up as mismatches.

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

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=321319=321318=321319=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Thu Dec 21 14:38:29 2017
@@ -468,6 +468,7 @@ void ODRHash::AddCXXRecordDecl(const CXX
 
 void ODRHash::AddDecl(const Decl *D) {
   assert(D && "Expecting non-null pointer.");
+  D = D->getCanonicalDecl();
   auto Result = DeclMap.insert(std::make_pair(D, DeclMap.size()));
   ID.AddInteger(Result.first->second);
   // On first encounter of a Decl pointer, process it.  Every time afterwards,


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


[PATCH] D41521: [CUDA] fixes for __shfl_* intrinsics.

2017-12-21 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added a subscriber: sanjoy.

- __shfl_{up,down}* uses `unsigned int` for the third parameter.
- added [unsigned] long overloads for non-sync shuffles. Augments r319908 which 
added long overload for sync shuffles.


https://reviews.llvm.org/D41521

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h

Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -34,23 +34,24 @@
 #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
 #pragma push_macro("__MAKE_SHUFFLES")
-#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)\
-  inline __device__ int __FnName(int __val, int __offset,  \
+#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask,\
+__Type)\
+  inline __device__ int __FnName(int __val, __Type __offset,   \
  int __width = warpSize) { \
 return __IntIntrinsic(__val, __offset, \
   ((warpSize - __width) << 8) | (__Mask)); \
   }\
-  inline __device__ float __FnName(float __val, int __offset,  \
+  inline __device__ float __FnName(float __val, __Type __offset,   \
int __width = warpSize) {   \
 return __FloatIntrinsic(__val, __offset,   \
 ((warpSize - __width) << 8) | (__Mask));   \
   }\
-  inline __device__ unsigned int __FnName(unsigned int __val, int __offset,\
+  inline __device__ unsigned int __FnName(unsigned int __val, __Type __offset, \
   int __width = warpSize) {\
 return static_cast(  \
 ::__FnName(static_cast(__val), __offset, __width));   \
   }\
-  inline __device__ long long __FnName(long long __val, int __offset,  \
+  inline __device__ long long __FnName(long long __val, __Type __offset,   \
int __width = warpSize) {   \
 struct __Bits {\
   int __a, __b;\
@@ -65,12 +66,29 @@
 memcpy(&__ret, &__tmp, sizeof(__tmp)); \
 return __ret;  \
   }\
+  inline __device__ long __FnName(long __val, __Type __offset, \
+  int __width = warpSize) {\
+_Static_assert(sizeof(long) == sizeof(long long) ||\
+   sizeof(long) == sizeof(int));   \
+if (sizeof(long) == sizeof(long long)) {   \
+  return static_cast(\
+  ::__FnName(static_cast(__val), __offset, __width));   \
+} else if (sizeof(long) == sizeof(int)) {  \
+  return static_cast(\
+  ::__FnName(static_cast(__val), __offset, __width)); \
+}  \
+  }\
+  inline __device__ unsigned long __FnName(\
+  unsigned long __val, __Type __offset, int __width = warpSize) {  \
+return static_cast( \
+::__FnName(static_cast(__val), __offset, __width));  \
+  }\
   inline __device__ unsigned long long __FnName(   \
-  unsigned long long __val, int __offset, int __width = warpSize) {\
+  unsigned long long __val, __Type __offset, int __width = warpSize) { \
 return static_cast(::__FnName( \
 static_cast(__val), __offset, __width));   \
   }\
-  inline __device__ double __FnName(double __val, int __offset,\
+  inline __device__ double __FnName(double 

[PATCH] D41520: smmintrin.h documentation fixes and updates

2017-12-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.

This is the result of several patches we made internally to update the 
documentation that we would like to have reviewed for possible submission.

The changes include:

1. Fix formatting issue due to hyphenated terms at line breaks.
2. Fix typo

These patches were made by Craig Flores


https://reviews.llvm.org/D41520

Files:
  lib/Headers/smmintrin.h


Index: lib/Headers/smmintrin.h
===
--- lib/Headers/smmintrin.h
+++ lib/Headers/smmintrin.h
@@ -648,7 +648,7 @@
 ///input vectors are used as an input for dot product; otherwise that input
 ///is treated as zero. Bits [1:0] determine which elements of the result
 ///will receive a copy of the final dot product, with bit [0] corresponding
-///to the lowest element and bit [3] corresponding to the highest element 
of
+///to the lowest element and bit [1] corresponding to the highest element 
of
 ///each [2 x double] vector. If a bit is set, the dot product is returned 
in
 ///the corresponding element; otherwise that element is set to zero.
 #define _mm_dp_pd(X, Y, M) __extension__ ({\
@@ -866,8 +866,8 @@
 ///  11: Copies the selected bits from \a Y to result bits [127:96]. \n
 ///Bits[3:0]: If any of these bits are set, the corresponding result
 ///element is cleared.
-/// \returns A 128-bit vector of [4 x float] containing the copied single-
-///precision floating point elements from the operands.
+/// \returns A 128-bit vector of [4 x float] containing the copied
+///single-precision floating point elements from the operands.
 #define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N))
 
 /// \brief Extracts a 32-bit integer from a 128-bit vector of [4 x float] and


Index: lib/Headers/smmintrin.h
===
--- lib/Headers/smmintrin.h
+++ lib/Headers/smmintrin.h
@@ -648,7 +648,7 @@
 ///input vectors are used as an input for dot product; otherwise that input
 ///is treated as zero. Bits [1:0] determine which elements of the result
 ///will receive a copy of the final dot product, with bit [0] corresponding
-///to the lowest element and bit [3] corresponding to the highest element of
+///to the lowest element and bit [1] corresponding to the highest element of
 ///each [2 x double] vector. If a bit is set, the dot product is returned in
 ///the corresponding element; otherwise that element is set to zero.
 #define _mm_dp_pd(X, Y, M) __extension__ ({\
@@ -866,8 +866,8 @@
 ///  11: Copies the selected bits from \a Y to result bits [127:96]. \n
 ///Bits[3:0]: If any of these bits are set, the corresponding result
 ///element is cleared.
-/// \returns A 128-bit vector of [4 x float] containing the copied single-
-///precision floating point elements from the operands.
+/// \returns A 128-bit vector of [4 x float] containing the copied
+///single-precision floating point elements from the operands.
 #define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N))
 
 /// \brief Extracts a 32-bit integer from a 128-bit vector of [4 x float] and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41518: pmmintrin.h documentation fixes and updates

2017-12-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.

This is the result of several patches we made internally to update the 
documentation that we would like to have reviewed for possible submission.

The changes include:

1. Fix incorrect wording in various intrinsic descriptions. Previously the 
descriptions used "low-order" and "high-order" when the intended meaning was 
"even-indexed" and "odd-indexed".

These patches were made by Craig Flores


https://reviews.llvm.org/D41518

Files:
  lib/Headers/pmmintrin.h


Index: lib/Headers/pmmintrin.h
===
--- lib/Headers/pmmintrin.h
+++ lib/Headers/pmmintrin.h
@@ -115,8 +115,8 @@
   return __builtin_ia32_hsubps((__v4sf)__a, (__v4sf)__b);
 }
 
-/// \brief Moves and duplicates high-order (odd-indexed) values from a 128-bit
-///vector of [4 x float] to float values stored in a 128-bit vector of
+/// \brief Moves and duplicates odd-indexed values from a 128-bit vector
+///of [4 x float] to float values stored in a 128-bit vector of
 ///[4 x float].
 ///
 /// \headerfile 
@@ -137,7 +137,7 @@
   return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 1, 1, 3, 3);
 }
 
-/// \brief Duplicates low-order (even-indexed) values from a 128-bit vector of
+/// \brief Duplicates even-indexed values from a 128-bit vector of
 ///[4 x float] to float values stored in a 128-bit vector of [4 x float].
 ///
 /// \headerfile 


Index: lib/Headers/pmmintrin.h
===
--- lib/Headers/pmmintrin.h
+++ lib/Headers/pmmintrin.h
@@ -115,8 +115,8 @@
   return __builtin_ia32_hsubps((__v4sf)__a, (__v4sf)__b);
 }
 
-/// \brief Moves and duplicates high-order (odd-indexed) values from a 128-bit
-///vector of [4 x float] to float values stored in a 128-bit vector of
+/// \brief Moves and duplicates odd-indexed values from a 128-bit vector
+///of [4 x float] to float values stored in a 128-bit vector of
 ///[4 x float].
 ///
 /// \headerfile 
@@ -137,7 +137,7 @@
   return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 1, 1, 3, 3);
 }
 
-/// \brief Duplicates low-order (even-indexed) values from a 128-bit vector of
+/// \brief Duplicates even-indexed values from a 128-bit vector of
 ///[4 x float] to float values stored in a 128-bit vector of [4 x float].
 ///
 /// \headerfile 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321318 - Suppress "redundant parens" warning for "A (::B())".

2017-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 21 14:26:47 2017
New Revision: 321318

URL: http://llvm.org/viewvc/llvm-project?rev=321318=rev
Log:
Suppress "redundant parens" warning for "A (::B())".

This is a slightly odd construct (it's more common to see "A (::B)()") but can
happen in friend declarations, and the parens are not redundant as they prevent
the :: binding to the left.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Parser/cxx-decl.cpp
cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=321318=321317=321318=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Dec 21 14:26:47 2017
@@ -3165,7 +3165,12 @@ static void warnAboutRedundantParens(Sem
   // In a new-type-id, function chunks require parentheses.
   if (D.getContext() == Declarator::CXXNewContext)
 return;
-  LLVM_FALLTHROUGH;
+  // FIXME: "A(f())" deserves a vexing-parse warning, not just a
+  // redundant-parens warning, but we don't know whether the function
+  // chunk was syntactically valid as an expression here.
+  CouldBeTemporaryObject = false;
+  continue;
+
 case DeclaratorChunk::BlockPointer:
 case DeclaratorChunk::MemberPointer:
 case DeclaratorChunk::Pipe:

Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=321318=321317=321318=diff
==
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Thu Dec 21 14:26:47 2017
@@ -282,6 +282,22 @@ namespace NNS {
   }
 }
 
+inline namespace ParensAroundFriend { // expected-error 0-1{{C++11}}
+  struct A {};
+  struct B {
+static A C();
+  };
+  namespace X {
+struct B {};
+struct D {
+  // No warning here: while this could be written as
+  //   friend (::B::C)();
+  // we do need parentheses *somewhere* here.
+  friend A (::B::C());
+};
+  }
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all 
declarations}}

Modified: cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp?rev=321318=321317=321318=diff
==
--- cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp Thu Dec 21 14:26:47 2017
@@ -125,3 +125,20 @@ void fizbin() {
   baz b3; // expected-error {{must use 'class' tag to refer to type 'baz' in 
this scope}}
 }
 }
+
+namespace TemporaryFromFunctionCall {
+  struct A {
+A(int);
+  };
+  int f();
+  int g(int);
+  namespace N {
+void x() {
+  // FIXME: For the first and second of these (but not the third), we
+  // should produce a vexing-parse warning.
+  A(f());
+  A(g(int()));
+  A(g(int));
+}
+  }
+}


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


[PATCH] D41517: mmintrin.h documentation fixes and updates

2017-12-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.

This is the result of several patches we made internally to update the 
documentation that we would like to have reviewed for possible submission.

The changes include:

1. Fix instruction mappings/listings for various intrinsics

These patches were made by Craig Flores


https://reviews.llvm.org/D41517

Files:
  lib/Headers/mmintrin.h


Index: lib/Headers/mmintrin.h
===
--- lib/Headers/mmintrin.h
+++ lib/Headers/mmintrin.h
@@ -52,7 +52,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __i
 ///A 32-bit integer value.
@@ -69,7 +69,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -85,7 +85,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __i
 ///A 64-bit signed integer.
@@ -101,7 +101,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -1289,7 +1289,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VXORPS / XORPS  instruction.
+/// This intrinsic corresponds to the  XOR  instruction.
 ///
 /// \returns An initialized 64-bit integer vector with all elements set to 
zero.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
@@ -1381,7 +1381,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFD / PSHUFD  instruction.
+/// This intrinsic corresponds to the  PSHUFD  instruction.
 ///
 /// \param __i
 ///A 32-bit integer value used to initialize each vector element of the
@@ -1399,7 +1399,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFLW / PSHUFLW  instruction.
+/// This intrinsic corresponds to the  PSHUFLW  instruction.
 ///
 /// \param __w
 ///A 16-bit integer value used to initialize each vector element of the
@@ -1416,8 +1416,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPUNPCKLBW + VPSHUFLW / PUNPCKLBW +
-///PSHUFLW  instruction.
+/// This intrinsic corresponds to the  PUNPCKLBW + PSHUFLW  instruction.
 ///
 /// \param __b
 ///An 8-bit integer value used to initialize each vector element of the


Index: lib/Headers/mmintrin.h
===
--- lib/Headers/mmintrin.h
+++ lib/Headers/mmintrin.h
@@ -52,7 +52,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __i
 ///A 32-bit integer value.
@@ -69,7 +69,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVD / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -85,7 +85,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __i
 ///A 64-bit signed integer.
@@ -101,7 +101,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VMOVQ / MOVD  instruction.
+/// This intrinsic corresponds to the  MOVD  instruction.
 ///
 /// \param __m
 ///A 64-bit integer vector.
@@ -1289,7 +1289,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VXORPS / XORPS  instruction.
+/// This intrinsic corresponds to the  XOR  instruction.
 ///
 /// \returns An initialized 64-bit integer vector with all elements set to zero.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
@@ -1381,7 +1381,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFD / PSHUFD  instruction.
+/// This intrinsic corresponds to the  PSHUFD  instruction.
 ///
 /// \param __i
 ///A 32-bit integer value used to initialize each vector element of the
@@ -1399,7 +1399,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPSHUFLW / PSHUFLW  instruction.
+/// This intrinsic corresponds to the  PSHUFLW  instruction.
 ///
 /// \param __w
 ///A 16-bit integer value used to initialize each vector element of the
@@ -1416,8 +1416,7 @@
 ///
 /// \headerfile 
 ///
-/// This intrinsic corresponds to the  VPUNPCKLBW + VPSHUFLW / PUNPCKLBW +
-///PSHUFLW  instruction.
+/// This intrinsic corresponds to the  PUNPCKLBW + PSHUFLW  instruction.
 ///
 /// \param __b
 ///An 8-bit integer value used to initialize each vector element of the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D41507: avxintrin.h documentation fixes and updates

2017-12-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Headers/avxintrin.h:1668
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equal (ordered, signaling)
-///0x03 : Unordered (non-signaling)
-///0x04 : Not-equal (unordered, non-signaling)
-///0x05 : Not-less-than (unordered, signaling)
-///0x06 : Not-less-than-or-equal (unordered, signaling)
-///0x07 : Ordered (non-signaling)
-///0x08 : Equal (unordered, non-signaling)
-///0x09 : Not-greater-than-or-equal (unordered, signaling)
-///0x0a : Not-greater-than (unordered, signaling)
-///0x0b : False (ordered, non-signaling)
-///0x0c : Not-equal (ordered, non-signaling)
-///0x0d : Greater-than-or-equal (ordered, signaling)
-///0x0e : Greater-than (ordered, signaling)
-///0x0f : True (unordered, non-signaling)
-///0x10 : Equal (ordered, signaling)
-///0x11 : Less-than (ordered, non-signaling)
-///0x12 : Less-than-or-equal (ordered, non-signaling)
-///0x13 : Unordered (signaling)
-///0x14 : Not-equal (unordered, signaling)
-///0x15 : Not-less-than (unordered, non-signaling)
-///0x16 : Not-less-than-or-equal (unordered, non-signaling)
-///0x17 : Ordered (signaling)
-///0x18 : Equal (unordered, signaling)
-///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
-///0x1a : Not-greater-than (unordered, non-signaling)
-///0x1b : False (ordered, signaling)
-///0x1c : Not-equal (ordered, signaling)
-///0x1d : Greater-than-or-equal (ordered, non-signaling)
-///0x1e : Greater-than (ordered, non-signaling)
-///0x1f : True (unordered, signaling)
+///00h: Equal (ordered, non-signaling) \n
+///01h: Less-than (ordered, signaling) \n

While i'm incompetent to actually review this, i have a question.
//Why// replace code-friendly `0x00` with `00h`?
And, //why// is this hex in the first place? Why not decimals?



https://reviews.llvm.org/D41507



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


[PATCH] D41498: [libcxx] Add clang negative thread safety assertions to std::mutex

2017-12-21 Thread Luis Héctor Chávez via Phabricator via cfe-commits
lhchavez added inline comments.



Comment at: include/__mutex_base:65
 void unlock() _NOEXCEPT 
_LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
+#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+const mutex& operator!() const { return *this; }

mclow.lists wrote:
> We don't get to add public member functions to classes defined in the 
> standard - at least not ones with pronounceable names.
> 
So there's no way to support negative assertions as stated in the docs? That's 
unfortunate :(


Repository:
  rCXX libc++

https://reviews.llvm.org/D41498



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


[PATCH] D41516: emmintrin.h documentation fixes and updates

2017-12-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.

This is the result of several patches we made internally to update the 
documentation that we would like to have reviewed for possible submission.

The changes include:

1. Fixed innaccurate instruction mappings for various intrinsics.
2. Fixed description of NaN handling in comparison intrinsics.
3. Unify description of _mm_store_pd1 to match _mm_store1_pd.
4. Fix incorrect wording in various intrinsic descriptions. Previously the 
descriptions used "low-order" and "high-order" when the intended meaning was 
"even-indexed" and "odd-indexed".
5. Fix typos.
6. Add missing italics command (\a) for params and fixed some parameter 
spellings.

These patches were made by Craig Flores


https://reviews.llvm.org/D41516

Files:
  lib/Headers/emmintrin.h

Index: lib/Headers/emmintrin.h
===
--- lib/Headers/emmintrin.h
+++ lib/Headers/emmintrin.h
@@ -217,8 +217,8 @@
 
 /// \brief Calculates the square root of the lower double-precision value of
 ///the second operand and returns it in the lower 64 bits of the result.
-///The upper 64 bits of the result are copied from the upper double-
-///precision value of the first operand.
+///The upper 64 bits of the result are copied from the upper
+///double-precision value of the first operand.
 ///
 /// \headerfile 
 ///
@@ -260,8 +260,8 @@
 
 /// \brief Compares lower 64-bit double-precision values of both operands, and
 ///returns the lesser of the pair of values in the lower 64-bits of the
-///result. The upper 64 bits of the result are copied from the upper double-
-///precision value of the first operand.
+///result. The upper 64 bits of the result are copied from the upper
+///double-precision value of the first operand.
 ///
 /// \headerfile 
 ///
@@ -304,8 +304,8 @@
 
 /// \brief Compares lower 64-bit double-precision values of both operands, and
 ///returns the greater of the pair of values in the lower 64-bits of the
-///result. The upper 64 bits of the result are copied from the upper double-
-///precision value of the first operand.
+///result. The upper 64 bits of the result are copied from the upper
+///double-precision value of the first operand.
 ///
 /// \headerfile 
 ///
@@ -983,8 +983,10 @@
 }
 
 /// \brief Compares the lower double-precision floating-point values in each of
-///the two 128-bit floating-point vectors of [2 x double] for equality. The
-///comparison yields 0 for false, 1 for true.
+///the two 128-bit floating-point vectors of [2 x double] for equality.
+///
+///The comparison yields 0 for false, 1 for true. If either of the two
+///lower double-precision values is NaN, 0 is returned.
 ///
 /// \headerfile 
 ///
@@ -996,7 +998,8 @@
 /// \param __b
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
 ///compared to the lower double-precision value of \a __a.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the two
+///lower double-precision values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comieq_sd(__m128d __a, __m128d __b)
 {
@@ -1008,7 +1011,8 @@
 ///the value in the first parameter is less than the corresponding value in
 ///the second parameter.
 ///
-///The comparison yields 0 for false, 1 for true.
+///The comparison yields 0 for false, 1 for true. If either of the two
+///lower double-precision values is NaN, 0 is returned.
 ///
 /// \headerfile 
 ///
@@ -1020,7 +1024,8 @@
 /// \param __b
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
 ///compared to the lower double-precision value of \a __a.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the two
+/// lower double-precision values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comilt_sd(__m128d __a, __m128d __b)
 {
@@ -1032,7 +1037,8 @@
 ///the value in the first parameter is less than or equal to the
 ///corresponding value in the second parameter.
 ///
-///The comparison yields 0 for false, 1 for true.
+///The comparison yields 0 for false, 1 for true. If either of the two
+///lower double-precision values is NaN, 0 is returned.
 ///
 /// \headerfile 
 ///
@@ -1044,7 +1050,8 @@
 /// \param __b
 /// A 128-bit vector of [2 x double]. The lower double-precision value is
 /// compared to the lower double-precision value of \a __a.
-/// \returns An integer containing the comparison results.
+/// \returns An integer containing the comparison results. If either of the two
+/// lower double-precision values is NaN, 0 is returned.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_comile_sd(__m128d __a, __m128d __b)
 {
@@ -1056,7 +1063,8 @@
 ///the value in the first parameter is 

[PATCH] D41514: [Index] Reduce size of SymbolInfo struct.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: akyrtzi.
Herald added subscribers: cfe-commits, ilya-biryukov.

This is currently 16 bytes, the patch reduces it to 4.
(Building with clang on linux x84, I guess others are similar)

The only subfield that might need a bigger type is SymbolPropertySet,
I've moved it to the end of the struct so if it grows, SymbolInfo will
only be 8 bytes.

With a full index of namespace-scope symbols from the LLVM project (200k)
loaded into clangd, this saves ~2MB of RAM.


Repository:
  rC Clang

https://reviews.llvm.org/D41514

Files:
  include/clang/Index/IndexSymbol.h
  lib/Index/IndexSymbol.cpp
  tools/libclang/CXIndexDataConsumer.cpp

Index: tools/libclang/CXIndexDataConsumer.cpp
===
--- tools/libclang/CXIndexDataConsumer.cpp
+++ tools/libclang/CXIndexDataConsumer.cpp
@@ -1304,11 +1304,11 @@
 
 static CXIdxEntityCXXTemplateKind
 getEntityKindFromSymbolProperties(SymbolPropertySet K) {
-  if (K & (unsigned)SymbolProperty::TemplatePartialSpecialization)
+  if (K & (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization)
 return CXIdxEntity_TemplatePartialSpecialization;
-  if (K & (unsigned)SymbolProperty::TemplateSpecialization)
+  if (K & (SymbolPropertySet)SymbolProperty::TemplateSpecialization)
 return CXIdxEntity_TemplateSpecialization;
-  if (K & (unsigned)SymbolProperty::Generic)
+  if (K & (SymbolPropertySet)SymbolProperty::Generic)
 return CXIdxEntity_Template;
   return CXIdxEntity_NonTemplate;
 }
Index: lib/Index/IndexSymbol.cpp
===
--- lib/Index/IndexSymbol.cpp
+++ lib/Index/IndexSymbol.cpp
@@ -42,10 +42,10 @@
 
 static void checkForIBOutlets(const Decl *D, SymbolPropertySet ) {
   if (D->hasAttr()) {
-PropSet |= (unsigned)SymbolProperty::IBAnnotated;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
   } else if (D->hasAttr()) {
-PropSet |= (unsigned)SymbolProperty::IBAnnotated;
-PropSet |= (unsigned)SymbolProperty::IBOutletCollection;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBOutletCollection;
   }
 }
 
@@ -93,7 +93,7 @@
   Info.Lang = SymbolLanguage::C;
 
   if (isFunctionLocalSymbol(D)) {
-Info.Properties |= (unsigned)SymbolProperty::Local;
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Local;
   }
 
   if (const TagDecl *TD = dyn_cast(D)) {
@@ -118,17 +118,19 @@
   if (!CXXRec->isCLike()) {
 Info.Lang = SymbolLanguage::CXX;
 if (CXXRec->getDescribedClassTemplate()) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
 }
   }
 }
 
 if (isa(D)) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
 } else if (isa(D)) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
 }
 
   } else if (auto *VD = dyn_cast(D)) {
@@ -142,15 +144,17 @@
 
 if (isa(D)) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
 } else if (isa(D)) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
 } else if (VD->getDescribedVarTemplate()) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
 }
 
   } else {
@@ -181,7 +185,7 @@
   if (!ClsD)
 ClsD = cast(D)->getClassInterface();
   if (isUnitTestCase(ClsD))
-Info.Properties |= (unsigned)SymbolProperty::UnitTest;
+Info.Properties |= (SymbolPropertySet)SymbolProperty::UnitTest;
   break;
 }
 case Decl::ObjCProtocol:
@@ -198,7 +202,7 @@
   else
 ClsD = cast(D)->getClassInterface();
   if (isUnitTestCase(ClsD))
-Info.Properties |= 

[PATCH] D41471: [CMake][Fuchsia] Enable assertions

2017-12-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321316: [CMake][Fuchsia] Enable assertions (authored by 
phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41471?vs=127801=127943#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41471

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
  cfe/trunk/cmake/caches/Fuchsia.cmake


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -23,6 +23,7 @@
   set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
 endif()
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -13,6 +13,7 @@
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -23,6 +23,7 @@
   set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
 endif()
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -13,6 +13,7 @@
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321316 - [CMake][Fuchsia] Enable assertions

2017-12-21 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Dec 21 14:10:27 2017
New Revision: 321316

URL: http://llvm.org/viewvc/llvm-project?rev=321316=rev
Log:
[CMake][Fuchsia] Enable assertions

Enable assertions in both stages.
Release+Asserts is fast enough.
No need to let insanity through.

Patch By: mcgrathr

Reviewers: phosek

Reviewed By: phosek

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/cmake/caches/Fuchsia.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=321316=321315=321316=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Thu Dec 21 14:10:27 2017
@@ -23,6 +23,7 @@ if(APPLE)
   set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
 endif()
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")

Modified: cfe/trunk/cmake/caches/Fuchsia.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=321316=321315=321316=diff
==
--- cfe/trunk/cmake/caches/Fuchsia.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia.cmake Thu Dec 21 14:10:27 2017
@@ -13,6 +13,7 @@ set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")


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


Re: r321301 - [AArch64] Enable fp16 data type for the Builtin for AArch64 only.

2017-12-21 Thread Ahmed Bougacha via cfe-commits
On Thu, Dec 21, 2017 at 12:10 PM, Abderrazek Zaafrani via cfe-commits
 wrote:
> Author: az
> Date: Thu Dec 21 12:10:03 2017
> New Revision: 321301
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321301=rev
> Log:
> [AArch64] Enable fp16 data type for the Builtin for AArch64 only.
>
> Differential Revision: https:://reviews.llvm.org/D41360
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/CodeGen/arm_neon_intrinsics.c
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=321301=321300=321301=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 21 12:10:03 2017
> @@ -3334,10 +3334,10 @@ static Value *EmitTargetArchBuiltinExpr(
>case llvm::Triple::armeb:
>case llvm::Triple::thumb:
>case llvm::Triple::thumbeb:
> -return CGF->EmitARMBuiltinExpr(BuiltinID, E);
> +return CGF->EmitARMBuiltinExpr(BuiltinID, E, Arch);
>case llvm::Triple::aarch64:
>case llvm::Triple::aarch64_be:
> -return CGF->EmitAArch64BuiltinExpr(BuiltinID, E);
> +return CGF->EmitAArch64BuiltinExpr(BuiltinID, E, Arch);
>case llvm::Triple::x86:
>case llvm::Triple::x86_64:
>  return CGF->EmitX86BuiltinExpr(BuiltinID, E);
> @@ -3378,6 +3378,7 @@ Value *CodeGenFunction::EmitTargetBuilti
>
>  static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
>   NeonTypeFlags TypeFlags,
> + llvm::Triple::ArchType Arch,
>   bool V1Ty=false) {
>int IsQuad = TypeFlags.isQuad();
>switch (TypeFlags.getEltType()) {
> @@ -3388,7 +3389,12 @@ static llvm::VectorType *GetNeonType(Cod
>case NeonTypeFlags::Poly16:
>  return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
>case NeonTypeFlags::Float16:
> -return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
> +// FIXME: Only AArch64 backend can so far properly handle half types.
> +// Remove else part once ARM backend support for half is complete.
> +if (Arch == llvm::Triple::aarch64)
> +  return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
> +else
> +  return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));

Hey Abderrazek,

I don't think you need to pass 'Arch' around.  You're already in CGF,
which has a triple:
  CGF->getTarget().getTriple().getArch()
It is slightly different from what's passed in EmitTargetArchBuiltinExpr:
   CGF->getContext().getAuxTargetInfo()->getTriple().getArch()

though IIRC the 'aux target' is only different for GPU target offloading.

More importantly, should you check for:
  LangOpts.HalfArgsAndReturns
and:
  LangOpts.NativeHalfType
instead?

I think that mirrors the actual requirement.   -fnative-half-type is
disabled by default on ARM.  And on AArch64, always picking 'half'
makes -fnative-half-type mandatory.  I don't remember the
ramifications off the top of my head, but that seems like a larger
discussion to be had.

Thanks for taking a look!
-Ahmed
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r315984 - [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info

2017-12-21 Thread Alex L via cfe-commits
Hi,

This commit has caused a new regression in LLVM 6. I filed the following
PR: https://bugs.llvm.org/show_bug.cgi?id=35724 .
Could you please take a look?

Thanks,
Alex

On 17 October 2017 at 02:12, Ivan A. Kosarev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: kosarev
> Date: Tue Oct 17 02:12:13 2017
> New Revision: 315984
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315984=rev
> Log:
> [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with
> LValue base info
>
> Differential Revision: https://reviews.llvm.org/D38796
>
> Added:
> cfe/trunk/test/CodeGen/tbaa-cast.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.h
> cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
> cfe/trunk/lib/CodeGen/CodeGenTBAA.h
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGExpr.cpp?rev=315984=315983=315984=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 17 02:12:13 2017
> @@ -916,7 +916,8 @@ void CodeGenModule::EmitExplicitCastExpr
>  /// EmitPointerWithAlignment - Given an expression of pointer type, try to
>  /// derive a more accurate bound on the alignment of the pointer.
>  Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E,
> -  LValueBaseInfo
> *BaseInfo) {
> +  LValueBaseInfo
> *BaseInfo,
> +  TBAAAccessInfo
> *TBAAInfo) {
>// We allow this with ObjC object pointers because of fragile ABIs.
>assert(E->getType()->isPointerType() ||
>   E->getType()->isObjCObjectPointerType());
> @@ -936,20 +937,30 @@ Address CodeGenFunction::EmitPointerWith
>  if (PtrTy->getPointeeType()->isVoidType())
>break;
>
> -LValueBaseInfo InnerInfo;
> -Address Addr = EmitPointerWithAlignment(CE->getSubExpr(),
> );
> -if (BaseInfo) *BaseInfo = InnerInfo;
> -
> -// If this is an explicit bitcast, and the source l-value is
> -// opaque, honor the alignment of the casted-to type.
> -if (isa(CE) &&
> -InnerInfo.getAlignmentSource() != AlignmentSource::Decl) {
> -  LValueBaseInfo ExpInfo;
> +LValueBaseInfo InnerBaseInfo;
> +TBAAAccessInfo InnerTBAAInfo;
> +Address Addr = EmitPointerWithAlignment(CE->getSubExpr(),
> +,
> +);
> +if (BaseInfo) *BaseInfo = InnerBaseInfo;
> +if (TBAAInfo) *TBAAInfo = InnerTBAAInfo;
> +
> +if (isa(CE)) {
> +  LValueBaseInfo TargetTypeBaseInfo;
> +  TBAAAccessInfo TargetTypeTBAAInfo;
>CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(),
> -   );
> -  if (BaseInfo)
> -BaseInfo->mergeForCast(ExpInfo);
> -  Addr = Address(Addr.getPointer(), Align);
> +
>  ,
> +
>  );
> +  if (TBAAInfo)
> +*TBAAInfo = CGM.mergeTBAAInfoForCast(*TBAAInfo,
> + TargetTypeTBAAInfo);
> +  // If the source l-value is opaque, honor the alignment of the
> +  // casted-to type.
> +  if (InnerBaseInfo.getAlignmentSource() !=
> AlignmentSource::Decl) {
> +if (BaseInfo)
> +  BaseInfo->mergeForCast(TargetTypeBaseInfo);
> +Addr = Address(Addr.getPointer(), Align);
> +  }
>  }
>
>  if (SanOpts.has(SanitizerKind::CFIUnrelatedCast) &&
> @@ -969,12 +980,13 @@ Address CodeGenFunction::EmitPointerWith
>
>  // Array-to-pointer decay.
>  case CK_ArrayToPointerDecay:
> -  return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo);
> +  return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo,
> TBAAInfo);
>
>  // Derived-to-base conversions.
>  case CK_UncheckedDerivedToBase:
>  case CK_DerivedToBase: {
> -  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(),
> BaseInfo);
> +  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo,
> +  TBAAInfo);
>auto Derived = CE->getSubExpr()->getType()->
> getPointeeCXXRecordDecl();
>return GetAddressOfBaseClass(Addr, Derived,
> CE->path_begin(), CE->path_end(),
> @@ -994,6 +1006,7 @@ Address CodeGenFunction::EmitPointerWith
>  if (UO->getOpcode() == UO_AddrOf) {
>LValue LV = EmitLValue(UO->getSubExpr());
>if (BaseInfo) *BaseInfo = LV.getBaseInfo();
> +  if (TBAAInfo) 

[PATCH] D41363: [clang-tidy] Adding Fuchsia checker for overloaded operators

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

Are the Fuchsia library headers intended to also comply with this rule? I 
notice there's mention of a unique_ptr class, and I can't imagine that working 
without overloading more operators than just assignment. Perhaps this check 
should not be triggered for system headers?




Comment at: docs/clang-tidy/checks/fuchsia-overloaded-operator.rst:15
+
+  B =(const B& other);  // No warning
+  B =(B &) // No warning

`&` should bind to `other` here.



Comment at: test/clang-tidy/fuchsia-overloaded-operator.cpp:11
+public:
+  B =(const B& other);
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' 
[fuchsia-overloaded-operator]

The `&` should bind to `other`. Same below. Also, the param identifier should 
start with a capital letter (also same below).


https://reviews.llvm.org/D41363



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


[PATCH] D41413: [scudo] Add -fsanitize=scudo option to Fuchsia.

2017-12-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321314: [scudo] Add -fsanitize=scudo option to Fuchsia 
(authored by phosek, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D41413

Files:
  lib/Driver/ToolChains/Fuchsia.cpp
  test/Driver/fuchsia.c


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,5 +280,6 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Scudo;
   return Res;
 }
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -79,3 +79,20 @@
 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
 // CHECK-ASAN-SHARED: "{{.*[/\\]}}libclang_rt.asan-x86_64.so"
 // CHECK-ASAN-SHARED-NOT: "{{.*[/\\]}}libclang_rt.asan-preinit-x86_64.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-X86
+// CHECK-SCUDO-X86: "-fsanitize=scudo"
+// CHECK-SCUDO-X86: "-pie"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64
+// CHECK-SCUDO-AARCH64: "-fsanitize=scudo"
+// CHECK-SCUDO-AARCH64: "-pie"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
+// CHECK-SCUDO-SHARED: "-fsanitize=scudo"


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,5 +280,6 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Scudo;
   return Res;
 }
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -79,3 +79,20 @@
 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
 // CHECK-ASAN-SHARED: "{{.*[/\\]}}libclang_rt.asan-x86_64.so"
 // CHECK-ASAN-SHARED-NOT: "{{.*[/\\]}}libclang_rt.asan-preinit-x86_64.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-X86
+// CHECK-SCUDO-X86: "-fsanitize=scudo"
+// CHECK-SCUDO-X86: "-pie"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64
+// CHECK-SCUDO-AARCH64: "-fsanitize=scudo"
+// CHECK-SCUDO-AARCH64: "-pie"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
+// CHECK-SCUDO-SHARED: "-fsanitize=scudo"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321314 - [scudo] Add -fsanitize=scudo option to Fuchsia

2017-12-21 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Dec 21 14:04:31 2017
New Revision: 321314

URL: http://llvm.org/viewvc/llvm-project?rev=321314=rev
Log:
[scudo] Add -fsanitize=scudo option to Fuchsia

Apparently the -fsanitize flag hadn't been added for Scudo upstream yet.

Patch By: flowerhack

Reviewers: cryptoad, alekseyshl, mcgrathr, phosek

Reviewed By: mcgrathr, phosek

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.c

Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=321314=321313=321314=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Thu Dec 21 14:04:31 2017
@@ -280,5 +280,6 @@ SanitizerMask Fuchsia::getSupportedSanit
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Scudo;
   return Res;
 }

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=321314=321313=321314=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Thu Dec 21 14:04:31 2017
@@ -79,3 +79,20 @@
 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
 // CHECK-ASAN-SHARED: "{{.*[/\\]}}libclang_rt.asan-x86_64.so"
 // CHECK-ASAN-SHARED-NOT: "{{.*[/\\]}}libclang_rt.asan-preinit-x86_64.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-X86
+// CHECK-SCUDO-X86: "-fsanitize=scudo"
+// CHECK-SCUDO-X86: "-pie"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64
+// CHECK-SCUDO-AARCH64: "-fsanitize=scudo"
+// CHECK-SCUDO-AARCH64: "-pie"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
+// CHECK-SCUDO-SHARED: "-fsanitize=scudo"


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


r321312 - [AST] Incorrectly qualified unscoped enumeration as template actual parameter.

2017-12-21 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Dec 21 13:47:22 2017
New Revision: 321312

URL: http://llvm.org/viewvc/llvm-project?rev=321312=rev
Log:
[AST] Incorrectly qualified unscoped enumeration as template actual parameter.

An unscoped enumeration used as template argument, should not have any
qualified information about its enclosing scope, as its visibility is
global.

In the case of scoped enumerations, they must include information
about their enclosing scope.

Patch by Carlos Alberto Enciso!

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

Added:
cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/Modules/odr.cpp
cfe/trunk/test/SemaCXX/return-noreturn.cpp
cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp
cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=321312=321311=321312=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Dec 21 13:47:22 2017
@@ -1548,7 +1548,10 @@ void NamedDecl::printQualifiedName(raw_o
   // enumerator is declared in the scope that immediately contains
   // the enum-specifier. Each scoped enumerator is declared in the
   // scope of the enumeration.
-  if (ED->isScoped() || ED->getIdentifier())
+  // For the case of unscoped enumerator, do not include in the qualified
+  // name any information about its enum enclosing scope, as is visibility
+  // is global.
+  if (ED->isScoped())
 OS << *ED;
   else
 continue;

Modified: cfe/trunk/test/Modules/odr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr.cpp?rev=321312=321311=321312=diff
==
--- cfe/trunk/test/Modules/odr.cpp (original)
+++ cfe/trunk/test/Modules/odr.cpp Thu Dec 21 13:47:22 2017
@@ -18,6 +18,6 @@ int x = f() + g();
 // expected-note@a.h:3 {{declaration of 'f' does not match}}
 // expected-note@a.h:1 {{definition has no member 'm'}}
 
-// expected-error@b.h:5 {{'E::e2' from module 'b' is not present in definition 
of 'E' in module 'a'}}
+// expected-error@b.h:5 {{'e2' from module 'b' is not present in definition of 
'E' in module 'a'}}
 // expected-error@b.h:3 {{'Y::f' from module 'b' is not present in definition 
of 'Y' in module 'a'}}
 // expected-error@b.h:2 {{'Y::m' from module 'b' is not present in definition 
of 'Y' in module 'a'}}

Modified: cfe/trunk/test/SemaCXX/return-noreturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return-noreturn.cpp?rev=321312=321311=321312=diff
==
--- cfe/trunk/test/SemaCXX/return-noreturn.cpp (original)
+++ cfe/trunk/test/SemaCXX/return-noreturn.cpp Thu Dec 21 13:47:22 2017
@@ -143,7 +143,7 @@ template  int PR9
 } // expected-warning {{control reaches end of non-void function}}
 
 void PR9412_f() {
-PR9412_t(); // expected-note {{in instantiation of function 
template specialization 'PR9412_t' requested 
here}}
+PR9412_t(); // expected-note {{in instantiation of function 
template specialization 'PR9412_t' requested here}}
 }
 
 struct NoReturn {

Modified: cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp?rev=321312=321311=321312=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp Thu Dec 21 13:47:22 
2017
@@ -13,9 +13,9 @@ template 
 void foo();
   
 void test() {
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo();
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo<(NamedEnum)1>();
   // CHECK: template<> void foo<2>()
   NamedEnumNS::foo<(NamedEnum)2>();

Added: cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp?rev=321312=auto
==
--- cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp (added)
+++ cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp Thu Dec 21 
13:47:22 2017
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-print %s -std=c++11 | FileCheck %s
+
+// Make sure that for template value arguments that are unscoped enumerators,
+// no qualified enum information is included in their name, as their visibility
+// is global. In the case of scoped enumerators, they must include information
+// about their enum enclosing scope.
+
+enum E1 { e1 };
+template struct tmpl_1 {};
+// 

[PATCH] D39239: [AST] Incorrectly qualified unscoped enumeration as template actual parameter.

2017-12-21 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321312: [AST] Incorrectly qualified unscoped enumeration as 
template actual parameter. (authored by probinson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D39239?vs=120066=127937#toc

Repository:
  rC Clang

https://reviews.llvm.org/D39239

Files:
  lib/AST/Decl.cpp
  test/Modules/odr.cpp
  test/SemaCXX/return-noreturn.cpp
  test/SemaTemplate/temp_arg_enum_printing.cpp
  test/SemaTemplate/temp_arg_enum_printing_more.cpp
  unittests/AST/NamedDeclPrinterTest.cpp

Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -143,7 +143,7 @@
   ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
 "enum X { A };",
 "A",
-"X::A"));
+"A"));
 }
 
 TEST(NamedDeclPrinter, TestScopedNamedEnum) {
@@ -164,7 +164,7 @@
   ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
 "class X { enum Y { A }; };",
 "A",
-"X::Y::A"));
+"X::A"));
 }
 
 TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) {
Index: test/SemaTemplate/temp_arg_enum_printing_more.cpp
===
--- test/SemaTemplate/temp_arg_enum_printing_more.cpp
+++ test/SemaTemplate/temp_arg_enum_printing_more.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-print %s -std=c++11 | FileCheck %s
+
+// Make sure that for template value arguments that are unscoped enumerators,
+// no qualified enum information is included in their name, as their visibility
+// is global. In the case of scoped enumerators, they must include information
+// about their enum enclosing scope.
+
+enum E1 { e1 };
+template struct tmpl_1 {};
+// CHECK: template<> struct tmpl_1
+tmpl_1 TMPL_1;  // Name must be 'e1'.
+
+namespace nsp_1 { enum E2 { e2 }; }
+template struct tmpl_2 {};
+// CHECK: template<> struct tmpl_2
+tmpl_2 TMPL_2;   // Name must be 'nsp_1::e2'.
+
+enum class E3 { e3 };
+template struct tmpl_3 {};
+// CHECK: template<> struct tmpl_3
+tmpl_3 TMPL_3;  // Name must be 'E3::e3'.
+
+namespace nsp_2 { enum class E4 { e4 }; }
+template struct tmpl_4 {};
+// CHECK: template<> struct tmpl_4
+tmpl_4 TMPL_4;   // Name must be 'nsp_2::E4::e4'.
Index: test/SemaTemplate/temp_arg_enum_printing.cpp
===
--- test/SemaTemplate/temp_arg_enum_printing.cpp
+++ test/SemaTemplate/temp_arg_enum_printing.cpp
@@ -13,9 +13,9 @@
 void foo();
   
 void test() {
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo();
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo<(NamedEnum)1>();
   // CHECK: template<> void foo<2>()
   NamedEnumNS::foo<(NamedEnum)2>();
Index: test/SemaCXX/return-noreturn.cpp
===
--- test/SemaCXX/return-noreturn.cpp
+++ test/SemaCXX/return-noreturn.cpp
@@ -143,7 +143,7 @@
 } // expected-warning {{control reaches end of non-void function}}
 
 void PR9412_f() {
-PR9412_t(); // expected-note {{in instantiation of function template specialization 'PR9412_t' requested here}}
+PR9412_t(); // expected-note {{in instantiation of function template specialization 'PR9412_t' requested here}}
 }
 
 struct NoReturn {
Index: test/Modules/odr.cpp
===
--- test/Modules/odr.cpp
+++ test/Modules/odr.cpp
@@ -18,6 +18,6 @@
 // expected-note@a.h:3 {{declaration of 'f' does not match}}
 // expected-note@a.h:1 {{definition has no member 'm'}}
 
-// expected-error@b.h:5 {{'E::e2' from module 'b' is not present in definition of 'E' in module 'a'}}
+// expected-error@b.h:5 {{'e2' from module 'b' is not present in definition of 'E' in module 'a'}}
 // expected-error@b.h:3 {{'Y::f' from module 'b' is not present in definition of 'Y' in module 'a'}}
 // expected-error@b.h:2 {{'Y::m' from module 'b' is not present in definition of 'Y' in module 'a'}}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1548,7 +1548,10 @@
   // enumerator is declared in the scope that immediately contains
   // the enum-specifier. Each scoped enumerator is declared in the
   // scope of the enumeration.
-  if (ED->isScoped() || ED->getIdentifier())
+  // For the case of unscoped enumerator, do not include in the qualified
+  // name any information about its enum enclosing scope, as is visibility
+  // is global.
+  if (ED->isScoped())
 OS << *ED;
   else
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread Alex L via cfe-commits
On 21 December 2017 at 12:34, James Y Knight  wrote:

> I totally agree with moving towards eliminating the -m-version-min
> flags, it's much better to put it in the target, and will clean up a lot of
> cruft in the driver, eventually.
>
> Now -- we (or anyone else who runs into this) can simply start specifying
> the version in both locations ("-target x86_64-apple-ios10
> -mios-simulator-version-min=10"), so as to work with both new and old
> clang, and be closer to the ultimate goal of having only -target. That's an
> overall nicer workaround to suggest than switching to -darwin. But, yea,
> there's no need for *temporary* patch to fix things just for us.
>
> However, I do not understand why you're against committing the patch you
> mention as option #2 -- that seems like it'd be best for all users, by
> preserving compatibility with existing command-lines. So, I'd still like
> that change to be committed, permanently, not temporarily. I'm sure we
> can't be the only ones running clang like "-target x86_64-apple-ios
> -mios-simulator-version-min=10", and it seems unfortunate and unnecessary
> to break that, even if it can be worked around.
>
> In the future, I'd hope the -m-version-min arguments can be deprecated
> more and more -- warning whenever you use them to modify the platform or
> version at all, rather just on specification conflict; then, warn anytime
> you use them at all; then, remove them. But in the meantime, it seems
> strictly better to preserve compatibility, don't you think?
>

+ Duncan

Thanks, I think your argument is convincing. I think I will commit the
change that you're proposing in the near future if there are no further
objections.



>
>
>
> On Dec 21, 2017 2:11 PM, "Alex L"  wrote:
>
> Thanks for raising your concerns.
>
> We decided to avoid -m-version-min flag in favor of -target to
> simplify the driver logic and to encourage the adoption of -target. Now
> after r321145 we only warn about -m-version-min flag when the OS
> version specified in it is different to the OS version specified in target,
> or when target has no OS version.
>
> There are two possible solutions here:
> 1) You can still use -target with -mios-simulator-version-min as before
> but you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
> version specified by  '-mios-simulator-version-min' is used.
> 2) I also do have a patch that implements the logic that you propose (use
> the OS version in -m-version-min flag if target has none). If you
> believe that the first solution is not suitable for your code then I can
> commit it. At the same time I believe that we would rather not use this
> patch, but if it's urgent for your projects then maybe I can land it now
> and then we can establish some sort of timeline for when it can be reverted?
>
> Thanks,
> Alex
>
>
> On 21 December 2017 at 08:00, James Y Knight  wrote:
>
>> I think if a version number isn't explicitly specified in the -target
>> value, the value from -m-version-min ought to still be used, as
>> it was before.
>>
>> Currently, clang will ignore the -m-version-min version number
>> if the target has a particular OS specified, even if it has no version
>> number as part of it.
>>
>> (We should be able to workaround this change backwards-compatibly by
>> specifying in both the -target argument and in the -m-version-min
>> arguments, but I do think the behavior should be fixed.)
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40983: Generate Libclang invocation reproducers using a new -cc1gen-reproducer option

2017-12-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 127935.
arphaman marked an inline comment as done.
arphaman added a comment.

Address review comments


https://reviews.llvm.org/D40983

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Index/create-libclang-completion-reproducer.c
  test/Index/create-libclang-parsing-reproducer.c
  tools/driver/CMakeLists.txt
  tools/driver/cc1gen_reproducer_main.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -205,6 +205,8 @@
 void *MainAddr);
 extern int cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
+extern int cc1gen_reproducer_main(ArrayRef Argv,
+  const char *Argv0, void *MainAddr);
 
 static void insertTargetAndModeArgs(const ParsedClangName ,
 SmallVectorImpl ,
@@ -309,6 +311,8 @@
 return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
   if (Tool == "as")
 return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
+  if (Tool == "gen-reproducer")
+return cc1gen_reproducer_main(argv.slice(2), argv[0], GetExecutablePathVP);
 
   // Reject unknown tools.
   llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n";
Index: tools/driver/cc1gen_reproducer_main.cpp
===
--- /dev/null
+++ tools/driver/cc1gen_reproducer_main.cpp
@@ -0,0 +1,196 @@
+//===-- cc1gen_reproducer_main.cpp - Clang reproducer generator  --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This is the entry point to the clang -cc1gen-reproducer functionality, which
+// generates reproducers for invocations for clang-based tools.
+//
+//===--===//
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+namespace {
+
+struct UnsavedFileHash {
+  std::string Name;
+  std::string MD5;
+};
+
+struct ClangInvocationInfo {
+  std::string Toolchain;
+  std::string LibclangOperation;
+  std::string LibclangOptions;
+  std::vector Arguments;
+  std::vector InvocationArguments;
+  std::vector UnsavedFileHashes;
+  bool Dump = false;
+};
+
+} // end anonymous namespace
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(UnsavedFileHash)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  static void mapping(IO , UnsavedFileHash ) {
+IO.mapRequired("name", Info.Name);
+IO.mapRequired("md5", Info.MD5);
+  }
+};
+
+template <> struct MappingTraits {
+  static void mapping(IO , ClangInvocationInfo ) {
+IO.mapRequired("toolchain", Info.Toolchain);
+IO.mapOptional("libclang.operation", Info.LibclangOperation);
+IO.mapOptional("libclang.opts", Info.LibclangOptions);
+IO.mapRequired("args", Info.Arguments);
+IO.mapOptional("invocation-args", Info.InvocationArguments);
+IO.mapOptional("unsaved_file_hashes", Info.UnsavedFileHashes);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
+static std::string generateReproducerMetaInfo(const ClangInvocationInfo ) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  OS << '{';
+  bool NeedComma = false;
+  auto EmitKey = [&](StringRef Key) {
+if (NeedComma)
+  OS << ", ";
+NeedComma = true;
+OS << '"' << Key << "\": ";
+  };
+  auto EmitStringKey = [&](StringRef Key, StringRef Value) {
+if (Value.empty())
+  return;
+EmitKey(Key);
+OS << '"' << Value << '"';
+  };
+  EmitStringKey("libclang.operation", Info.LibclangOperation);
+  EmitStringKey("libclang.opts", Info.LibclangOptions);
+  if (!Info.InvocationArguments.empty()) {
+EmitKey("invocation-args");
+OS << '[';
+for (const auto  : llvm::enumerate(Info.InvocationArguments)) {
+  if (Arg.index())
+OS << ',';
+  OS << '"' << Arg.value() << '"';
+}
+OS << ']';
+  }
+  OS << '}';
+  // FIXME: Compare unsaved file hashes and report mismatch in the reproducer.
+  if (Info.Dump)
+llvm::outs() << "REPRODUCER METAINFO: " << OS.str() << "\n";
+  return std::move(OS.str());
+}
+
+/// Generates a reproducer for a set of arguments from a specific invocation.
+static llvm::Optional
+generateReproducerForInvocationArguments(ArrayRef Argv,
+

[PATCH] D40983: Generate Libclang invocation reproducers using a new -cc1gen-reproducer option

2017-12-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked 2 inline comments as done.
arphaman added a comment.

In https://reviews.llvm.org/D40983#958809, @bruno wrote:

> Hi Alex,
>
> Thanks for improving this.
>
> - Instead of adding `-cc1gen-reproducer`, why can't you run that through 
> `-cc1` and have a flag similar to `-###`, which just prints the reproducer 
> line?


It would be difficult to add this logic to the regular `-cc1`, as it would need 
to construct a real compiler invocation on top of the pseudo one which takes 
the libclang invocation file (because it has to load the actual compiler 
arguments from the libclang file). This would be difficult and quite disruptive 
to the code in the cc1 driver and the compiler invocation. The approach in this 
patch is much simpler to implement and maintain, and does not disrupt the code 
in the `cc1` driver. This patch makes it more of a tool rather than a clang 
driver invocation.

> - I didn't  understand how you can use the final output information, can you 
> give an example to illustrate?

Given a sample output like:

REPRODUCER:
{
 "files":["/tmp/a.c","/tmp/a.sh"]
}

The tool's client (also a libclang client) will parse the JSON object with the 
files that make up the reproducer. It will then be able to do whatever it needs 
with those specific files.




Comment at: include/clang/Driver/Driver.h:394
+  struct CompilationDiagnosticReport {
+std::vector TemporaryFiles;
+  };

bruno wrote:
> I assume the number of temporary files are usually small, can you switch to 
> SmallVector here?
Yep.


Repository:
  rC Clang

https://reviews.llvm.org/D40983



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


[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: aaron.ballman, rsmith, smeenai, rjmccall, rnk, 
mclow.lists.
lebedev.ri added a project: clang.

The diagnostic was mostly introduced in https://reviews.llvm.org/D38101 by me, 
as a reaction to wasting a lot of time, see mail 
.
However, the diagnostic is pretty dumb. While it works with no false-positives,
there are some questionable cases that are diagnosed when one would argue that 
they should not be.

The common complaint is that it diagnoses the comparisons between an `int` and
`long` when compiling for a 32-bit target as tautological, but not when
compiling for 64-bit targets. The underlying problem is obvious: data model.
In most cases, 64-bit target is `LP64` (`int` is 32-bit, `long` and pointer are
64-bit), and the 32-bit target is `ILP32` (`int`, `long`, and pointer are 
32-bit).

I.e. the common pattern is: (pseudocode)

  #include 
  #include 
  int main() {
using T1 = long;
using T2 = int;
  
T1 r;
if (r < std::numeric_limits::min()) {}
if (r > std::numeric_limits::max()) {}
  }

As an example, https://reviews.llvm.org/D39149 was trying to fix this 
diagnostic in libc++, and it was not well-received.

This *could* be "fixed", by changing the diagnostics logic to something like
`if the types of the values being compared are different, but are of the same 
size, then do diagnose`,
and i even attempted to do so in https://reviews.llvm.org/D39462, but as 
@rjmccall rightfully commented,
that implementation is incomplete to say the least.

So to stop causing trouble, and avoid contaminating upcoming release, lets do 
this workaround:

- disable `warn_tautological_constant_compare` by default, make sure it is not 
part of `-Wall`

  FIXME: it appears `warn_unsigned_enum_always_true_comparison` also got 
disabled by default, which is not intentional. Do we want that?
- Add `-Wtautological-constant-compare` into `-Wextra`.


Repository:
  rC Clang

https://reviews.llvm.org/D41512

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-constant-enum-compare.c
  test/SemaCXX/compare.cpp


Index: test/SemaCXX/compare.cpp
===
--- test/SemaCXX/compare.cpp
+++ test/SemaCXX/compare.cpp
@@ -1,7 +1,7 @@
 // Force x86-64 because some of our heuristics are actually based
 // on integer sizes.
 
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify 
-Wsign-compare -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify 
-Wsign-compare -Wtautological-constant-compare -std=c++11 %s
 
 int test0(long a, unsigned long b) {
   enum EnumA {A};
Index: test/Sema/tautological-constant-enum-compare.c
===
--- test/Sema/tautological-constant-enum-compare.c
+++ test/Sema/tautological-constant-enum-compare.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-verify %s
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-Wtautological-constant-compare -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED 
-Wtautological-constant-compare -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-DSILENCE -Wno-tautological-constant-compare -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -DSILENCE 
-Wno-tautological-constant-compare -verify %s
 
Index: test/Sema/tautological-constant-compare.c
===
--- test/Sema/tautological-constant-compare.c
+++ test/Sema/tautological-constant-compare.c
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wno-tautological-constant-compare -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify -x 
c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wno-tautological-constant-compare -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wtautological-constant-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wtautological-constant-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple 

[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

2017-12-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/AST/Type.h:1152
+NTFK_Struct,  // non-trivial C struct.
+NTFK_Array// array that has non-trivial elements.
+  };

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > We don't actually distinguish arrays in DestructionKind.  Is it important 
> > > here?  You can't actually do anything with that information.
> > > 
> > > Regarding your naming question, I wonder if it would be useful to just 
> > > invent a new term here, something meaning "non-trivial" but without the 
> > > C++ baggage.  Maybe just "PrimitiveCopyKind", with the understanding that 
> > > C++ can never do a "primitive" copy?  And for consistency with 
> > > DestructionKind, maybe you should lowercase the second words.
> > > 
> > > I'm not sure how isNonTrivialToCopy is supposed to be used.  Where does 
> > > the function come from?  And why is a context required when it isn't 
> > > required for isDestructedType?
> > Enum NonTrivialCopyKind and isNonTrivialToCopy() are used just to 
> > distinguish the different types of fields in a C struct. Currently, there 
> > are four types that are handled by visitField functions in 
> > CGNonTrivialStruct.cpp:
> > 
> > - struct field
> > - array field
> > - __strong field
> > - trivial field that can be copied using memcpy
> > 
> > I thought using enums would make the code easier to read, but of course 
> > it's possible to remove them and instead just check the field types calling 
> > functions like getAsArrayType or getAs. ASTContext is passed to 
> > isNonTrivialToCopy so that it can call ASTContext::getAsArrayType to 
> > determine whether the type is an array. Maybe there is another way to 
> > detect an array that doesn't require ASTContext?
> > 
> > As for the naming, PrimitiveCopyKind seems find if we want to distinguish 
> > it from C++ non-trivial classes (I don't have a better name). If we are 
> > going to call non-trivial C structs primitiveCopyKind, what should we call 
> > the C structs that are trivial (those that can be copied using memcpy)?
> I think "trivial" is a reasonable kind of primitive-copy semantics.  
> Basically, we're saying that all complete object types other than non-trivial 
> C++ types have some sort of primitive-copy semantics, and this enum tells us 
> what those semantics are.
> 
> DestructionKind has to deal with arrays as well, but it does so by just 
> reporting the appropriate value for the underlying element type without 
> mentioning that it's specifically an *array* of the type.  I think that's a 
> reasonable design, since most places do not need to distinguish arrays from 
> non-arrays.  IRGen does, but only when you're actually finally emitting code; 
> prior to that (when e.g. deciding that a field is non-trivial to copy) you 
> can just use the enum value.
> 
> You can do without getAsArrayType the same way that isDestructedType() does: 
> the more complex operation is only necessary in order to preserve qualifiers 
> on the element type, but that's unnecessary for this operation because the 
> array type itself is considered to have the same qualifiers as its element 
> type.  That is, you can ask the original type whether it's 
> __strong/__weak-qualified without having to specifically handle array types, 
> and once you've done all of those queries, you can use the "unsafe" 
> operations to drill down to the element type because you no longer care about 
> qualification.
So QualType::hasNonTrivialToDefaultInitializeStruct should be renamed to 
QualType::hasPrimitiveDefaultInitializeStruct and 
RecordDecl::isNonTrivialToPrimitiveDefaultInitialize to 
RecordDecl::isPrimitiveDefaultInitialize, for example?

Also, I realized that, after I made the changes that removed the NonTrivial 
flags from RecordDecl, CGNonTrivialStruct.cpp is the only user of enum 
NonTrivialCopyKind and the following methods of QualType 
(Sema::isValidVarArgType calls nonTrivialToDestroy, but it should call methods 
like hasNonTrivialToDestroyStruct that detect non-trivial C structs instead):

nonTrivialToDefaultInitialize
nonTrivialToCopy
nonTrivialToDestructiveMove
nonTrivialToDestroy

Maybe we should make these enums and functions local to CGNonTrivialStruct.cpp 
to avoid adding something that is not used outside CGNonTrivialStruct.cpp?


https://reviews.llvm.org/D41228



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


r321306 - Revert "[CodeGen] Fix crash when a function taking transparent union is redeclared."

2017-12-21 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Dec 21 12:52:59 2017
New Revision: 321306

URL: http://llvm.org/viewvc/llvm-project?rev=321306=rev
Log:
Revert "[CodeGen] Fix crash when a function taking transparent union is 
redeclared."

This reverts commit r321296. It caused performance regressions
FAIL: imp.execution_time
FAIL: 2007-01-04-KNR-Args.execution_time
FAIL: sse_expandfft.execution_time
FAIL: sse_stepfft.execution_time


Removed:
cfe/trunk/test/CodeGen/transparent-union-redecl.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/kr-func-promote.c
cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=321306=321305=321306=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Dec 21 12:52:59 2017
@@ -2317,7 +2317,7 @@ void CodeGenFunction::EmitFunctionProlog
 
   // If we have the trivial case, handle it with no muss and fuss.
   if (!isa(ArgI.getCoerceToType()) &&
-  ArgI.getCoerceToType() == ConvertType(Arg->getType()) &&
+  ArgI.getCoerceToType() == ConvertType(Ty) &&
   ArgI.getDirectOffset() == 0) {
 assert(NumIRArgs == 1);
 llvm::Value *V = FnArgs[FirstIRArg];
@@ -2414,8 +2414,8 @@ void CodeGenFunction::EmitFunctionProlog
 break;
   }
 
-  Address Alloca = CreateMemTemp(
-  Arg->getType(), getContext().getDeclAlign(Arg), Arg->getName());
+  Address Alloca = CreateMemTemp(Ty, getContext().getDeclAlign(Arg),
+ Arg->getName());
 
   // Pointer to store into.
   Address Ptr = emitAddressAtOffset(*this, Alloca, ArgI);
@@ -2461,9 +2461,9 @@ void CodeGenFunction::EmitFunctionProlog
   }
 
   // Match to what EmitParmDecl is expecting for this type.
-  if (CodeGenFunction::hasScalarEvaluationKind(Arg->getType())) {
+  if (CodeGenFunction::hasScalarEvaluationKind(Ty)) {
 llvm::Value *V =
-EmitLoadOfScalar(Alloca, false, Arg->getType(), 
Arg->getLocStart());
+  EmitLoadOfScalar(Alloca, false, Ty, Arg->getLocStart());
 if (isPromoted)
   V = emitArgumentDemotion(*this, Arg, V);
 ArgVals.push_back(ParamValue::forDirect(V));

Modified: cfe/trunk/test/CodeGen/kr-func-promote.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/kr-func-promote.c?rev=321306=321305=321306=diff
==
--- cfe/trunk/test/CodeGen/kr-func-promote.c (original)
+++ cfe/trunk/test/CodeGen/kr-func-promote.c Thu Dec 21 12:52:59 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck 
%s
-// CHECK: i32 @a(i32
+// CHECK: i32 @a(i32)
 
 int a();
 int a(x) short x; {return x;}

Removed: cfe/trunk/test/CodeGen/transparent-union-redecl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union-redecl.c?rev=321305=auto
==
--- cfe/trunk/test/CodeGen/transparent-union-redecl.c (original)
+++ cfe/trunk/test/CodeGen/transparent-union-redecl.c (removed)
@@ -1,36 +0,0 @@
-// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
-
-// Test that different order of declarations is acceptable and that
-// implementing different redeclarations is acceptable.
-// rdar://problem/34949329
-
-typedef union {
-  int i;
-  float f;
-} TU __attribute__((transparent_union));
-
-// CHECK-LABEL: define void @f0(i32 %tu.coerce)
-// CHECK: %tu = alloca %union.TU, align 4
-// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 
0, i32 0
-// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
-void f0(TU tu) {}
-void f0(int i);
-
-// CHECK-LABEL: define void @f1(i32 %tu.coerce)
-// CHECK: %tu = alloca %union.TU, align 4
-// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 
0, i32 0
-// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
-void f1(int i);
-void f1(TU tu) {}
-
-// CHECK-LABEL: define void @f2(i32 %i)
-// CHECK: %i.addr = alloca i32, align 4
-// CHECK: store i32 %i, i32* %i.addr, align 4
-void f2(TU tu);
-void f2(int i) {}
-
-// CHECK-LABEL: define void @f3(i32 %i)
-// CHECK: %i.addr = alloca i32, align 4
-// CHECK: store i32 %i, i32* %i.addr, align 4
-void f3(int i) {}
-void f3(TU tu);

Modified: 
cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
URL: 

r321304 - Don't produce redundant parentheses warning for "A (::B); " and the like.

2017-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 21 12:50:39 2017
New Revision: 321304

URL: http://llvm.org/viewvc/llvm-project?rev=321304=rev
Log:
Don't produce redundant parentheses warning for "A (::B);" and the like.

The parentheses here are not redundant as they affect the binding of the
'::' token.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Parser/cxx-decl.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=321304=321303=321304=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Dec 21 12:50:39 2017
@@ -3137,10 +3137,14 @@ static void warnAboutRedundantParens(Sem
   (T->isRecordType() || T->isDependentType()) &&
   D.getDeclSpec().getTypeQualifiers() == 0 && D.isFirstDeclarator();
 
+  bool StartsWithDeclaratorId = true;
   for (auto  : D.type_objects()) {
 switch (C.Kind) {
-case DeclaratorChunk::Pointer:
 case DeclaratorChunk::Paren:
+  if ( == )
+continue;
+case DeclaratorChunk::Pointer:
+  StartsWithDeclaratorId = false;
   continue;
 
 case DeclaratorChunk::Array:
@@ -3154,6 +3158,7 @@ static void warnAboutRedundantParens(Sem
   // We assume that something like 'T () = y;' is highly likely to not
   // be intended to be a temporary object.
   CouldBeTemporaryObject = false;
+  StartsWithDeclaratorId = false;
   continue;
 
 case DeclaratorChunk::Function:
@@ -3166,6 +3171,7 @@ static void warnAboutRedundantParens(Sem
 case DeclaratorChunk::Pipe:
   // These cannot appear in expressions.
   CouldBeTemporaryObject = false;
+  StartsWithDeclaratorId = false;
   continue;
 }
   }
@@ -3186,6 +3192,18 @@ static void warnAboutRedundantParens(Sem
   SourceRange ParenRange(Paren.Loc, Paren.EndLoc);
 
   if (!CouldBeTemporaryObject) {
+// If we have A (::B), the parentheses affect the meaning of the program.
+// Suppress the warning in that case. Don't bother looking at the DeclSpec
+// here: even (e.g.) "int ::x" is visually ambiguous even though it's
+// formally unambiguous.
+if (StartsWithDeclaratorId && D.getCXXScopeSpec().isValid()) {
+  for (NestedNameSpecifier *NNS = D.getCXXScopeSpec().getScopeRep(); NNS;
+   NNS = NNS->getPrefix()) {
+if (NNS->getKind() == NestedNameSpecifier::Global)
+  return;
+  }
+}
+
 S.Diag(Paren.Loc, diag::warn_redundant_parens_around_declarator)
 << ParenRange << FixItHint::CreateRemoval(Paren.Loc)
 << FixItHint::CreateRemoval(Paren.EndLoc);

Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=321304=321303=321304=diff
==
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Thu Dec 21 12:50:39 2017
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors 
-fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors 
-fcxx-exceptions -fexceptions -std=c++98 %s
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors 
-fcxx-exceptions -fexceptions -std=c++11 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens 
-pedantic-errors -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens 
-pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens 
-pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s
 
 const char const *x10; // expected-error {{duplicate 'const' declaration 
specifier}}
 
@@ -83,7 +83,7 @@ namespace Commas {
 
   int global1,
   __attribute__(()) global2,
-  (global5),
+  (global5), // expected-warning {{redundant parentheses surrounding 
declarator}}
   *global6,
= global1,
   & = static_cast(global1),
@@ -263,6 +263,25 @@ namespace DuplicateFriend {
   };
 }
 
+namespace NNS {
+  struct A {};
+  namespace B { extern A C1, C2, *C3, C4[], C5; }
+  // Do not produce a redundant parentheses warning here; removing these parens
+  // changes the meaning of the program.
+  A (::NNS::B::C1);
+  A (NNS::B::C2); // expected-warning {{redundant parentheses surrounding 
declarator}}
+  A (*::NNS::B::C3); // expected-warning {{redundant parentheses surrounding 
declarator}}
+  A (::NNS::B::C4[2]);
+  // Removing one of these sets of parentheses would be reasonable.
+  A ((::NNS::B::C5)); // expected-warning {{redundant parentheses surrounding 
declarator}}
+
+  void f() {
+// FIXME: A vexing-parse warning here would be useful.
+A(::NNS::B::C1); // expected-error {{definition or redeclaration}}
+A(NNS::B::C1); // 

Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread James Y Knight via cfe-commits
I totally agree with moving towards eliminating the -m-version-min
flags, it's much better to put it in the target, and will clean up a lot of
cruft in the driver, eventually.

Now -- we (or anyone else who runs into this) can simply start specifying
the version in both locations ("-target x86_64-apple-ios10
-mios-simulator-version-min=10"), so as to work with both new and old
clang, and be closer to the ultimate goal of having only -target. That's an
overall nicer workaround to suggest than switching to -darwin. But, yea,
there's no need for *temporary* patch to fix things just for us.

However, I do not understand why you're against committing the patch you
mention as option #2 -- that seems like it'd be best for all users, by
preserving compatibility with existing command-lines. So, I'd still like
that change to be committed, permanently, not temporarily. I'm sure we
can't be the only ones running clang like "-target x86_64-apple-ios
-mios-simulator-version-min=10", and it seems unfortunate and unnecessary
to break that, even if it can be worked around.

In the future, I'd hope the -m-version-min arguments can be deprecated
more and more -- warning whenever you use them to modify the platform or
version at all, rather just on specification conflict; then, warn anytime
you use them at all; then, remove them. But in the meantime, it seems
strictly better to preserve compatibility, don't you think?



On Dec 21, 2017 2:11 PM, "Alex L"  wrote:

Thanks for raising your concerns.

We decided to avoid -m-version-min flag in favor of -target to simplify
the driver logic and to encourage the adoption of -target. Now after r321145
we only warn about -m-version-min flag when the OS version specified in
it is different to the OS version specified in target, or when target has
no OS version.

There are two possible solutions here:
1) You can still use -target with -mios-simulator-version-min as before but
you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
version specified by  '-mios-simulator-version-min' is used.
2) I also do have a patch that implements the logic that you propose (use
the OS version in -m-version-min flag if target has none). If you
believe that the first solution is not suitable for your code then I can
commit it. At the same time I believe that we would rather not use this
patch, but if it's urgent for your projects then maybe I can land it now
and then we can establish some sort of timeline for when it can be reverted?

Thanks,
Alex


On 21 December 2017 at 08:00, James Y Knight  wrote:

> I think if a version number isn't explicitly specified in the -target
> value, the value from -m-version-min ought to still be used, as
> it was before.
>
> Currently, clang will ignore the -m-version-min version number
> if the target has a particular OS specified, even if it has no version
> number as part of it.
>
> (We should be able to workaround this change backwards-compatibly by
> specifying in both the -target argument and in the -m-version-min
> arguments, but I do think the behavior should be fixed.)
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread Martin Böhme via cfe-commits
Thanks for the quick response and your suggestions!

I believe the workaround you suggest in 1) will work for us, so there's no
need for an urgent change. Thanks again!

On 21 December 2017 at 20:11, Alex L  wrote:

> Thanks for raising your concerns.
>
> We decided to avoid -m-version-min flag in favor of -target to
> simplify the driver logic and to encourage the adoption of -target. Now
> after r321145 we only warn about -m-version-min flag when the OS
> version specified in it is different to the OS version specified in target,
> or when target has no OS version.
>
> There are two possible solutions here:
> 1) You can still use -target with -mios-simulator-version-min as before
> but you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
> version specified by  '-mios-simulator-version-min' is used.
> 2) I also do have a patch that implements the logic that you propose (use
> the OS version in -m-version-min flag if target has none). If you
> believe that the first solution is not suitable for your code then I can
> commit it. At the same time I believe that we would rather not use this
> patch, but if it's urgent for your projects then maybe I can land it now
> and then we can establish some sort of timeline for when it can be reverted?
>
> Thanks,
> Alex
>
>
> On 21 December 2017 at 08:00, James Y Knight  wrote:
>
>> I think if a version number isn't explicitly specified in the -target
>> value, the value from -m-version-min ought to still be used, as
>> it was before.
>>
>> Currently, clang will ignore the -m-version-min version number
>> if the target has a particular OS specified, even if it has no version
>> number as part of it.
>>
>> (We should be able to workaround this change backwards-compatibly by
>> specifying in both the -target argument and in the -m-version-min
>> arguments, but I do think the behavior should be fixed.)
>>
>> On Thu, Dec 21, 2017 at 10:45 AM, Martin Böhme 
>> wrote:
>>
>>> This is causing problems in some internal builds that specify both
>>> -mios-simulator-version-min=9.0 and --target=x86_64-apple-ios
>>>
>>> My expectation would be for the code to take the minimum OS version
>>> number from the -mios-simulator-version-min flag. In fact, however, the
>>> code seems to be completely ignoring this flag.
>>>
>>> Is my expectation wrong or does the code need to be modified to take
>>> this situation into account?
>>>
>>>
>>> On 19 December 2017 at 20:05, Alex Lorenz via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: arphaman
 Date: Tue Dec 19 11:05:04 2017
 New Revision: 321099

 URL: http://llvm.org/viewvc/llvm-project?rev=321099=rev
 Log:
 [driver][darwin] Take the OS version specified in "-target" as the
 target
 OS instead of inferring it from SDK / environment

 The OS version is specified in -target should be used instead of the
 one in an
 environment variable / SDK name.

 rdar://35813850

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

 Modified:
 cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
 cfe/trunk/test/Driver/darwin-version.c
 cfe/trunk/test/Driver/objc-weak.m
 cfe/trunk/test/Driver/pic.c
 cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp

 Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
 lChains/Darwin.cpp?rev=321099=321098=321099=diff
 
 ==
 --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
 +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
 @@ -1233,6 +1233,10 @@ struct DarwinPlatform {
  llvm_unreachable("Unsupported Darwin Source Kind");
}

 +  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
 + StringRef OSVersion, Arg *A) {
 +return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion,
 A);
 +  }
static DarwinPlatform createOSVersionArg(DarwinPlatformKind
 Platform,
 Arg *A) {
  return DarwinPlatform(OSVersionArg, Platform, A);
 @@ -1250,33 +1254,32 @@ struct DarwinPlatform {
}
static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
 StringRef Value) {
 -DarwinPlatformKind Platform;
 +return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
 Value);
 +  }
 +
 +private:
 +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
 *Argument)
 +  : Kind(Kind), Platform(Platform), Argument(Argument) {}
 +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform,
 StringRef Value,
 + Arg 

[clang-tools-extra] r321302 - [clangd] Don't re-hash SymbolID in maps, just use the SHA1 data

2017-12-21 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Dec 21 12:11:46 2017
New Revision: 321302

URL: http://llvm.org/viewvc/llvm-project?rev=321302=rev
Log:
[clangd] Don't re-hash SymbolID in maps, just use the SHA1 data

Modified:
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=321302=321301=321302=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu Dec 21 12:11:46 2017
@@ -24,7 +24,7 @@ llvm::raw_ostream <<(llvm::raw_
 
 void operator>>(llvm::StringRef Str, SymbolID ) {
   std::string HexString = fromHex(Str);
-  assert(HexString.size() == 20);
+  assert(HexString.size() == ID.HashValue.size());
   std::copy(HexString.begin(), HexString.end(), ID.HashValue.begin());
 }
 

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=321302=321301=321302=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu Dec 21 12:11:46 2017
@@ -52,7 +52,9 @@ public:
 
 private:
   friend llvm::hash_code hash_value(const SymbolID ) {
-return hash_value(ArrayRef(ID.HashValue));
+// We already have a good hash, just return the first bytes.
+static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+return *reinterpret_cast(ID.HashValue.data());
   }
   friend llvm::raw_ostream <<(llvm::raw_ostream ,
const SymbolID );


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


r321301 - [AArch64] Enable fp16 data type for the Builtin for AArch64 only.

2017-12-21 Thread Abderrazek Zaafrani via cfe-commits
Author: az
Date: Thu Dec 21 12:10:03 2017
New Revision: 321301

URL: http://llvm.org/viewvc/llvm-project?rev=321301=rev
Log:
[AArch64] Enable fp16 data type for the Builtin for AArch64 only.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/arm_neon_intrinsics.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=321301=321300=321301=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 21 12:10:03 2017
@@ -3334,10 +3334,10 @@ static Value *EmitTargetArchBuiltinExpr(
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
-return CGF->EmitARMBuiltinExpr(BuiltinID, E);
+return CGF->EmitARMBuiltinExpr(BuiltinID, E, Arch);
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be:
-return CGF->EmitAArch64BuiltinExpr(BuiltinID, E);
+return CGF->EmitAArch64BuiltinExpr(BuiltinID, E, Arch);
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 return CGF->EmitX86BuiltinExpr(BuiltinID, E);
@@ -3378,6 +3378,7 @@ Value *CodeGenFunction::EmitTargetBuilti
 
 static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
  NeonTypeFlags TypeFlags,
+ llvm::Triple::ArchType Arch,
  bool V1Ty=false) {
   int IsQuad = TypeFlags.isQuad();
   switch (TypeFlags.getEltType()) {
@@ -3388,7 +3389,12 @@ static llvm::VectorType *GetNeonType(Cod
   case NeonTypeFlags::Poly16:
 return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
   case NeonTypeFlags::Float16:
-return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
+// FIXME: Only AArch64 backend can so far properly handle half types.
+// Remove else part once ARM backend support for half is complete.
+if (Arch == llvm::Triple::aarch64)
+  return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
+else
+  return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
   case NeonTypeFlags::Int32:
 return llvm::VectorType::get(CGF->Int32Ty, V1Ty ? 1 : (2 << IsQuad));
   case NeonTypeFlags::Int64:
@@ -4226,7 +4232,8 @@ static Value *EmitCommonNeonSISDBuiltinE
 Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
 unsigned BuiltinID, unsigned LLVMIntrinsic, unsigned AltLLVMIntrinsic,
 const char *NameHint, unsigned Modifier, const CallExpr *E,
-SmallVectorImpl , Address PtrOp0, Address PtrOp1) {
+SmallVectorImpl , Address PtrOp0, Address PtrOp1,
+llvm::Triple::ArchType Arch) {
   // Get the last argument, which specifies the vector type.
   llvm::APSInt NeonTypeConst;
   const Expr *Arg = E->getArg(E->getNumArgs() - 1);
@@ -4238,7 +4245,7 @@ Value *CodeGenFunction::EmitCommonNeonBu
   bool Usgn = Type.isUnsigned();
   bool Quad = Type.isQuad();
 
-  llvm::VectorType *VTy = GetNeonType(this, Type);
+  llvm::VectorType *VTy = GetNeonType(this, Type, Arch);
   llvm::Type *Ty = VTy;
   if (!Ty)
 return nullptr;
@@ -4312,13 +4319,13 @@ Value *CodeGenFunction::EmitCommonNeonBu
   case NEON::BI__builtin_neon_vcvt_f32_v:
   case NEON::BI__builtin_neon_vcvtq_f32_v:
 Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
-Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, Quad));
+Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, Quad), 
Arch);
 return Usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
 : Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
   case NEON::BI__builtin_neon_vcvt_f16_v:
   case NEON::BI__builtin_neon_vcvtq_f16_v:
 Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
-Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float16, false, Quad));
+Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float16, false, Quad), 
Arch);
 return Usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
 : Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
   case NEON::BI__builtin_neon_vcvt_n_f16_v:
@@ -4887,7 +4894,8 @@ static bool HasExtraNeonArgument(unsigne
 }
 
 Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
-   const CallExpr *E) {
+   const CallExpr *E,
+   llvm::Triple::ArchType Arch) {
   if (auto Hint = GetValueForARMHint(BuiltinID))
 return Hint;
 
@@ -5426,7 +5434,7 @@ Value *CodeGenFunction::EmitARMBuiltinEx
   bool usgn = Type.isUnsigned();
   bool rightShift = false;
 
-  llvm::VectorType *VTy = GetNeonType(this, Type);
+  llvm::VectorType *VTy = GetNeonType(this, Type, Arch);
   llvm::Type *Ty = VTy;
   if (!Ty)
 return nullptr;
@@ -5439,7 +5447,7 @@ Value 

[PATCH] D41103: [CMake] Allow passing extra CMake arguments to custom libc++

2017-12-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321299: [CMake] Allow passing extra CMake arguments to 
custom libc++ (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41103?vs=126488=127924#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41103

Files:
  compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake


Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
@@ -469,7 +469,7 @@
 message(FATAL_ERROR "libcxx not found!")
   endif()
 
-  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS" ${ARGN})
+  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN})
   foreach(flag ${LIBCXX_CFLAGS})
 set(flagstr "${flagstr} ${flag}")
   endforeach()
@@ -491,6 +491,7 @@
-DCMAKE_INSTALL_PREFIX:PATH=
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
-DLIBCXX_STANDALONE_BUILD=On
+   ${LIBCXX_CMAKE_ARGS}
 LOG_BUILD 1
 LOG_CONFIGURE 1
 LOG_INSTALL 1


Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
@@ -469,7 +469,7 @@
 message(FATAL_ERROR "libcxx not found!")
   endif()
 
-  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS" ${ARGN})
+  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN})
   foreach(flag ${LIBCXX_CFLAGS})
 set(flagstr "${flagstr} ${flag}")
   endforeach()
@@ -491,6 +491,7 @@
-DCMAKE_INSTALL_PREFIX:PATH=
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
-DLIBCXX_STANDALONE_BUILD=On
+   ${LIBCXX_CMAKE_ARGS}
 LOG_BUILD 1
 LOG_CONFIGURE 1
 LOG_INSTALL 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321298 - Revert "Fix for PR32990"

2017-12-21 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Dec 21 11:44:23 2017
New Revision: 321298

URL: http://llvm.org/viewvc/llvm-project?rev=321298=rev
Log:
Revert "Fix for PR32990"

This reverts commit r321239. It broke the Chromium DLL build:

[8834/50217] LINK(DLL) icui18n.dll icui18n.dll.lib icui18n.dll.pdb
FAILED: icui18n.dll icui18n.dll.lib icui18n.dll.pdb
zrule.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __cdecl icu_60::UnicodeString::`vbase 
destructor'(void)"
(__imp_??_DUnicodeString@icu_60@@QEAAXXZ)

Removed:
cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp
cfe/trunk/test/CodeGenCXX/external-linkage.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp
cfe/trunk/test/CodeGenCXX/dllimport-members.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=321298=321297=321298=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Dec 21 11:44:23 2017
@@ -856,25 +856,14 @@ CodeGenModule::getFunctionLinkage(Global
   GVALinkage Linkage = getContext().GetGVALinkageForFunction(D);
 
   if (isa(D) &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-switch (GD.getDtorType()) {
-case CXXDtorType::Dtor_Base:
-  break;
-case CXXDtorType::Dtor_Comdat:
-case CXXDtorType::Dtor_Complete:
-  if (D->hasAttr() &&
- (cast(D)->getParent()->getNumVBases() ||
-  (Linkage == GVA_AvailableExternally ||
-   Linkage == GVA_StrongExternal)))
-   return llvm::Function::AvailableExternallyLinkage;
-  else
-return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
-   : llvm::GlobalValue::LinkOnceODRLinkage;
-case CXXDtorType::Dtor_Deleting:
-  return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
- : llvm::GlobalValue::LinkOnceODRLinkage;
-}
+  getCXXABI().useThunkForDtorVariant(cast(D),
+ GD.getDtorType())) {
+// Destructor variants in the Microsoft C++ ABI are always internal or
+// linkonce_odr thunks emitted on an as-needed basis.
+return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
+   : llvm::GlobalValue::LinkOnceODRLinkage;
   }
+
   if (isa(D) &&
   cast(D)->isInheritingConstructor() &&
   Context.getTargetInfo().getCXXABI().isMicrosoft()) {
@@ -890,25 +879,12 @@ CodeGenModule::getFunctionLinkage(Global
 void CodeGenModule::setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function 
*F) {
   const auto *FD = cast(GD.getDecl());
 
-  if (dyn_cast_or_null(FD)) {
-switch (GD.getDtorType()) {
-case CXXDtorType::Dtor_Comdat:
-case CXXDtorType::Dtor_Deleting: {
+  if (const auto *Dtor = dyn_cast_or_null(FD)) {
+if (getCXXABI().useThunkForDtorVariant(Dtor, GD.getDtorType())) {
   // Don't dllexport/import destructor thunks.
   F->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
   return;
 }
-case CXXDtorType::Dtor_Complete:
-  if (FD->hasAttr())
-F->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
-  else if (FD->hasAttr())
-F->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
-  else
-F->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass);
-  return;
-case CXXDtorType::Dtor_Base:
-  break;
-}
   }
 
   if (FD->hasAttr())

Modified: cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp?rev=321298=321297=321298=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp Thu Dec 21 11:44:23 2017
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc 
-fms-extensions -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc 
-fms-extensions -emit-llvm -O1 -disable-llvm-passes -o - | FileCheck 
--check-prefix=MO1 %s
 
 // FIXME: We should really consider removing -mconstructor-aliases for MS C++
 // ABI. The risk of bugs introducing ABI incompatibility under
@@ -24,7 +23,9 @@ struct __declspec(dllimport) ImportOverr
   virtual ~ImportOverrideVDtor() {}
 };
 
-// Virtually inherits from a non-dllimport base class. Emit the vbase 
destructor.
+// Virtually inherits from a non-dllimport base class. This time we need to 
call
+// the complete destructor and emit it inline. It's not exported from the DLL,
+// and it must be emitted.
 struct 

r321297 - When instantiating a deduction guide, transform its name.

2017-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 21 11:43:39 2017
New Revision: 321297

URL: http://llvm.org/viewvc/llvm-project?rev=321297=rev
Log:
When instantiating a deduction guide, transform its name.

Otherwise it will serve as a deduction guide for the wrong class template.

Added:
cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=321297=321296=321297=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Dec 21 11:43:39 2017
@@ -1587,9 +1587,10 @@ static QualType adjustFunctionTypeForIns
 }
 
 /// Normal class members are of more specific types and therefore
-/// don't make it here.  This function serves two purposes:
+/// don't make it here.  This function serves three purposes:
 ///   1) instantiating function templates
 ///   2) substituting friend declarations
+///   3) substituting deduction guide declarations for nested class templates
 Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
TemplateParameterList *TemplateParams) {
   // Check whether there is already a function template specialization for
@@ -1650,16 +1651,19 @@ Decl *TemplateDeclInstantiator::VisitFun
  TemplateArgs);
   }
 
+  DeclarationNameInfo NameInfo
+= SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
+
   FunctionDecl *Function;
   if (auto *DGuide = dyn_cast(D)) {
 Function = CXXDeductionGuideDecl::Create(
   SemaRef.Context, DC, D->getInnerLocStart(), DGuide->isExplicit(),
-  D->getNameInfo(), T, TInfo, D->getSourceRange().getEnd());
+  NameInfo, T, TInfo, D->getSourceRange().getEnd());
 if (DGuide->isCopyDeductionCandidate())
   cast(Function)->setIsCopyDeductionCandidate();
   } else {
 Function = FunctionDecl::Create(
-SemaRef.Context, DC, D->getInnerLocStart(), D->getNameInfo(), T, TInfo,
+SemaRef.Context, DC, D->getInnerLocStart(), NameInfo, T, TInfo,
 D->getCanonicalDecl()->getStorageClass(), D->isInlineSpecified(),
 D->hasWrittenPrototype(), D->isConstexpr());
 Function->setRangeEnd(D->getSourceRange().getEnd());

Added: cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp?rev=321297=auto
==
--- cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp (added)
+++ cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp Thu Dec 21 11:43:39 
2017
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// expected-no-diagnostics
+
+template struct A {
+  template struct B {
+B(...);
+  };
+  template B(U) -> B;
+};
+A::B b = 123;
+
+using T = decltype(b);
+using T = A::B;


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


[PATCH] D41311: [CodeGen] Fix crash when a function taking transparent union is redeclared.

2017-12-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321296: [CodeGen] Fix crash when a function taking 
transparent union is redeclared. (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41311?vs=127779=127923#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41311

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/kr-func-promote.c
  test/CodeGen/transparent-union-redecl.c
  test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  test/Sema/transparent-union.c

Index: test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -115,9 +115,15 @@
 // B::foo gets 'this' cast to VBase* in ECX (i.e. this+8) so we
 // need to adjust 'this' before use.
 //
-// Store initial this:
+// Coerce this to correct type:
+// CHECK:   %[[THIS_STORE:.*]] = alloca %struct.B*
 // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
-// CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
+// CHECK:   %[[COERCE_VAL:.*]] = bitcast i8* %{{.*}} to %struct.B*
+// CHECK:   store %struct.B* %[[COERCE_VAL]], %struct.B** %[[THIS_STORE]], align 4
+//
+// Store initial this:
+// CHECK:   %[[THIS_INIT:.*]] = load %struct.B*, %struct.B** %[[THIS_STORE]]
+// CHECK:   store %struct.B* %[[THIS_INIT]], %struct.B** %[[THIS_ADDR]], align 4
 //
 // Reload and adjust the this parameter:
 // CHECK:   %[[THIS_RELOAD:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
Index: test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
===
--- test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
+++ test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
@@ -25,6 +25,7 @@
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPM@A@AEXXZ"
 // Note that the vtordisp is applied before really adjusting to D*.
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
@@ -36,6 +37,7 @@
 // CHECK: ret void
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPI@3AEXXZ"
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -8
@@ -64,7 +66,8 @@
 
 G::G() {}  // Forces vftable emission.
 
-// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*)
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.E*, %struct.E** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.E*, %struct.E** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.E* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
Index: test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
===
--- test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
+++ test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
@@ -88,8 +88,11 @@
 // ChildOverride::right gets 'this' cast to Right* in ECX (i.e. this+4) so we
 // need to adjust 'this' before use.
 //
+// CHECK: %[[THIS_STORE:.*]] = alloca %struct.ChildOverride*, align 4
 // CHECK: %[[THIS_ADDR:.*]] = alloca %struct.ChildOverride*, align 4
-// CHECK: %[[THIS_INIT:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
+// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
+// CHECK: store %struct.ChildOverride* %[[COERCE_VAL]], %struct.ChildOverride** %[[THIS_STORE]], align 4
+// CHECK: %[[THIS_INIT:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_STORE]], align 4
 // CHECK: store %struct.ChildOverride* %[[THIS_INIT]], %struct.ChildOverride** %[[THIS_ADDR]], align 4
 // CHECK: %[[THIS_RELOAD:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_ADDR]]
 // CHECK: %[[THIS_i8:.*]] = bitcast %struct.ChildOverride* %[[THIS_RELOAD]] to i8*
@@ -132,8 +135,11 @@
 void GrandchildOverride::right() {
 // CHECK-LABEL: define x86_thiscallcc void @"\01?right@GrandchildOverride@@UAEXXZ"(i8*
 //
+// CHECK: %[[THIS_STORE:.*]] = alloca %struct.GrandchildOverride*, align 4
 // CHECK: %[[THIS_ADDR:.*]] = alloca %struct.GrandchildOverride*, align 4
-// CHECK: 

r321296 - [CodeGen] Fix crash when a function taking transparent union is redeclared.

2017-12-21 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Dec 21 11:42:37 2017
New Revision: 321296

URL: http://llvm.org/viewvc/llvm-project?rev=321296=rev
Log:
[CodeGen] Fix crash when a function taking transparent union is redeclared.

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

The fix is in checking for the trivial case if ABIArgInfo type matches with
parameter declaration type. It exposed inconsistency that we check
hasScalarEvaluationKind for different types in EmitParmDecl and
EmitFunctionProlog, and comment says they should match.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls

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

Added:
cfe/trunk/test/CodeGen/transparent-union-redecl.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/kr-func-promote.c
cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=321296=321295=321296=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Dec 21 11:42:37 2017
@@ -2317,7 +2317,7 @@ void CodeGenFunction::EmitFunctionProlog
 
   // If we have the trivial case, handle it with no muss and fuss.
   if (!isa(ArgI.getCoerceToType()) &&
-  ArgI.getCoerceToType() == ConvertType(Ty) &&
+  ArgI.getCoerceToType() == ConvertType(Arg->getType()) &&
   ArgI.getDirectOffset() == 0) {
 assert(NumIRArgs == 1);
 llvm::Value *V = FnArgs[FirstIRArg];
@@ -2414,8 +2414,8 @@ void CodeGenFunction::EmitFunctionProlog
 break;
   }
 
-  Address Alloca = CreateMemTemp(Ty, getContext().getDeclAlign(Arg),
- Arg->getName());
+  Address Alloca = CreateMemTemp(
+  Arg->getType(), getContext().getDeclAlign(Arg), Arg->getName());
 
   // Pointer to store into.
   Address Ptr = emitAddressAtOffset(*this, Alloca, ArgI);
@@ -2461,9 +2461,9 @@ void CodeGenFunction::EmitFunctionProlog
   }
 
   // Match to what EmitParmDecl is expecting for this type.
-  if (CodeGenFunction::hasScalarEvaluationKind(Ty)) {
+  if (CodeGenFunction::hasScalarEvaluationKind(Arg->getType())) {
 llvm::Value *V =
-  EmitLoadOfScalar(Alloca, false, Ty, Arg->getLocStart());
+EmitLoadOfScalar(Alloca, false, Arg->getType(), 
Arg->getLocStart());
 if (isPromoted)
   V = emitArgumentDemotion(*this, Arg, V);
 ArgVals.push_back(ParamValue::forDirect(V));

Modified: cfe/trunk/test/CodeGen/kr-func-promote.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/kr-func-promote.c?rev=321296=321295=321296=diff
==
--- cfe/trunk/test/CodeGen/kr-func-promote.c (original)
+++ cfe/trunk/test/CodeGen/kr-func-promote.c Thu Dec 21 11:42:37 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck 
%s
-// CHECK: i32 @a(i32)
+// CHECK: i32 @a(i32
 
 int a();
 int a(x) short x; {return x;}

Added: cfe/trunk/test/CodeGen/transparent-union-redecl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union-redecl.c?rev=321296=auto
==
--- cfe/trunk/test/CodeGen/transparent-union-redecl.c (added)
+++ cfe/trunk/test/CodeGen/transparent-union-redecl.c Thu Dec 21 11:42:37 2017
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+
+// Test that different order of declarations is acceptable and that
+// implementing different redeclarations is acceptable.
+// rdar://problem/34949329
+
+typedef union {
+  int i;
+  float f;
+} TU __attribute__((transparent_union));
+
+// CHECK-LABEL: define void @f0(i32 %tu.coerce)
+// CHECK: %tu = alloca %union.TU, align 4
+// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 
0, i32 

[PATCH] D41507: avxintrin.h documentation fixes and updates

2017-12-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.

This is the result of several patches we made internally to update the 
documentation that we would like to have reviewed for possible submission.

The changes include:

1. Fix incorrect wording in various intrinsic descriptions. Previously the 
descriptions used "low-order" and "high-order" when the intended meaning was 
"even-indexed" and "odd-indexed".
2. Fix a few typos and errors found during review.
3. Restore new line endings and change to use hex suffixes (0h instead of 0x0).

These patches were made by Craig Flores


https://reviews.llvm.org/D41507

Files:
  lib/Headers/avxintrin.h

Index: lib/Headers/avxintrin.h
===
--- lib/Headers/avxintrin.h
+++ lib/Headers/avxintrin.h
@@ -1120,7 +1120,7 @@
 /// \param A
 ///A 256-bit vector of [8 x float].
 /// \param C
-///An immediate integer operand specifying how the values are to be \n
+///An immediate integer operand specifying how the values are to be
 ///copied. \n
 ///Bits [1:0]: \n
 ///  00: Bits [31:0] of the source are copied to bits [31:0] of the
@@ -1150,7 +1150,7 @@
 ///  11: Bits [127:96] of the source are copied to bits [95:64] of the
 ///  returned vector. \n
 ///Bits [7:6]: \n
-///  00: Bits [31:qq0] of the source are copied to bits [127:96] of the
+///  00: Bits [31:0] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
 ///  01: Bits [63:32] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
@@ -1665,38 +1665,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equal (ordered, signaling)
-///0x03 : Unordered (non-signaling)
-///0x04 : Not-equal (unordered, non-signaling)
-///0x05 : Not-less-than (unordered, signaling)
-///0x06 : Not-less-than-or-equal (unordered, signaling)
-///0x07 : Ordered (non-signaling)
-///0x08 : Equal (unordered, non-signaling)
-///0x09 : Not-greater-than-or-equal (unordered, signaling)
-///0x0a : Not-greater-than (unordered, signaling)
-///0x0b : False (ordered, non-signaling)
-///0x0c : Not-equal (ordered, non-signaling)
-///0x0d : Greater-than-or-equal (ordered, signaling)
-///0x0e : Greater-than (ordered, signaling)
-///0x0f : True (unordered, non-signaling)
-///0x10 : Equal (ordered, signaling)
-///0x11 : Less-than (ordered, non-signaling)
-///0x12 : Less-than-or-equal (ordered, non-signaling)
-///0x13 : Unordered (signaling)
-///0x14 : Not-equal (unordered, signaling)
-///0x15 : Not-less-than (unordered, non-signaling)
-///0x16 : Not-less-than-or-equal (unordered, non-signaling)
-///0x17 : Ordered (signaling)
-///0x18 : Equal (unordered, signaling)
-///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
-///0x1a : Not-greater-than (unordered, non-signaling)
-///0x1b : False (ordered, signaling)
-///0x1c : Not-equal (ordered, signaling)
-///0x1d : Greater-than-or-equal (ordered, non-signaling)
-///0x1e : Greater-than (ordered, non-signaling)
-///0x1f : True (unordered, signaling)
+///00h: Equal (ordered, non-signaling) \n
+///01h: Less-than (ordered, signaling) \n
+///02h: Less-than-or-equal (ordered, signaling) \n
+///03h: Unordered (non-signaling) \n
+///04h: Not-equal (unordered, non-signaling) \n
+///05h: Not-less-than (unordered, signaling) \n
+///06h: Not-less-than-or-equal (unordered, signaling) \n
+///07h: Ordered (non-signaling) \n
+///08h: Equal (unordered, non-signaling) \n
+///09h: Not-greater-than-or-equal (unordered, signaling) \n
+///0Ah: Not-greater-than (unordered, signaling) \n
+///0Bh: False (ordered, non-signaling) \n
+///0Ch: Not-equal (ordered, non-signaling) \n
+///0Dh: Greater-than-or-equal (ordered, signaling) \n
+///0Eh: Greater-than (ordered, signaling) \n
+///0Fh: True (unordered, non-signaling) \n
+///10h: Equal (ordered, signaling) \n
+///11h: Less-than (ordered, non-signaling) \n
+///12h: Less-than-or-equal (ordered, non-signaling) \n
+///13h: Unordered (signaling) \n
+///14h: Not-equal (unordered, signaling) \n
+///15h: Not-less-than (unordered, non-signaling) \n
+///16h: Not-less-than-or-equal (unordered, non-signaling) \n
+///17h: Ordered (signaling) \n
+///18h: Equal (unordered, signaling) \n
+///19h: Not-greater-than-or-equal (unordered, non-signaling) \n
+///1Ah: Not-greater-than (unordered, non-signaling) \n
+///1Bh: False (ordered, signaling) \n
+///1Ch: Not-equal (ordered, signaling) \n
+///1Dh: Greater-than-or-equal (ordered, non-signaling) \n
+///1Eh: Greater-than (ordered, non-signaling) \n
+///1Fh: True (unordered, 

[PATCH] D40443: [Modules TS] Make imports from an interface unit visible to its implementation units

2017-12-21 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added a comment.

Ping


https://reviews.llvm.org/D40443



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


[PATCH] D41498: [libcxx] Add clang negative thread safety assertions to std::mutex

2017-12-21 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/__mutex_base:65
 void unlock() _NOEXCEPT 
_LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
+#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+const mutex& operator!() const { return *this; }

We don't get to add public member functions to classes defined in the standard 
- at least not ones with pronounceable names.



Repository:
  rCXX libc++

https://reviews.llvm.org/D41498



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


[PATCH] D41506: [clangd] Use Builder for symbol slabs, and use sorted-vector for storage

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 127918.
sammccall added a comment.

minor doc and code layout tweaks


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41506

Files:
  clangd/index/FileIndex.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -32,8 +32,7 @@
 
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
-  return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name).str() == Name;
+  return (arg.Scope + (arg.Scope.empty() ? "" : "::") + arg.Name).str() == Name;
 }
 
 namespace clang {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -45,18 +45,18 @@
 std::shared_ptr
 generateSymbols(std::vector QualifiedNames,
 std::weak_ptr *WeakSymbols = nullptr) {
-  auto Slab = std::make_shared();
-  if (WeakSymbols)
-*WeakSymbols = Slab;
-
+  SymbolSlab::Builder Slab;
   for (llvm::StringRef QName : QualifiedNames)
-Slab->Slab.insert(symbol(QName));
+Slab.insert(symbol(QName));
 
-  for (const auto  : Slab->Slab)
-Slab->Pointers.push_back();
-
-  auto *Pointers = >Pointers;
-  return {std::move(Slab), Pointers};
+  auto Storage = std::make_shared();
+  Storage->Slab = std::move(Slab).build();
+  for (const auto  : Storage->Slab)
+Storage->Pointers.push_back();
+  if (WeakSymbols)
+*WeakSymbols = Storage;
+  auto *Pointers = >Pointers;
+  return {std::move(Storage), Pointers};
 }
 
 // Create a slab of symbols with IDs and names [Begin, End], otherwise identical
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -28,9 +28,11 @@
   return Sym;
 }
 
-void addNumSymbolsToSlab(int Begin, int End, SymbolSlab *Slab) {
+std::unique_ptr numSlab(int Begin, int End) {
+  SymbolSlab::Builder Slab;
   for (int i = Begin; i <= End; i++)
-Slab->insert(symbol(std::to_string(i)));
+Slab.insert(symbol(std::to_string(i)));
+  return llvm::make_unique(std::move(Slab).build());
 }
 
 std::vector
@@ -45,46 +47,29 @@
   FileSymbols FS;
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3"));
 }
 
 TEST(FileSymbolsTest, Overlap) {
   FileSymbols FS;
-
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
-  Slab = llvm::make_unique();
-  addNumSymbolsToSlab(3, 5, Slab.get());
-
-  FS.update("f2", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
+  FS.update("f2", numSlab(3, 5));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3", "3", "4", "5"));
 }
 
 TEST(FileSymbolsTest, SnapshotAliveAfterRemove) {
   FileSymbols FS;
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
+  FS.update("f1", numSlab(1, 3));
 
   auto Symbols = FS.allSymbols();
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 
   FS.update("f1", nullptr);
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
-
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 }
 
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -449,6 +449,7 @@
 std::vector Pointers;
   };
   auto Snap = std::make_shared();
+  SymbolSlab::Builder Slab;
   for (const auto  : Symbols) {
 Symbol Sym;
 Sym.ID = SymbolID(Pair.first);
@@ -462,10 +463,11 @@
   Sym.Scope = QName.substr(0, Pos);
 }
 Sym.SymInfo.Kind = Pair.second;
-Snap->Slab.insert(std::move(Sym));
+Slab.insert(Sym);
   }
+  Snap->Slab = std::move(Slab).build();
   for (auto  : Snap->Slab)
-Snap->Pointers.push_back();
+Snap->Pointers.push_back();
   auto S = std::shared_ptr(std::move(Snap),
 >Pointers);
   I->build(std::move(S));
Index: clangd/index/SymbolYAML.cpp

Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread Alex L via cfe-commits
Thanks for raising your concerns.

We decided to avoid -m-version-min flag in favor of -target to simplify
the driver logic and to encourage the adoption of -target. Now after r321145
we only warn about -m-version-min flag when the OS version specified in
it is different to the OS version specified in target, or when target has
no OS version.

There are two possible solutions here:
1) You can still use -target with -mios-simulator-version-min as before but
you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
version specified by  '-mios-simulator-version-min' is used.
2) I also do have a patch that implements the logic that you propose (use
the OS version in -m-version-min flag if target has none). If you
believe that the first solution is not suitable for your code then I can
commit it. At the same time I believe that we would rather not use this
patch, but if it's urgent for your projects then maybe I can land it now
and then we can establish some sort of timeline for when it can be reverted?

Thanks,
Alex


On 21 December 2017 at 08:00, James Y Knight  wrote:

> I think if a version number isn't explicitly specified in the -target
> value, the value from -m-version-min ought to still be used, as
> it was before.
>
> Currently, clang will ignore the -m-version-min version number
> if the target has a particular OS specified, even if it has no version
> number as part of it.
>
> (We should be able to workaround this change backwards-compatibly by
> specifying in both the -target argument and in the -m-version-min
> arguments, but I do think the behavior should be fixed.)
>
> On Thu, Dec 21, 2017 at 10:45 AM, Martin Böhme  wrote:
>
>> This is causing problems in some internal builds that specify both
>> -mios-simulator-version-min=9.0 and --target=x86_64-apple-ios
>>
>> My expectation would be for the code to take the minimum OS version
>> number from the -mios-simulator-version-min flag. In fact, however, the
>> code seems to be completely ignoring this flag.
>>
>> Is my expectation wrong or does the code need to be modified to take this
>> situation into account?
>>
>>
>> On 19 December 2017 at 20:05, Alex Lorenz via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: arphaman
>>> Date: Tue Dec 19 11:05:04 2017
>>> New Revision: 321099
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=321099=rev
>>> Log:
>>> [driver][darwin] Take the OS version specified in "-target" as the target
>>> OS instead of inferring it from SDK / environment
>>>
>>> The OS version is specified in -target should be used instead of the one
>>> in an
>>> environment variable / SDK name.
>>>
>>> rdar://35813850
>>>
>>> Differential Revision: https://reviews.llvm.org/D40998
>>>
>>> Modified:
>>> cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>>> cfe/trunk/test/Driver/darwin-version.c
>>> cfe/trunk/test/Driver/objc-weak.m
>>> cfe/trunk/test/Driver/pic.c
>>> cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
>>>
>>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>>> lChains/Darwin.cpp?rev=321099=321098=321099=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
>>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
>>> @@ -1233,6 +1233,10 @@ struct DarwinPlatform {
>>>  llvm_unreachable("Unsupported Darwin Source Kind");
>>>}
>>>
>>> +  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
>>> + StringRef OSVersion, Arg *A) {
>>> +return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion,
>>> A);
>>> +  }
>>>static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
>>> Arg *A) {
>>>  return DarwinPlatform(OSVersionArg, Platform, A);
>>> @@ -1250,33 +1254,32 @@ struct DarwinPlatform {
>>>}
>>>static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
>>> StringRef Value) {
>>> -DarwinPlatformKind Platform;
>>> +return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
>>> Value);
>>> +  }
>>> +
>>> +private:
>>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
>>> *Argument)
>>> +  : Kind(Kind), Platform(Platform), Argument(Argument) {}
>>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform,
>>> StringRef Value,
>>> + Arg *Argument = nullptr)
>>> +  : Kind(Kind), Platform(Platform), OSVersion(Value),
>>> Argument(Argument) {}
>>> +
>>> +  static DarwinPlatformKind getPlatformFromOS(llvm::Triple::OSType OS)
>>> {
>>>  switch (OS) {
>>>  case llvm::Triple::Darwin:
>>>  case llvm::Triple::MacOSX:
>>> -  Platform = DarwinPlatformKind::MacOS;
>>> -  break;
>>> +  return 

[PATCH] D41506: [clangd] Use Builder for symbol slabs, and use sorted-vector for storage

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, mgrang, klimek.

This improves a few things:

- the insert -> freeze -> read sequence is now enforced/communicated by the 
type system
- SymbolSlab::const_iterator iterates over symbols, not over id-symbol pairs
- we avoid permanently storing a second copy of the IDs, and the string map's 
hashtable

The slab size is now down to 21.8MB for the LLVM project.
Of this only 2.7MB is strings, the rest is #symbols * `sizeof(Symbol)`.
`sizeof(Symbol)` is currently 96, which seems too big - I think
SymbolInfo isn't efficiently packed. That's a topic for another patch!

Also added simple API to see the memory usage/#symbols of a slab, since
it seems likely we will continue to care about this.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41506

Files:
  clangd/index/FileIndex.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -32,8 +32,7 @@
 
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
-  return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name).str() == Name;
+  return (arg.Scope + (arg.Scope.empty() ? "" : "::") + arg.Name).str() == Name;
 }
 
 namespace clang {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -45,18 +45,18 @@
 std::shared_ptr
 generateSymbols(std::vector QualifiedNames,
 std::weak_ptr *WeakSymbols = nullptr) {
-  auto Slab = std::make_shared();
-  if (WeakSymbols)
-*WeakSymbols = Slab;
-
+  SymbolSlab::Builder Slab;
   for (llvm::StringRef QName : QualifiedNames)
-Slab->Slab.insert(symbol(QName));
+Slab.insert(symbol(QName));
 
-  for (const auto  : Slab->Slab)
-Slab->Pointers.push_back();
-
-  auto *Pointers = >Pointers;
-  return {std::move(Slab), Pointers};
+  auto Storage = std::make_shared();
+  Storage->Slab = std::move(Slab).build();
+  for (const auto  : Storage->Slab)
+Storage->Pointers.push_back();
+  if (WeakSymbols)
+*WeakSymbols = Storage;
+  auto *Pointers = >Pointers;
+  return {std::move(Storage), Pointers};
 }
 
 // Create a slab of symbols with IDs and names [Begin, End], otherwise identical
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -28,9 +28,11 @@
   return Sym;
 }
 
-void addNumSymbolsToSlab(int Begin, int End, SymbolSlab *Slab) {
+std::unique_ptr numSlab(int Begin, int End) {
+  SymbolSlab::Builder Slab;
   for (int i = Begin; i <= End; i++)
-Slab->insert(symbol(std::to_string(i)));
+Slab.insert(symbol(std::to_string(i)));
+  return llvm::make_unique(std::move(Slab).build());
 }
 
 std::vector
@@ -45,46 +47,29 @@
   FileSymbols FS;
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3"));
 }
 
 TEST(FileSymbolsTest, Overlap) {
   FileSymbols FS;
-
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
-  Slab = llvm::make_unique();
-  addNumSymbolsToSlab(3, 5, Slab.get());
-
-  FS.update("f2", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
+  FS.update("f2", numSlab(3, 5));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3", "3", "4", "5"));
 }
 
 TEST(FileSymbolsTest, SnapshotAliveAfterRemove) {
   FileSymbols FS;
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
+  FS.update("f1", numSlab(1, 3));
 
   auto Symbols = FS.allSymbols();
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 
   FS.update("f1", nullptr);
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
-
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 }
 
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -449,6 +449,7 @@
 

r321290 - [analyzer] Fix zero-initialization of stack VLAs under ObjC ARC.

2017-12-21 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Dec 21 10:43:02 2017
New Revision: 321290

URL: http://llvm.org/viewvc/llvm-project?rev=321290=rev
Log:
[analyzer] Fix zero-initialization of stack VLAs under ObjC ARC.

Using ARC, strong, weak, and autoreleasing stack variables are implicitly
initialized with nil. This includes variable-length arrays of Objective-C object
pointers. However, in the analyzer we don't zero-initialize them. We used to,
but it accidentally regressed after r289618.

Under ARC, the array variable's initializer within DeclStmt is an
ImplicitValueInitExpr. Environment doesn't maintain any bindings for this
expression kind - instead it always knows that it's a known constant
(0 in our case), so it just returns the known value by calling
SValBuilder::makeZeroVal() (see EnvironmentManager::getSVal().
Commit r289618 had introduced reasonable behavior of SValBuilder::makeZeroVal()
for the arrays, which produces a zero-length compoundVal{}. When such value
is bound to arrays, in RegionStoreManager::bindArray() "remaining" items in the
array are default-initialized with zero, as in
RegionStoreManager::setImplicitDefaultValue(). The similar mechanism works when
an array is initialized by an initializer list that is too short, eg.
  int a[3] = { 1, 2 };
would result in a[2] initialized with 0. However, in case of variable-length
arrays it didn't know if any more items need to be added,
because, well, the length is variable.

Add the default binding anyway, regardless of how many actually need
to be added. We don't really care how many, because the default binding covers
the whole array anyway.

Differential Revision: https://reviews.llvm.org/D41478
rdar://problem/35477763

Added:
cfe/trunk/test/Analysis/arc-zero-init.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=321290=321289=321290=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Thu Dec 21 10:43:02 2017
@@ -2132,9 +2132,10 @@ RegionStoreManager::bindArray(RegionBind
   NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
   }
 
-  // If the init list is shorter than the array length, set the
-  // array default value.
-  if (Size.hasValue() && i < Size.getValue())
+  // If the init list is shorter than the array length (or the array has
+  // variable length), set the array default value. Values that are already set
+  // are not overwritten.
+  if (!Size.hasValue() || i < Size.getValue())
 NewB = setImplicitDefaultValue(NewB, R, ElementTy);
 
   return NewB;

Added: cfe/trunk/test/Analysis/arc-zero-init.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/arc-zero-init.m?rev=321290=auto
==
--- cfe/trunk/test/Analysis/arc-zero-init.m (added)
+++ cfe/trunk/test/Analysis/arc-zero-init.m Thu Dec 21 10:43:02 2017
@@ -0,0 +1,46 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -fobjc-arc %s
+
+#if __has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+@interface SomeClass
+@end
+
+void simpleStrongPointerValue() {
+  SomeClass *x;
+  if (x) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void simpleArray() {
+  SomeClass *vlaArray[5];
+
+  if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArray() {
+   int count = 1;
+   SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArrayWithExplicitStrongAttribute() {
+   int count = 1;
+   __attribute__((objc_ownership(strong))) SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}


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


[PATCH] D41478: [analyzer] Fix zero-initialization of stack VLAs under ARC.

2017-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321290: [analyzer] Fix zero-initialization of stack VLAs 
under ObjC ARC. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D41478

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/arc-zero-init.m


Index: test/Analysis/arc-zero-init.m
===
--- test/Analysis/arc-zero-init.m
+++ test/Analysis/arc-zero-init.m
@@ -0,0 +1,46 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -fobjc-arc %s
+
+#if __has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+@interface SomeClass
+@end
+
+void simpleStrongPointerValue() {
+  SomeClass *x;
+  if (x) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void simpleArray() {
+  SomeClass *vlaArray[5];
+
+  if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArray() {
+   int count = 1;
+   SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArrayWithExplicitStrongAttribute() {
+   int count = 1;
+   __attribute__((objc_ownership(strong))) SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2132,9 +2132,10 @@
   NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
   }
 
-  // If the init list is shorter than the array length, set the
-  // array default value.
-  if (Size.hasValue() && i < Size.getValue())
+  // If the init list is shorter than the array length (or the array has
+  // variable length), set the array default value. Values that are already set
+  // are not overwritten.
+  if (!Size.hasValue() || i < Size.getValue())
 NewB = setImplicitDefaultValue(NewB, R, ElementTy);
 
   return NewB;


Index: test/Analysis/arc-zero-init.m
===
--- test/Analysis/arc-zero-init.m
+++ test/Analysis/arc-zero-init.m
@@ -0,0 +1,46 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -fobjc-arc %s
+
+#if __has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+@interface SomeClass
+@end
+
+void simpleStrongPointerValue() {
+  SomeClass *x;
+  if (x) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void simpleArray() {
+  SomeClass *vlaArray[5];
+
+  if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArray() {
+   int count = 1;
+   SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArrayWithExplicitStrongAttribute() {
+   int count = 1;
+   __attribute__((objc_ownership(strong))) SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2132,9 +2132,10 @@
   NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
   }
 
-  // If the init list is shorter than the array length, set the
-  // array default value.
-  if (Size.hasValue() && i < Size.getValue())
+  // If the init list is shorter than the array length (or the array has
+  // variable length), set the array default value. Values that are already set
+  // are not overwritten.
+  if (!Size.hasValue() || i < Size.getValue())
 NewB = setImplicitDefaultValue(NewB, R, ElementTy);
 
   return NewB;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

2017-12-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/CodeGen/CodeGenTypes.h:378
+  /// specification removed.
+  QualType removeNothrowQualification(const FunctionProtoType *Proto) const;
 };

Please use the frontend language terminology here: "nothrow" is appropriate 
when talking about an LLVM function, but for the frontend type we should call 
this "removeExceptionSpecification" or similar. It would make sense for this to 
live on `ASTContext` instead of `CodeGenTypes`, since it's an AST type 
transformation utility not something related to IR generation. (There's a call 
to `getFunctionType` in `Sema::IsFunctionConversion` that you could also 
convert to use this `ASTContext` utility function.)

Perhaps exposing the currently-internal `getFunctionTypeWithExceptionSpec` from 
ASTContext.cpp would be a good way forward. (That function also handles 
wrapping, unwrapping, and adjusting type sugar nodes, but has the same effect 
as this one on the canonical type.)



Comment at: clang/test/CodeGenCXX/ubsan-function-noexcept.cpp:5
+// qualifier in its mangled name.
+// CHECK: @[[LABEL:[0-9]+]] = private constant i8* bitcast ({ i8*, i8* }* 
@_ZTIFvvE to i8*)
+// CHECK: define void @_Z1fv() #{{.*}} prologue <{ i32, i32 }> <{ i32 {{.*}}, 
i32 trunc (i64 sub (i64 ptrtoint (i8** @[[LABEL]] to i64), i64 ptrtoint (void 
()* @_Z1fv to i64)) to i32) }>

A name more meaningful than "LABEL" would be more useful to future readers of 
this code.


https://reviews.llvm.org/D40720



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


[PATCH] D41478: [analyzer] Fix zero-initialization of stack VLAs under ARC.

2017-12-21 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM. The tests are great!!


Repository:
  rC Clang

https://reviews.llvm.org/D41478



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


[PATCH] D41242: [Solaris] Silence -pthread warning on Solaris

2017-12-21 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev accepted this revision.
fedor.sergeev added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D41242



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


[PATCH] D24933: Enable configuration files in clang

2017-12-21 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 127911.
sepavloff marked 2 inline comments as done.
sepavloff added a comment.

Small corrections to the patch

- Avoid quick return in the case of error, it may cause fails of clang tools.
- Fixed typo.


Repository:
  rC Clang

https://reviews.llvm.org/D24933

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Config/config.h.cmake
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/Inputs/config-2a.cfg
  test/Driver/Inputs/config-3.cfg
  test/Driver/Inputs/config-4.cfg
  test/Driver/Inputs/config-5.cfg
  test/Driver/Inputs/config-6.cfg
  test/Driver/Inputs/config/config-4.cfg
  test/Driver/Inputs/config/i386-qqq.cfg
  test/Driver/Inputs/config/i386-qqq3.cfg
  test/Driver/Inputs/config/x86_64-qqq.cfg
  test/Driver/Inputs/config/x86_64-qqq2.cfg
  test/Driver/Inputs/config/x86_64.cfg
  test/Driver/Inputs/config2/config-4.cfg
  test/Driver/Inputs/config2/i386.cfg
  test/Driver/config-file-errs.c
  test/Driver/config-file.c
  test/Driver/config-file2.c
  test/Driver/config-file3.c

Index: test/Driver/config-file3.c
===
--- /dev/null
+++ test/Driver/config-file3.c
@@ -0,0 +1,98 @@
+// REQUIRES: shell
+// REQUIRES: x86-registered-target
+
+//--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by that path.
+//
+// RUN: mkdir -p %T/workdir
+// RUN: echo "@subdir/cfg-s2" > %T/workdir/cfg-1
+// RUN: mkdir -p %T/workdir/subdir
+// RUN: echo "-Wundefined-var-template" > %T/workdir/subdir/cfg-s2
+//
+// RUN: ( cd %T && %clang --config workdir/cfg-1 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-REL )
+//
+// CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1
+// CHECK-REL: -Wundefined-var-template
+
+
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
+//
+// RUN: mkdir -p %T/testdmode
+// RUN: [ ! -s %T/testdmode/qqq-clang-g++ ] || rm %T/testdmode/qqq-clang-g++
+// RUN: ln -s %clang %T/testdmode/qqq-clang-g++
+// RUN: echo "-Wundefined-func-template" > %T/testdmode/qqq-clang-g++.cfg
+// RUN: echo "-Werror" > %T/testdmode/qqq.cfg
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix FULL-NAME
+//
+// FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+// FULL-NAME: -Wundefined-func-template
+// FULL-NAME-NOT: -Werror
+//
+//--- File specified by --config overrides config inferred from clang executable.
+//
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT
+//
+// CHECK-EXPLICIT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg
+//
+//--- Invocation qqq-clang-g++ tries to find config file qqq.cfg if qqq-clang-g++.cfg is not found.
+//
+// RUN: rm %T/testdmode/qqq-clang-g++.cfg
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix SHORT-NAME
+//
+// SHORT-NAME: Configuration file: {{.*}}/testdmode/qqq.cfg
+// SHORT-NAME: -Werror
+// SHORT-NAME-NOT: -Wundefined-func-template
+
+
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: mkdir -p %T/testbin
+// RUN: [ ! -s %T/testbin/clang ] || rm %T/testbin/clang
+// RUN: ln -s %clang %T/testbin/clang
+// RUN: echo "-Werror" > %T/testbin/aaa.cfg
+// RUN: %T/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
+
+
+//--- If command line contains options that change triple (for instance, -m32), clang tries
+//reloading config file.
+
+//--- When reloading config file, x86_64-clang-g++ tries to find config i386-clang-g++.cfg first.
+//
+// RUN: mkdir -p %T/testreload
+// RUN: [ ! -s %T/testreload/x86_64-clang-g++ ] || rm %T/testreload/x86_64-clang-g++
+// RUN: ln -s %clang %T/testreload/x86_64-clang-g++
+// RUN: echo "-Wundefined-func-template" > %T/testreload/i386-clang-g++.cfg
+// RUN: echo "-Werror" > %T/testreload/i386.cfg
+// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD
+//
+// CHECK-RELOAD: Configuration file: {{.*}}/testreload/i386-clang-g++.cfg
+// CHECK-RELOAD: -Wundefined-func-template
+// CHECK-RELOAD-NOT: -Werror
+
+//--- If config file is specified by --config and its name does not start with architecture, it is used without reloading.
+//
+// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -m32 -no-canonical-prefixes 

[PATCH] D40478: Added control flow architecture protection Flag

2017-12-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Are we sure we want a different command line option name from gcc? From our 
internal conversations with the gcc folks I thought they were suggesting that 
-fcf-protection could imply a software mechanism if a hardware mechanism was 
not available thorugh -mibt or -march?

Should we emit an error to the user if -mibt isn't available?  We should be 
able to add virtual methods on TargetInfo that X86 can customize to check for 
ibt and shstk.

Can you provide more information about the miscompile on MSVC? I think we 
should do more to understand that, this sounds like it could be a time bomb 
waiting to fail somewhere else.


Repository:
  rL LLVM

https://reviews.llvm.org/D40478



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


[PATCH] D41500: ananas: Add shared library support

2017-12-21 Thread Rink via Phabricator via cfe-commits
zhmu created this revision.
zhmu added a reviewer: ed.
Herald added a subscriber: cfe-commits.

The Ananas Operating System (https://github.com/zhmu/ananas) has shared library 
support as of commit 57739c0b6ece56dd4872aedf30264ed4b9412c77.

This change adds the necessary settings to clang so that shared executables and 
libraries can be build correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D41500

Files:
  lib/Driver/ToolChains/Ananas.cpp
  test/Driver/ananas.c


Index: test/Driver/ananas.c
===
--- test/Driver/ananas.c
+++ test/Driver/ananas.c
@@ -7,3 +7,11 @@
 // CHECK-STATIC: crtbegin.o
 // CHECK-STATIC: crtend.o
 // CHECK-STATIC: crtn.o
+
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-ananas -shared %s 
\
+// RUN:   --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: crti.o
+// CHECK-SHARED: crtbeginS.o
+// CHECK-SHARED: crtendS.o
+// CHECK-SHARED: crtn.o
Index: lib/Driver/ToolChains/Ananas.cpp
===
--- lib/Driver/ToolChains/Ananas.cpp
+++ lib/Driver/ToolChains/Ananas.cpp
@@ -64,8 +64,19 @@
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
-  // Ananas only supports static linkage for now.
-  CmdArgs.push_back("-Bstatic");
+  if (Args.hasArg(options::OPT_static)) {
+CmdArgs.push_back("-Bstatic");
+  } else {
+if (Args.hasArg(options::OPT_rdynamic))
+  CmdArgs.push_back("-export-dynamic");
+if (Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back("-Bshareable");
+} else {
+  Args.AddAllArgs(CmdArgs, options::OPT_pie);
+  CmdArgs.push_back("-dynamic-linker");
+  CmdArgs.push_back("/lib/ld-ananas.so");
+}
+  }
 
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
@@ -75,9 +86,15 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+}
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie)) {
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbeginS.o")));
+} else {
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+}
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -98,7 +115,10 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
+else
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
   }
 


Index: test/Driver/ananas.c
===
--- test/Driver/ananas.c
+++ test/Driver/ananas.c
@@ -7,3 +7,11 @@
 // CHECK-STATIC: crtbegin.o
 // CHECK-STATIC: crtend.o
 // CHECK-STATIC: crtn.o
+
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-ananas -shared %s \
+// RUN:   --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: crti.o
+// CHECK-SHARED: crtbeginS.o
+// CHECK-SHARED: crtendS.o
+// CHECK-SHARED: crtn.o
Index: lib/Driver/ToolChains/Ananas.cpp
===
--- lib/Driver/ToolChains/Ananas.cpp
+++ lib/Driver/ToolChains/Ananas.cpp
@@ -64,8 +64,19 @@
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
-  // Ananas only supports static linkage for now.
-  CmdArgs.push_back("-Bstatic");
+  if (Args.hasArg(options::OPT_static)) {
+CmdArgs.push_back("-Bstatic");
+  } else {
+if (Args.hasArg(options::OPT_rdynamic))
+  CmdArgs.push_back("-export-dynamic");
+if (Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back("-Bshareable");
+} else {
+  Args.AddAllArgs(CmdArgs, options::OPT_pie);
+  CmdArgs.push_back("-dynamic-linker");
+  CmdArgs.push_back("/lib/ld-ananas.so");
+}
+  }
 
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
@@ -75,9 +86,15 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+}
 

[PATCH] D39053: [Bitfield] Add more cases to making the bitfield a separate location

2017-12-21 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic added a comment.

ping


https://reviews.llvm.org/D39053



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


[clang-tools-extra] r321286 - [clangd] Fix use after free.

2017-12-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Dec 21 09:51:35 2017
New Revision: 321286

URL: http://llvm.org/viewvc/llvm-project?rev=321286=rev
Log:
[clangd] Fix use after free.

Found by asan.

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=321286=321285=321286=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Thu Dec 21 
09:51:35 2017
@@ -95,9 +95,10 @@ bool SymbolCollector::handleDeclOccurenc
   return true;
 
 auto  = ND->getASTContext().getSourceManager();
-SymbolLocation Location = {
-makeAbsolutePath(SM, SM.getFilename(D->getLocation())),
-SM.getFileOffset(D->getLocStart()), SM.getFileOffset(D->getLocEnd())};
+std::string FilePath =
+makeAbsolutePath(SM, SM.getFilename(D->getLocation()));
+SymbolLocation Location = {FilePath, SM.getFileOffset(D->getLocStart()),
+   SM.getFileOffset(D->getLocEnd())};
 std::string QName = ND->getQualifiedNameAsString();
 auto ScopeAndName = splitQualifiedName(QName);
 Symbols.insert({std::move(ID), ScopeAndName.second, ScopeAndName.first,


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


[PATCH] D41444: [ASTImporterTest] Make testing under '-fdelayed-template-parsing' mandatory

2017-12-21 Thread Aleksei Sidorin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321285: [ASTImporterTest] Add mandatory testing with 
-fdelayed-template-parsing (authored by a.sidorin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41444?vs=127748=127903#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41444

Files:
  cfe/trunk/unittests/AST/ASTImporterTest.cpp

Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -22,38 +22,50 @@
 namespace clang {
 namespace ast_matchers {
 
-typedef std::vector StringVector;
+typedef std::vector ArgVector;
+typedef std::vector RunOptions;
 
-void getLangArgs(Language Lang, StringVector ) {
+static bool isCXX(Language Lang) {
+  return Lang == Lang_CXX || Lang == Lang_CXX11;
+}
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs;
+  // Test with basic arguments.
   switch (Lang) {
   case Lang_C:
-Args.insert(Args.end(), { "-x", "c", "-std=c99" });
+BasicArgs = {"-x", "c", "-std=c99"};
 break;
   case Lang_C89:
-Args.insert(Args.end(), { "-x", "c", "-std=c89" });
+BasicArgs = {"-x", "c", "-std=c89"};
 break;
   case Lang_CXX:
-Args.push_back("-std=c++98");
+BasicArgs = {"-std=c++98"};
 break;
   case Lang_CXX11:
-Args.push_back("-std=c++11");
+BasicArgs = {"-std=c++11"};
 break;
   case Lang_OpenCL:
   case Lang_OBJCXX:
-break;
+llvm_unreachable("Not implemented yet!");
   }
+
+  // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
+  // default behaviour.
+  if (isCXX(Lang)) {
+ArgVector ArgsForDelayedTemplateParse = BasicArgs;
+ArgsForDelayedTemplateParse.emplace_back("-fdelayed-template-parsing");
+return {BasicArgs, ArgsForDelayedTemplateParse};
+  }
+
+  return {BasicArgs};
 }
 
 template
 testing::AssertionResult
-testImport(const std::string , Language FromLang,
-   const std::string , Language ToLang,
-   MatchVerifier ,
-   const MatcherType ) {
-  StringVector FromArgs, ToArgs;
-  getLangArgs(FromLang, FromArgs);
-  getLangArgs(ToLang, ToArgs);
-
+testImport(const std::string , const ArgVector ,
+   const std::string , const ArgVector ,
+   MatchVerifier , const MatcherType ) {
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
@@ -92,7 +104,7 @@
 return testing::AssertionFailure() << "Import failed, nullptr returned!";
 
   // This should dump source locations and assert if some source locations
-  // were not imported
+  // were not imported.
   SmallString<1024> ImportChecker;
   llvm::raw_svector_ostream ToNothing(ImportChecker);
   ToCtx.getTranslationUnitDecl()->print(ToNothing);
@@ -104,148 +116,154 @@
   return Verifier.match(Imported, AMatcher);
 }
 
+template
+void testImport(const std::string , Language FromLang,
+const std::string , Language ToLang,
+MatchVerifier ,
+const MatcherType ) {
+  auto RunOptsFrom = getRunOptionsForLanguage(FromLang);
+  auto RunOptsTo = getRunOptionsForLanguage(ToLang);
+  for (const auto  : RunOptsFrom)
+for (const auto  : RunOptsTo)
+  EXPECT_TRUE(testImport(FromCode, FromArgs, ToCode, ToArgs,
+ Verifier, AMatcher));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const char [4]");
-  EXPECT_TRUE(testImport("void declToImport() { L\"foo\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const wchar_t [4]");
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\" \"bar\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const char [7]");
+  testImport("void declToImport() { \"foo\"; }",
+ Lang_CXX, "", Lang_CXX, Verifier,
+   

r321285 - [ASTImporterTest] Add mandatory testing with '-fdelayed-template-parsing'

2017-12-21 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Thu Dec 21 09:41:06 2017
New Revision: 321285

URL: http://llvm.org/viewvc/llvm-project?rev=321285=rev
Log:
[ASTImporterTest] Add mandatory testing with '-fdelayed-template-parsing'

 * While running ASTImporterTests, we often forget about Windows MSVC
   buildbots which enable '-fdelayed-template-parsing' by default.
   This leads to AST import errors because templates are not parsed
   and corresponding parts of AST are not built so importer cannot import them.
   It takes both reviewing time to find such issues and post-commit time
   to fix unexpected buildbot failures. To solve this issue, we enable testing
   with '-fdelayed-template-parsing' option enabled by default in addition
   to testing with default compiler options. This allows us to catch
   the problem during development.

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


Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=321285=321284=321285=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Thu Dec 21 09:41:06 2017
@@ -22,38 +22,50 @@
 namespace clang {
 namespace ast_matchers {
 
-typedef std::vector StringVector;
+typedef std::vector ArgVector;
+typedef std::vector RunOptions;
 
-void getLangArgs(Language Lang, StringVector ) {
+static bool isCXX(Language Lang) {
+  return Lang == Lang_CXX || Lang == Lang_CXX11;
+}
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs;
+  // Test with basic arguments.
   switch (Lang) {
   case Lang_C:
-Args.insert(Args.end(), { "-x", "c", "-std=c99" });
+BasicArgs = {"-x", "c", "-std=c99"};
 break;
   case Lang_C89:
-Args.insert(Args.end(), { "-x", "c", "-std=c89" });
+BasicArgs = {"-x", "c", "-std=c89"};
 break;
   case Lang_CXX:
-Args.push_back("-std=c++98");
+BasicArgs = {"-std=c++98"};
 break;
   case Lang_CXX11:
-Args.push_back("-std=c++11");
+BasicArgs = {"-std=c++11"};
 break;
   case Lang_OpenCL:
   case Lang_OBJCXX:
-break;
+llvm_unreachable("Not implemented yet!");
   }
+
+  // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
+  // default behaviour.
+  if (isCXX(Lang)) {
+ArgVector ArgsForDelayedTemplateParse = BasicArgs;
+ArgsForDelayedTemplateParse.emplace_back("-fdelayed-template-parsing");
+return {BasicArgs, ArgsForDelayedTemplateParse};
+  }
+
+  return {BasicArgs};
 }
 
 template
 testing::AssertionResult
-testImport(const std::string , Language FromLang,
-   const std::string , Language ToLang,
-   MatchVerifier ,
-   const MatcherType ) {
-  StringVector FromArgs, ToArgs;
-  getLangArgs(FromLang, FromArgs);
-  getLangArgs(ToLang, ToArgs);
-
+testImport(const std::string , const ArgVector ,
+   const std::string , const ArgVector ,
+   MatchVerifier , const MatcherType ) {
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
@@ -92,7 +104,7 @@ testImport(const std::string ,
 return testing::AssertionFailure() << "Import failed, nullptr returned!";
 
   // This should dump source locations and assert if some source locations
-  // were not imported
+  // were not imported.
   SmallString<1024> ImportChecker;
   llvm::raw_svector_ostream ToNothing(ImportChecker);
   ToCtx.getTranslationUnitDecl()->print(ToNothing);
@@ -104,148 +116,154 @@ testImport(const std::string ,
   return Verifier.match(Imported, AMatcher);
 }
 
+template
+void testImport(const std::string , Language FromLang,
+const std::string , Language ToLang,
+MatchVerifier ,
+const MatcherType ) {
+  auto RunOptsFrom = getRunOptionsForLanguage(FromLang);
+  auto RunOptsTo = getRunOptionsForLanguage(ToLang);
+  for (const auto  : RunOptsFrom)
+for (const auto  : RunOptsTo)
+  EXPECT_TRUE(testImport(FromCode, FromArgs, ToCode, ToArgs,
+ Verifier, AMatcher));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const char [4]");
-  EXPECT_TRUE(testImport("void declToImport() { L\"foo\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   

[PATCH] D41498: [libcxx] Add clang negative thread safety assertions to std::mutex

2017-12-21 Thread Luis Héctor Chávez via Phabricator via cfe-commits
lhchavez created this revision.
Herald added a reviewer: EricWF.
Herald added a subscriber: cfe-commits.

This adds clang negative thread safery assertion support to std::mutex,
as documented in:

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html

Fixes #34951.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41498

Files:
  include/__mutex_base
  test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.pass.cpp
  utils/libcxx/test/config.py

Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -135,6 +135,7 @@
 self.configure_cxx_library_root()
 self.configure_use_clang_verify()
 self.configure_use_thread_safety()
+self.configure_use_thread_safety_negative()
 self.configure_execute_external()
 self.configure_ccache()
 self.configure_compile_flags()
@@ -354,6 +355,15 @@
 self.config.available_features.add('thread-safety')
 self.lit_config.note("enabling thread-safety annotations")
 
+def configure_use_thread_safety_negative(self):
+'''If set, run clang with -verify on failing tests.'''
+has_thread_safety_negative = self.cxx.hasCompileFlag(
+'-Werror=thread-safety-negative')
+if has_thread_safety_negative:
+self.cxx.compile_flags += ['-Werror=thread-safety-negative']
+self.config.available_features.add('thread-safety-negative')
+self.lit_config.note("enabling thread-safety-negative annotations")
+
 def configure_execute_external(self):
 # Choose between lit's internal shell pipeline runner and a real shell.
 # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.pass.cpp
@@ -0,0 +1,29 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: thread-safety, thread-safety-negative
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(!m))) {
+  m.lock();
+  foo++;
+  m.unlock();
+}
+
+int main() {
+  increment();
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.fail.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: thread-safety, thread-safety-negative
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(!m))) {
+  m.lock();
+  foo++;
+  m.unlock();
+}
+
+int main() {
+  m.lock();
+  increment();
+  m.unlock();
+}
Index: include/__mutex_base
===
--- include/__mutex_base
+++ include/__mutex_base
@@ -62,6 +62,9 @@
 void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
 bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
 void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
+#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+const mutex& operator!() const { return *this; }
+#endif
 
 typedef __libcpp_mutex_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38639: [clangd] #include statements support for Open definition

2017-12-21 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 127900.
Nebiroth marked 11 inline comments as done.
Nebiroth added a comment.

  Minor code cleanup


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38639

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.h
  clangd/XRefs.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "Context.h"
 #include "TestFS.h"
@@ -751,6 +750,75 @@
   EXPECT_FALSE(PathResult.hasValue());
 }
 
+TEST_F(ClangdVFSTest, CheckDefinitionIncludes) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const auto SourceContents = R"cpp(
+  #include "foo.h"
+  #include "invalid.h"
+  int b = a;
+  // test
+  int foo;
+  #include "foo.h"
+  )cpp";
+  FS.Files[FooCpp] = SourceContents;
+  auto FooH = getVirtualTestFilePath("foo.h");
+  const auto HeaderContents = "int a;";
+
+  FS.Files[FooCpp] = SourceContents;
+  FS.Files[FooH] = HeaderContents;
+
+  Server.addDocument(FooH, HeaderContents);
+  Server.addDocument(FooCpp, SourceContents);
+
+  Position P = Position{1, 11};
+
+  auto ExpectedLocations = Server.findDefinitions(FooCpp, P);
+  ASSERT_TRUE(!!ExpectedLocations);
+  std::vector Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+  std::string s("file:///");
+  std::string check = Locations[0].uri.uri;
+  check = check.erase(0, s.size() - 1);
+  check = check.substr(0, check.size());
+  ASSERT_EQ(check, FooH);
+  ASSERT_EQ(Locations[0].range.start.line, 0);
+  ASSERT_EQ(Locations[0].range.start.character, 0);
+  ASSERT_EQ(Locations[0].range.end.line, 0);
+  ASSERT_EQ(Locations[0].range.end.character, 0);
+
+  // Test ctrl-clicking on the #include part on the statement
+  Position P2 = Position{1, 3};
+
+  ExpectedLocations = Server.findDefinitions(FooCpp, P2);
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+
+  // Test invalid include
+  Position P3 = Position{2, 11};
+
+  ExpectedLocations = Server.findDefinitions(FooCpp, P3);
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(Locations.empty());
+
+  // Test include outside of Preamble
+  Position P4  = Position{6, 5};
+
+  ExpectedLocations = Server.findDefinitions(FooCpp, P4);
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+}
+
 TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
   class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
   public:
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -18,6 +18,7 @@
 class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
   std::vector Decls;
   std::vector MacroInfos;
+  std::vector DeclarationLocations;
   const SourceLocation 
   const ASTContext 
   Preprocessor 
@@ -37,14 +38,26 @@
 return std::move(Decls);
   }
 
+  std::vector takeLocations() {
+// Don't keep the same location multiple times.
+// This can happen when nodes in the AST are visited twice.
+std::sort(DeclarationLocations.begin(), DeclarationLocations.end());
+auto Last =
+std::unique(DeclarationLocations.begin(), DeclarationLocations.end());
+DeclarationLocations.erase(Last, DeclarationLocations.end());
+return std::move(DeclarationLocations);
+  }
+
   std::vector takeMacroInfos() {
 // Don't keep the same Macro info multiple times.
 std::sort(MacroInfos.begin(), MacroInfos.end());
 auto Last = std::unique(MacroInfos.begin(), MacroInfos.end());
 MacroInfos.erase(Last, MacroInfos.end());
 return std::move(MacroInfos);
   }
 
+  const SourceLocation () { return SearchedLocation; };
+
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
   ArrayRef Relations, FileID FID,
@@ -62,6 +75,25 @@
SourceMgr.getFileID(SearchedLocation) == FID;
   }
 
+  void addDeclarationLocation(const SourceRange ) {
+const SourceManager  = AST.getSourceManager();
+const LangOptions  = AST.getLangOpts();
+SourceLocation LocStart = ValSourceRange.getBegin();
+SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(),
+   0, SourceMgr, LangOpts);
+Position Begin;
+Begin.line = SourceMgr.getSpellingLineNumber(LocStart) 

[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

2017-12-21 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 127899.
sberg added a comment.

(need to call getAs instead of cast in 
one place, in case the name in the function decl is wrapped in parens, as 
happens in HarfBuzz's hb-buffer.cc)


https://reviews.llvm.org/D40720

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp

Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx -fsanitize=function %s -O3 -g -o %t
+// RUN: %clangxx -std=c++17 -fsanitize=function %s -O3 -g -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
 // Verify that we can disable symbolization if needed:
 // RUN: %env_ubsan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM
@@ -23,9 +23,49 @@
   reinterpret_cast(reinterpret_cast(f))(42);
 }
 
+void f1(int) {}
+void f2(unsigned int) {}
+void f3(int) noexcept {}
+void f4(unsigned int) noexcept {}
+
+void check_noexcept_calls() {
+  void (*p1)(int);
+  p1 = 
+  p1(0);
+  p1 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+  p1 = 
+  p1(0);
+  p1 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+
+  void (*p2)(int) noexcept;
+  p2 = reinterpret_cast();
+  // TODO: Unclear whether calling a non-noexcept function through a pointer to
+  // nexcept function should cause an error.
+  // CHECK-NOT: function.cpp:[[@LINE+2]]:3: runtime error: call to function f1(int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM-NOT: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = 
+  p2(0);
+  p2 = reinterpret_cast();
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+}
+
 int main(void) {
   make_valid_call();
   make_invalid_call();
+  check_noexcept_calls();
   // Check that no more errors will be printed.
   // CHECK-NOT: runtime error: call to function
   // NOSYM-NOT: runtime error: call to function
Index: clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++17 -fsanitize=function -emit-llvm -triple x86_64-linux-gnu %s -o - | FileCheck %s
+
+// Check that typeinfo recorded in function prolog doesn't have "Do" noexcept
+// qualifier in its mangled name.
+// CHECK: @[[LABEL:[0-9]+]] = private constant i8* bitcast ({ i8*, i8* }* @_ZTIFvvE to i8*)
+// CHECK: define void @_Z1fv() #{{.*}} prologue <{ i32, i32 }> <{ i32 {{.*}}, i32 trunc (i64 sub (i64 ptrtoint (i8** @[[LABEL]] to i64), i64 ptrtoint (void ()* @_Z1fv to i64)) to i32) }>
+void f() noexcept {}
+
+// CHECK: define void @_Z1gPDoFvvE
+void g(void (*p)() noexcept) {
+  // Check that reference typeinfo at call site doesn't have "Do" noexcept
+  // qualifier in its mangled name, either.
+  // CHECK: icmp eq i8* %{{.*}}, bitcast ({ i8*, i8* }* @_ZTIFvvE to i8*), !nosanitize
+  p();
+}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3415,7 +3415,7 @@
 
 /// Compute the flags for a __pbase_type_info, and remove the corresponding
 /// pieces from \p Type.
-static unsigned extractPBaseFlags(ASTContext , QualType ) {
+static unsigned extractPBaseFlags(CodeGenTypes , 

[PATCH] D41150: [CFG] Adding new CFGStmt LoopEntrance for the StaticAnalyzer

2017-12-21 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 127894.
szepet marked an inline comment as done.
szepet added a comment.

Comment added to LoopEntrance CFGElement.


https://reviews.llvm.org/D41150

Files:
  include/clang/Analysis/CFG.h
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/loopexit-cfg-output.cpp

Index: test/Analysis/loopexit-cfg-output.cpp
===
--- test/Analysis/loopexit-cfg-output.cpp
+++ test/Analysis/loopexit-cfg-output.cpp
@@ -34,6 +34,7 @@
 // CHECK:   [B5]
 // CHECK-NEXT:   1: 0
 // CHECK-NEXT:   2: int i = 0;
+// CHECK-NEXT:   3: ForStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (1): B4
 
@@ -46,8 +47,8 @@
   return;
 }
 
-// CHECK:   [B4 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B3
+// CHECK:   [B5 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B4
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: ForStmt (LoopExit)
@@ -62,15 +63,20 @@
 // CHECK-NEXT:   Preds (2): B2 B4
 // CHECK-NEXT:   Succs (2): B2 NULL
 
+// CHECK:   [B4]
+// CHECK-NEXT:   1: ForStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B5
+// CHECK-NEXT:   Succs (1): B3
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_forloop2() {
   for (;;)
 ;
 }
 
-// CHECK:   [B5 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B4
+// CHECK:   [B6 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B5
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: WhileStmt (LoopExit)
@@ -91,6 +97,11 @@
 // CHECK-NEXT:   Preds (2): B2 B5
 // CHECK-NEXT:   Succs (2): B3 NULL
 
+// CHECK:   [B5]
+// CHECK-NEXT:   1: WhileStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B6
+// CHECK-NEXT:   Succs (1): B4
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_while1() {
@@ -125,6 +136,7 @@
 
 // CHECK:   [B4]
 // CHECK-NEXT:   1: int l;
+// CHECK-NEXT:   2: WhileStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B5
 // CHECK-NEXT:   Succs (1): B3
 
@@ -138,8 +150,8 @@
   return;
 }
 
-// CHECK:   [B4 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B3
+// CHECK:   [B5 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B4
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: WhileStmt (LoopExit)
@@ -155,16 +167,21 @@
 // CHECK-NEXT:   Preds (2): B2 B4
 // CHECK-NEXT:   Succs (2): NULL B1
 
+// CHECK:   [B4]
+// CHECK-NEXT:   1: WhileStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B5
+// CHECK-NEXT:   Succs (1): B3
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_while3() {
   while (false) {
 ;
   }
 }
 
-// CHECK:   [B4 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B2
+// CHECK:   [B5 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B4
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: DoStmt (LoopExit)
@@ -180,6 +197,11 @@
 // CHECK:   [B3]
 // CHECK-NEXT:   Succs (1): B2
 
+// CHECK:   [B4]
+// CHECK-NEXT:   1: DoStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B5
+// CHECK-NEXT:   Succs (1): B2
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_dowhile1() {
@@ -221,6 +243,7 @@
 // CHECK:   [B5]
 // CHECK-NEXT:   1: 2
 // CHECK-NEXT:   2: int j = 2;
+// CHECK-NEXT:   3: DoStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (1): B3
 
@@ -276,6 +299,7 @@
 // CHECK:   [B7]
 // CHECK-NEXT:   1: 1
 // CHECK-NEXT:   2: int j = 1;
+// CHECK-NEXT:   3: ForStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B8
 // CHECK-NEXT:   Succs (1): B6
 
@@ -292,6 +316,7 @@
 // CHECK-NEXT:   1: 40
 // CHECK-NEXT:   2: -[B9.1]
 // CHECK-NEXT:   3: int i = -40;
+// CHECK-NEXT:   4: WhileStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B10
 // CHECK-NEXT:   Succs (1): B8
 
@@ -305,19 +330,19 @@
   }
 }
 
-// CHECK:   [B9 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B8
+// CHECK:   [B10 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B9
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: ForStmt (LoopExit)
-// CHECK-NEXT:   Preds (1): B7
+// CHECK-NEXT:   Preds (1): B8
 // CHECK-NEXT:   Succs (1): B0
 
 // CHECK:   [B2]
 // CHECK-NEXT:   1: j
 // CHECK-NEXT:   2: [B2.1]++
 // CHECK-NEXT:   Preds (1): B3
-// CHECK-NEXT:   Succs (1): B7
+// CHECK-NEXT:   Succs (1): B8
 
 // CHECK:   [B3]
 // CHECK-NEXT:   1: DoStmt (LoopExit)
@@ -346,22 +371,28 @@
 // CHECK-NEXT:   Succs (1): B5
 
 // CHECK:   [B7]
+// CHECK-NEXT:   1: DoStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B8
+// CHECK-NEXT:   Succs (1): B5
+
+// CHECK:   [B8]
 // CHECK-NEXT:   1: j
-// CHECK-NEXT:   2: [B7.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   2: [B8.1] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:   3: 6
-// CHECK-NEXT:   4: [B7.2] < [B7.3]
-// CHECK-NEXT:   T: for (...; [B7.4]; ...)
-// CHECK-NEXT:   Preds (2): B2 B8
-// CHECK-NEXT:   Succs (2): B5 B1
+// CHECK-NEXT:   4: [B8.2] < [B8.3]
+// CHECK-NEXT:   T: for (...; [B8.4]; ...)
+// CHECK-NEXT:   Preds (2): B2 B9
+// CHECK-NEXT:   Succs (2): B7 B1
 
-// CHECK:   [B8]
+// CHECK:   [B9]
 // CHECK-NEXT:   1: 40
-// 

[PATCH] D41394: [CodeGen] Support generation of TBAA info in the new format

2017-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

That's great, thanks.  LGTM.


https://reviews.llvm.org/D41394



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


[PATCH] D41495: [clangd] Skip function bodies when building the preamble

2017-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I haven't done proper benchmarks, but here are some numbers from running this 
on my machine:

Sizes of preamble with (before the change) and without (after the change) 
functon bodies:

| File   | Before  | After   |
| ClangdUnit.cpp | 49.58MB | 34.79MB |
| SemaDecl.cpp   | 47.03MB | 31.51MB |
| All C++11 stl includes | 13.15MB | 8.75M   |
|

Time to build the preamble (just a single run, not a proper benchmark):

| File   | Before | After |
| ClangdUnit.cpp | 4.39s  | 2.49s |
| SemaDecl.cpp   | 4.28s  | 2.29s |
| All C++11 stl includes | 1.40s  | 0.80s |
|

Time to build AST and provide diagnostics after preamble is ready (just a 
single run, not a proper benchmark):

| File   | Before | After |
| ClangdUnit.cpp | 1.75s  | 0.18s |
| SemaDecl.cpp   | 2.30s  | 0.74s |
|


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41495



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


[PATCH] D41495: [clangd] Skip function bodies when building the preamble

2017-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added a subscriber: klimek.

To make building preambles faster and keep them smaller.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41495

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -529,12 +529,22 @@
   IntrusiveRefCntPtr PreambleDiagsEngine =
   CompilerInstance::createDiagnostics(
   >getDiagnosticOpts(), , false);
+
+  // Skip function bodies when building the preamble to speed up building
+  // the preamble and make it smaller. CI is later reused to build the AST,
+  // so we set SkipFunctionBodies back to false after preamble is built.
+  assert(!CI->getFrontendOpts().SkipFunctionBodies);
+  CI->getFrontendOpts().SkipFunctionBodies = true;
+
   CppFilePreambleCallbacks SerializedDeclsCollector;
   auto BuiltPreamble = PrecompiledPreamble::Build(
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
   /*StoreInMemory=*/That->StorePreamblesInMemory,
   SerializedDeclsCollector);
 
+  // Preamble is built, restore SkipFunctionBodies.
+  CI->getFrontendOpts().SkipFunctionBodies = false;
+
   if (BuiltPreamble) {
 log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
  " for file " + Twine(That->FileName));


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -529,12 +529,22 @@
   IntrusiveRefCntPtr PreambleDiagsEngine =
   CompilerInstance::createDiagnostics(
   >getDiagnosticOpts(), , false);
+
+  // Skip function bodies when building the preamble to speed up building
+  // the preamble and make it smaller. CI is later reused to build the AST,
+  // so we set SkipFunctionBodies back to false after preamble is built.
+  assert(!CI->getFrontendOpts().SkipFunctionBodies);
+  CI->getFrontendOpts().SkipFunctionBodies = true;
+
   CppFilePreambleCallbacks SerializedDeclsCollector;
   auto BuiltPreamble = PrecompiledPreamble::Build(
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
   /*StoreInMemory=*/That->StorePreamblesInMemory,
   SerializedDeclsCollector);
 
+  // Preamble is built, restore SkipFunctionBodies.
+  CI->getFrontendOpts().SkipFunctionBodies = false;
+
   if (BuiltPreamble) {
 log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
  " for file " + Twine(That->FileName));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread James Y Knight via cfe-commits
I think if a version number isn't explicitly specified in the -target
value, the value from -m-version-min ought to still be used, as
it was before.

Currently, clang will ignore the -m-version-min version number if
the target has a particular OS specified, even if it has no version number
as part of it.

(We should be able to workaround this change backwards-compatibly by
specifying in both the -target argument and in the -m-version-min
arguments, but I do think the behavior should be fixed.)

On Thu, Dec 21, 2017 at 10:45 AM, Martin Böhme  wrote:

> This is causing problems in some internal builds that specify both
> -mios-simulator-version-min=9.0 and --target=x86_64-apple-ios
>
> My expectation would be for the code to take the minimum OS version number
> from the -mios-simulator-version-min flag. In fact, however, the code seems
> to be completely ignoring this flag.
>
> Is my expectation wrong or does the code need to be modified to take this
> situation into account?
>
>
> On 19 December 2017 at 20:05, Alex Lorenz via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: arphaman
>> Date: Tue Dec 19 11:05:04 2017
>> New Revision: 321099
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=321099=rev
>> Log:
>> [driver][darwin] Take the OS version specified in "-target" as the target
>> OS instead of inferring it from SDK / environment
>>
>> The OS version is specified in -target should be used instead of the one
>> in an
>> environment variable / SDK name.
>>
>> rdar://35813850
>>
>> Differential Revision: https://reviews.llvm.org/D40998
>>
>> Modified:
>> cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> cfe/trunk/test/Driver/darwin-version.c
>> cfe/trunk/test/Driver/objc-weak.m
>> cfe/trunk/test/Driver/pic.c
>> cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>> lChains/Darwin.cpp?rev=321099=321098=321099=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
>> @@ -1233,6 +1233,10 @@ struct DarwinPlatform {
>>  llvm_unreachable("Unsupported Darwin Source Kind");
>>}
>>
>> +  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
>> + StringRef OSVersion, Arg *A) {
>> +return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion,
>> A);
>> +  }
>>static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
>> Arg *A) {
>>  return DarwinPlatform(OSVersionArg, Platform, A);
>> @@ -1250,33 +1254,32 @@ struct DarwinPlatform {
>>}
>>static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
>> StringRef Value) {
>> -DarwinPlatformKind Platform;
>> +return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
>> Value);
>> +  }
>> +
>> +private:
>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
>> *Argument)
>> +  : Kind(Kind), Platform(Platform), Argument(Argument) {}
>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef
>> Value,
>> + Arg *Argument = nullptr)
>> +  : Kind(Kind), Platform(Platform), OSVersion(Value),
>> Argument(Argument) {}
>> +
>> +  static DarwinPlatformKind getPlatformFromOS(llvm::Triple::OSType OS) {
>>  switch (OS) {
>>  case llvm::Triple::Darwin:
>>  case llvm::Triple::MacOSX:
>> -  Platform = DarwinPlatformKind::MacOS;
>> -  break;
>> +  return DarwinPlatformKind::MacOS;
>>  case llvm::Triple::IOS:
>> -  Platform = DarwinPlatformKind::IPhoneOS;
>> -  break;
>> +  return DarwinPlatformKind::IPhoneOS;
>>  case llvm::Triple::TvOS:
>> -  Platform = DarwinPlatformKind::TvOS;
>> -  break;
>> +  return DarwinPlatformKind::TvOS;
>>  case llvm::Triple::WatchOS:
>> -  Platform = DarwinPlatformKind::WatchOS;
>> -  break;
>> +  return DarwinPlatformKind::WatchOS;
>>  default:
>>llvm_unreachable("Unable to infer Darwin variant");
>>  }
>> -return DarwinPlatform(InferredFromArch, Platform, Value);
>>}
>>
>> -private:
>> -  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
>> *Argument)
>> -  : Kind(Kind), Platform(Platform), Argument(Argument) {}
>> -  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef
>> Value)
>> -  : Kind(Kind), Platform(Platform), OSVersion(Value),
>> Argument(nullptr) {}
>> -
>>SourceKind Kind;
>>DarwinPlatformKind Platform;
>>std::string OSVersion;
>> @@ -1449,20 +1452,15 @@ inferDeploymentTargetFromArch(DerivedArg
>>const Driver ) {
>>llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS;

[PATCH] D41487: [clang-format] Adds a FormatStyleSet

2017-12-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 127888.
krasimir added a comment.

- Remove accidentally created file


Repository:
  rC Clang

https://reviews.llvm.org/D41487

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -853,6 +853,20 @@
   return true;
 }
 
+FormatStyle::FormatStyleSet FormatStyle::BuildStyleSetFromConfiguration(
+const FormatStyle ,
+const std::vector ) {
+  FormatStyleSet StyleSet;
+  StyleSet.Add(MainStyle);
+  for (size_t i = 0; i < ConfigurationStyles.size(); ++i) {
+if (ConfigurationStyles[i].Language != FormatStyle::LK_None &&
+ConfigurationStyles[i].Language != MainStyle.Language) {
+  StyleSet.Add(ConfigurationStyles[i]);
+}
+  }
+  return StyleSet;
+}
+
 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
@@ -888,15 +902,20 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can only be at slot 0) after it.
+  bool LanguageFound = false;
   for (int i = Styles.size() - 1; i >= 0; --i) {
 if (Styles[i].Language == Language ||
 Styles[i].Language == FormatStyle::LK_None) {
   *Style = Styles[i];
   Style->Language = Language;
-  return make_error_code(ParseError::Success);
+  LanguageFound = true;
+  break;
 }
   }
-  return make_error_code(ParseError::Unsuitable);
+  if (!LanguageFound)
+return make_error_code(ParseError::Unsuitable);
+  Style->StyleSet = FormatStyle::BuildStyleSetFromConfiguration(*Style, Styles);
+  return make_error_code(ParseError::Success);
 }
 
 std::string configurationAsText(const FormatStyle ) {
@@ -910,6 +929,30 @@
   return Stream.str();
 }
 
+llvm::Optional
+FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
+  if (!Styles)
+return None;
+  auto It = Styles->find(Language);
+  if (It == Styles->end())
+return None;
+  FormatStyle Style = *It->second;
+  Style.StyleSet = *this;
+  return Style;
+}
+
+void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
+  Style.StyleSet.Styles.reset();
+  if (!Styles)
+Styles = std::make_shared();
+  (*Styles)[Style.Language].reset(new FormatStyle(Style));
+}
+
+llvm::Optional
+FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
+  return StyleSet.Get(Language);
+}
+
 namespace {
 
 class JavaScriptRequoter : public TokenAnalyzer {
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1685,6 +1685,36 @@
Standard == R.Standard && TabWidth == R.TabWidth &&
UseTab == R.UseTab;
   }
+
+  llvm::Optional GetLanguageStyle(LanguageKind Language) const;
+
+  // Stores per-language styles. A FormatStyle instance inside has an empty
+  // StyleSet. A FormatStyle instance returned by the Get method has its
+  // StyleSet set to a copy of the originating StyleSet, effectively keeping the
+  // internal representation of that StyleSet alive.
+  //
+  // The memory management and ownership reminds of a birds nest: chicks
+  // leaving the nest take photos of the nest with them.
+  struct FormatStyleSet {
+typedef std::map
+MapType;
+
+llvm::Optional Get(FormatStyle::LanguageKind Language) const;
+void Add(FormatStyle Style);
+
+  private:
+std::shared_ptr Styles;
+  };
+
+  static FormatStyleSet BuildStyleSetFromConfiguration(
+  const FormatStyle ,
+  const std::vector );
+
+private:
+  FormatStyleSet StyleSet;
+
+  friend std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
 };
 
 /// \brief Returns a format style complying with the LLVM coding standards:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >