r290329 - Speculative revert of r290310 to see if that's the change that's making some of

2016-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 22 01:24:39 2016
New Revision: 290329

URL: http://llvm.org/viewvc/llvm-project?rev=290329=rev
Log:
Speculative revert of r290310 to see if that's the change that's making some of
the bots unhappy.

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

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290329=290328=290329=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Dec 22 01:24:39 2016
@@ -2059,8 +2059,7 @@ static bool isSameTemplateArg(ASTContext
 ///
 /// \param NTTPType For a declaration template argument, the type of
 /// the non-type template parameter that corresponds to this template
-/// argument. Can be null if no type sugar is available to add to the
-/// type from the template argument.
+/// argument.
 ///
 /// \param Loc The source location to use for the resulting template
 /// argument.
@@ -2076,16 +2075,12 @@ Sema::getTrivialTemplateArgumentLoc(cons
 Arg, Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
 
   case TemplateArgument::Declaration: {
-if (NTTPType.isNull())
-  NTTPType = Arg.getParamTypeForDecl();
 Expr *E = BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc)
   .getAs();
 return TemplateArgumentLoc(TemplateArgument(E), E);
   }
 
   case TemplateArgument::NullPtr: {
-if (NTTPType.isNull())
-  NTTPType = Arg.getNullPtrType();
 Expr *E = BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc)
   .getAs();
 return TemplateArgumentLoc(TemplateArgument(NTTPType, /*isNullPtr*/true),
@@ -2136,13 +2131,31 @@ ConvertDeducedTemplateArgument(Sema ,
TemplateDeductionInfo ,
bool InFunctionTemplate,
SmallVectorImpl ) {
+  // First, for a non-type template parameter type that is
+  // initialized by a declaration, we need the type of the
+  // corresponding non-type template parameter.
+  QualType NTTPType;
+  if (NonTypeTemplateParmDecl *NTTP =
+  dyn_cast(Param)) {
+NTTPType = NTTP->getType();
+if (NTTPType->isDependentType()) {
+  TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Output);
+  NTTPType = S.SubstType(NTTPType,
+ MultiLevelTemplateArgumentList(TemplateArgs),
+ NTTP->getLocation(),
+ NTTP->getDeclName());
+  if (NTTPType.isNull())
+return true;
+}
+  }
+
   auto ConvertArg = [&](DeducedTemplateArgument Arg,
 unsigned ArgumentPackIndex) {
 // Convert the deduced template argument into a template
 // argument that we can check, almost as if the user had written
 // the template argument explicitly.
 TemplateArgumentLoc ArgLoc =
-S.getTrivialTemplateArgumentLoc(Arg, QualType(), Info.getLocation());
+S.getTrivialTemplateArgumentLoc(Arg, NTTPType, Info.getLocation());
 
 // Check the template argument, converting it as necessary.
 return S.CheckTemplateArgument(
@@ -2174,28 +2187,22 @@ ConvertDeducedTemplateArgument(Sema ,
 }
 
 // If the pack is empty, we still need to substitute into the parameter
-// itself, in case that substitution fails.
-if (PackedArgsBuilder.empty()) {
+// itself, in case that substitution fails. For non-type parameters, we did
+// this above. For type parameters, no substitution is ever required.
+auto *TTP = dyn_cast(Param);
+if (TTP && PackedArgsBuilder.empty()) {
+  // Set up a template instantiation context.
   LocalInstantiationScope Scope(S);
-  TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Output);
-  MultiLevelTemplateArgumentList Args(TemplateArgs);
+  Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
+   TTP, Output,
+   Template->getSourceRange());
+  if (Inst.isInvalid())
+return true;
 
-  if (auto *NTTP = dyn_cast(Param)) {
-Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
- NTTP, Output,
- Template->getSourceRange());
-if (Inst.isInvalid() || 
-S.SubstType(NTTP->getType(), Args, NTTP->getLocation(),
-NTTP->getDeclName()).isNull())
-  return true;
-  } else if (auto *TTP = dyn_cast(Param)) {
-Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
- TTP, Output,
- Template->getSourceRange());
-if (Inst.isInvalid() || 

r290326 - [CrashReproducer] Add support for merging -ivfsoverlay

2016-12-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec 22 01:06:03 2016
New Revision: 290326

URL: http://llvm.org/viewvc/llvm-project?rev=290326=rev
Log:
[CrashReproducer] Add support for merging -ivfsoverlay

Merge all VFS mapped files inside -ivfsoverlay inputs into the vfs
overlay provided by the crash reproducer. This is the last missing piece
to allow crash reproducers to fully work with user frameworks; when
combined with headermaps, it allows clang to find additional frameworks.

rdar://problem/27913709

Added:
cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=290326=290325=290326=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Thu Dec 22 01:06:03 2016
@@ -362,6 +362,16 @@ struct YAMLVFSEntry {
   std::string RPath;
 };
 
+/// \brief Collect all pairs of  entries from the
+/// \p YAMLFilePath. This is used by the module dependency collector to forward
+/// the entries into the reproducer output VFS YAML file.
+void collectVFSFromYAML(
+std::unique_ptr Buffer,
+llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath,
+SmallVectorImpl ,
+void *DiagContext = nullptr,
+IntrusiveRefCntPtr ExternalFS = getRealFileSystem());
+
 class YAMLVFSWriter {
   std::vector Mappings;
   Optional IsCaseSensitive;

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=290326=290325=290326=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Thu Dec 22 01:06:03 2016
@@ -128,11 +128,11 @@ class ModuleDependencyCollector : public
   llvm::StringMap SymLinkMap;
 
   bool getRealPath(StringRef SrcPath, SmallVectorImpl );
-  std::error_code copyToRoot(StringRef Src);
+  std::error_code copyToRoot(StringRef Src, StringRef Dst = "");
 public:
   StringRef getDest() { return DestDir; }
   bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
-  void addFile(StringRef Filename);
+  void addFile(StringRef Filename, StringRef FileDst = "");
   void addFileMapping(StringRef VPath, StringRef RPath) {
 VFSWriter.addFileMapping(VPath, RPath);
   }

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=290326=290325=290326=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Dec 22 01:06:03 2016
@@ -887,9 +887,6 @@ private:
   RedirectingFileSystem(IntrusiveRefCntPtr ExternalFS)
   : ExternalFS(std::move(ExternalFS)) {}
 
-  /// \brief Looks up \p Path in \c Roots.
-  ErrorOr lookupPath(const Twine );
-
   /// \brief Looks up the path [Start, End) in \p From, possibly
   /// recursing into the contents of \p From if it is a directory.
   ErrorOr lookupPath(sys::path::const_iterator Start,
@@ -899,6 +896,9 @@ private:
   ErrorOr status(const Twine , Entry *E);
 
 public:
+  /// \brief Looks up \p Path in \c Roots.
+  ErrorOr lookupPath(const Twine );
+
   /// \brief Parses \p Buffer, which is expected to be in YAML format and
   /// returns a virtual file system representing its contents.
   static RedirectingFileSystem *
@@ -1606,6 +1606,47 @@ vfs::getVFSFromYAML(std::unique_ptr ,
+  SmallVectorImpl ) {
+  auto Kind = SrcE->getKind();
+  if (Kind == EK_Directory) {
+auto *DE = dyn_cast(SrcE);
+assert(DE && "Must be a directory");
+for (std::unique_ptr  :
+ llvm::make_range(DE->contents_begin(), DE->contents_end())) {
+  Path.push_back(SubEntry->getName());
+  getVFSEntries(SubEntry.get(), Path, Entries);
+  Path.pop_back();
+}
+return;
+  }
+
+  assert(Kind == EK_File && "Must be a EK_File");
+  auto *FE = dyn_cast(SrcE);
+  assert(FE && "Must be a file");
+  SmallString<128> VPath;
+  for (auto  : Path)
+llvm::sys::path::append(VPath, Comp);
+  Entries.push_back(YAMLVFSEntry(VPath.c_str(), 
FE->getExternalContentsPath()));
+}
+
+void vfs::collectVFSFromYAML(std::unique_ptr Buffer,
+ SourceMgr::DiagHandlerTy DiagHandler,
+ StringRef YAMLFilePath,
+ SmallVectorImpl ,
+ void *DiagContext,
+ 

[PATCH] D27710: [analyzer] Prohibit ExplodedGraph's edges duplicating

2016-12-21 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

If this is a common mistake for checker writers, we could consider adding 
assertions that check for this situation. We should make sure that we do not to 
add any release builds overhead. Maybe we could put this check behind NDEBUG or 
ensure that whatever code is added to support the assertion is optimized away.

As Artem points out, the checkers in tree do not create a node for every bug 
reported - there is no reason to do that.


Repository:
  rL LLVM

https://reviews.llvm.org/D27710



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


r290319 - Make FormatStyle.GetStyleOfFile test work on MSVC

2016-12-21 Thread Antonio Maiorano via cfe-commits
Author: amaiorano
Date: Wed Dec 21 23:10:07 2016
New Revision: 290319

URL: http://llvm.org/viewvc/llvm-project?rev=290319=rev
Log:
Make FormatStyle.GetStyleOfFile test work on MSVC

Modify getStyle to use vfs::FileSystem::makeAbsolute just like FS.addFile does,
rather than sys::fs::make_absolute. The latter gets the CWD from the platform,
while the former expects it to be set by the client, causing a mismatch when
converting relative paths to absolute.

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=290319=290318=290319=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Dec 21 23:10:07 2016
@@ -1917,7 +1917,11 @@ FormatStyle getStyle(StringRef StyleName
   // Look for .clang-format/_clang-format file in the file's parent 
directories.
   SmallString<128> UnsuitableConfigFiles;
   SmallString<128> Path(FileName);
-  llvm::sys::fs::make_absolute(Path);
+  if (std::error_code EC = FS->makeAbsolute(Path)) {
+llvm::errs() << EC.message() << "\n";
+return Style;
+  }
+
   for (StringRef Directory = Path; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=290319=290318=290319=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Dec 21 23:10:07 2016
@@ -10936,10 +10936,6 @@ TEST_F(FormatTest, ArrayAsTemplateType)
 format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
 }
 
-// Since this test case uses UNIX-style file path. We disable it for MS
-// compiler.
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-
 TEST(FormatStyle, GetStyleOfFile) {
   vfs::InMemoryFileSystem FS;
   // Test 1: format file in the same directory.
@@ -10967,8 +10963,6 @@ TEST(FormatStyle, GetStyleOfFile) {
   ASSERT_EQ(Style3, getGoogleStyle());
 }
 
-#endif // _MSC_VER
-
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
   // Column limit is 20.
   std::string Code = "Type *a =\n"


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


r290315 - Sema: print qualified name for overload candidates

2016-12-21 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Dec 21 22:26:57 2016
New Revision: 290315

URL: http://llvm.org/viewvc/llvm-project?rev=290315=rev
Log:
Sema: print qualified name for overload candidates

Print the fully qualified names for the overload candidates.  This makes
it easier to tell what the ambiguity is.  Especially if a template
is instantiated after a using namespace, it will not inherit the
namespace where it was declared.  The specialization will give a message
about a partial order being ambiguous for the same (unqualified) name,
which does not help identify the failure.

Addresses PR31450!

Added:
cfe/trunk/test/SemaCXX/template-ambiguous-overload.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290315=290314=290315=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 21 22:26:57 
2016
@@ -3318,18 +3318,18 @@ def note_ovl_candidate : Note<"candidate
 "is the implicit copy assignment operator|"
 "is the implicit move assignment operator|"
 "inherited constructor|"
-"inherited constructor }0%1"
-"%select{| has different class%diff{ (expected $ but has $)|}3,4"
-"| has different number of parameters (expected %3 but has %4)"
-"| has type mismatch at %ordinal3 parameter"
-"%diff{ (expected $ but has $)|}4,5"
-"| has different return type%diff{ ($ expected but has $)|}3,4"
+"inherited constructor }0%2"
+"%select{| has different class%diff{ (expected $ but has $)|}4,5"
+"| has different number of parameters (expected %4 but has %5)"
+"| has type mismatch at %ordinal4 parameter"
+"%diff{ (expected $ but has $)|}5,6"
+"| has different return type%diff{ ($ expected but has $)|}4,5"
 "| has different qualifiers (expected "
 "%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
-"|volatile and restrict|const, volatile, and restrict}3 but found "
+"|volatile and restrict|const, volatile, and restrict}4 but found "
 "%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
-"|volatile and restrict|const, volatile, and restrict}4)"
-"| has different exception specification}2">;
+"|volatile and restrict|const, volatile, and restrict}5)"
+"| has different exception specification}3">;
 
 def note_ovl_candidate_inherited_constructor : Note<
 "constructor from base class %0 inherited here">;
@@ -4076,7 +4076,7 @@ def err_function_template_spec_ambiguous
 "function template; explicitly specify%select{| additional}1 template "
 "arguments to identify a particular function template">;
 def note_function_template_spec_matched : Note<
-"function template matches specialization %0">;
+"function template %q0 matches specialization %1">;
 def err_function_template_partial_spec : Error<
 "function template partial specialization is not allowed">;
 
@@ -4214,7 +4214,7 @@ def err_explicit_instantiation_member_fu
 def err_explicit_instantiation_ambiguous : Error<
   "partial ordering for explicit instantiation of %0 is ambiguous">;
 def note_explicit_instantiation_candidate : Note<
-  "explicit instantiation candidate function template here %0">;
+  "explicit instantiation candidate function %q0 template here %1">;
 def err_explicit_instantiation_inline : Error<
   "explicit instantiation cannot be 'inline'">;
 def warn_explicit_instantiation_inline_0x : Warning<

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=290315=290314=290315=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Dec 21 22:26:57 2016
@@ -9160,7 +9160,7 @@ void Sema::NoteOverloadCandidate(NamedDe
   std::string FnDesc;
   OverloadCandidateKind K = ClassifyOverloadCandidate(*this, Found, Fn, 
FnDesc);
   PartialDiagnostic PD = PDiag(diag::note_ovl_candidate)
- << (unsigned) K << FnDesc;
+ << (unsigned) K << Fn << FnDesc;
 
   HandleFunctionTypeMismatch(PD, Fn->getType(), DestType);
   Diag(Fn->getLocation(), PD);

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290315=290314=290315=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Dec 21 22:26:57 2016
@@ -4581,12 +4581,12 @@ 

r290310 - Only substitute into type of non-type template parameter once, rather than

2016-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 21 21:52:37 2016
New Revision: 290310

URL: http://llvm.org/viewvc/llvm-project?rev=290310=rev
Log:
Only substitute into type of non-type template parameter once, rather than
twice, in finalization of template argumetn deduction.

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

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290310=290309=290310=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Dec 21 21:52:37 2016
@@ -2059,7 +2059,8 @@ static bool isSameTemplateArg(ASTContext
 ///
 /// \param NTTPType For a declaration template argument, the type of
 /// the non-type template parameter that corresponds to this template
-/// argument.
+/// argument. Can be null if no type sugar is available to add to the
+/// type from the template argument.
 ///
 /// \param Loc The source location to use for the resulting template
 /// argument.
@@ -2075,12 +2076,16 @@ Sema::getTrivialTemplateArgumentLoc(cons
 Arg, Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
 
   case TemplateArgument::Declaration: {
+if (NTTPType.isNull())
+  NTTPType = Arg.getParamTypeForDecl();
 Expr *E = BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc)
   .getAs();
 return TemplateArgumentLoc(TemplateArgument(E), E);
   }
 
   case TemplateArgument::NullPtr: {
+if (NTTPType.isNull())
+  NTTPType = Arg.getNullPtrType();
 Expr *E = BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc)
   .getAs();
 return TemplateArgumentLoc(TemplateArgument(NTTPType, /*isNullPtr*/true),
@@ -2131,31 +2136,13 @@ ConvertDeducedTemplateArgument(Sema ,
TemplateDeductionInfo ,
bool InFunctionTemplate,
SmallVectorImpl ) {
-  // First, for a non-type template parameter type that is
-  // initialized by a declaration, we need the type of the
-  // corresponding non-type template parameter.
-  QualType NTTPType;
-  if (NonTypeTemplateParmDecl *NTTP =
-  dyn_cast(Param)) {
-NTTPType = NTTP->getType();
-if (NTTPType->isDependentType()) {
-  TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Output);
-  NTTPType = S.SubstType(NTTPType,
- MultiLevelTemplateArgumentList(TemplateArgs),
- NTTP->getLocation(),
- NTTP->getDeclName());
-  if (NTTPType.isNull())
-return true;
-}
-  }
-
   auto ConvertArg = [&](DeducedTemplateArgument Arg,
 unsigned ArgumentPackIndex) {
 // Convert the deduced template argument into a template
 // argument that we can check, almost as if the user had written
 // the template argument explicitly.
 TemplateArgumentLoc ArgLoc =
-S.getTrivialTemplateArgumentLoc(Arg, NTTPType, Info.getLocation());
+S.getTrivialTemplateArgumentLoc(Arg, QualType(), Info.getLocation());
 
 // Check the template argument, converting it as necessary.
 return S.CheckTemplateArgument(
@@ -2187,22 +2174,28 @@ ConvertDeducedTemplateArgument(Sema ,
 }
 
 // If the pack is empty, we still need to substitute into the parameter
-// itself, in case that substitution fails. For non-type parameters, we did
-// this above. For type parameters, no substitution is ever required.
-auto *TTP = dyn_cast(Param);
-if (TTP && PackedArgsBuilder.empty()) {
-  // Set up a template instantiation context.
+// itself, in case that substitution fails.
+if (PackedArgsBuilder.empty()) {
   LocalInstantiationScope Scope(S);
-  Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
-   TTP, Output,
-   Template->getSourceRange());
-  if (Inst.isInvalid())
-return true;
-
   TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Output);
-  if (!S.SubstDecl(TTP, S.CurContext,
-   MultiLevelTemplateArgumentList(TemplateArgs)))
-return true;
+  MultiLevelTemplateArgumentList Args(TemplateArgs);
+
+  if (auto *NTTP = dyn_cast(Param)) {
+Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
+ NTTP, Output,
+ Template->getSourceRange());
+if (Inst.isInvalid() || 
+S.SubstType(NTTP->getType(), Args, NTTP->getLocation(),
+NTTP->getDeclName()).isNull())
+  return true;
+  } else if (auto *TTP = dyn_cast(Param)) {
+Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,
+ 

r290304 - Driver: remove unnecessary parameter

2016-12-21 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Dec 21 21:09:02 2016
New Revision: 290304

URL: http://llvm.org/viewvc/llvm-project?rev=290304=rev
Log:
Driver: remove unnecessary parameter

We can query the Triple and EffectiveTriple from the ToolChain.  Avoid
passing in the argument and query it in the function.  NFC.

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290304=290303=290304=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec 21 21:09:02 2016
@@ -3789,13 +3789,14 @@ static void addPS4ProfileRTArgs(const To
 /// this compile should be using PIC mode or not. Returns a tuple of
 /// (RelocationModel, PICLevel, IsPIE).
 static std::tuple
-ParsePICArgs(const ToolChain , const llvm::Triple ,
- const ArgList ) {
+ParsePICArgs(const ToolChain , const ArgList ) {
+  const llvm::Triple  = ToolChain.getEffectiveTriple();
+  const llvm::Triple  = ToolChain.getTriple();
+
   bool PIE = ToolChain.isPIEDefault();
   bool PIC = PIE || ToolChain.isPICDefault();
   // The Darwin/MachO default to use PIC does not apply when using -static.
-  if (ToolChain.getTriple().isOSBinFormatMachO() &&
-  Args.hasArg(options::OPT_static))
+  if (Triple.isOSBinFormatMachO() && Args.hasArg(options::OPT_static))
 PIE = PIC = false;
   bool IsPICLevelTwo = PIC;
 
@@ -3803,7 +3804,7 @@ ParsePICArgs(const ToolChain ,
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
 
   // Android-specific defaults for PIC/PIE
-  if (ToolChain.getTriple().isAndroid()) {
+  if (Triple.isAndroid()) {
 switch (ToolChain.getArch()) {
 case llvm::Triple::arm:
 case llvm::Triple::armeb:
@@ -3829,7 +3830,7 @@ ParsePICArgs(const ToolChain ,
   }
 
   // OpenBSD-specific defaults for PIE
-  if (ToolChain.getTriple().getOS() == llvm::Triple::OpenBSD) {
+  if (Triple.getOS() == llvm::Triple::OpenBSD) {
 switch (ToolChain.getArch()) {
 case llvm::Triple::mips64:
 case llvm::Triple::mips64el:
@@ -3888,7 +3889,7 @@ ParsePICArgs(const ToolChain ,
   // Introduce a Darwin and PS4-specific hack. If the default is PIC, but the
   // PIC level would've been set to level 1, force it back to level 2 PIC
   // instead.
-  if (PIC && (ToolChain.getTriple().isOSDarwin() || 
EffectiveTriple.isPS4CPU()))
+  if (PIC && (Triple.isOSDarwin() || EffectiveTriple.isPS4CPU()))
 IsPICLevelTwo |= ToolChain.isPICDefault();
 
   // This kernel flags are a trump-card: they will disable PIC/PIE
@@ -3901,9 +3902,9 @@ ParsePICArgs(const ToolChain ,
   if (Arg *A = Args.getLastArg(options::OPT_mdynamic_no_pic)) {
 // This is a very special mode. It trumps the other modes, almost no one
 // uses it, and it isn't even valid on any OS but Darwin.
-if (!ToolChain.getTriple().isOSDarwin())
+if (!Triple.isOSDarwin())
   ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
-  << A->getSpelling() << ToolChain.getTriple().str();
+  << A->getSpelling() << Triple.str();
 
 // FIXME: Warn when this flag trumps some other PIC or PIE flag.
 
@@ -3933,14 +3934,14 @@ ParsePICArgs(const ToolChain ,
   if (LastROPIArg && LastROPIArg->getOption().matches(options::OPT_fropi)) {
 if (!EmbeddedPISupported)
   ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
-  << LastROPIArg->getSpelling() << ToolChain.getTriple().str();
+  << LastROPIArg->getSpelling() << Triple.str();
 ROPI = true;
   }
   Arg *LastRWPIArg = Args.getLastArg(options::OPT_frwpi, 
options::OPT_fno_rwpi);
   if (LastRWPIArg && LastRWPIArg->getOption().matches(options::OPT_frwpi)) {
 if (!EmbeddedPISupported)
   ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
-  << LastRWPIArg->getSpelling() << ToolChain.getTriple().str();
+  << LastRWPIArg->getSpelling() << Triple.str();
 RWPI = true;
   }
 
@@ -3986,8 +3987,7 @@ static void AddAssemblerKPIC(const ToolC
   llvm::Reloc::Model RelocationModel;
   unsigned PICLevel;
   bool IsPIE;
-  std::tie(RelocationModel, PICLevel, IsPIE) =
-  ParsePICArgs(ToolChain, ToolChain.getTriple(), Args);
+  std::tie(RelocationModel, PICLevel, IsPIE) = ParsePICArgs(ToolChain, Args);
 
   if (RelocationModel != llvm::Reloc::Static)
 CmdArgs.push_back("-KPIC");
@@ -4329,7 +4329,7 @@ void Clang::ConstructJob(Compilation ,
   unsigned PICLevel;
   bool IsPIE;
   std::tie(RelocationModel, PICLevel, IsPIE) =
-  ParsePICArgs(getToolChain(), Triple, Args);
+  ParsePICArgs(getToolChain(), Args);
 
   const char *RMName = RelocationModelName(RelocationModel);
 
@@ -7036,7 +7036,7 @@ void ClangAs::ConstructJob(Compilation &
   unsigned PICLevel;
   bool IsPIE;
   std::tie(RelocationModel, PICLevel, IsPIE) =
-  ParsePICArgs(getToolChain(), Triple, 

r290305 - Driver: use the triple to query the arch, not the toolchain

2016-12-21 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Dec 21 21:09:04 2016
New Revision: 290305

URL: http://llvm.org/viewvc/llvm-project?rev=290305=rev
Log:
Driver: use the triple to query the arch, not the toolchain

Although the result is the same, the intent is much more clear this way:
we care about the architecture we are targeting.  NFC.

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290305=290304=290305=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec 21 21:09:04 2016
@@ -3805,7 +3805,7 @@ ParsePICArgs(const ToolChain ,
 
   // Android-specific defaults for PIC/PIE
   if (Triple.isAndroid()) {
-switch (ToolChain.getArch()) {
+switch (Triple.getArch()) {
 case llvm::Triple::arm:
 case llvm::Triple::armeb:
 case llvm::Triple::thumb:
@@ -3917,7 +3917,7 @@ ParsePICArgs(const ToolChain ,
   }
 
   bool EmbeddedPISupported;
-  switch (ToolChain.getArch()) {
+  switch (Triple.getArch()) {
 case llvm::Triple::arm:
 case llvm::Triple::armeb:
 case llvm::Triple::thumb:
@@ -3946,9 +3946,8 @@ ParsePICArgs(const ToolChain ,
   }
 
   // ROPI and RWPI are not comaptible with PIC or PIE.
-  if ((ROPI || RWPI) && (PIC || PIE)) {
+  if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
-  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);


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


r290303 - Driver: rename parameter to reduce confusion

2016-12-21 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Dec 21 21:09:00 2016
New Revision: 290303

URL: http://llvm.org/viewvc/llvm-project?rev=290303=rev
Log:
Driver: rename parameter to reduce confusion

The parameter to ParsePICOpts passed the effective triple and then used
that in a few places and used the actual triple in others.  This was
slightly confusing.  Rename the parameter to make it more obvious.

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290303=290302=290303=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec 21 21:09:00 2016
@@ -3789,10 +3789,8 @@ static void addPS4ProfileRTArgs(const To
 /// this compile should be using PIC mode or not. Returns a tuple of
 /// (RelocationModel, PICLevel, IsPIE).
 static std::tuple
-ParsePICArgs(const ToolChain , const llvm::Triple ,
+ParsePICArgs(const ToolChain , const llvm::Triple ,
  const ArgList ) {
-  // FIXME: why does this code...and so much everywhere else, use both
-  // ToolChain.getTriple() and Triple?
   bool PIE = ToolChain.isPIEDefault();
   bool PIC = PIE || ToolChain.isPICDefault();
   // The Darwin/MachO default to use PIC does not apply when using -static.
@@ -3874,7 +3872,7 @@ ParsePICArgs(const ToolChain ,
 O.matches(options::OPT_fPIE) || O.matches(options::OPT_fPIC);
   } else {
 PIE = PIC = false;
-if (Triple.isPS4CPU()) {
+if (EffectiveTriple.isPS4CPU()) {
   Arg *ModelArg = Args.getLastArg(options::OPT_mcmodel_EQ);
   StringRef Model = ModelArg ? ModelArg->getValue() : "";
   if (Model != "kernel") {
@@ -3890,13 +3888,14 @@ ParsePICArgs(const ToolChain ,
   // Introduce a Darwin and PS4-specific hack. If the default is PIC, but the
   // PIC level would've been set to level 1, force it back to level 2 PIC
   // instead.
-  if (PIC && (ToolChain.getTriple().isOSDarwin() || Triple.isPS4CPU()))
+  if (PIC && (ToolChain.getTriple().isOSDarwin() || 
EffectiveTriple.isPS4CPU()))
 IsPICLevelTwo |= ToolChain.isPICDefault();
 
   // This kernel flags are a trump-card: they will disable PIC/PIE
   // generation, independent of the argument order.
-  if (KernelOrKext && ((!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
-   !Triple.isWatchOS()))
+  if (KernelOrKext &&
+  ((!EffectiveTriple.isiOS() || EffectiveTriple.isOSVersionLT(6)) &&
+   !EffectiveTriple.isWatchOS()))
 PIC = PIE = false;
 
   if (Arg *A = Args.getLastArg(options::OPT_mdynamic_no_pic)) {


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


r290297 - Add the alloc_size attribute to clang, attempt 2.

2016-12-21 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Dec 21 20:50:20 2016
New Revision: 290297

URL: http://llvm.org/viewvc/llvm-project?rev=290297=rev
Log:
Add the alloc_size attribute to clang, attempt 2.

This is a recommit of r290149, which was reverted in r290169 due to msan
failures. msan was failing because we were calling
`isMostDerivedAnUnsizedArray` on an invalid designator, which caused us
to read uninitialized memory. To fix this, the logic of the caller of
said function was simplified, and we now have a `!Invalid` assert in
`isMostDerivedAnUnsizedArray`, so we can catch this particular bug more
easily in the future.

Fingers crossed that this patch sticks this time. :)

Original commit message:

This patch does three things:
- Gives us the alloc_size attribute in clang, which lets us infer the
  number of bytes handed back to us by malloc/realloc/calloc/any user
  functions that act in a similar manner.
- Teaches our constexpr evaluator that evaluating some `const` variables
  is OK sometimes. This is why we have a change in
  test/SemaCXX/constant-expression-cxx11.cpp and other seemingly
  unrelated tests. Richard Smith okay'ed this idea some time ago in
  person.
- Uniques some Blocks in CodeGen, which was reviewed separately at
  D26410. Lack of uniquing only really shows up as a problem when
  combined with our new eagerness in the face of const.

Added:
cfe/trunk/test/CodeGen/alloc-size.c
cfe/trunk/test/CodeGenCXX/alloc-size.cpp
cfe/trunk/test/Sema/alloc-size.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGenCXX/block-in-ctor-dtor.cpp
cfe/trunk/test/CodeGenCXX/global-init.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=290297=290296=290297=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Dec 21 20:50:20 2016
@@ -780,6 +780,15 @@ def EmptyBases : InheritableAttr, Target
   let Documentation = [EmptyBasesDocs];
 }
 
+def AllocSize : InheritableAttr {
+  let Spellings = [GCC<"alloc_size">];
+  let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
+ "ExpectedFunctionWithProtoType">;
+  let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>];
+  let TemplateDependent = 1;
+  let Documentation = [AllocSizeDocs];
+}
+
 def EnableIf : InheritableAttr {
   let Spellings = [GNU<"enable_if">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=290297=290296=290297=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Dec 21 20:50:20 2016
@@ -206,6 +206,44 @@ to enforce the provided alignment assump
   }];
 }
 
+def AllocSizeDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``alloc_size`` attribute can be placed on functions that return pointers in
+order to hint to the compiler how many bytes of memory will be available at the
+returned poiner. ``alloc_size`` takes one or two arguments.
+
+- ``alloc_size(N)`` implies that argument number N equals the number of
+  available bytes at the returned pointer.
+- ``alloc_size(N, M)`` implies that the product of argument number N and
+  argument number M equals the number of available bytes at the returned
+  pointer.
+
+Argument numbers are 1-based.
+
+An example of how to use ``alloc_size``
+
+.. code-block:: c
+
+  void *my_malloc(int a) __attribute__((alloc_size(1)));
+  void *my_calloc(int a, int b) __attribute__((alloc_size(1, 2)));
+
+  int main() {
+void *const p = my_malloc(100);
+assert(__builtin_object_size(p, 0) == 100);
+void *const a = my_calloc(20, 5);
+assert(__builtin_object_size(a, 0) == 100);
+  }
+
+.. Note:: This attribute works differently in clang than it does in GCC.
+  Specifically, clang will only trace ``const`` pointers (as above); we give up
+  on pointers that are not marked as ``const``. In the vast majority of cases,
+  this is unimportant, because LLVM has support for the ``alloc_size``
+  attribute. However, this may cause mildly unintuitive behavior when used with
+  other attributes, such as ``enable_if``.
+  }];
+}
+
 def EnableIfDocs : Documentation {
   let Category = 

[PATCH] D28037: [PowerPC, DAGCombiner] Change vec_sl to a << (b % (sizeof(a) * 8)), and fold it back to a << b.

2016-12-21 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added reviewers: kbarton, hfinkel, iteratee, echristo, bogner.
timshen added subscribers: llvm-commits, cfe-commits.
Herald added subscribers: amehsan, nemanjai, mehdi_amini.

For a << b (as original vec_sl does), if b >= sizeof(a) * 8, the
behavior is undefined. However, Power instructions do define the
behavior, which is equivalent to a << (b % (sizeof(a) * 8)).

This patch changes altivec.h to use a << (b % (sizeof(a) * 8)), to ensure
the consistent semantic of the instructions. Then it combines
the generated multiple instructions back to a single shift.

This patch handles left shift only. Right shift, on the other hand, is more
complicated, considering arithematic/logical right shift.


https://reviews.llvm.org/D28037

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-altivec.c
  llvm/include/llvm/Target/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/test/CodeGen/PowerPC/shift_mask.ll

Index: llvm/test/CodeGen/PowerPC/shift_mask.ll
===
--- llvm/test/CodeGen/PowerPC/shift_mask.ll
+++ llvm/test/CodeGen/PowerPC/shift_mask.ll
@@ -5,7 +5,6 @@
 define i8 @test000(i8 %a, i8 %b) {
 ; CHECK-LABEL: test000:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:rlwinm 4, 4, 0, 29, 31
 ; CHECK-NEXT:slw 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i8 %b, 7
@@ -16,7 +15,6 @@
 define i16 @test001(i16 %a, i16 %b) {
 ; CHECK-LABEL: test001:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:rlwinm 4, 4, 0, 28, 31
 ; CHECK-NEXT:slw 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i16 %b, 15
@@ -27,7 +25,6 @@
 define i32 @test002(i32 %a, i32 %b) {
 ; CHECK-LABEL: test002:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:rlwinm 4, 4, 0, 27, 31
 ; CHECK-NEXT:slw 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i32 %b, 31
@@ -38,7 +35,6 @@
 define i64 @test003(i64 %a, i64 %b) {
 ; CHECK-LABEL: test003:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:rlwinm 4, 4, 0, 26, 31
 ; CHECK-NEXT:sld 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i64 %b, 63
@@ -49,8 +45,6 @@
 define <16 x i8> @test010(<16 x i8> %a, <16 x i8> %b) {
 ; CHECK-LABEL: test010:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:vspltisb 4, 7
-; CHECK-NEXT:xxland 35, 35, 36
 ; CHECK-NEXT:vslb 2, 2, 3
 ; CHECK-NEXT:blr
   %rem = and <16 x i8> %b, 
@@ -61,8 +55,6 @@
 define <8 x i16> @test011(<8 x i16> %a, <8 x i16> %b) {
 ; CHECK-LABEL: test011:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:vspltish 4, 15
-; CHECK-NEXT:xxland 35, 35, 36
 ; CHECK-NEXT:vslh 2, 2, 3
 ; CHECK-NEXT:blr
   %rem = and <8 x i16> %b, 
@@ -73,10 +65,6 @@
 define <4 x i32> @test012(<4 x i32> %a, <4 x i32> %b) {
 ; CHECK-LABEL: test012:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:vspltisw 4, -16
-; CHECK-NEXT:vspltisw 5, 15
-; CHECK-NEXT:vsubuwm 4, 5, 4
-; CHECK-NEXT:xxland 35, 35, 36
 ; CHECK-NEXT:vslw 2, 2, 3
 ; CHECK-NEXT:blr
   %rem = and <4 x i32> %b, 
@@ -87,11 +75,6 @@
 define <2 x i64> @test013(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test013:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:addis 3, 2, .LCPI7_0@toc@ha
-; CHECK-NEXT:addi 3, 3, .LCPI7_0@toc@l
-; CHECK-NEXT:lxvd2x 0, 0, 3
-; CHECK-NEXT:xxswapd 36, 0
-; CHECK-NEXT:xxland 35, 35, 36
 ; CHECK-NEXT:vsld 2, 2, 3
 ; CHECK-NEXT:blr
   %rem = and <2 x i64> %b, 
@@ -103,7 +86,6 @@
 ; CHECK-LABEL: test100:
 ; CHECK:   # BB#0:
 ; CHECK-NEXT:rlwinm 3, 3, 0, 24, 31
-; CHECK-NEXT:rlwinm 4, 4, 0, 29, 31
 ; CHECK-NEXT:srw 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i8 %b, 7
@@ -115,7 +97,6 @@
 ; CHECK-LABEL: test101:
 ; CHECK:   # BB#0:
 ; CHECK-NEXT:rlwinm 3, 3, 0, 16, 31
-; CHECK-NEXT:rlwinm 4, 4, 0, 28, 31
 ; CHECK-NEXT:srw 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i16 %b, 15
@@ -126,7 +107,6 @@
 define i32 @test102(i32 %a, i32 %b) {
 ; CHECK-LABEL: test102:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:rlwinm 4, 4, 0, 27, 31
 ; CHECK-NEXT:srw 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i32 %b, 31
@@ -137,7 +117,6 @@
 define i64 @test103(i64 %a, i64 %b) {
 ; CHECK-LABEL: test103:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:rlwinm 4, 4, 0, 26, 31
 ; CHECK-NEXT:srd 3, 3, 4
 ; CHECK-NEXT:blr
   %rem = and i64 %b, 63
@@ -148,8 +127,6 @@
 define <16 x i8> @test110(<16 x i8> %a, <16 x i8> %b) {
 ; CHECK-LABEL: test110:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:vspltisb 4, 7
-; CHECK-NEXT:xxland 35, 35, 36
 ; CHECK-NEXT:vsrb 2, 2, 3
 ; CHECK-NEXT:blr
   %rem = and <16 x i8> %b, 
@@ -160,8 +137,6 @@
 define <8 x i16> @test111(<8 x i16> %a, <8 x i16> %b) {
 ; CHECK-LABEL: test111:
 ; CHECK:   # BB#0:
-; CHECK-NEXT:vspltish 4, 15
-; CHECK-NEXT:xxland 35, 35, 36
 ; CHECK-NEXT:vsrh 2, 2, 3
 ; CHECK-NEXT:blr
   %rem = and <8 x i16> %b, 
@@ -172,10 +147,6 @@
 define <4 x i32> @test112(<4 x i32> %a, <4 x i32> %b) {
 ; CHECK-LABEL: test112:
 ; CHECK:   # 

[clang-tools-extra] r290289 - [clang-tidy] Ignore `size() == 0` in the container implementation.

2016-12-21 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Dec 21 17:44:23 2016
New Revision: 290289

URL: http://llvm.org/viewvc/llvm-project?rev=290289=rev
Log:
[clang-tidy] Ignore `size() == 0` in the container implementation.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp?rev=290289=290288=290289=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
Wed Dec 21 17:44:23 2016
@@ -58,7 +58,9 @@ void ContainerSizeEmptyCheck::registerMa
   hasType(pointsTo(ValidContainer)),
   hasType(references(ValidContainer
.bind("STLObject")),
-callee(cxxMethodDecl(hasName("size"))), WrongUse)
+callee(cxxMethodDecl(hasName("size"))), WrongUse,
+unless(hasAncestor(cxxMethodDecl(
+ofClass(equalsBoundNode("container"))
   .bind("SizeCallExpr"),
   this);
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp?rev=290289=290288=290289=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp 
Wed Dec 21 17:44:23 2016
@@ -61,6 +61,20 @@ public:
 class Derived : public Container {
 };
 
+class Container2 {
+public:
+  int size() const;
+  bool empty() const { return size() == 0; }
+};
+
+class Container3 {
+public:
+  int size() const;
+  bool empty() const;
+};
+
+bool Container3::empty() const { return this->size() == 0; }
+
 int main() {
   std::set intSet;
   std::string str;


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


[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

2016-12-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D27680#628272, @rjmccall wrote:

> Wouldn't it be simpler to just record an insertion point for the beginning of 
> the current lexical scope and insert the lifetime.begin there instead of at 
> the current IP?


I'm not sure I understood your comment, but it seems to me that simply moving 
the lifetime.start intrinsics to the current lexical scope wouldn't work in a 
case like this:

  { // This is the previous lexical scope.
  label1:
...
int a; // We want to move the lifetime.start for "a" to the beginning of 
this scope (not the current lexical scope), since goto is not leaving its scope.
...
{ // This is the current lexical scope.
  int b; // We don't want to move the lifetime.start for "b", since goto is 
leaving its scope.
  goto label1;
}
  }

Currently, the lifetime.start is inserted at the beginning of the basic block 
of the lexical scope holding the goto's destination.

Let me know if I misunderstood your comment or you've found a flaw in this 
approach.


https://reviews.llvm.org/D27680



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


[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

2016-12-21 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D27773#629171, @dcoughlin wrote:

> I already committed this, but I'll address the feedback in a follow-on commit.


I should have written "I already committed this, *so* I'll address the feedback 
in a follow-on commit."


https://reviews.llvm.org/D27773



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


Re: [clang-tools-extra] r290202 - [clang-tidy] Add modernize-use-default-member-init check

2016-12-21 Thread NAKAMURA Takumi via cfe-commits
It'd be the issue if the test depended on installed headers. The builder
doesn't have MS headers installed.

On Thu, Dec 22, 2016 at 1:27 AM Aaron Ballman 
wrote:

> On Tue, Dec 20, 2016 at 5:58 PM, Malcolm Parsons
>  wrote:
> > On 20 December 2016 at 22:32, Aaron Ballman 
> wrote:
> >> On Tue, Dec 20, 2016 at 4:26 PM, Malcolm Parsons via cfe-commits
> >>  wrote:
> >>> Author: malcolm.parsons
> >>> Date: Tue Dec 20 15:26:07 2016
> >>> New Revision: 290202
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=290202=rev
> >>> Log:
> >>> [clang-tidy] Add modernize-use-default-member-init check
> >>>
> >>> Summary: Fixes PR18858
> >>
> >> This appears to have broken one of the bots:
> >>
> >> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/33046
> >
> > error: unknown type name 'char16_t'
> > error: unknown type name 'char32_t'
> >
> > I see commented tests in other clang-tidy tests:
> >
> > // TODO: enable these tests once all supported compilers
> > // support char16_t and char32_t (VS2013 does not)
> >
> > // disabled for now until it is clear
> > // how to enable them in the test
> > //} catch (const char16_t*) {
>
> We no longer support MSVC 2013, so that should not be an issue.
> Takumi, I'm not certain what to make of this builder (MSVC centos?).
> What version of Visual Studio is it compiling with? Or is this an
> instance where we need to set the -fms-compatibility-version=19 when
> running the test with clang-cl?
>
> ~Aaron
>
> >
> > --
> > Malcolm Parsons
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

2016-12-21 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I already committed this, but I'll address the feedback in a follow-on commit.




Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:172
+const CXXConstructorCall *Call, CheckerContext ) const {
+  assert(Call->getNumArgs() > 0);
+

zaks.anna wrote:
> "getNumArgs() == 1" ?
You can have additional arguments to a copy constructor as long as they are 
defaulted. I was trying to be robust against future source-compatible changes, 
but this was probably too clever. If the copy constructor changes then maybe it 
would be better to just not model.



Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:209
+
+  if (CtorDecl->getNumParams() == 0)
+return;

zaks.anna wrote:
> It seems that the num of parameter checking logic here is less restrictive 
> than it could be and that makes this a bit hard to read without looking into 
> the 'model' methods. Ex: I think there are 2 cases: 
> - Constructor taking a bool can have either 1 or 2 arguments.
> - Copy constructor taking exactly one argument.
> 
> 
I'll make this more clear.



Comment at: test/Driver/analyzer-target-enabled-checkers.cpp:7
 // CHECK-DARWIN: "-analyzer-checker=core"
+// CHECK-DARWIN-SAME: "-analyzer-checker=apiModeling"
 // CHECK-DARWIN-SAME: "-analyzer-checker=unix"

a.sidorin wrote:
> A very minor nit/question.
> Do we have any convention on checker naming? Most checkers are starting with 
> capital letters, but some not. As "API" is an abbreviation, I think we should 
> at least start it with capital.
We're not terribly consistent, but in general we start packages with lowercase 
letters and checkers with uppercase names. Checkers are generally 
UpperCamelCase.

"apiModeling" is a package name, not a checker name. I think to be consistent 
with most of the other packages it should (?) probably be lowerCamelCase. This 
matches "coreFoundation" and "insecureAPI" but not  "deadcode". I had "api" 
lowercase since it is an initialism for a thing (package) that starts with 
lower case and this is how we treat lower camel-case initialisms in Swift. It 
also matches "osx", which is similarly an initialism.

Does knowing it is a package name (rather than a checker name) change your 
opinion of whether "API" should be upper case. I'm happy to change it, since it 
will not be user facing.



https://reviews.llvm.org/D27773



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


[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

2016-12-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 82279.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Remove Addr and Size from CallLifetimeEnd.


https://reviews.llvm.org/D27680

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ test/CodeGen/lifetime2.c
@@ -1,4 +1,4 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O2 -mllvm -disable-llvm-optzns %s | FileCheck %s -check-prefixes=CHECK,O2
 // RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
@@ -19,11 +19,11 @@
 
 // CHECK-LABEL: @no_goto_bypass
 void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 5
   // O2: @llvm.lifetime.start(i64 1
   char x;
 l1:
   bar(, 1);
-  // O2: @llvm.lifetime.start(i64 5
   // O2: @llvm.lifetime.end(i64 5
   char y[5];
   bar(y, 5);
@@ -89,3 +89,58 @@
 L:
   bar(, 1);
 }
+
+// O2-LABEL: define i32 @move_lifetime_start
+// O2: %i = alloca i32, align 4
+// O2: %[[BITCAST:[0-9]+]] = bitcast i32* %i to i8*
+// O2: call void @llvm.lifetime.start(i64 4, i8* %[[BITCAST]])
+// O2: br label %[[DESTLABEL:[a-z0-9]+]]
+// O2: [[DESTLABEL]]:
+// O2: switch i32 %{{.*}}, label %{{.*}} [
+// O2-NEXT: i32 2, label %[[DESTLABEL]]
+
+extern void foo2(int p);
+
+int move_lifetime_start(int a) {
+  int *p = 0;
+label1:
+  if (p) {
+foo2(*p);
+return 0;
+  }
+
+  int i = 999;
+  if (a != 2) {
+p = 
+goto label1;
+  }
+  return -1;
+}
+
+// O2-LABEL: define i32 @dont_move_lifetime_start
+// O2: %i = alloca i32, align 4
+// O2: br label %[[DESTLABEL:[a-z0-9]+]]
+// O2: [[DESTLABEL]]:
+// O2: %[[BITCAST:[0-9]+]] = bitcast i32* %i to i8*
+// O2: call void @llvm.lifetime.start(i64 4, i8* %[[BITCAST]])
+// O2: switch i32 %{{.*}}, label %{{.*}} [
+// O2-NEXT: i32 0, label %{{.*}}
+// O2-NEXT: i32 2, label %[[DESTLABEL]]
+
+int dont_move_lifetime_start(int a) {
+  int *p = 0;
+label1:
+  {
+if (p) {
+  foo2(*p);
+  return 0;
+}
+
+int i = 999;
+if (a != 2) {
+  p = 
+  goto label1;
+}
+  }
+  return -1;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -346,15 +346,32 @@
   llvm::Instruction *CurrentFuncletPad = nullptr;
 
   class CallLifetimeEnd final : public EHScopeStack::Cleanup {
-llvm::Value *Addr;
-llvm::Value *Size;
+// lifetime.start intrinsic and a flag indicating whether it has been moved
+// to the beginning of the lexical scope of the object associated with the
+// intrinsic.
+llvm::PointerIntPair LifetimeStart;
 
   public:
-CallLifetimeEnd(Address addr, llvm::Value *size)
-: Addr(addr.getPointer()), Size(size) {}
+CallLifetimeEnd(llvm::CallInst *lifetimeStart)
+: LifetimeStart(lifetimeStart) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
-  CGF.EmitLifetimeEnd(Size, Addr);
+  auto *Addr = LifetimeStart.getPointer()->getOperand(1);
+  if (auto *BC = dyn_cast(Addr))
+Addr = BC->getOperand(0);
+  CGF.EmitLifetimeEnd(LifetimeStart.getPointer()->getOperand(0), Addr);
+}
+
+llvm::CallInst *getLifetimeStart() {
+  return LifetimeStart.getPointer();
+}
+
+bool lifetimeStartMoved() const {
+  return LifetimeStart.getInt();
+}
+
+void setLifetimeStartMoved() {
+  LifetimeStart.setInt(true);
 }
   };
 
@@ -523,10 +540,10 @@
   /// \brief Enters a new scope for capturing cleanups, all of which
   /// will be executed once the scope is exited.
   class RunCleanupsScope {
-EHScopeStack::stable_iterator CleanupStackDepth;
 size_t LifetimeExtendedCleanupStackSize;
 bool OldDidCallStackSave;
   protected:
+EHScopeStack::stable_iterator CleanupStackDepth;
 bool PerformCleanup;
   private:
 
@@ -578,6 +595,7 @@
 SourceRange Range;
 SmallVector Labels;
 LexicalScope *ParentScope;
+llvm::BasicBlock *BB;
 
 LexicalScope(const LexicalScope &) = delete;
 void operator=(const LexicalScope &) = delete;
@@ -589,13 +607,27 @@
   CGF.CurLexicalScope = this;
   if (CGDebugInfo *DI = CGF.getDebugInfo())
 DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
+  CGF.EnsureInsertPoint();
+  BB = CGF.Builder.GetInsertBlock();
 }
 
 void addLabel(const LabelDecl *label) {
   assert(PerformCleanup && "adding label to dead scope?");
   Labels.push_back(label);
 }
 
+EHScopeStack::stable_iterator getCleanupStackDepth() const {
+  return CleanupStackDepth;
+}
+
+llvm::BasicBlock *getBasicBlock() const {
+  return BB;
+}
+
+LexicalScope *getParentScope() const {

[PATCH] D28034: [ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl.

2016-12-21 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: sbenza, bkramer, klimek.
malcolm.parsons added a subscriber: cfe-commits.

I needed to know whether a FieldDecl had an in-class
initializer for https://reviews.llvm.org/D26453. I used a narrowing matcher 
there, but a
traversal matcher might be generally useful.

VarDecl has a hasInitializer traversal matcher.
ForStmt has a withLoopInit traversal matcher.
CXXCtorInitializer has a withInitializer traversal matcher.
EnumConstantDecl doesn't have a traversal matcher for its initializer.
IfStmt doesn't have a traversal matcher for its initializer.


https://reviews.llvm.org/D28034

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1404,6 +1404,16 @@
   fieldDecl(isBitField(), hasBitWidth(2), hasName("a";
 }
 
+TEST(Member, InClassInitializer) {
+  EXPECT_TRUE(
+  matches("class C { int a = 2; int b; };",
+  fieldDecl(hasInClassInitializer(integerLiteral(equals(2))),
+hasName("a";
+  EXPECT_TRUE(
+  notMatches("class C { int a = 2; int b; };",
+ fieldDecl(hasInClassInitializer(anything()), hasName("b";
+}
+
 TEST(Member, UnderstandsAccess) {
   EXPECT_TRUE(matches(
 "struct A { int i; };", fieldDecl(isPublic(), hasName("i";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -232,6 +232,7 @@
   REGISTER_MATCHER(hasFalseExpression);
   REGISTER_MATCHER(hasGlobalStorage);
   REGISTER_MATCHER(hasImplicitDestinationType);
+  REGISTER_MATCHER(hasInClassInitializer);
   REGISTER_MATCHER(hasIncrement);
   REGISTER_MATCHER(hasIndex);
   REGISTER_MATCHER(hasInitializer);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -533,7 +533,8 @@
   return Node.isBitField();
 }
 
-/// \brief Matches non-static data members that are bit-fields.
+/// \brief Matches non-static data members that are bit-fields of the specified
+/// bit width.
 ///
 /// Given
 /// \code
@@ -543,13 +544,31 @@
 /// int c : 2;
 ///   };
 /// \endcode
-/// fieldDecl(isBitField())
+/// fieldDecl(hasBitWidth(2))
 ///   matches 'int a;' and 'int c;' but not 'int b;'.
 AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width) {
   return Node.isBitField() &&
  Node.getBitWidthValue(Finder->getASTContext()) == Width;
 }
 
+/// \brief Matches non-static data members that have an in-class initializer.
+///
+/// Given
+/// \code
+///   class C {
+/// int a = 2;
+/// int b = 3;
+///   };
+/// \endcode
+/// fieldDecl(hasInClassInitializer(integerLiteral(equals(2
+///   matches 'int a;' but not 'int b;'.
+AST_MATCHER_P(FieldDecl, hasInClassInitializer, internal::Matcher,
+  InnerMatcher) {
+  const Expr *Initializer = Node.getInClassInitializer();
+  return (Initializer != nullptr &&
+  InnerMatcher.matches(*Initializer, Finder, Builder));
+}
+
 /// \brief Matches a declaration that has been implicitly added
 /// by the compiler (eg. implicit default/copy constructors).
 AST_MATCHER(Decl, isImplicit) {
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2430,15 +2430,16 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html;>FieldDeclhasBitWidthunsigned Width
-Matches non-static data members that are bit-fields.
+Matches non-static data members that are bit-fields of the specified
+bit width.
 
 Given
   class C {
 int a : 2;
 int b : 4;
 int c : 2;
   };
-fieldDecl(isBitField())
+fieldDecl(hasBitWidth(2))
   matches 'int a;' and 'int c;' but not 'int b;'.
 
 
@@ -4750,6 +4751,19 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html;>FieldDeclhasInClassInitializerMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr InnerMatcher
+Matches non-static data members that have an in-class initializer.
+
+Given
+  class C {
+int a = 2;
+int b = 3;
+  };
+fieldDecl(hasInClassInitializer(integerLiteral(equals(2
+  matches 'int a;' but not 'int b;'.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ForStmt.html;>ForStmthasBodyMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>Stmt InnerMatcher
 Matches a 'for', 'while', 'do while' statement or a function
 definition that has a 

[PATCH] D28033: [analyzer] Treat pointers to static member functions as function pointers

2016-12-21 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin created this revision.
dcoughlin added a reviewer: kromanenkov.
dcoughlin added subscribers: cfe-commits, NoQ, zaks.anna.

Sema treats pointers to static member functions as having function pointer
type, so treat treat them as function pointer values in the analyzer as well.
This prevents an assertion failure in SValBuilder::evalBinOp caused by code
that expects function pointers to be Locs (in contrast, PointerToMember values
are nonlocs).

Kirill: does this look alright to you?


https://reviews.llvm.org/D28033

Files:
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  test/Analysis/pointer-to-member.cpp


Index: test/Analysis/pointer-to-member.cpp
===
--- test/Analysis/pointer-to-member.cpp
+++ test/Analysis/pointer-to-member.cpp
@@ -78,6 +78,7 @@
   struct A {
 virtual int foo() { return 1; }
 int bar() { return 2;  }
+int static staticMemberFunction(int p) { return p + 1; };
   };
 
   struct B : public A {
@@ -111,11 +112,19 @@
 
 clang_analyzer_eval((APtr->*AFP)() == 3); // expected-warning{{TRUE}}
   }
+
+  void testPointerToStaticMemberCall() {
+int (*fPtr)(int) = ::staticMemberFunction;
+if (fPtr != 0) { // no-crash
+  clang_analyzer_eval(fPtr(2) == 3); // expected-warning{{TRUE}}
+}
+  }
 } // end of testPointerToMemberFunction namespace
 
 namespace testPointerToMemberData {
   struct A {
 int i;
+static int j;
   };
 
   void testPointerToMemberData() {
@@ -126,6 +135,13 @@
 a.*AMdPointer += 1;
 
 clang_analyzer_eval(a.i == 43); // expected-warning{{TRUE}}
+
+int *ptrToStaticField = ::j;
+if (ptrToStaticField != 0) {
+  *ptrToStaticField = 7;
+  clang_analyzer_eval(*ptrToStaticField == 7); // expected-warning{{TRUE}}
+  clang_analyzer_eval(A::j == 7); // expected-warning{{TRUE}}
+}
   }
 } // end of testPointerToMemberData namespace
 
Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -218,6 +218,18 @@
 }
 
 DefinedSVal SValBuilder::getMemberPointer(const DeclaratorDecl* DD) {
+  assert(!DD || isa(DD) || isa(DD));
+
+  if (auto *MD = dyn_cast_or_null(DD)) {
+// Sema treats pointers to static member functions as have function pointer
+// type, so return a function pointer for the method.
+// We don't need to play a similar trick for static member fields
+// because these are represented as plain VarDecls and not FieldDecls
+// in the AST.
+if (MD->isStatic())
+  return getFunctionPointer(MD);
+  }
+
   return nonloc::PointerToMember(DD);
 }
 


Index: test/Analysis/pointer-to-member.cpp
===
--- test/Analysis/pointer-to-member.cpp
+++ test/Analysis/pointer-to-member.cpp
@@ -78,6 +78,7 @@
   struct A {
 virtual int foo() { return 1; }
 int bar() { return 2;  }
+int static staticMemberFunction(int p) { return p + 1; };
   };
 
   struct B : public A {
@@ -111,11 +112,19 @@
 
 clang_analyzer_eval((APtr->*AFP)() == 3); // expected-warning{{TRUE}}
   }
+
+  void testPointerToStaticMemberCall() {
+int (*fPtr)(int) = ::staticMemberFunction;
+if (fPtr != 0) { // no-crash
+  clang_analyzer_eval(fPtr(2) == 3); // expected-warning{{TRUE}}
+}
+  }
 } // end of testPointerToMemberFunction namespace
 
 namespace testPointerToMemberData {
   struct A {
 int i;
+static int j;
   };
 
   void testPointerToMemberData() {
@@ -126,6 +135,13 @@
 a.*AMdPointer += 1;
 
 clang_analyzer_eval(a.i == 43); // expected-warning{{TRUE}}
+
+int *ptrToStaticField = ::j;
+if (ptrToStaticField != 0) {
+  *ptrToStaticField = 7;
+  clang_analyzer_eval(*ptrToStaticField == 7); // expected-warning{{TRUE}}
+  clang_analyzer_eval(A::j == 7); // expected-warning{{TRUE}}
+}
   }
 } // end of testPointerToMemberData namespace
 
Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -218,6 +218,18 @@
 }
 
 DefinedSVal SValBuilder::getMemberPointer(const DeclaratorDecl* DD) {
+  assert(!DD || isa(DD) || isa(DD));
+
+  if (auto *MD = dyn_cast_or_null(DD)) {
+// Sema treats pointers to static member functions as have function pointer
+// type, so return a function pointer for the method.
+// We don't need to play a similar trick for static member fields
+// because these are represented as plain VarDecls and not FieldDecls
+// in the AST.
+if (MD->isStatic())
+  return getFunctionPointer(MD);
+  }
+
   return nonloc::PointerToMember(DD);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290276 - Perform type-checking for a converted constant expression in a template

2016-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec 21 15:42:57 2016
New Revision: 290276

URL: http://llvm.org/viewvc/llvm-project?rev=290276=rev
Log:
Perform type-checking for a converted constant expression in a template
argument even if the expression is value-dependent (we need to suppress the
final portion of the narrowing check, but the rest of the checking can still be
done eagerly).

This affects template template argument validity and partial ordering under
p0522r0.

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=290276=290275=290276=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Wed Dec 21 15:42:57 2016
@@ -121,7 +121,11 @@ namespace clang {
 
 /// A narrowing conversion, because a non-constant-expression variable 
might
 /// have got narrowed.
-NK_Variable_Narrowing
+NK_Variable_Narrowing,
+
+/// Cannot tell whether this is a narrowing conversion because the
+/// expression is value-dependent.
+NK_Dependent_Narrowing,
   };
 
   /// StandardConversionSequence - represents a standard conversion

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=290276=290275=290276=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Dec 21 15:42:57 2016
@@ -6816,7 +6816,7 @@ InitializationSequence::Perform(Sema ,
   CurInit = CurInitExprRes;
 
   if (Step->Kind == SK_ConversionSequenceNoNarrowing &&
-  S.getLangOpts().CPlusPlus && !CurInit.get()->isValueDependent())
+  S.getLangOpts().CPlusPlus)
 DiagnoseNarrowingInInitList(S, *Step->ICS, SourceType, 
Entity.getType(),
 CurInit.get());
 
@@ -8070,6 +8070,7 @@ static void DiagnoseNarrowingInInitList(
   switch (SCS->getNarrowingKind(S.Context, PostInit, ConstantValue,
 ConstantType)) {
   case NK_Not_Narrowing:
+  case NK_Dependent_Narrowing:
 // No narrowing occurred.
 return;
 

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=290276=290275=290276=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Dec 21 15:42:57 2016
@@ -329,6 +329,11 @@ StandardConversionSequence::getNarrowing
 } else if (FromType->isIntegralType(Ctx) && ToType->isRealFloatingType()) {
   llvm::APSInt IntConstantValue;
   const Expr *Initializer = IgnoreNarrowingConversion(Converted);
+
+  // If it's value-dependent, we can't tell whether it's narrowing.
+  if (Initializer->isValueDependent())
+return NK_Dependent_Narrowing;
+
   if (Initializer &&
   Initializer->isIntegerConstantExpr(IntConstantValue, Ctx)) {
 // Convert the integer to the floating type.
@@ -362,6 +367,11 @@ StandardConversionSequence::getNarrowing
 Ctx.getFloatingTypeOrder(FromType, ToType) == 1) {
   // FromType is larger than ToType.
   const Expr *Initializer = IgnoreNarrowingConversion(Converted);
+
+  // If it's value-dependent, we can't tell whether it's narrowing.
+  if (Initializer->isValueDependent())
+return NK_Dependent_Narrowing;
+
   if (Initializer->isCXX11ConstantExpr(Ctx, )) {
 // Constant!
 assert(ConstantValue.isFloat());
@@ -403,6 +413,11 @@ StandardConversionSequence::getNarrowing
   // Not all values of FromType can be represented in ToType.
   llvm::APSInt InitializerValue;
   const Expr *Initializer = IgnoreNarrowingConversion(Converted);
+
+  // If it's value-dependent, we can't tell whether it's narrowing.
+  if (Initializer->isValueDependent())
+return NK_Dependent_Narrowing;
+
   if (!Initializer->isIntegerConstantExpr(InitializerValue, Ctx)) {
 // Such conversions on variables are always narrowing.
 return NK_Variable_Narrowing;
@@ -5289,6 +5304,9 @@ static ExprResult CheckConvertedConstant
   QualType PreNarrowingType;
   switch (SCS->getNarrowingKind(S.Context, Result.get(), PreNarrowingValue,
 PreNarrowingType)) {
+  case NK_Dependent_Narrowing:
+// Implicit conversion to a narrower type, but the expression is
+// value-dependent so we can't tell whether it's actually narrowing.
   case NK_Variable_Narrowing:
 // Implicit conversion to a narrower type, and 

Re: [PATCH] D27123: Add AVR target and toolchain to Clang

2016-12-21 Thread Nico Weber via cfe-commits
On Wed, Dec 21, 2016 at 6:42 AM, Senthil Kumar Selvaraj via Phabricator via
cfe-commits  wrote:

> saaadhu added a comment.
>
> Would someone with a llvm bugzilla account please file the PR for me? New
> user registration is disabled, and I've been waiting for
> llvm-ad...@lists.llvm.org to respond for nearly a week now.
>

Email to...@nondot.org directly, see
http://lists.llvm.org/pipermail/cfe-dev/2016-December/051921.html


>
> And how should I proceed after that? Would one of the reviewers commit the
> patch for me?
>
>
> https://reviews.llvm.org/D27123
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D27123: Add AVR target and toolchain to Clang

2016-12-21 Thread Dylan McKay via cfe-commits
I'm happy to file a bug if you give me a description

> Would one of the reviewers commit the patch for me?

I'm happy to commit it, so long as somebody else signs off on it.

On Thu, Dec 22, 2016 at 12:42 AM, Senthil Kumar Selvaraj via Phabricator <
revi...@reviews.llvm.org> wrote:

> saaadhu added a comment.
>
> Would someone with a llvm bugzilla account please file the PR for me? New
> user registration is disabled, and I've been waiting for
> llvm-ad...@lists.llvm.org to respond for nearly a week now.
>
> And how should I proceed after that? Would one of the reviewers commit the
> patch for me?
>
>
> https://reviews.llvm.org/D27123
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290268 - ARM: define a macro for the FPv5 FPU in ARM mode.

2016-12-21 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Dec 21 14:49:43 2016
New Revision: 290268

URL: http://llvm.org/viewvc/llvm-project?rev=290268=rev
Log:
ARM: define a macro for the FPv5 FPU in ARM mode.

FPv5 is in Cortex-M7 and the 64-bit CPUs when running in 32-bit mode. The name
is from the Cortex-M7 TRM.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=290268=290267=290268=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Dec 21 14:49:43 2016
@@ -5391,6 +5391,8 @@ public:
 Builder.defineMacro("__ARM_VFPV3__");
   if (FPU & VFP4FPU)
 Builder.defineMacro("__ARM_VFPV4__");
+  if (FPU & FPARMV8)
+Builder.defineMacro("__ARM_FPV5__");
 }
 
 // This only gets set when Neon instructions are actually available, unlike

Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=290268=290267=290268=diff
==
--- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/arm-target-features.c Wed Dec 21 14:49:43 2016
@@ -389,6 +389,7 @@
 // M7-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
 // M7-THUMB:#define __ARM_FEATURE_DSP 1
 // M7-THUMB:#define __ARM_FP 0xE
+// M7-THUMB:#define __ARM_FPV5__ 1
 
 // Test whether predefines are as expected when targeting krait.
 // RUN: %clang -target armv7 -mcpu=krait -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=KRAIT %s


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


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-21 Thread Weiming Zhao via Phabricator via cfe-commits
weimingz added a comment.

The patch looks good to me.


https://reviews.llvm.org/D27898



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


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-21 Thread Weiming Zhao via Phabricator via cfe-commits
weimingz added a comment.

Thanks for the formatting. Regarding the refactoring, Regarding factoring out 
common code, I think it's OK to do it in a follow-up patch. For readability, it 
should be OK. For example, fp_add_impl.inc is used by float, double and long 
double.


https://reviews.llvm.org/D27898



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


r290262 - Make some diagnostic tests C++11 clean.

2016-12-21 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Wed Dec 21 12:33:17 2016
New Revision: 290262

URL: http://llvm.org/viewvc/llvm-project?rev=290262=rev
Log:
Make some diagnostic tests C++11 clean.

Differential Revision: http://reviews.llvm.org/D27794

Modified:
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/Parser/backtrack-off-by-one.cpp
cfe/trunk/test/SemaCXX/copy-assignment.cpp

Modified: cfe/trunk/test/FixIt/fixit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.cpp?rev=290262=290261=290262=diff
==
--- cfe/trunk/test/FixIt/fixit.cpp (original)
+++ cfe/trunk/test/FixIt/fixit.cpp Wed Dec 21 12:33:17 2016
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x 
c++ %s
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x 
c++ -std=c++98 %s
+// RUN: cp %s %t-98
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x 
c++ -std=c++98 %t-98
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment 
-fcxx-exceptions -x c++ -std=c++98 %t-98
 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ 
-std=c++11 %s 2>&1 | FileCheck %s
-// RUN: cp %s %t
-// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x 
c++ %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment 
-fcxx-exceptions -x c++ %t
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x 
c++ -std=c++11 %s
+// RUN: cp %s %t-11
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x 
c++ -std=c++11 %t-11
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment 
-fcxx-exceptions -x c++ -std=c++11 %t-11
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
@@ -21,7 +25,11 @@ static void C1::g() { } // expected-erro
 
 template struct CT { template struct Inner; }; // 
expected-note{{previous use is here}}
 
+// FIXME: In C++11 this gets 'expected unqualified-id' which fixit can't fix.
+// Probably parses as `CT<10> > 2 > ct;` rather than `CT<(10 >> 2)> ct;`.
+#if __cplusplus < 201103L
 CT<10 >> 2> ct; // expected-warning{{require parentheses}}
+#endif
 
 class C3 {
 public:
@@ -41,7 +49,11 @@ protected:
 };
 
 class B : public A {
+#if __cplusplus >= 201103L
+  A::foo; // expected-error{{ISO C++11 does not allow access declarations}}
+#else
   A::foo; // expected-warning{{access declarations are deprecated}}
+#endif
 };
 
 void f() throw(); // expected-note{{previous}}
@@ -285,8 +297,10 @@ namespace greatergreater {
 void (*p)() = ;
 (void)(==p); // expected-error {{use '> ='}}
 (void)(>=p); // expected-error {{use '> >'}}
+#if __cplusplus < 201103L
 (void)(>=p); // expected-error {{use '> >'}}
 (Shr)>>=p; // expected-error {{use '> >'}}
+#endif
 
 // FIXME: We correct this to ' > >= p;' not ' >>= p;'
 //(Shr)>>=p;

Modified: cfe/trunk/test/Parser/backtrack-off-by-one.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/backtrack-off-by-one.cpp?rev=290262=290261=290262=diff
==
--- cfe/trunk/test/Parser/backtrack-off-by-one.cpp (original)
+++ cfe/trunk/test/Parser/backtrack-off-by-one.cpp Wed Dec 21 12:33:17 2016
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -std=c++98
+// RUN: %clang_cc1 -verify %s -std=c++11
 
 // PR25946
 // We had an off-by-one error in an assertion when annotating A below.  
Our
@@ -10,8 +12,10 @@ template  class A {};
 
 // expected-error@+1 {{expected '{' after base class list}}
 template  class B : T // not ',' or '{'
-// expected-error@+3 {{C++ requires a type specifier for all declarations}}
-// expected-error@+2 {{expected ';' after top level declarator}}
+#if __cplusplus < 201103L
+// expected-error@+4 {{expected ';' after top level declarator}}
+#endif
+// expected-error@+2 {{C++ requires a type specifier for all declarations}}
 // expected-error@+1 {{expected ';' after class}}
 A {
 };

Modified: cfe/trunk/test/SemaCXX/copy-assignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/copy-assignment.cpp?rev=290262=290261=290262=diff
==
--- cfe/trunk/test/SemaCXX/copy-assignment.cpp (original)
+++ cfe/trunk/test/SemaCXX/copy-assignment.cpp Wed Dec 21 12:33:17 2016
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+#if __cplusplus >= 201103L
+// expected-note@+3 2 {{candidate constructor}}
+// expected-note@+2 {{passing argument to parameter here}}
+#endif
 struct A {
 };
 
@@ -7,6 +14,9 @@ struct ConvertibleToA {
 };
 
 struct 

[PATCH] D27794: Make some diagnostic tests C++11 clean

This revision was automatically updated to reflect the committed changes.
Closed by commit rL290262: Make some diagnostic tests C++11 clean. (authored by 
probinson).

Changed prior to commit:
  https://reviews.llvm.org/D27794?vs=81977=82248#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27794

Files:
  cfe/trunk/test/FixIt/fixit.cpp
  cfe/trunk/test/Parser/backtrack-off-by-one.cpp
  cfe/trunk/test/SemaCXX/copy-assignment.cpp

Index: cfe/trunk/test/FixIt/fixit.cpp
===
--- cfe/trunk/test/FixIt/fixit.cpp
+++ cfe/trunk/test/FixIt/fixit.cpp
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++98 %s
+// RUN: cp %s %t-98
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++98 %t-98
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++98 %t-98
 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
-// RUN: cp %s %t
-// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++11 %s
+// RUN: cp %s %t-11
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++11 %t-11
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++11 %t-11
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
@@ -21,7 +25,11 @@
 
 template struct CT { template struct Inner; }; // expected-note{{previous use is here}}
 
+// FIXME: In C++11 this gets 'expected unqualified-id' which fixit can't fix.
+// Probably parses as `CT<10> > 2 > ct;` rather than `CT<(10 >> 2)> ct;`.
+#if __cplusplus < 201103L
 CT<10 >> 2> ct; // expected-warning{{require parentheses}}
+#endif
 
 class C3 {
 public:
@@ -41,7 +49,11 @@
 };
 
 class B : public A {
+#if __cplusplus >= 201103L
+  A::foo; // expected-error{{ISO C++11 does not allow access declarations}}
+#else
   A::foo; // expected-warning{{access declarations are deprecated}}
+#endif
 };
 
 void f() throw(); // expected-note{{previous}}
@@ -285,8 +297,10 @@
 void (*p)() = ;
 (void)(==p); // expected-error {{use '> ='}}
 (void)(>=p); // expected-error {{use '> >'}}
+#if __cplusplus < 201103L
 (void)(>=p); // expected-error {{use '> >'}}
 (Shr)>>=p; // expected-error {{use '> >'}}
+#endif
 
 // FIXME: We correct this to ' > >= p;' not ' >>= p;'
 //(Shr)>>=p;
Index: cfe/trunk/test/Parser/backtrack-off-by-one.cpp
===
--- cfe/trunk/test/Parser/backtrack-off-by-one.cpp
+++ cfe/trunk/test/Parser/backtrack-off-by-one.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -std=c++98
+// RUN: %clang_cc1 -verify %s -std=c++11
 
 // PR25946
 // We had an off-by-one error in an assertion when annotating A below.  Our
@@ -10,8 +12,10 @@
 
 // expected-error@+1 {{expected '{' after base class list}}
 template  class B : T // not ',' or '{'
-// expected-error@+3 {{C++ requires a type specifier for all declarations}}
-// expected-error@+2 {{expected ';' after top level declarator}}
+#if __cplusplus < 201103L
+// expected-error@+4 {{expected ';' after top level declarator}}
+#endif
+// expected-error@+2 {{C++ requires a type specifier for all declarations}}
 // expected-error@+1 {{expected ';' after class}}
 A {
 };
Index: cfe/trunk/test/SemaCXX/copy-assignment.cpp
===
--- cfe/trunk/test/SemaCXX/copy-assignment.cpp
+++ cfe/trunk/test/SemaCXX/copy-assignment.cpp
@@ -1,12 +1,22 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+#if __cplusplus >= 201103L
+// expected-note@+3 2 {{candidate constructor}}
+// expected-note@+2 {{passing argument to parameter here}}
+#endif
 struct A {
 };
 
 struct ConvertibleToA {
   operator A();
 };
 
 struct ConvertibleToConstA {
+#if __cplusplus >= 201103L
+// expected-note@+2 {{candidate function}}
+#endif
   operator const A();
 };
 
@@ -69,6 +79,9 @@
   na = a;
   na = constA;
   na = convertibleToA;
+#if __cplusplus >= 201103L
+// expected-error@+2 {{no viable conversion}}
+#endif
   na = convertibleToConstA;
   na += a; // expected-error{{no viable overloaded '+='}}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27794: Make some diagnostic tests C++11 clean

probinson marked an inline comment as done.
probinson added a comment.

FIXME added.


https://reviews.llvm.org/D27794



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


[PATCH] D27710: [analyzer] Prohibit ExplodedGraph's edges duplicating

zaks.anna added a comment.

To deal with non-determinism, you can sort the results by non-pointer values, 
such as identifiers, before producing the warnings.

It is not clear if you want to print all warnings or only the first one. Is it 
an option to list all dead symbols in one warning message? Do we support 
attaching multiple bug reports to the same node?


Repository:
  rL LLVM

https://reviews.llvm.org/D27710



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


Re: r290146 - Fix completely bogus types for some builtins:


On 12/20/2016 6:56 PM, Richard Smith wrote:
On 20 December 2016 at 18:14, Richard Smith > wrote:


On 19 December 2016 at 17:00, Friedman, Eli via cfe-commits
>
wrote:

On 12/19/2016 3:59 PM, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Mon Dec 19 17:59:34 2016
New Revision: 290146

URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vfprintf-valid-redecl.c?rev=290146=290145=290146=diff



==
--- cfe/trunk/test/Sema/vfprintf-valid-redecl.c (original)
+++ cfe/trunk/test/Sema/vfprintf-valid-redecl.c Mon Dec 19
17:59:34 2016
@@ -1,16 +1,18 @@
  // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
  // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
-DPREDECLARE
-// expected-no-diagnostics
#ifdef PREDECLARE
  // PR16344
  // Clang has defined 'vfprint' in builtin list. If the
following line occurs before any other
  // `vfprintf' in this file, and we
getPreviousDecl()->getTypeSourceInfo() on it, then we will
  // get a null pointer since the one in builtin list
doesn't has valid TypeSourceInfo.
-int vfprintf(void) { return 0; }
+int vfprintf(void) { return 0; } // expected-warning
{{requires inclusion of the header }}
  #endif
// PR4290
  // The following declaration is compatible with
vfprintf, so we shouldn't
-// warn.
+// reject.
  int vfprintf();
+#ifndef PREDECLARE
+// expected-warning@-2 {{requires inclusion of the header
}}
+#endif


We shouldn't warn here; this declaration of vfprintf() is
compatible with the actual prototype.  (Granted, you can't
call vfprintf() without including stdio.h, but that's a
separate problem.)


I agree (but I'd note that this is a pre-existing problem for
other lib builtins taking a FILE*, particularly vfscanf). Perhaps
we could deem the builtin to have a FunctionNoProtoType type in C
if it's not variadic and depends on a type that is not yet declared?


What do you think of the attached approach? I'm a little uncomfortable 
that we no longer recognise a declaration of sigsetjmp as a builtin if 
it has the wrong return type (and issue only a warning for that case).


Alternatively, if we're OK with recognising wrongly-typed declarations 
as library builtins in this corner case, we could just remove the 
warning entirely.


The "right" approach is probably something a bit more invasive. We could 
wait, and attempt to recognize the builtin later, when the function is 
declared with a prototype or called.  Or we could try to 
"forward-declare" FILE (map it to some opaque type until we have an 
actual declaration we can use).


Short of that, it's probably okay to leave things as-is for now; better 
to have extra warnings in weird edge cases than to miss a warning in a 
case where it's important.


-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


[PATCH] D27641: DebugInfo: Added support for Checksum debug info feature (Clang part)

rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

This side looks good.




Comment at: lib/CodeGen/CGDebugInfo.cpp:325
+llvm::DIFile::ChecksumKind
+CGDebugInfo::getChecksum(FileID FID, SmallString<32> ) const {
+  Checksum.clear();

This is uncached. Maybe call it computeChecksum to indicate that it is 
expensive?


https://reviews.llvm.org/D27641



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


[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

zaks.anna added a comment.

Looks great overall. I have minor comments below. Thanks for the awesome 
comments!!!




Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:152
+
+  ProgramStateRef State = C.getState();
+

This could be moved up as you are using the state on the previous line.



Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:159
+
+  State = assumeValuesEqual(ThisSuccess, BooleanArgVal, State, C);
+  C.addTransition(State);

What happens when they are known not to be equal? I am guessing the transition 
is just not added, correct? Do you test for that (I did not check.)?



Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:172
+const CXXConstructorCall *Call, CheckerContext ) const {
+  assert(Call->getNumArgs() > 0);
+

"getNumArgs() == 1" ?



Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:209
+
+  if (CtorDecl->getNumParams() == 0)
+return;

It seems that the num of parameter checking logic here is less restrictive than 
it could be and that makes this a bit hard to read without looking into the 
'model' methods. Ex: I think there are 2 cases: 
- Constructor taking a bool can have either 1 or 2 arguments.
- Copy constructor taking exactly one argument.




https://reviews.llvm.org/D27773



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


[PATCH] D27794: Make some diagnostic tests C++11 clean

rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Everything here looks good to me.




Comment at: test/FixIt/fixit.cpp:28
 
+// In C++11 this gets 'expected unqualified-id' which fixit can't fix.
+#if __cplusplus < 201103L

I guess in C++11 we now parse this as `CT<10> > 2 > ct;`. I'd add a FIXME 
comment here to re-enable this recovery in C++11.


https://reviews.llvm.org/D27794



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


r290259 - clang-format: Fix bug in handling of single-column lists.

Author: djasper
Date: Wed Dec 21 11:02:06 2016
New Revision: 290259

URL: http://llvm.org/viewvc/llvm-project?rev=290259=rev
Log:
clang-format: Fix bug in handling of single-column lists.

Members that are themselves wrapped in fake parentheses would lead to
AvoidBinPacking be set on the wrong ParenState.

After:
  vector  = {
  aa.aaa,
  aa.aaa,
  aa.aaa,
  aa.aaa,
  aa.aaa,
  aa.aaa,
  };

Before we were falling back to bin-packing these.

Modified:
cfe/trunk/lib/Format/FormatToken.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/FormatToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=290259=290258=290259=diff
==
--- cfe/trunk/lib/Format/FormatToken.cpp (original)
+++ cfe/trunk/lib/Format/FormatToken.cpp Wed Dec 21 11:02:06 2016
@@ -77,6 +77,9 @@ unsigned CommaSeparatedList::formatAfter
   if (State.NextToken == nullptr || !State.NextToken->Previous)
 return 0;
 
+  if (Formats.size() == 1)
+return 0; // Handled by formatFromToken
+
   // Ensure that we start on the opening brace.
   const FormatToken *LBrace =
   State.NextToken->Previous->getPreviousNonComment();
@@ -93,13 +96,6 @@ unsigned CommaSeparatedList::formatAfter
   // Find the best ColumnFormat, i.e. the best number of columns to use.
   const ColumnFormat *Format = getColumnFormat(RemainingCodePoints);
 
-  // Formatting with 1 Column isn't really a column layout, so we don't need 
the
-  // special logic here. We can just avoid bin packing any of the parameters.
-  if (Format && Format->Columns == 1) {
-State.Stack.back().AvoidBinPacking = true;
-return 0;
-  }
-
   // If no ColumnFormat can be used, the braced list would generally be
   // bin-packed. Add a severe penalty to this so that column layouts are
   // preferred if possible.
@@ -137,7 +133,9 @@ unsigned CommaSeparatedList::formatAfter
 unsigned CommaSeparatedList::formatFromToken(LineState ,
  ContinuationIndenter *Indenter,
  bool DryRun) {
-  if (HasNestedBracedList)
+  // Formatting with 1 Column isn't really a column layout, so we don't need 
the
+  // special logic here. We can just avoid bin packing any of the parameters.
+  if (Formats.size() == 1 || HasNestedBracedList)
 State.Stack.back().AvoidBinPacking = true;
   return 0;
 }

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=290259=290258=290259=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Dec 21 11:02:06 2016
@@ -6800,6 +6800,14 @@ TEST_F(FormatTest, FormatsBracedListsInC
",\n"
"aaa};",
getLLVMStyleWithColumns(30));
+  verifyFormat("vector  = {\n"
+   "aa.aaa,\n"
+   "aa.aaa,\n"
+   "aa.aaa,\n"
+   "aa.aaa,\n"
+   "aa.aaa,\n"
+   "aa.aaa,\n"
+   "};");
 }
 
 TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {


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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

aaron.ballman added inline comments.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:96
 
-  // Do not trigger on non-const value parameters when:
-  // 1. they are in a constructor definition since they can likely trigger
-  //modernize-pass-by-value which will suggest to move the argument.
-  if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody()))
-return;
+  const FunctionDecl  = *Function->getDefinition();
 

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > malcolm.parsons wrote:
> > > > aaron.ballman wrote:
> > > > > Instead of using `hasBody()` and `getDefinition()`, you should use 
> > > > > `FunctionDecl::getBody()` and pass in an argument to receive the 
> > > > > function's definition.
> > > > I don't want the body - the `CXXCtorInitializer`s are not in it.
> > > I should use `hasBody()` and pass in an argument.
> > You are calling `Function-hasBody()` followed by 
> > `Function->getDefinition()`, which is what `FunctionDecl::getBody()` does. 
> > The difference is that `FunctionDecl::getBody()` will also load serialized 
> > bodies from the AST (if the body happens to be in a PCH, for instance).
> Do I want to load serialized bodies?
I would imagine you would want to deserialize, since you care about the 
contents of the body, not just the presence of one. This may or may not be 
important with modules (Richard Smith would be able to give a more definitive 
answer there).


https://reviews.llvm.org/D28022



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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

malcolm.parsons added inline comments.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:96
 
-  // Do not trigger on non-const value parameters when:
-  // 1. they are in a constructor definition since they can likely trigger
-  //modernize-pass-by-value which will suggest to move the argument.
-  if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody()))
-return;
+  const FunctionDecl  = *Function->getDefinition();
 

aaron.ballman wrote:
> malcolm.parsons wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > Instead of using `hasBody()` and `getDefinition()`, you should use 
> > > > `FunctionDecl::getBody()` and pass in an argument to receive the 
> > > > function's definition.
> > > I don't want the body - the `CXXCtorInitializer`s are not in it.
> > I should use `hasBody()` and pass in an argument.
> You are calling `Function-hasBody()` followed by `Function->getDefinition()`, 
> which is what `FunctionDecl::getBody()` does. The difference is that 
> `FunctionDecl::getBody()` will also load serialized bodies from the AST (if 
> the body happens to be in a PCH, for instance).
Do I want to load serialized bodies?


https://reviews.llvm.org/D28022



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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

malcolm.parsons updated this revision to Diff 82239.
malcolm.parsons added a comment.

Move hasBody check into matcher.
The matcher checks the function is a definition.


https://reviews.llvm.org/D28022

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -82,6 +82,7 @@
 struct PositiveConstValueConstructor {
   PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
   // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-FIXES: PositiveConstValueConstructor(const ExpensiveToCopyType& ConstCopy) {}
 };
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
@@ -143,8 +144,29 @@
   Obj.nonConstMethod();
 }
 
-struct NegativeValueCopyConstructor {
-  NegativeValueCopyConstructor(ExpensiveToCopyType Copy) {}
+struct PositiveValueUnusedConstructor {
+  PositiveValueUnusedConstructor(ExpensiveToCopyType Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueUnusedConstructor(const ExpensiveToCopyType& Copy) {}
+};
+
+struct PositiveValueCopiedConstructor {
+  PositiveValueCopiedConstructor(ExpensiveToCopyType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueCopiedConstructor(const ExpensiveToCopyType& Copy) : Field(Copy) {}
+  ExpensiveToCopyType Field;
+};
+
+struct PositiveValueMovableConstructor {
+  PositiveValueMovableConstructor(ExpensiveMovableType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:70: warning: parameter 'Copy'
+  // CHECK-FIXES: PositiveValueMovableConstructor(ExpensiveMovableType Copy) : Field(std::move(Copy)) {}
+  ExpensiveMovableType Field;
+};
+
+struct NegativeValueMovedConstructor {
+  NegativeValueMovedConstructor(ExpensiveMovableType Copy) : Field(static_cast(Copy)) {}
+  ExpensiveMovableType Field;
 };
 
 template 
Index: test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
+++ test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
@@ -64,6 +64,7 @@
 struct PositiveConstValueConstructor {
   PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
   // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-FIXES: PositiveConstValueConstructor(const ExpensiveToCopyType& ConstCopy) {}
 };
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
@@ -125,8 +126,17 @@
   Obj.nonConstMethod();
 }
 
-struct NegativeValueCopyConstructor {
-  NegativeValueCopyConstructor(ExpensiveToCopyType Copy) {}
+struct PositiveValueUnusedConstructor {
+  PositiveValueUnusedConstructor(ExpensiveToCopyType Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueUnusedConstructor(const ExpensiveToCopyType& Copy) {}
+};
+
+struct PositiveValueCopiedConstructor {
+  PositiveValueCopiedConstructor(ExpensiveToCopyType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueCopiedConstructor(const ExpensiveToCopyType& Copy) : Field(Copy) {}
+  ExpensiveToCopyType Field;
 };
 
 template 
Index: clang-tidy/utils/DeclRefExprUtils.h
===
--- clang-tidy/utils/DeclRefExprUtils.h
+++ clang-tidy/utils/DeclRefExprUtils.h
@@ -28,23 +28,34 @@
 bool isOnlyUsedAsConst(const VarDecl , const Stmt ,
ASTContext );
 
-// Returns set of all DeclRefExprs to VarDecl in Stmt.
+/// Returns set of all DeclRefExprs to VarDecl within Stmt.
 llvm::SmallPtrSet
 allDeclRefExprs(const VarDecl , const Stmt , ASTContext );
 
-// Returns set of all DeclRefExprs where VarDecl is guaranteed to be accessed in
-// a const fashion.
+/// Returns set of all DeclRefExprs to VarDecl within Decl.
+llvm::SmallPtrSet
+allDeclRefExprs(const VarDecl , const Decl , ASTContext );
+
+/// Returns set of all DeclRefExprs to VarDecl within Stmt where VarDecl is
+/// guaranteed to be accessed in a const fashion.
 llvm::SmallPtrSet
 constReferenceDeclRefExprs(const VarDecl , const Stmt ,
ASTContext );
 
-// Returns true if DeclRefExpr is the argument of a copy-constructor call expr.
-bool isCopyConstructorArgument(const DeclRefExpr , const Stmt ,
+/// Returns set of all DeclRefExprs to VarDecl within Decl 

[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

aaron.ballman added inline comments.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:96
 
-  // Do not trigger on non-const value parameters when:
-  // 1. they are in a constructor definition since they can likely trigger
-  //modernize-pass-by-value which will suggest to move the argument.
-  if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody()))
-return;
+  const FunctionDecl  = *Function->getDefinition();
 

malcolm.parsons wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > Instead of using `hasBody()` and `getDefinition()`, you should use 
> > > `FunctionDecl::getBody()` and pass in an argument to receive the 
> > > function's definition.
> > I don't want the body - the `CXXCtorInitializer`s are not in it.
> I should use `hasBody()` and pass in an argument.
You are calling `Function-hasBody()` followed by `Function->getDefinition()`, 
which is what `FunctionDecl::getBody()` does. The difference is that 
`FunctionDecl::getBody()` will also load serialized bodies from the AST (if the 
body happens to be in a PCH, for instance).


https://reviews.llvm.org/D28022



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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

malcolm.parsons added inline comments.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:96
 
-  // Do not trigger on non-const value parameters when:
-  // 1. they are in a constructor definition since they can likely trigger
-  //modernize-pass-by-value which will suggest to move the argument.
-  if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody()))
-return;
+  const FunctionDecl  = *Function->getDefinition();
 

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Instead of using `hasBody()` and `getDefinition()`, you should use 
> > `FunctionDecl::getBody()` and pass in an argument to receive the function's 
> > definition.
> I don't want the body - the `CXXCtorInitializer`s are not in it.
I should use `hasBody()` and pass in an argument.


https://reviews.llvm.org/D28022



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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

malcolm.parsons added inline comments.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:96
 
-  // Do not trigger on non-const value parameters when:
-  // 1. they are in a constructor definition since they can likely trigger
-  //modernize-pass-by-value which will suggest to move the argument.
-  if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody()))
-return;
+  const FunctionDecl  = *Function->getDefinition();
 

aaron.ballman wrote:
> Instead of using `hasBody()` and `getDefinition()`, you should use 
> `FunctionDecl::getBody()` and pass in an argument to receive the function's 
> definition.
I don't want the body - the `CXXCtorInitializer`s are not in it.


https://reviews.llvm.org/D28022



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


Re: [PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

On Wed, Dec 21, 2016 at 11:47 AM, Reid Kleckner  wrote:
> On Wed, Dec 21, 2016 at 8:36 AM, Aaron Ballman 
> wrote:
>>
>> That change appears to have been lost, and I would like to see them
>> brought back. I think they may have gotten lost during the rebase, as
>> they were present in https://reviews.llvm.org/D26846?id=78569.
>
>
> I removed the tablegen logic because it was dead after changing the uuid
> SubjectList to this:
>   let Subjects = SubjectList<[Record, Enum], WarnDiag,
> "ExpectedEnumOrClass">;
>
> It was necessary to go from CXXRecord to Record here so that we would accept
> __uuid on structs in C and then reject the attribute as being C++-only
> later.
>
> Feel free to add the case back. From my reading of the code, it seems like
> CalculateDiagnostic isn't intended to cover every case.

It's intended to cover the common ones; Record or Enum seems like
something we will hit in the future as well, which is why it'd be nice
to have. However, I still have hopes to make a more general solution
so that we don't need to do this dance in the future, so it's not a
high priority.

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


[PATCH] D28023: [analyzer] Fix leak false positives before no-return functions caused by incomplete analyses.

dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

With the change Aleksei suggested (can you get the CFGStmtMap from the 
AnalysisDeclContext?), looks good to me.

I especially like the test!




Comment at: lib/StaticAnalyzer/Core/BugReporter.cpp:3363
+// we're post-dominated by.
+// FIXME: This is far from enough to handle the incomplete analysis case.
+// We may be post-dominated in subsequent blocks, or even

a.sidorin wrote:
> I took a brief look and found that we have Domination analysis for clang CFG 
> but not PostDomination analysis. However, `llvm::DominatorTreeBase` that is 
> used internally in `clang::DominatorTree` may be constructed for 
> post-domination analysis. Is it possible to implement such analysis quickly 
> (or modify `clang::DominatorTree` to support it)? If the answer is no, don't 
> mind.
Do you actually want a FIXME here? Are you certain it would it be a good use of 
some future contributor's time to rewrite this? If not then you might want to 
soften it to a normal comment. (New contributors often search the codebase for 
FIXMEs to address as their first patch -- so a FIXME is a recommendation that 
someone  actually fix it, rather than an acknowledgement/documentation of some 
known limitation).



Comment at: test/Analysis/max-nodes-suppress-on-sink.c:6
+
+// If we throw a warning of a bug-type with "suppress on sink" attribute set
+// (such as MallocChecker's memory leak warning), then failing to reach the

Using "throw" is not correct here. I would suggest "emit" or"report".



Comment at: test/Analysis/max-nodes-suppress-on-sink.c:27
+  // the max-nodes run-line helps.
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning

This is great.


https://reviews.llvm.org/D28023



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


r290258 - Wdocumentation fix

Author: rksimon
Date: Wed Dec 21 10:39:09 2016
New Revision: 290258

URL: http://llvm.org/viewvc/llvm-project?rev=290258=rev
Log:
Wdocumentation fix

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

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=290258=290257=290258=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Dec 21 10:39:09 2016
@@ -455,9 +455,9 @@ public:
   /// \brief Store a list of either DeclRefExprs or MemberExprs
   ///  that contain a reference to a variable (constant) that may or may not
   ///  be odr-used in this Expr, and we won't know until all lvalue-to-rvalue
-  ///  and discarded value conversions have been applied to all subexpressions 
-  ///  of the enclosing full expression.  This is cleared at the end of each 
-  ///  full expression. 
+  ///  and discarded value conversions have been applied to all subexpressions
+  ///  of the enclosing full expression.  This is cleared at the end of each
+  ///  full expression.
   llvm::SmallPtrSet MaybeODRUseExprs;
 
   /// \brief Stack containing information about each of the nested
@@ -671,15 +671,15 @@ public:
   class SynthesizedFunctionScope {
 Sema 
 Sema::ContextRAII SavedContext;
-
+
   public:
 SynthesizedFunctionScope(Sema , DeclContext *DC)
-  : S(S), SavedContext(S, DC) 
+  : S(S), SavedContext(S, DC)
 {
   S.PushFunctionScope();
   S.PushExpressionEvaluationContext(Sema::PotentiallyEvaluated);
 }
-
+
 ~SynthesizedFunctionScope() {
   S.PopExpressionEvaluationContext();
   S.PopFunctionScopeInfo();
@@ -793,7 +793,7 @@ public:
   bool GlobalNewDeleteDeclared;
 
   /// A flag to indicate that we're in a context that permits abstract
-  /// references to fields.  This is really a 
+  /// references to fields.  This is really a
   bool AllowAbstractFieldReference;
 
   /// \brief Describes how the expressions currently being parsed are
@@ -1184,7 +1184,7 @@ public:
   /// is during Parsing.  Currently it is used to pass on the depth
   /// when parsing generic lambda 'auto' parameters.
   void RecordParsingTemplateParameterDepth(unsigned Depth);
-  
+
   void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
RecordDecl *RD,
CapturedRegionKind K);
@@ -1196,11 +1196,11 @@ public:
   sema::FunctionScopeInfo *getCurFunction() const {
 return FunctionScopes.back();
   }
-  
+
   sema::FunctionScopeInfo *getEnclosingFunction() const {
 if (FunctionScopes.empty())
   return nullptr;
-
+
 for (int e = FunctionScopes.size()-1; e >= 0; --e) {
   if (isa(FunctionScopes[e]))
 continue;
@@ -1208,13 +1208,13 @@ public:
 }
 return nullptr;
   }
-  
+
   template 
   void recordUseOfEvaluatedWeak(const ExprT *E, bool IsRead=true) {
 if (!isUnevaluatedContext())
   getCurFunction()->recordUseOfWeak(E, IsRead);
   }
-  
+
   void PushCompoundScope();
   void PopCompoundScope();
 
@@ -2574,7 +2574,7 @@ public:
OverloadCandidateSet& CandidateSet,
SourceRange OpRange = SourceRange());
   void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
-   ArrayRef Args, 
+   ArrayRef Args,
OverloadCandidateSet& CandidateSet,
bool IsAssignmentOperator = false,
unsigned NumContextualBoolArguments = 0);
@@ -3070,7 +3070,7 @@ public:
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   bool CheckRegparmAttr(const AttributeList , unsigned );
-  bool CheckCallingConvAttr(const AttributeList , CallingConv , 
+  bool CheckCallingConvAttr(const AttributeList , CallingConv ,
 const FunctionDecl *FD = nullptr);
   bool CheckNoReturnAttr(const AttributeList );
   bool checkStringLiteralArgumentAttr(const AttributeList ,
@@ -3176,18 +3176,18 @@ public:
   /// declared in class 'IFace'.
   bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace,
   ObjCMethodDecl *Method, ObjCIvarDecl 
*IV);
-  
+
   /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar 
which
   /// backs the property is not used in the property's accessor.
   void DiagnoseUnusedBackingIvarInAccessor(Scope *S,
const ObjCImplementationDecl 
*ImplD);
-  
+
   /// GetIvarBackingPropertyAccessor - If method is a property setter/getter 
and
   /// it property has a backing ivar, returns this ivar; otherwise, returns 
NULL.
   /// It also returns ivar's property on success.
   ObjCIvarDecl *GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
   

Re: [PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

On Wed, Dec 21, 2016 at 8:36 AM, Aaron Ballman 
wrote:

> That change appears to have been lost, and I would like to see them
> brought back. I think they may have gotten lost during the rebase, as
> they were present in https://reviews.llvm.org/D26846?id=78569.
>

I removed the tablegen logic because it was dead after changing the uuid
SubjectList to this:
  let Subjects = SubjectList<[Record, Enum], WarnDiag,
"ExpectedEnumOrClass">;

It was necessary to go from CXXRecord to Record here so that we would
accept __uuid on structs in C and then reject the attribute as being
C++-only later.

Feel free to add the case back. From my reading of the code, it seems
like CalculateDiagnostic isn't intended to cover every case.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

aaron.ballman added inline comments.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:96
 
-  // Do not trigger on non-const value parameters when:
-  // 1. they are in a constructor definition since they can likely trigger
-  //modernize-pass-by-value which will suggest to move the argument.
-  if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody()))
-return;
+  const FunctionDecl  = *Function->getDefinition();
 

Instead of using `hasBody()` and `getDefinition()`, you should use 
`FunctionDecl::getBody()` and pass in an argument to receive the function's 
definition.


https://reviews.llvm.org/D28022



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


Re: [PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

On Tue, Dec 20, 2016 at 5:58 PM, Kevin Puetz via Phabricator
 wrote:
> puetzk added a comment.
>
> I see that you added a FIXME mentioning that it should be C++-only, but I 
> don't see where you actually did anything that would make it so. What am I 
> missing?

You aren't missing anything, the fix isn't in yet -- the comment is
calling out that we should fix this at some point in the future.

> Also, did you mean to drop the changes to utils/TableGen/ClangAttrEmitter.cpp 
> and bring back the WarnDiag, "ExpectedEnumOrClass" @aaron.ballman asked for 
> in the first review?

That change appears to have been lost, and I would like to see them
brought back. I think they may have gotten lost during the rebase, as
they were present in https://reviews.llvm.org/D26846?id=78569.

~Aaron

>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D26846
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28018: AMD family 17h (znver1) enablement

RKSimon added a reviewer: RKSimon.
RKSimon added a comment.

Also, I don't think there is any clzero support on clang yet so adding that 
feature probably isn't safe. You may need to put up a separate clzero patch for 
review, preferably including _mm_clzero support to the headers as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D28018



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


Re: [clang-tools-extra] r290202 - [clang-tidy] Add modernize-use-default-member-init check

On Tue, Dec 20, 2016 at 5:58 PM, Malcolm Parsons
 wrote:
> On 20 December 2016 at 22:32, Aaron Ballman  wrote:
>> On Tue, Dec 20, 2016 at 4:26 PM, Malcolm Parsons via cfe-commits
>>  wrote:
>>> Author: malcolm.parsons
>>> Date: Tue Dec 20 15:26:07 2016
>>> New Revision: 290202
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=290202=rev
>>> Log:
>>> [clang-tidy] Add modernize-use-default-member-init check
>>>
>>> Summary: Fixes PR18858
>>
>> This appears to have broken one of the bots:
>>
>> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/33046
>
> error: unknown type name 'char16_t'
> error: unknown type name 'char32_t'
>
> I see commented tests in other clang-tidy tests:
>
> // TODO: enable these tests once all supported compilers
> // support char16_t and char32_t (VS2013 does not)
>
> // disabled for now until it is clear
> // how to enable them in the test
> //} catch (const char16_t*) {

We no longer support MSVC 2013, so that should not be an issue.
Takumi, I'm not certain what to make of this builder (MSVC centos?).
What version of Visual Studio is it compiling with? Or is this an
instance where we need to set the -fms-compatibility-version=19 when
running the test with clang-cl?

~Aaron

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


[PATCH] D28023: [analyzer] Fix leak false positives before no-return functions caused by incomplete analyses.

a.sidorin added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporter.cpp:3363
+// we're post-dominated by.
+// FIXME: This is far from enough to handle the incomplete analysis case.
+// We may be post-dominated in subsequent blocks, or even

I took a brief look and found that we have Domination analysis for clang CFG 
but not PostDomination analysis. However, `llvm::DominatorTreeBase` that is 
used internally in `clang::DominatorTree` may be constructed for 
post-domination analysis. Is it possible to implement such analysis quickly (or 
modify `clang::DominatorTree` to support it)? If the answer is no, don't mind.


https://reviews.llvm.org/D28023



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


[PATCH] D27710: [analyzer] Prohibit ExplodedGraph's edges duplicating

ilya-palachev added a comment.

In https://reviews.llvm.org/D27710#628069, @zaks.anna wrote:

> Are there any negative effects from having the duplicates in edges?


Yes, you're right; in current implementation there seems to be no negative 
effects from this, since duplicate edges are quite rare, and they produce very 
small overhead on memory (just two additional pointers for each excessive edge).

> When does this occur? It's a bit suspicious since we have a FromN, and a path 
> is split at that node, resulting in successors that are the same. Is it 
> possible that whoever split the state did not encode enough interesting info?

Yes, this  does occur (for one of our checkers on Android).
This patch is more likely a request for comments for what to do in the 
situation discussed below...

Consider the checker that can emit warnings on multiple dead symbols (one 
warning for each buggy symbol). When the checker encounters such situation, it 
first emits a warning for the 1st symbol, then for the 2nd one. For the 2nd and 
other symbols the CheckerContext::addTransition returns `nullptr'. That means 
that the requested node already exist, because the State hasn't changed. And 
for each warning beginning from the 2nd, the additional edge is added for the 
ExplodedGraph. It can be even simply seen with DOT graph.

Yes, this problem can be resolved with checker tags for nodes, but in this case 
we'll need to create new tag for each such warning (because ProgramPoint and 
ProgramState are equal for them all).

Moreover, such cases can even lead to non-determinism in warnings.

The checker stores a set(map/list...) of buggy symbols (regions...) in GDM. 
When checkDeadSymbols callback happens, this set is iterated, and the checker 
tries to emit a warning for each of them. But actually the order in which 
symbols are stored in the set depends on their order as pointers, and it's 
controlled by allocator. The allocator contains non-determinism by design, and 
region for symbol A can be greater (as a pointer) that the region for the 
symbol B in one analysis run, and smaller during the another run.

That's why in such cases different warnings can be emitted from time to time. 
The discussed patch doesn't address this issue, but I'd like at least to 
discuss the situation.


Repository:
  rL LLVM

https://reviews.llvm.org/D27710



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


[PATCH] D28023: [analyzer] Fix leak false positives before no-return functions caused by incomplete analyses.

a.sidorin added a comment.

Looks useful and mostly good. A small advice is in inline comments.




Comment at: lib/StaticAnalyzer/Core/BugReporter.cpp:3294
+  // Find the node's current statement in the CFG.
+  // FIXME: CFG lookup should be made easier.
+  const CFG  = N->getCFG();

Maybe it is possible to use `CFGStmtMap` for search?


https://reviews.llvm.org/D28023



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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

malcolm.parsons updated this revision to Diff 82237.
malcolm.parsons marked 3 inline comments as done.
malcolm.parsons added a comment.

Add some variables.
Improve comments.


https://reviews.llvm.org/D28022

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -82,6 +82,7 @@
 struct PositiveConstValueConstructor {
   PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
   // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-FIXES: PositiveConstValueConstructor(const ExpensiveToCopyType& ConstCopy) {}
 };
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
@@ -143,8 +144,29 @@
   Obj.nonConstMethod();
 }
 
-struct NegativeValueCopyConstructor {
-  NegativeValueCopyConstructor(ExpensiveToCopyType Copy) {}
+struct PositiveValueUnusedConstructor {
+  PositiveValueUnusedConstructor(ExpensiveToCopyType Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueUnusedConstructor(const ExpensiveToCopyType& Copy) {}
+};
+
+struct PositiveValueCopiedConstructor {
+  PositiveValueCopiedConstructor(ExpensiveToCopyType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueCopiedConstructor(const ExpensiveToCopyType& Copy) : Field(Copy) {}
+  ExpensiveToCopyType Field;
+};
+
+struct PositiveValueMovableConstructor {
+  PositiveValueMovableConstructor(ExpensiveMovableType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:70: warning: parameter 'Copy'
+  // CHECK-FIXES: PositiveValueMovableConstructor(ExpensiveMovableType Copy) : Field(std::move(Copy)) {}
+  ExpensiveMovableType Field;
+};
+
+struct NegativeValueMovedConstructor {
+  NegativeValueMovedConstructor(ExpensiveMovableType Copy) : Field(static_cast(Copy)) {}
+  ExpensiveMovableType Field;
 };
 
 template 
Index: test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
+++ test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
@@ -64,6 +64,7 @@
 struct PositiveConstValueConstructor {
   PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
   // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-FIXES: PositiveConstValueConstructor(const ExpensiveToCopyType& ConstCopy) {}
 };
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
@@ -125,8 +126,17 @@
   Obj.nonConstMethod();
 }
 
-struct NegativeValueCopyConstructor {
-  NegativeValueCopyConstructor(ExpensiveToCopyType Copy) {}
+struct PositiveValueUnusedConstructor {
+  PositiveValueUnusedConstructor(ExpensiveToCopyType Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueUnusedConstructor(const ExpensiveToCopyType& Copy) {}
+};
+
+struct PositiveValueCopiedConstructor {
+  PositiveValueCopiedConstructor(ExpensiveToCopyType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueCopiedConstructor(const ExpensiveToCopyType& Copy) : Field(Copy) {}
+  ExpensiveToCopyType Field;
 };
 
 template 
Index: clang-tidy/utils/DeclRefExprUtils.h
===
--- clang-tidy/utils/DeclRefExprUtils.h
+++ clang-tidy/utils/DeclRefExprUtils.h
@@ -28,23 +28,34 @@
 bool isOnlyUsedAsConst(const VarDecl , const Stmt ,
ASTContext );
 
-// Returns set of all DeclRefExprs to VarDecl in Stmt.
+/// Returns set of all DeclRefExprs to VarDecl within Stmt.
 llvm::SmallPtrSet
 allDeclRefExprs(const VarDecl , const Stmt , ASTContext );
 
-// Returns set of all DeclRefExprs where VarDecl is guaranteed to be accessed in
-// a const fashion.
+/// Returns set of all DeclRefExprs to VarDecl within Decl.
+llvm::SmallPtrSet
+allDeclRefExprs(const VarDecl , const Decl , ASTContext );
+
+/// Returns set of all DeclRefExprs to VarDecl within Stmt where VarDecl is
+/// guaranteed to be accessed in a const fashion.
 llvm::SmallPtrSet
 constReferenceDeclRefExprs(const VarDecl , const Stmt ,
ASTContext );
 
-// Returns true if DeclRefExpr is the argument of a copy-constructor call expr.
-bool isCopyConstructorArgument(const DeclRefExpr , const Stmt ,
+/// Returns set of all DeclRefExprs to VarDecl within 

[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

a.sidorin added a comment.

Looks good for me, but I'm not a reviewer. Thank you Devin!




Comment at: test/Driver/analyzer-target-enabled-checkers.cpp:7
 // CHECK-DARWIN: "-analyzer-checker=core"
+// CHECK-DARWIN-SAME: "-analyzer-checker=apiModeling"
 // CHECK-DARWIN-SAME: "-analyzer-checker=unix"

A very minor nit/question.
Do we have any convention on checker naming? Most checkers are starting with 
capital letters, but some not. As "API" is an abbreviation, I think we should 
at least start it with capital.


https://reviews.llvm.org/D27773



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


[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

malcolm.parsons added a comment.

https://reviews.llvm.org/D28022 changes performance-unnecessary-value-param so 
that it handles this part of modernize-pass-by-value.
So this isn't the end of the story here yet.




Comment at: 
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp:1
-// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 
-isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s 
misc-move-constructor-init,modernize-pass-by-value %t -- \
+// RUN: -config='{CheckOptions: \

alexfh wrote:
> Test for one check running a different check is somewhat confusing. If we 
> need to ensure that the patterns the two checks target don't overlap, maybe 
> we should rename the test (+.cpp or something like that)?
Doing it like this was to show that no functionality was lost, not that there's 
no overlap.
The pass-by-value tests can be moved somewhere else.


Repository:
  rL LLVM

https://reviews.llvm.org/D26453



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


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

mgorny updated this revision to Diff 82235.
mgorny marked an inline comment as done.
mgorny added a comment.

I think I've shifted all of `{`/`}` to be in line with keywords.

As for the splitting the code, you're probably right. However, I'd rather do 
that in a separate patch (I'll add it to my TODO, I promise).

I think that most of those files reuse a similar code -- I think it's for the 
case when the integer has greater range than the float. It would certainly also 
make sense to try to commonize the code used for signed and unsigned. However, 
I'm a little worried that it might make the result unreadable.


https://reviews.llvm.org/D27898

Files:
  lib/builtins/CMakeLists.txt
  lib/builtins/floattitf.c
  lib/builtins/floatuntitf.c
  test/builtins/Unit/floattitf_test.c
  test/builtins/Unit/floatuntitf_test.c

Index: test/builtins/Unit/floatuntitf_test.c
===
--- /dev/null
+++ test/builtins/Unit/floatuntitf_test.c
@@ -0,0 +1,220 @@
+//===-- floatuntitf.c - Test __floatuntitf ===//
+//
+// 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.
+//
+//===--===//
+//
+// This file tests __floatuntitf for the compiler_rt library.
+//
+//===--===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+#include "int_lib.h"
+#include 
+#include 
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+
+/* Returns: convert a tu_int to a fp_t, rounding toward even. */
+
+/* Assumption: fp_t is a IEEE 128 bit floating point type
+ * tu_int is a 128 bit integral type
+ */
+
+/* seee        |         |
+ *         |        
+ */
+
+COMPILER_RT_ABI fp_t __floatuntitf(tu_int a);
+
+int test__floatuntitf(tu_int a, fp_t expected) {
+fp_t x = __floatuntitf(a);
+if (x != expected) {
+utwords at;
+at.all = a;
+printf("error in __floatuntitf(0x%.16llX%.16llX) = %LA, expected %LA\n",
+   at.s.high, at.s.low, x, expected);
+}
+return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main() {
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+if (test__floatuntitf(0, 0.0))
+return 1;
+
+if (test__floatuntitf(1, 1.0))
+return 1;
+if (test__floatuntitf(2, 2.0))
+return 1;
+if (test__floatuntitf(20, 20.0))
+return 1;
+
+if (test__floatuntitf(0x7F80ULL, 0x1.FEp+62))
+return 1;
+if (test__floatuntitf(0x7800ULL, 0x1.Ep+62))
+return 1;
+if (test__floatuntitf(0x7F00ULL, 0x1.FCp+62))
+return 1;
+if (test__floatuntitf(0x7000ULL, 0x1.Cp+62))
+return 1;
+if (test__floatuntitf(0x7FFFULL, 0xF.FFEp+59L))
+return 1;
+if (test__floatuntitf(0xFFFEULL, 0xF.FFEp+60L))
+return 1;
+if (test__floatuntitf(0xULL, 0xF.FFFp+60L))
+return 1;
+
+if (test__floatuntitf(0x8080ULL, 0x8.08p+60))
+return 1;
+if (test__floatuntitf(0x8800ULL, 0x8.8p+60))
+return 1;
+if (test__floatuntitf(0x8100ULL, 0x8.1p+60))
+return 1;
+if (test__floatuntitf(0x80001000ULL, 0x8.0001p+60))
+return 1;
+
+if (test__floatuntitf(0x8000ULL, 0x8p+60))
+return 1;
+if (test__floatuntitf(0x8001ULL, 0x8.001p+60L))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E800LL, 0x1.FEDCBAp+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72EA00LL, 0x1.FEDCBA8p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EB00LL, 0x1.FEDCBACp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EBFFLL, 0x1.FEDCBAFFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EC00LL, 0x1.FEDCBBp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E801LL, 0x1.FEDCBA004p+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E600LL, 0x1.FEDCB98p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E700LL, 0x1.FEDCB9Cp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E7FFLL, 0x1.FEDCB9FFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E401LL, 0x1.FEDCB9004p+50))
+return 1;
+if 

[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

alexfh added a comment.

LG.

In https://reviews.llvm.org/D26453#592934, @flx wrote:

> In https://reviews.llvm.org/D26453#590720, @malcolm.parsons wrote:
>
> > Add ValuesOnly option to modernize-pass-by-value.
>
>
> Thanks for doing this. Alex, would this work for us?


Yep, I think so.




Comment at: 
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp:1
-// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 
-isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s 
misc-move-constructor-init,modernize-pass-by-value %t -- \
+// RUN: -config='{CheckOptions: \

Test for one check running a different check is somewhat confusing. If we need 
to ensure that the patterns the two checks target don't overlap, maybe we 
should rename the test (+.cpp or something like that)?


Repository:
  rL LLVM

https://reviews.llvm.org/D26453



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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:114
 if (AllDeclRefExprs.size() == 1 &&
-!hasLoopStmtAncestor(**AllDeclRefExprs.begin(), *Function->getBody(),
- *Result.Context) &&
+!hasLoopStmtAncestor(**AllDeclRefExprs.begin(),
+ *Function->getDefinition(), *Result.Context) &&

How about pulling out variables for `**AllDeclRefExprs.begin()` and 
`*Function->getDefinition()` to remove some boilerplate?



Comment at: clang-tidy/utils/DeclRefExprUtils.h:35
 
+// Returns set of all DeclRefExprs to VarDecl in Decl.
+llvm::SmallPtrSet

Please convert the comment (and the other ones the patch touches) to doxygen 
style.



Comment at: clang-tidy/utils/DeclRefExprUtils.h:55-56
 
 // Returns true if DeclRefExpr is the argument of a copy-assignment operator
 // call expr.
+bool isCopyAssignmentArgument(const DeclRefExpr , const Decl ,

The comment is now confusing. It says nothing about `Decl` and doesn't make it 
clear where the "call expr" (btw, it should either be `CallExpr`, if it 
references to the corresponding type or "call expression" otherwise) comes 
from. Same above.


https://reviews.llvm.org/D28022



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


[PATCH] D28023: [analyzer] Fix leak false positives before no-return functions caused by incomplete analyses.

NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin, xazax.hun, a.sidorin.
NoQ added a subscriber: cfe-commits.

Consider an example:

  void foo(int y) {
void *x = malloc(1);
assert(y); // macro that expands to "if (!y) exit(1);"
free(x);
  }

In CFG block corresponding to `exit(1)`, variable `x` is //dead//, because both 
CFG and `LivenessAnalysis` are aware of no-return functions and realize that we 
don't ever reach the reference to `x` in `free(x)` from this block.

Because `x` is dead, its binding - symbol returned by malloc - is also dead, 
and `MallocChecker` reports a memory leak warning.

However, because such warning would not be particularly useful (nobody ever 
frees memory before assertion failures), `MallocChecker`'s `BugType` has 
`setSuppressOnSink(true)`, and this warning would be discarded later by 
`BugReporter` and never presented to the user.

Warnings with suppress-on-sink are discarded during `FlushReports` when 
`BugReporter` notices that all paths in `ExplodedGraph` that pass through the 
warning eventually run into a sink node.

Apart from suppressing false positives similar to the example above, this 
mechanism has a second purpose - to filter out non-fatal bugs when the path 
runs into a fatal bug. For that second purpose, the mechanism works perfectly.

However, suppress-on-sink fails to filter out false positives when the analysis 
terminates too early - by running into analyzer limits, such as block count 
limits or graph size limits - and //the interruption hits the narrow window 
between throwing the leak report and reaching the no-return function call//. In 
such case the report is there, however suppression-on-sink doesn't work, 
because the sink node was never constructed in the incomplete `ExplodedGraph`.

In a particular report i've been investigating, the false positive disappeared 
when i set `-analyzer-config max-nodes` to less than 149995 or more than 150105 
(+/- 0.08% of the default value 15).

Note that suppress-on-sink is an "all paths" problem - we're trying to detect 
an event that occurs on all execution paths after a certain point. Such 
problems should not be solved by exploring `ExplodedGraph` for this very reason 
- the graph is not guaranteed to even contain all paths. In some cases it is 
acceptable to behave conservatively when the graph is known to be incomplete, 
however in this case it would result in disproportional amounts of leak 
false-negatives.

This patch implements a very partial solution: also suppress reports thrown 
against a statement-node that corresponds to a statement that belongs to a 
no-return block of the CFG.

This solution is partial because no-return functions that we failed to reach 
may also be found in subsequent blocks or in a different function. However, for 
the simple implementation of the `assert()` macro (that expands to an `if` 
followed by a no-return function), this patch fixes the problem.


https://reviews.llvm.org/D28023

Files:
  lib/StaticAnalyzer/Core/BugReporter.cpp
  test/Analysis/max-nodes-suppress-on-sink.c


Index: test/Analysis/max-nodes-suppress-on-sink.c
===
--- /dev/null
+++ test/Analysis/max-nodes-suppress-on-sink.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config 
max-nodes=12 -verify %s
+
+// Here we test how "suppress on sink" feature of certain bugtypes interacts
+// with reaching analysis limits.
+
+// If we throw a warning of a bug-type with "suppress on sink" attribute set
+// (such as MallocChecker's memory leak warning), then failing to reach the
+// reason for the sink (eg. no-return function such as "exit()") due to 
analysis
+// limits (eg. max-nodes option), we may produce a false positive.
+
+#include "Inputs/system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+extern void exit(int) __attribute__ ((__noreturn__));
+
+void clang_analyzer_warnIfReached(void);
+
+void test_single_cfg_block_sink() {
+  void *p = malloc(1); // no-warning (wherever the leak warning may occur here)
+
+  // Due to max-nodes option in the run line, we should reach the first call
+  // but bail out before the second call.
+  // If the test on these two lines starts failing, see if modifying
+  // the max-nodes run-line helps.
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // no-warning
+
+  // Even though we do not reach this line, we should still suppress
+  // the leak report.
+  exit(0);
+}
Index: lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- lib/StaticAnalyzer/Core/BugReporter.cpp
+++ lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3285,6 +3285,29 @@
 };
 }
 
+static const CFGBlock *findBlockForNode(const ExplodedNode *N) {
+  ProgramPoint P = N->getLocation();
+  if (auto BEP = 

[PATCH] D26546: [PPC] Add vec_insert4b/vec_extract4b to altivec.h

nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

Just one minor inline nit. Other than that, LGTM.




Comment at: test/CodeGen/builtins-ppc-error.c:5
+// RUN:   -triple powerpc64-unknown-unknown -fsyntax-only   \
+// RUN: -Wall -Werror -verify %s
+

I'm just curious why -Werror? This should be an error even without that.


Repository:
  rL LLVM

https://reviews.llvm.org/D26546



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


[PATCH] D28022: [clang-tidy] Handle constructors in performance-unnecessary-value-param

malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, flx, alexfh.
malcolm.parsons added a subscriber: cfe-commits.
Herald added a subscriber: JDevlieghere.

modernize-pass-by-value doesn't warn about value parameters that
cannot be moved, so performance-unnecessary-value-param should.


https://reviews.llvm.org/D28022

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -82,6 +82,7 @@
 struct PositiveConstValueConstructor {
   PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
   // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-FIXES: PositiveConstValueConstructor(const ExpensiveToCopyType& ConstCopy) {}
 };
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
@@ -143,8 +144,29 @@
   Obj.nonConstMethod();
 }
 
-struct NegativeValueCopyConstructor {
-  NegativeValueCopyConstructor(ExpensiveToCopyType Copy) {}
+struct PositiveValueUnusedConstructor {
+  PositiveValueUnusedConstructor(ExpensiveToCopyType Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueUnusedConstructor(const ExpensiveToCopyType& Copy) {}
+};
+
+struct PositiveValueCopiedConstructor {
+  PositiveValueCopiedConstructor(ExpensiveToCopyType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueCopiedConstructor(const ExpensiveToCopyType& Copy) : Field(Copy) {}
+  ExpensiveToCopyType Field;
+};
+
+struct PositiveValueMovableConstructor {
+  PositiveValueMovableConstructor(ExpensiveMovableType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:70: warning: parameter 'Copy'
+  // CHECK-FIXES: PositiveValueMovableConstructor(ExpensiveMovableType Copy) : Field(std::move(Copy)) {}
+  ExpensiveMovableType Field;
+};
+
+struct NegativeValueMovedConstructor {
+  NegativeValueMovedConstructor(ExpensiveMovableType Copy) : Field(static_cast(Copy)) {}
+  ExpensiveMovableType Field;
 };
 
 template 
Index: test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
+++ test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
@@ -64,6 +64,7 @@
 struct PositiveConstValueConstructor {
   PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
   // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-FIXES: PositiveConstValueConstructor(const ExpensiveToCopyType& ConstCopy) {}
 };
 
 template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
@@ -125,8 +126,17 @@
   Obj.nonConstMethod();
 }
 
-struct NegativeValueCopyConstructor {
-  NegativeValueCopyConstructor(ExpensiveToCopyType Copy) {}
+struct PositiveValueUnusedConstructor {
+  PositiveValueUnusedConstructor(ExpensiveToCopyType Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueUnusedConstructor(const ExpensiveToCopyType& Copy) {}
+};
+
+struct PositiveValueCopiedConstructor {
+  PositiveValueCopiedConstructor(ExpensiveToCopyType Copy) : Field(Copy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:54: warning: the parameter 'Copy'
+  // CHECK-FIXES: PositiveValueCopiedConstructor(const ExpensiveToCopyType& Copy) : Field(Copy) {}
+  ExpensiveToCopyType Field;
 };
 
 template 
Index: clang-tidy/utils/DeclRefExprUtils.h
===
--- clang-tidy/utils/DeclRefExprUtils.h
+++ clang-tidy/utils/DeclRefExprUtils.h
@@ -32,19 +32,29 @@
 llvm::SmallPtrSet
 allDeclRefExprs(const VarDecl , const Stmt , ASTContext );
 
+// Returns set of all DeclRefExprs to VarDecl in Decl.
+llvm::SmallPtrSet
+allDeclRefExprs(const VarDecl , const Decl , ASTContext );
+
 // Returns set of all DeclRefExprs where VarDecl is guaranteed to be accessed in
 // a const fashion.
 llvm::SmallPtrSet
 constReferenceDeclRefExprs(const VarDecl , const Stmt ,
ASTContext );
 
+// Returns set of all DeclRefExprs where VarDecl is guaranteed to be accessed in
+// a const fashion.
+llvm::SmallPtrSet
+constReferenceDeclRefExprs(const VarDecl , const Decl ,
+   ASTContext );
+
 // Returns true if DeclRefExpr is the argument of a copy-constructor call expr.
-bool isCopyConstructorArgument(const DeclRefExpr , const Stmt ,
+bool 

[PATCH] D27920: [find-all-symbols] Index partial template specializations.

ioeric added a comment.

I'm not quite convinced/sure if we want to match all partial specializations 
just for `std::function`. We filtered out template specialization because there 
could be multiple specializations for a template in different headers and it 
was not clear which one we would choose. And if we do index specializations, I 
don't see why we would want to filter out full specializations.

We might want to wait for Ben's opinion.


https://reviews.llvm.org/D27920



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


[PATCH] D27920: [find-all-symbols] Index partial template specializations.

hokein added a comment.

In https://reviews.llvm.org/D27920#628586, @ioeric wrote:

> Why do we allow partially specialization but fully specialization now? Could 
> you elaborate in the cl description?


Done.


https://reviews.llvm.org/D27920



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


[PATCH] D27971: Make FormatStyle.GetStyleOfFile test work on MSVC

klimek added inline comments.



Comment at: lib/Format/Format.cpp:1920-1922
+  std::error_code EC = FS->makeAbsolute(Path);
+  assert(!EC);
+  (void)EC;

amaiorano wrote:
> klimek wrote:
> > I think if makeAbsolute doesn't work, we will probably want to err out here:
> > if (EC) {
> >   llvm::errs() << ... << EC.message << ...
> >   return Style;
> > }
> Okay. I based myself on the fact that the old code didn't do error checking 
> on fs::make_absolute - in fact most calls to fs::make_absolute in the 
> codebase assert on the result. I suppose it's because it's just a string 
> manipulation function, and if it fails, the subsequent code that will make 
> use of the path will fail with a more useful error.
> 
> In any case, I don't mind handling the error here as you propose.
> 
I don't think it's overly important in this case. Generally, I like a good 
error message more than an assert that gives me no info on what happened...


https://reviews.llvm.org/D27971



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


[PATCH] D27971: Make FormatStyle.GetStyleOfFile test work on MSVC

amaiorano added inline comments.



Comment at: lib/Format/Format.cpp:1920-1922
+  std::error_code EC = FS->makeAbsolute(Path);
+  assert(!EC);
+  (void)EC;

klimek wrote:
> I think if makeAbsolute doesn't work, we will probably want to err out here:
> if (EC) {
>   llvm::errs() << ... << EC.message << ...
>   return Style;
> }
Okay. I based myself on the fact that the old code didn't do error checking on 
fs::make_absolute - in fact most calls to fs::make_absolute in the codebase 
assert on the result. I suppose it's because it's just a string manipulation 
function, and if it fails, the subsequent code that will make use of the path 
will fail with a more useful error.

In any case, I don't mind handling the error here as you propose.



https://reviews.llvm.org/D27971



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


[PATCH] D27123: Add AVR target and toolchain to Clang

saaadhu added a comment.

Would someone with a llvm bugzilla account please file the PR for me? New user 
registration is disabled, and I've been waiting for llvm-ad...@lists.llvm.org 
to respond for nearly a week now.

And how should I proceed after that? Would one of the reviewers commit the 
patch for me?


https://reviews.llvm.org/D27123



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


[PATCH] D28015: [OpenMP] Sema and parsing for 'target teams distribute' pragma

ABataev added a comment.

LG


https://reviews.llvm.org/D28015



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


[PATCH] D27920: [find-all-symbols] Index partial template specializations.

ioeric added a comment.

Why do we allow partially specialization but fully specialization now? Could 
you elaborate in the cl description?


https://reviews.llvm.org/D27920



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


[PATCH] D26167: [Clang-tidy] check for malloc, realloc and free calls

malcolm.parsons added a comment.

In https://reviews.llvm.org/D26167#622792, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D26167#621942, @JonasToth wrote:
>
> > what do you think about configuration of the allocating functions? e.g. for 
> > aligned memory you must use OS-specific allocation functions.
> >  should the check catch custom allocation functions as well?
>
>
> Sounds like a good idea to me.


I think this check should also warn about `strdup()`, `strndup()` and 
`wcsdup()`.


Repository:
  rL LLVM

https://reviews.llvm.org/D26167



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


[PATCH] D27971: Make FormatStyle.GetStyleOfFile test work on MSVC

klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

Apart from the error handling LG. Thanks!




Comment at: lib/Format/Format.cpp:1920-1922
+  std::error_code EC = FS->makeAbsolute(Path);
+  assert(!EC);
+  (void)EC;

I think if makeAbsolute doesn't work, we will probably want to err out here:
if (EC) {
  llvm::errs() << ... << EC.message << ...
  return Style;
}


https://reviews.llvm.org/D27971



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