[clang-tools-extra] r344033 - [clangd] Mark colon as a safe character when percent-encoding.

2018-10-09 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Tue Oct  9 03:29:54 2018
New Revision: 344033

URL: http://llvm.org/viewvc/llvm-project?rev=344033&view=rev
Log:
[clangd] Mark colon as a safe character when percent-encoding.

Summary: Also change output of percent-encoding to use upper-case letters.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/URI.cpp
clang-tools-extra/trunk/unittests/clangd/URITests.cpp

Modified: clang-tools-extra/trunk/clangd/URI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/URI.cpp?rev=344033&r1=344032&r2=344033&view=diff
==
--- clang-tools-extra/trunk/clangd/URI.cpp (original)
+++ clang-tools-extra/trunk/clangd/URI.cpp Tue Oct  9 03:29:54 2018
@@ -91,6 +91,8 @@ bool shouldEscape(unsigned char C) {
   case '.':
   case '~':
   case '/': // '/' is only reserved when parsing.
+  // ':' is only reserved for relative URI paths, which clangd doesn't produce.
+  case ':':
 return false;
   }
   return true;
@@ -105,7 +107,7 @@ std::string percentEncode(llvm::StringRe
   llvm::raw_string_ostream OS(Result);
   for (unsigned char C : Content)
 if (shouldEscape(C))
-  OS << '%' << llvm::format_hex_no_prefix(C, 2);
+  OS << '%' << llvm::format_hex_no_prefix(C, 2, /*Upper = */true);
 else
   OS << C;
 

Modified: clang-tools-extra/trunk/unittests/clangd/URITests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/URITests.cpp?rev=344033&r1=344032&r2=344033&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/URITests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/URITests.cpp Tue Oct  9 03:29:54 
2018
@@ -44,8 +44,9 @@ URI parseOrDie(llvm::StringRef Uri) {
 
 TEST(PercentEncodingTest, Encode) {
   EXPECT_EQ(URI("x", /*Authority=*/"", "a/b/c").toString(), "x:a/b/c");
-  EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3bc~");
+  EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3Bc~");
   EXPECT_EQ(URI("x", /*Authority=*/"", "a123b").toString(), "x:a123b");
+  EXPECT_EQ(URI("x", /*Authority=*/"", "a:b;c").toString(), "x:a:b%3Bc");
 }
 
 TEST(PercentEncodingTest, Decode) {
@@ -56,6 +57,7 @@ TEST(PercentEncodingTest, Decode) {
   EXPECT_EQ(parseOrDie("s%2b://%3a/%3").body(), "/%3");
 
   EXPECT_EQ(parseOrDie("x:a%21b%3ac~").body(), "a!b:c~");
+  EXPECT_EQ(parseOrDie("x:a:b%3bc").body(), "a:b;c");
 }
 
 std::string resolveOrDie(const URI &U, llvm::StringRef HintPath = "") {
@@ -67,10 +69,10 @@ std::string resolveOrDie(const URI &U, l
 
 TEST(URITest, Create) {
 #ifdef _WIN32
-  EXPECT_THAT(createOrDie("c:\\x\\y\\z"), "file:///c%3a/x/y/z");
+  EXPECT_THAT(createOrDie("c:\\x\\y\\z"), "file:///c:/x/y/z");
 #else
   EXPECT_THAT(createOrDie("/x/y/z"), "file:///x/y/z");
-  EXPECT_THAT(createOrDie("/(x)/y/\\ z"), "file:///%28x%29/y/%5c%20z");
+  EXPECT_THAT(createOrDie("/(x)/y/\\ z"), "file:///%28x%29/y/%5C%20z");
 #endif
 }
 
@@ -138,6 +140,7 @@ TEST(URITest, ParseFailed) {
 TEST(URITest, Resolve) {
 #ifdef _WIN32
   EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), "c:\\x\\y\\z");
+  EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:\\x\\y\\z");
 #else
   EXPECT_EQ(resolveOrDie(parseOrDie("file:/a/b/c")), "/a/b/c");
   EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "/a/b/c");


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


[PATCH] D52296: [Clang] - Add -gsingle-file-split-dwarf option.

2018-10-09 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

@grimar, this is an interesting observation which I've had on my mind for quite 
some time as well; a couple of things which I have not double-checked yet - 
just in case - do both gold and lld completely ignore dwo-related sections ? 
(did you check that ?), and another small question - just wondering if the 
debuggers (GDB and LLDB) are okay with it / or smth needs to be adjusted or 
fixed on their side. I guess everything should be fine, but asking just in case.


https://reviews.llvm.org/D52296



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


[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019

Files:
  clangd/index/dex/dexp/Dexp.cpp


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -12,8 +12,9 @@
 //
 
//===--===//
 
-#include "../../Serialization.h"
-#include "../Dex.h"
+#include "Dex.h"
+#include "Serialization.h"
+#include "SourceCode.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -88,7 +89,6 @@
 };
 
 // FIXME(kbobyrev): Ideas for more commands:
-// * find symbol references: print set of reference locations
 // * load/swap/reload index: this would make it possible to get rid of llvm::cl
 //   usages in the tool driver and actually use llvm::cl library in the REPL.
 // * show posting list density histogram (our dump data somewhere so that user
@@ -162,13 +162,46 @@
   }
 };
 
+class Refs : public Command {
+  cl::opt QualifiedName{
+  "qualified_name", cl::Positional, cl::Required,
+  cl::desc("Qualified name of the symbol being queried."),
+  };
+  cl::opt Filter{
+  "filter", cl::init(".*"),
+  cl::desc("Print all results from files matching this filter."),
+  };
+
+  void run() override {
+FuzzyFindRequest Request;
+Request.Limit = 1;
+Request.Scopes.emplace_back();
+std::tie(Request.Scopes.back(), Request.Query) =
+clang::clangd::splitQualifiedName(QualifiedName);
+clang::clangd::SymbolID ID;
+Index->fuzzyFind(Request, [&](const Symbol &Sym) {
+  llvm::outs() << "Find references for symbol " << Sym.Scope + Sym.Name
+   << "\n";
+  ID = Sym.ID;
+});
+clang::clangd::RefsRequest RefRequest;
+RefRequest.IDs.insert(ID);
+llvm::Regex RegexFilter(Filter);
+Index->refs(RefRequest, [&RegexFilter](const clang::clangd::Ref &R) {
+  if (RegexFilter.match(R.Location.FileURI))
+llvm::outs() << R << "\n";
+});
+  }
+};
+
 struct {
   const char *Name;
   const char *Description;
   std::function()> Implementation;
 } CommandInfo[] = {
 {"find", "Search for symbols with fuzzyFind", 
llvm::make_unique},
 {"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"refs", "Find references by qualified name", llvm::make_unique},
 };
 
 } // namespace


Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -12,8 +12,9 @@
 //
 //===--===//
 
-#include "../../Serialization.h"
-#include "../Dex.h"
+#include "Dex.h"
+#include "Serialization.h"
+#include "SourceCode.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -88,7 +89,6 @@
 };
 
 // FIXME(kbobyrev): Ideas for more commands:
-// * find symbol references: print set of reference locations
 // * load/swap/reload index: this would make it possible to get rid of llvm::cl
 //   usages in the tool driver and actually use llvm::cl library in the REPL.
 // * show posting list density histogram (our dump data somewhere so that user
@@ -162,13 +162,46 @@
   }
 };
 
+class Refs : public Command {
+  cl::opt QualifiedName{
+  "qualified_name", cl::Positional, cl::Required,
+  cl::desc("Qualified name of the symbol being queried."),
+  };
+  cl::opt Filter{
+  "filter", cl::init(".*"),
+  cl::desc("Print all results from files matching this filter."),
+  };
+
+  void run() override {
+FuzzyFindRequest Request;
+Request.Limit = 1;
+Request.Scopes.emplace_back();
+std::tie(Request.Scopes.back(), Request.Query) =
+clang::clangd::splitQualifiedName(QualifiedName);
+clang::clangd::SymbolID ID;
+Index->fuzzyFind(Request, [&](const Symbol &Sym) {
+  llvm::outs() << "Find references for symbol " << Sym.Scope + Sym.Name
+   << "\n";
+  ID = Sym.ID;
+});
+clang::clangd::RefsRequest RefRequest;
+RefRequest.IDs.insert(ID);
+llvm::Regex RegexFilter(Filter);
+Index->refs(RefRequest, [&RegexFilter](const clang::clangd::Ref &R) {
+  if (RegexFilter.match(R.Location.FileURI))
+llvm::outs() << R << "\n";
+});
+  }
+};
+
 struct {
   const char *Name;
   const char *Description;
   std::function()> Implementation;
 } CommandInfo[] = {
 {"find", "Search for symbols with fuzzyFind", llvm::make_unique},
 {"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"refs", "Find references by qualified name", llvm::make_unique},
 };
 
 } // namespace
___
cfe-commits mailing list
cfe-co

[PATCH] D51300: [analyzer][UninitializedObjectChecker] No longer using nonloc::LazyCompoundVal

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 168775.
Szelethus added a comment.
This revision is now accepted and ready to land.

Finally managed to run creduce. I added the test that caused a crash on our 
server, but as I said, I couldn't replicate it elsewhere.


https://reviews.llvm.org/D51300

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object.cpp

Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1130,3 +1130,29 @@
   // TODO: we'd expect the warning: {{2 uninitializeds field}}
   CXX11MemberInitTest2(); // no-warning
 }
+
+//===--===//
+// Test for cases when the constructed region after the constructor call isn't
+// CXXRecordDecl, when it should be.
+//===--===//
+
+struct UndefinedStruct;
+
+struct CXXRecordDeclRegionBugTest {
+  CXXRecordDeclRegionBugTest(const UndefinedStruct &t);
+
+  struct UserDefinedDefaultCtorStruct {
+UserDefinedDefaultCtorStruct() {}
+  };
+};
+
+using size_t = long unsigned;
+void *operator new[](size_t, const UndefinedStruct &) throw() {
+  return nullptr;
+}
+
+CXXRecordDeclRegionBugTest::CXXRecordDeclRegionBugTest(
+const UndefinedStruct &U) {
+  size_t N;
+  new (U) UserDefinedDefaultCtorStruct[N];
+}
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -124,12 +124,11 @@
 
 // Utility function declarations.
 
-/// Returns the object that was constructed by CtorDecl, or None if that isn't
-/// possible.
-// TODO: Refactor this function so that it returns the constructed object's
-// region.
-static Optional
-getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context);
+/// Returns the region that was constructed by CtorDecl, or nullptr if that
+/// isn't possible.
+static const TypedValueRegion *
+getConstructedRegion(const CXXConstructorDecl *CtorDecl,
+ CheckerContext &Context);
 
 /// Checks whether the object constructed by \p Ctor will be analyzed later
 /// (e.g. if the object is a field of another object, in which case we'd check
@@ -159,12 +158,11 @@
   if (willObjectBeAnalyzedLater(CtorDecl, Context))
 return;
 
-  Optional Object = getObjectVal(CtorDecl, Context);
-  if (!Object)
+  const TypedValueRegion *R = getConstructedRegion(CtorDecl, Context);
+  if (!R)
 return;
 
-  FindUninitializedFields F(Context.getState(), Object->getRegion(),
-CheckPointeeInitialization);
+  FindUninitializedFields F(Context.getState(), R, CheckPointeeInitialization);
 
   const UninitFieldMap &UninitFields = F.getUninitFields();
 
@@ -446,25 +444,27 @@
 //   Utility functions.
 //===--===//
 
-static Optional
-getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context) {
+static const TypedValueRegion *
+getConstructedRegion(const CXXConstructorDecl *CtorDecl,
+ CheckerContext &Context) {
 
-  Loc ThisLoc = Context.getSValBuilder().getCXXThis(CtorDecl->getParent(),
-Context.getStackFrame());
-  // Getting the value for 'this'.
-  SVal This = Context.getState()->getSVal(ThisLoc);
+  Loc ThisLoc =
+  Context.getSValBuilder().getCXXThis(CtorDecl, Context.getStackFrame());
 
-  // Getting the value for '*this'.
-  SVal Object = Context.getState()->getSVal(This.castAs());
+  SVal ObjectV = Context.getState()->getSVal(ThisLoc);
 
-  return Object.getAs();
+  auto *R = ObjectV.getAsRegion()->getAs();
+  if (R && !R->getValueType()->getAsCXXRecordDecl())
+return nullptr;
+
+  return R;
 }
 
 static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
   CheckerContext &Context) {
 
-  Optional CurrentObject = getObjectVal(Ctor, Context);
-  if (!CurrentObject)
+  const TypedValueRegion *CurrRegion = getConstructedRegion(Ctor, Context);
+  if (!CurrRegion)
 return false;
 
   const LocationContext *LC = Context.getLocationContext();
@@ -475,14 +475,14 @@
 if (!OtherCtor)
   continue;
 
-Optional OtherObject =
-getObjectVal(OtherCtor, Context);
-if (!OtherObject)
+const TypedValueRegion *OtherRegion =
+getConstructedRegion(OtherCtor, Context);
+if (!OtherRegion)
   continue;
 
-// If the CurrentObject is a subregion of OtherObject, it will be analyzed
-// during the analysis of OtherObject.
-

[PATCH] D51300: [analyzer][UninitializedObjectChecker] No longer using nonloc::LazyCompoundVal

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Since a good amount of time passed since this patch was made, I'll re-analyze 
the LLVM project with this patch rebased on trunk just to be sure that nothing 
breaks.


https://reviews.llvm.org/D51300



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


[PATCH] D51429: [AArch64] Return Address Signing B Key Support

2018-10-09 Thread Oliver Stannard via Phabricator via cfe-commits
olista01 added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:1133
+  if (Arg *A = Args.getLastArg(OPT_msign_return_address_EQ)) {
+const auto SignScopeKey = StringRef(A->getValue()).split('+');
+StringRef SignScope = SignScopeKey.first;

The driver code is emitting a separate -msign-return-address-key= option, but 
this is expecting the key to still be part of -msign-return-address=, so we can 
never end up selecting the B key. Out of the two approaches, I prefer having 
multiple simpler options in CC1, so that we don't have to repeat all of the 
parsing that happens in the driver.

Also, you're emitting the -mbranch-target-enforce option in the driver, but not 
handling it here. We should either reject it in the driver for now, or add the 
CC1 part of that in this patch.


https://reviews.llvm.org/D51429



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


[PATCH] D52984: [analyzer] Checker reviewer's checklist

2018-10-09 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

Greate idea! If we can enrich this list, it will not only help the reviewer, 
but also help beginners, like me, avoid some pitfalls when developing a new 
checker.

I agree with NoQ to classify the lists. In addition to the two categories 
proposed by NoQ, there is another classof issues, see below, we don't have to 
take them into account.

- Develop a checker(proposed by NoQ). Like:
  1. Does it have to be in the path-sensitive manner?
  2. Should we move it into `clang-tidy`?
  3. Prefer `ASTMatcher` to `StmtVisitor`?
  4. Use `CallDescription` to get a stricter filter.
  5. Could we use `checkPreCall()` instead of `checkPreStmt(const CallExpr *, 
)`?
  6. Could we put this function model into `StdLibraryFunctionsChecker.cpp`?
- Make a good checke(proposed by NoQ).
- More general coding standards. Like:
  1. Use `isa<>` instead of `dyn_cast<>` if we don't need the casted result.
  2. Use `dyn_cast_or_null` instead of `dyn_cast` to enable the null-check.
  3. Use `llvm::make_unique` instead of `std::make_unique` because 
`std::make_unique` is not included in C++11.
  4. Avoid unnecessary null-check
  5. ... and so on.

The third list can be long, and maybe we don't need to take it into account, 
because developers will follow this standards whether they are developing 
checkers or contribute to other projects, like LLDB. We need to dig deeper into 
the analyzer-specific coding standards.


https://reviews.llvm.org/D52984



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


[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

2018-10-09 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 168787.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D52727

Files:
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/ForRangeCopyCheck.h
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.h
  clang-tidy/utils/Matchers.h
  docs/clang-tidy/checks/performance-for-range-copy.rst
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  docs/clang-tidy/checks/performance-unnecessary-value-param.rst
  test/clang-tidy/performance-for-range-copy-allowed-types.cpp
  test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp
  test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp

Index: test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp
@@ -0,0 +1,66 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -config="{CheckOptions: [{key: performance-unnecessary-value-param.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" --
+
+struct SmartPointer {
+  ~SmartPointer();
+};
+
+struct smart_pointer {
+  ~smart_pointer();
+};
+
+struct SmartPtr {
+  ~SmartPtr();
+};
+
+struct smart_ptr {
+  ~smart_ptr();
+};
+
+struct SmartReference {
+  ~SmartReference();
+};
+
+struct smart_reference {
+  ~smart_reference();
+};
+
+struct SmartRef {
+  ~SmartRef();
+};
+
+struct smart_ref {
+  ~smart_ref();
+};
+
+struct OtherType {
+  ~OtherType();
+};
+
+void negativeSmartPointer(SmartPointer P) {
+}
+
+void negative_smart_pointer(smart_pointer p) {
+}
+
+void negativeSmartPtr(SmartPtr P) {
+}
+
+void negative_smart_ptr(smart_ptr p) {
+}
+
+void negativeSmartReference(SmartReference R) {
+}
+
+void negative_smart_reference(smart_reference r) {
+}
+
+void negativeSmartRef(SmartRef R) {
+}
+
+void negative_smart_ref(smart_ref r) {
+}
+
+void positiveOtherType(OtherType O) {
+  // CHECK-MESSAGES: [[@LINE-1]]:34: warning: the parameter 'O' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveOtherType(const OtherType& O) {
+}
Index: test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp
@@ -0,0 +1,85 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t -- -config="{CheckOptions: [{key: performance-unnecessary-copy-initialization.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" --
+
+struct SmartPointer {
+  ~SmartPointer();
+};
+
+struct smart_pointer {
+  ~smart_pointer();
+};
+
+struct SmartPtr {
+  ~SmartPtr();
+};
+
+struct smart_ptr {
+  ~smart_ptr();
+};
+
+struct SmartReference {
+  ~SmartReference();
+};
+
+struct smart_reference {
+  ~smart_reference();
+};
+
+struct SmartRef {
+  ~SmartRef();
+};
+
+struct smart_ref {
+  ~smart_ref();
+};
+
+struct OtherType {
+  ~OtherType();
+};
+
+const SmartPointer &getSmartPointer();
+const smart_pointer &get_smart_pointer();
+const SmartPtr &getSmartPtr();
+const smart_ptr &get_smart_ptr();
+const SmartReference &getSmartReference();
+const smart_reference &get_smart_reference();
+const SmartRef &getSmartRef();
+const smart_ref &get_smart_ref();
+const OtherType &getOtherType();
+
+void negativeSmartPointer() {
+  const auto P = getSmartPointer();
+}
+
+void negative_smart_pointer() {
+  const auto p = get_smart_pointer();
+}
+
+void negativeSmartPtr() {
+  const auto P = getSmartPtr();
+}
+
+void negative_smart_ptr() {
+  const auto p = get_smart_ptr();
+}
+
+void negativeSmartReference() {
+  const auto R = getSmartReference();
+}
+
+void negative_smart_reference() {
+  const auto r = get_smart_reference();
+}
+
+void negativeSmartRef() {
+  const auto R = getSmartRef();
+}
+
+void negative_smart_ref() {
+  const auto r = get_smart_ref();
+}
+
+void positiveOtherType() {
+  const auto O = getOtherType();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'O' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& O = getOtherType();
+}
Index: test/clang-tidy/performance-for-range-copy-allowed-types.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-for-range-copy-allowed-types.cpp
@@ -0,0 +1,112 @@
+// RUN: %check_clang_tidy %s performance-for-range-copy %t -- -config="{CheckOptions: [{key: performance-fo

[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

2018-10-09 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:65-66
has(varDecl(hasLocalStorage(),
-   hasType(matchers::isExpensiveToCopy()),
+   hasType(hasCanonicalType(
+   allOf(matchers::isExpensiveToCopy(),
+ unless(hasDeclaration(namedDecl(

JonasToth wrote:
> lebedev.ri wrote:
> > Does it matter whether we are calling `matchers::isExpensiveToCopy()` on 
> > the type, or on the canonical type?
> the canonical type does resolve all typedefs, which is what is desirable in 
> this case.
The real question is whether we want to match the canonical type to the list of 
allowed type names. I am not sure.


https://reviews.llvm.org/D52727



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


[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/index/dex/dexp/Dexp.cpp:172
+  "filter", cl::init(".*"),
+  cl::desc("Print all results from files matching this filter."),
+  };

filter -> regular expression



Comment at: clangd/index/dex/dexp/Dexp.cpp:191
+Index->refs(RefRequest, [&RegexFilter](const clang::clangd::Ref &R) {
+  if (RegexFilter.match(R.Location.FileURI))
+llvm::outs() << R << "\n";

you're requiring a full match, and matching the URI, which is going to confuse 
users who try to use a filter of `/usr/include/.*` or so.

Consider just using the URI path?



Comment at: clangd/index/dex/dexp/Dexp.cpp:204
 {"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"refs", "Find references by qualified name", llvm::make_unique},
 };

I'm not sure "by qualified name" is a good idea, at least as the only option:
 - if there are overloads, you can't choose the right one (possible fix: make 
this a named flag like `refs --name foo::bar`)
 - you can't search for refs for std::unique without getting std::unique_ptr 
(possible fix: postfilter by name)
 - it seems inconsistent with Lookup (possible fix: update both)




Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019



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


[clang-tools-extra] r344044 - [clangd] fix miscompiling lower_bound call

2018-10-09 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Tue Oct  9 06:24:50 2018
New Revision: 344044

URL: http://llvm.org/viewvc/llvm-project?rev=344044&view=rev
Log:
[clangd] fix miscompiling lower_bound call

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

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=344044&r1=344043&r2=344044&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Tue Oct  9 06:24:50 2018
@@ -84,8 +84,9 @@ float quality(const Symbol &S) {
 }
 
 SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &ID) const {
-  auto It = llvm::lower_bound(
-  Symbols, ID, [](const Symbol &S, const SymbolID &I) { return S.ID < I; 
});
+  auto It = std::lower_bound(
+  Symbols.begin(), Symbols.end(), ID,
+  [](const Symbol &S, const SymbolID &I) { return S.ID < I; });
   if (It != Symbols.end() && It->ID == ID)
 return It;
   return Symbols.end();


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


[clang-tools-extra] r344046 - [clang-tidy] NFC fix warnings from missing braces

2018-10-09 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Tue Oct  9 06:29:31 2018
New Revision: 344046

URL: http://llvm.org/viewvc/llvm-project?rev=344046&view=rev
Log:
[clang-tidy] NFC fix warnings from missing braces

The std::array create multiple StringRef but did not wrap
them in braces. Some compilers warned for that. Adding the
braces is not possible and result in a compilation error.
This commit changes the array to vector which works without warning.

Modified:

clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp?rev=344046&r1=344045&r2=344046&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp 
Tue Oct  9 06:29:31 2018
@@ -17,11 +17,12 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
-static const std::array DeprecatedTypes = {
-"::std::ios_base::io_state",  "::std::ios_base::open_mode",
-"::std::ios_base::seek_dir",  "::std::ios_base::streamoff",
-"::std::ios_base::streampos",
-};
+static const llvm::SmallVector DeprecatedTypes = {
+{"::std::ios_base::io_state"},
+{"::std::ios_base::open_mode"},
+{"::std::ios_base::seek_dir"},
+{"::std::ios_base::streamoff"},
+{"::std::ios_base::streampos"}};
 
 static const llvm::StringMap ReplacementTypes = {
 {"io_state", "iostate"},


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


[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

2018-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:65-66
has(varDecl(hasLocalStorage(),
-   hasType(matchers::isExpensiveToCopy()),
+   hasType(hasCanonicalType(
+   allOf(matchers::isExpensiveToCopy(),
+ unless(hasDeclaration(namedDecl(

baloghadamsoftware wrote:
> JonasToth wrote:
> > lebedev.ri wrote:
> > > Does it matter whether we are calling `matchers::isExpensiveToCopy()` on 
> > > the type, or on the canonical type?
> > the canonical type does resolve all typedefs, which is what is desirable in 
> > this case.
> The real question is whether we want to match the canonical type to the list 
> of allowed type names. I am not sure.
Well, very long template names are impractical, even for something "simple" as 
std::string the name gets very long without the typedef. I would say the 
typedefs should be respected


https://reviews.llvm.org/D52727



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


[PATCH] D52859: [clang-query] Add option to print matcher expression

2018-10-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52859



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


[PATCH] D52905: CSA: fix accessing GDM data from shared libraries

2018-10-09 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech added a comment.

In https://reviews.llvm.org/D52905#1257040, @NoQ wrote:

> Hmmm, interesting. A checker doesn't usually need to access these specific 
> static locals, at least not directly. These are usually accessed through 
> functions in .cpp files that are supposed to be compiled with a pointer to 
> the correct instance of the static local, and it doesn't seem to be necessary 
> to expose them to plugins, simply because i don't immediately see why would a 
> plugin want to use them. In this sense, i believe that the entire definition 
> of these traits should be moved to .cpp files and be made private, accessed 
> only via public methods of respective classes. But i guess it's more 
> difficult and it's a separate chunk of work, so i totally approve this patch.


My current goal is to examine all of the information the analyzer has available 
at callsites and extract the portions that the project I'm working on might be 
interested in. I wouldn't disagree with your assessment in general, but it's 
definitely not something I have time allocated towards doing.

> Also, i guess that's what they meant when they were saying that 
> REGISTER_TRAIT_WITH_PROGRAMSTATE [and similar] macros shouldn't be used in 
> headers (https://reviews.llvm.org/D51388?id=162968#inline-455495).

Yeah, I think so.

> Did you use any sort of tool to find those? I.e., are there more such bugs, 
> and can we prevent this from regressing and breaking your workflow later?

I wrote a very quick and dirty clang plugin that has this AST matcher:

  returnStmt(hasReturnValue(ignoringImplicit(unaryOperator(
 hasOperatorName("&"),
 hasUnaryOperand(declRefExpr(
 to(varDecl(isStaticLocal(,
 isExpansionInFileMatching("/include/.*\\.h"))

where `isStaticLocal` is defined as:

  AST_MATCHER(VarDecl, isStaticLocal) {
return Node.isStaticLocal();
  }

I've since adapted it to a clang-tidy checker under the llvm 'module', which 
I'll aim at getting approval to open source as well. Do you know if there's a 
way to run clang-tidy over all of clang+llvm automatically? My plugin approach 
had the advantage of just needing to fiddle with CMAKE_CXX_FLAGS to run against 
the whole codebase...

> You didn't add reviewers. Does it mean that you are still planning to work on 
> this patch further, or do you want this patch to be committed in its current 
> shape? Static Analyzer patches are usually prefixed with [analyzer] (a few 
> people auto-subscribe to those) and please feel free to add me and 
> @george.karpenkov as reviewers, and the code owner is @dcoughlin.

This is just my inexperience with the Phabricator patch submission process 
showing through; I've traditionally emailed patches to the various -dev lists.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not all that keen on the idea of deprecating `set output` like this -- that 
command has been around since forever, and scripts outside of our control are 
likely to rely on it. However, it seems like you should be able to make `set 
output` accept a comma-delimited list of options. e.g., `set output dump, diag` 
This would give you the same level of granularity while still being backwards 
compatible. Do you think that would work for your needs?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D53023: Prototype OpenCL BIFs using Tablegen

2018-10-09 Thread Joey Gouly via Phabricator via cfe-commits
joey created this revision.
joey added reviewers: asavonic, Anastasia.
Herald added subscribers: cfe-commits, yaxunl, mgorny.

This is the prototype for the approach that was mentioned by Anastasia in 
http://lists.llvm.org/pipermail/cfe-dev/2018-September/059529.html

The tablegen file describes the BIFs and all their overloads, in hopefully a 
concise manner.

There are 3 things generated from the OpenCLBuiltins.td file.

1. OpenCLArgTypes[], this is a table containing all the different types of 
overloads. This is a separate table so it can be shared by the BIFs.
2. OpenCLBuiltins[], this is a table that contains all the overloads for the 
BIFs.
3. isOpenCLBuiltin, this is a function that uses a trie-like switch/case to 
determine if a StringRef is the name of a BIF.

Just a quick snippet of the above:

  OpenCLType OpenCLArgTypes[] = {
  // 0
  { OCLT_float, 0, 0, clang::LangAS::Default, },
  // 1
  { OCLT_float, 2, 0, clang::LangAS::Default, },

  OpenCLBuiltinDecl OpenCLBuiltins[] = {
  // acos
{ { OCLT_float, 0, 0, clang::LangAS::Default, }, 1, 0, "", 100,  },
{ { OCLT_float, 2, 0, clang::LangAS::Default, }, 1, 1, "", 100,  },

  std::pair isOpenCLBuiltin(llvm::StringRef name) {
switch (name.size()) {
default: break;
case 3:  // 1 string to match.
  if (memcmp(name.data()+0, "foo", 3) != 0)
break;
  return std::make_pair(707, 2);   // "foo"

While it's a prototype, I have tried to keep it as clean as possible.

TODO:

1. Bit-pack the tables to reduce the size.
2. Include the return type in the ArgTypes table to reduce the size.
3. Measure the performance / size impact
4. Auto-generate parts of OCL2Qual, to reduce repeated typing
5. OCL2Qual does not support pointers-to-pointers currently, but I believe no 
BIFs use that.
6. InsertBuiltinDeclarations builds up an AST function declaration manually, 
perhaps there is a helper function for this.
7. There is a FIXME in SemaDecl.cpp that needs to be implemented.


Repository:
  rC Clang

https://reviews.llvm.org/D53023

Files:
  Sema/SemaDecl.cpp
  Sema/SemaExpr.cpp
  SemaOpenCL/builtin-new.cl
  TableGen/CMakeLists.txt
  TableGen/ClangOpenCLBuiltinEmitter.cpp
  TableGen/TableGen.cpp
  TableGen/TableGenBackends.h
  clang/Basic/CMakeLists.txt
  clang/Basic/OpenCLBuiltins.td

Index: TableGen/TableGenBackends.h
===
--- TableGen/TableGenBackends.h
+++ TableGen/TableGenBackends.h
@@ -81,6 +81,7 @@
 void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper &Records,
 raw_ostream &OS);
 
+void EmitClangOpenCLBuiltins(RecordKeeper &Records, raw_ostream &OS);
 } // end namespace clang
 
 #endif
Index: TableGen/TableGen.cpp
===
--- TableGen/TableGen.cpp
+++ TableGen/TableGen.cpp
@@ -61,7 +61,8 @@
   GenDiagDocs,
   GenOptDocs,
   GenDataCollectors,
-  GenTestPragmaAttributeSupportedAttributes
+  GenTestPragmaAttributeSupportedAttributes,
+  GenClangOpenCLBuiltins,
 };
 
 namespace {
@@ -161,7 +162,9 @@
 clEnumValN(GenTestPragmaAttributeSupportedAttributes,
"gen-clang-test-pragma-attribute-supported-attributes",
"Generate a list of attributes supported by #pragma clang "
-   "attribute for testing purposes")));
+   "attribute for testing purposes"),
+clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
+   "Generate OpenCL builtin handlers")));
 
 cl::opt
 ClangComponent("clang-component",
@@ -288,6 +291,9 @@
   case GenTestPragmaAttributeSupportedAttributes:
 EmitTestPragmaAttributeSupportedAttributes(Records, OS);
 break;
+  case GenClangOpenCLBuiltins:
+EmitClangOpenCLBuiltins(Records, OS);
+break;
   }
 
   return false;
Index: TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- /dev/null
+++ TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -0,0 +1,195 @@
+//===- ClangOpenCLBuiltinEmitter.cpp - Generate Clang OpenCL Builtin handling
+//=-*- C++ -*--=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This tablegen backend emits Clang OpenCL Builtin checking code.
+//
+//===--===//
+
+#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
+#include "llvm

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-10-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5599
 
+bool Sema::isInlineFunctionDLLExportable(const CXXMethodDecl *MD) {
+  assert(MD->isInlined());

Okay, breaking out this logic is a little better, but I still don't like that 
we now have split the "inherit dllexport attribute" in two places: one for 
non-inline functions and one for inline (even if they both call this function). 
It feels like it will be hard to maintain.

Here is another idea:

When we inherit the dllexport attribute to class members, if 
getLangOpts().DllExportInlines is false, we don't put dllexport on inline 
functions, but instead we put a new attribute "dllexportstaticlocals".

That attribute only has the effect that it makes static locals exported. We 
would check for it when computing the linkage of the static local, similar to 
how it works in hidden functions.

This has two benefits: it doesn't complicate the "inherit dllexport" code very 
much, and it avoids the need for a separate AST walk of the function.

What do you think?


https://reviews.llvm.org/D51340



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


r344049 - [OPENMP][NVPTX] Support memory coalescing for globalized variables.

2018-10-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  9 07:49:00 2018
New Revision: 344049

URL: http://llvm.org/viewvc/llvm-project?rev=344049&view=rev
Log:
[OPENMP][NVPTX] Support memory coalescing for globalized variables.

Added support for memory coalescing for better performance for
globalized variables. From now on all the globalized variables are
represented as arrays of 32 elements and each thread accesses these
elements using `tid & 31` as index.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/declare_target_codegen_globalization.cpp
cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=344049&r1=344048&r2=344049&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Oct  9 07:49:00 2018
@@ -169,7 +169,7 @@ enum MachineConfiguration : unsigned {
   LaneIDMask = WarpSize - 1,
 
   /// Global memory alignment for performance.
-  GlobalMemoryAlignment = 256,
+  GlobalMemoryAlignment = 128,
 };
 
 enum NamedBarrier : unsigned {
@@ -186,20 +186,30 @@ static bool stable_sort_comparator(const
 
 static RecordDecl *buildRecordForGlobalizedVars(
 ASTContext &C, ArrayRef EscapedDecls,
+ArrayRef EscapedDeclsForTeams,
 llvm::SmallDenseMap
 &MappedDeclsFields) {
-  if (EscapedDecls.empty())
+  if (EscapedDecls.empty() && EscapedDeclsForTeams.empty())
 return nullptr;
   SmallVector GlobalizedVars;
   for (const ValueDecl *D : EscapedDecls)
+GlobalizedVars.emplace_back(
+CharUnits::fromQuantity(std::max(
+C.getDeclAlign(D).getQuantity(),
+static_cast(GlobalMemoryAlignment))),
+D);
+  for (const ValueDecl *D : EscapedDeclsForTeams)
 GlobalizedVars.emplace_back(C.getDeclAlign(D), D);
   std::stable_sort(GlobalizedVars.begin(), GlobalizedVars.end(),
stable_sort_comparator);
   // Build struct _globalized_locals_ty {
-  // /*  globalized vars  */
+  // /*  globalized vars  */[32] align (max(decl_align, 128))
+  // /*  globalized vars  */ for EscapedDeclsForTeams
   //   };
   RecordDecl *GlobalizedRD = C.buildImplicitRecord("_globalized_locals_ty");
   GlobalizedRD->startDefinition();
+  llvm::SmallPtrSet SingleEscaped(
+  EscapedDeclsForTeams.begin(), EscapedDeclsForTeams.end());
   for (const auto &Pair : GlobalizedVars) {
 const ValueDecl *VD = Pair.second;
 QualType Type = VD->getType();
@@ -208,19 +218,39 @@ static RecordDecl *buildRecordForGlobali
 else
   Type = Type.getNonReferenceType();
 SourceLocation Loc = VD->getLocation();
-auto *Field =
-FieldDecl::Create(C, GlobalizedRD, Loc, Loc, VD->getIdentifier(), Type,
-  C.getTrivialTypeSourceInfo(Type, SourceLocation()),
-  /*BW=*/nullptr, /*Mutable=*/false,
-  /*InitStyle=*/ICIS_NoInit);
-Field->setAccess(AS_public);
-GlobalizedRD->addDecl(Field);
-if (VD->hasAttrs()) {
-  for (specific_attr_iterator I(VD->getAttrs().begin()),
-   E(VD->getAttrs().end());
-   I != E; ++I)
-Field->addAttr(*I);
+FieldDecl *Field;
+if (SingleEscaped.count(VD)) {
+  Field = FieldDecl::Create(
+  C, GlobalizedRD, Loc, Loc, VD->getIdentifier(), Type,
+  C.getTrivialTypeSourceInfo(Type, SourceLocation()),
+  /*BW=*/nullptr, /*Mutable=*/false,
+  /*InitStyle=*/ICIS_NoInit);
+  Field->setAccess(AS_public);
+  if (VD->hasAttrs()) {
+for (specific_attr_iterator I(VD->getAttrs().begin()),
+ E(VD->getAttrs().end());
+ I != E; ++I)
+  Field->addAttr(*I);
+  }
+} else {
+  llvm::APInt ArraySize(32, WarpSize);
+  Type = C.getConstantArrayType(Type, ArraySize, ArrayType::Normal, 0);
+  Field = FieldDecl::Create(
+  C, GlobalizedRD, Loc, Loc, VD->getIdentifier(), Type,
+  C.getTrivialTypeSourceInfo(Type, SourceLocation()),
+  /*BW=*/nullptr, /*Mutable=*/false,
+  /*InitStyle=*/ICIS_NoInit);
+  Field->setAccess(AS_public);
+  llvm::APInt Align(32, std::max(C.getDeclAlign(VD).getQuantity(),
+ static_cast(
+ GlobalMemoryAlignment)));
+  Field->addAttr(AlignedAttr::CreateImplicit(
+  C, AlignedAttr::GNU_aligned, /*IsAlignmentExpr=*/true,
+  Integer

[PATCH] D52703: Allow ifunc resolvers to accept arguments

2018-10-09 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

Given that there's no technical reason for the compiler to prohibit this (it 
was just clang trying to diagnose a probable user-error, which turns out to not 
be as probable as ), this seems like the right solution to me.


https://reviews.llvm.org/D52703



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

- The scripts will continue to work at least until `set output` is removed, 
which is not going to happen soon.
- A comma-delimited list of options means that if I have `foo, bar, bat`  
enabled and want to add `bang`, I need to `set output foo, bar, bat, bang`. Or 
alternatively if I want to remove `bat`, I need to write out all the others. I 
don't think that's suitable.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 168801.
hokein marked 3 inline comments as done.
hokein added a comment.
Herald added a subscriber: mgorny.

Address review comments:

- provide query by qualified name (with -name)
- add -name support for Lookup.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019

Files:
  clangd/index/dex/dexp/CMakeLists.txt
  clangd/index/dex/dexp/Dexp.cpp

Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -12,13 +12,15 @@
 //
 //===--===//
 
-#include "../../Serialization.h"
-#include "../Dex.h"
+#include "Dex.h"
+#include "Serialization.h"
+#include "SourceCode.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Signals.h"
 
 using clang::clangd::FuzzyFindRequest;
@@ -52,6 +54,27 @@
   llvm::outs() << llvm::formatv("{0} took {1:ms+n}.\n", Name, Duration);
 }
 
+llvm::Expected
+getSymbolIDFromIndex(llvm::StringRef QualifiedName, const SymbolIndex *Index) {
+  FuzzyFindRequest Request;
+  Request.Scopes.emplace_back();
+  std::tie(Request.Scopes.back(), Request.Query) =
+  clang::clangd::splitQualifiedName(QualifiedName);
+  bool Found = false;
+  clang::clangd::SymbolID SymID;
+  // We choose the first one if there are overloaded symbols.
+  Index->fuzzyFind(Request, [&](const Symbol &Sym) {
+std::string SymQualifiedName = (Sym.Scope + Sym.Name).str();
+if (!Found && QualifiedName == SymQualifiedName) {
+  SymID = Sym.ID;
+  Found = true;
+}
+  });
+  return Found ? SymID
+   : llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Symbol not found in index.");
+}
+
 // REPL commands inherit from Command and contain their options as members.
 // Creating a Command populates parser options, parseAndRun() resets them.
 class Command {
@@ -88,7 +111,6 @@
 };
 
 // FIXME(kbobyrev): Ideas for more commands:
-// * find symbol references: print set of reference locations
 // * load/swap/reload index: this would make it possible to get rid of llvm::cl
 //   usages in the tool driver and actually use llvm::cl library in the REPL.
 // * show posting list density histogram (our dump data somewhere so that user
@@ -139,12 +161,21 @@
   cl::opt ID{
   "id",
   cl::Positional,
-  cl::Required,
   cl::desc("Symbol ID to look up (hex)"),
   };
+  cl::opt Name{
+  "name", cl::desc("Qualified name to look up."),
+  };
 
   void run() override {
-auto SID = clang::clangd::SymbolID::fromStr(ID);
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
 if (!SID) {
   llvm::outs() << llvm::toString(SID.takeError()) << "\n";
   return;
@@ -162,13 +193,59 @@
   }
 };
 
+class Refs : public Command {
+  cl::opt ID{
+  "id", cl::Positional,
+  cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  cl::opt Name{
+  "name", cl::desc("Qualified name of the symbol being queried."),
+  };
+  cl::opt Filter{
+  "filter",
+  cl::init(".*"),
+  cl::desc(
+  "Print all results from files matching this regular expression."),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
+if (!SID) {
+  llvm::outs() << llvm::toString(SID.takeError()) << "\n";
+  return;
+}
+clang::clangd::RefsRequest RefRequest;
+RefRequest.IDs.insert(*SID);
+llvm::Regex RegexFilter(Filter);
+Index->refs(RefRequest, [&RegexFilter](const clang::clangd::Ref &R) {
+  auto U = clang::clangd::URI::parse(R.Location.FileURI);
+  if (!U) {
+llvm::outs() << U.takeError();
+return;
+  }
+  if (RegexFilter.match(U->body()))
+llvm::outs() << R << "\n";
+});
+  }
+};
+
 struct {
   const char *Name;
   const char *Description;
   std::function()> Implementation;
 } CommandInfo[] = {
 {"find", "Search for symbols with fuzzyFind", llvm::make_unique},
-{"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"lookup", "Dump symbol details by ID or qualified name",
+ llvm::make_unique

[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/dex/dexp/Dexp.cpp:204
 {"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"refs", "Find references by qualified name", llvm::make_unique},
 };

sammccall wrote:
> I'm not sure "by qualified name" is a good idea, at least as the only option:
>  - if there are overloads, you can't choose the right one (possible fix: make 
> this a named flag like `refs --name foo::bar`)
>  - you can't search for refs for std::unique without getting std::unique_ptr 
> (possible fix: postfilter by name)
>  - it seems inconsistent with Lookup (possible fix: update both)
> 
> 
Sounds fair enough. I think query the symbol by "qualified_name" would be more 
convenient and practical when we use the tool. ID is not quite straight-forward.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019



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


[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 168802.
hokein added a comment.

Minor fix.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019

Files:
  clangd/index/dex/dexp/CMakeLists.txt
  clangd/index/dex/dexp/Dexp.cpp

Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -12,13 +12,15 @@
 //
 //===--===//
 
-#include "../../Serialization.h"
-#include "../Dex.h"
+#include "Dex.h"
+#include "Serialization.h"
+#include "SourceCode.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Signals.h"
 
 using clang::clangd::FuzzyFindRequest;
@@ -52,6 +54,29 @@
   llvm::outs() << llvm::formatv("{0} took {1:ms+n}.\n", Name, Duration);
 }
 
+llvm::Expected
+getSymbolIDFromIndex(llvm::StringRef QualifiedName, const SymbolIndex *Index) {
+  FuzzyFindRequest Request;
+  Request.Scopes.emplace_back();
+  std::tie(Request.Scopes.back(), Request.Query) =
+  clang::clangd::splitQualifiedName(QualifiedName);
+  bool Found = false;
+  clang::clangd::SymbolID SymID;
+  // We choose the first one if there are overloaded symbols.
+  Index->fuzzyFind(Request, [&](const Symbol &Sym) {
+std::string SymQualifiedName = (Sym.Scope + Sym.Name).str();
+if (!Found && QualifiedName == SymQualifiedName) {
+  SymID = Sym.ID;
+  Found = true;
+}
+  });
+  if (Found)
+return SymID;
+
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Symbol not found in index.");
+}
+
 // REPL commands inherit from Command and contain their options as members.
 // Creating a Command populates parser options, parseAndRun() resets them.
 class Command {
@@ -88,7 +113,6 @@
 };
 
 // FIXME(kbobyrev): Ideas for more commands:
-// * find symbol references: print set of reference locations
 // * load/swap/reload index: this would make it possible to get rid of llvm::cl
 //   usages in the tool driver and actually use llvm::cl library in the REPL.
 // * show posting list density histogram (our dump data somewhere so that user
@@ -139,12 +163,21 @@
   cl::opt ID{
   "id",
   cl::Positional,
-  cl::Required,
   cl::desc("Symbol ID to look up (hex)"),
   };
+  cl::opt Name{
+  "name", cl::desc("Qualified name to look up."),
+  };
 
   void run() override {
-auto SID = clang::clangd::SymbolID::fromStr(ID);
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
 if (!SID) {
   llvm::outs() << llvm::toString(SID.takeError()) << "\n";
   return;
@@ -162,13 +195,59 @@
   }
 };
 
+class Refs : public Command {
+  cl::opt ID{
+  "id", cl::Positional,
+  cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  cl::opt Name{
+  "name", cl::desc("Qualified name of the symbol being queried."),
+  };
+  cl::opt Filter{
+  "filter",
+  cl::init(".*"),
+  cl::desc(
+  "Print all results from files matching this regular expression."),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
+if (!SID) {
+  llvm::outs() << llvm::toString(SID.takeError()) << "\n";
+  return;
+}
+clang::clangd::RefsRequest RefRequest;
+RefRequest.IDs.insert(*SID);
+llvm::Regex RegexFilter(Filter);
+Index->refs(RefRequest, [&RegexFilter](const clang::clangd::Ref &R) {
+  auto U = clang::clangd::URI::parse(R.Location.FileURI);
+  if (!U) {
+llvm::outs() << U.takeError();
+return;
+  }
+  if (RegexFilter.match(U->body()))
+llvm::outs() << R << "\n";
+});
+  }
+};
+
 struct {
   const char *Name;
   const char *Description;
   std::function()> Implementation;
 } CommandInfo[] = {
 {"find", "Search for symbols with fuzzyFind", llvm::make_unique},
-{"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"lookup", "Dump symbol details by ID or qualified name",
+ llvm::make_unique},
+{"refs", "Find references by ID or qualified name",
+ llvm::make_unique},
 };
 
 } // namespace
Index: clangd/index/dex/dexp/CMakeLists.txt
===

[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/index/dex/dexp/Dexp.cpp:65
+  clang::clangd::SymbolID SymID;
+  // We choose the first one if there are overloaded symbols.
+  Index->fuzzyFind(Request, [&](const Symbol &Sym) {

I don't think this is reasonable behavior. I'd suggest either of:
 - processing all results (this function would return a vector)
 - treat this as an error, the error message should include the ID of each 
symbol so we can rerun the command in an unambiguous way



Comment at: clangd/index/dex/dexp/Dexp.cpp:173
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;

nit: just "id" with no dash


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019



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


[clang-tools-extra] r344054 - [clangd] Fix an accident change in r342999.

2018-10-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct  9 08:16:14 2018
New Revision: 344054

URL: http://llvm.org/viewvc/llvm-project?rev=344054&view=rev
Log:
[clangd] Fix an accident change in r342999.

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

Modified: clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp?rev=344054&r1=344053&r2=344054&view=diff
==
--- clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp Tue Oct  9 
08:16:14 2018
@@ -286,7 +286,7 @@ std::string toYAML(const Symbol &S) {
 llvm::raw_string_ostream OS(Buf);
 llvm::yaml::Output Yout(OS);
 Symbol Sym = S; // copy: Yout<< requires mutability.
-OS << Sym;
+Yout << Sym;
   }
   return Buf;
 }


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


[clang-tools-extra] r344055 - [clang-move] Fix broken json output.

2018-10-09 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Oct  9 08:17:16 2018
New Revision: 344055

URL: http://llvm.org/viewvc/llvm-project?rev=344055&view=rev
Log:
[clang-move] Fix broken json output.

Modified:
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=344055&r1=344054&r2=344055&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Tue Oct  9 
08:17:16 2018
@@ -128,7 +128,7 @@ int main(int argc, const char **argv) {
  InitialDirectory.str(), Style, DumpDecls};
   move::DeclarationReporter Reporter;
   move::ClangMoveActionFactory Factory(&Context, &Reporter);
-  
+
   int CodeStatus = Tool.run(&Factory);
   if (CodeStatus)
 return CodeStatus;
@@ -138,8 +138,9 @@ int main(int argc, const char **argv) {
 const auto &Declarations = Reporter.getDeclarationList();
 for (auto I = Declarations.begin(), E = Declarations.end(); I != E; ++I) {
   llvm::outs() << "  {\n";
-  llvm::outs() << "\"DeclarationName\": \"" << I->QualifiedName << 
"\",\n";
-  llvm::outs() << "\"DeclarationType\": \"" << I->Kind << "\"\n";
+  llvm::outs() << "\"DeclarationName\": \"" << I->QualifiedName
+   << "\",\n";
+  llvm::outs() << "\"DeclarationType\": \"" << I->Kind << "\",\n";
   llvm::outs() << "\"Templated\": " << (I->Templated ? "true" : 
"false")
<< "\n";
   llvm::outs() << "  }";


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


[PATCH] D51809: [CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

2018-10-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:7231
+if (ICI)
+  CSM = getSpecialMember(MD);
+

jlebar wrote:
> LGTM, but perhaps we should use a new variable instead of modifying `CSM` in 
> case someone adds code beneath this branch?
will do when committing.


https://reviews.llvm.org/D51809



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, MTC.
Herald added subscribers: cfe-commits, jfb, mikhail.ramalho, a.sidorin, 
rnkovacs, szepet, whisperity.

Added some extra tasks to the open projects. These are the ideas of @NoQ and 
@george.karpenkov, I just converted them to HTML.


Repository:
  rC Clang

https://reviews.llvm.org/D53024

Files:
  www/analyzer/open_projects.html

Index: www/analyzer/open_projects.html
===
--- www/analyzer/open_projects.html
+++ www/analyzer/open_projects.html
@@ -25,6 +25,86 @@
   
   Core Analyzer Infrastructure
   
+Implement a dataflow flamework.
+
+ (Difficulty: Hard) 
+
+
+Handle aggregate construction.
+Aggregates are object that can be brace-initialized without calling a
+constructor (i.e., no https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html";>
+CXXConstructExpr in the AST), but potentially calling
+constructors for their fields and (since C++17) base classes - and these
+constructors of sub-objects need to know what object (field in the
+aggregate) they are constructing. Moreover, if the aggregate contains
+references, lifetime extension needs to be modeled. Aggregates can be
+nested, so https://clang.llvm.org/doxygen/classclang_1_1ConstructionContext.html";>
+ConstructionContext can potentially cover an unlimited amount of
+statements. One can start untangling this problem by trying to replace the
+hacky https://clang.llvm.org/doxygen/classclang_1_1ParentMap.html";>
+ParentMap lookup in https://clang.llvm.org/doxygen/ExprEngineCXX_8cpp_source.html#l00430";>
+CXXConstructExpr::CK_NonVirtualBase branch of
+ExprEngine::VisitCXXConstructExpr() with some actual
+support for the feature.
+ (Difficulty: Medium) 
+
+
+Fix CFG for GNU "binary conditional" operator ?:.
+CFG for GNU "binary conditional" operator ?: is broken in
+C++. Its condition-and-LHS need to only be evaluated once.
+(Difficulty: Easy)
+
+
+Handle unions.
+Currently in the analyzer, the value of a union is always regarded as
+unknown. There has been some discussion about this on the http://lists.llvm.org/pipermail/cfe-dev/2017-March/052864.html";>
+mailing list already, but it is still an untouched area.
+ (Difficulty: Medium) 
+
+
+Enhance the modeling of the standard library.
+There is a huge amount of checker work for teaching the Static Analyzer
+about the C++ standard library. It is very easy to explain to the static
+analyzer that calling .length() on an empty std::string
+ will yield 0, and vice versa, but supporting all of them is a huge
+amount of work. One good thing to start with here would be to notice that
+inlining methods of C++ "containers" is currently outright forbidden in
+order to suppress a lot of false alarms due to weird assume()s
+made within inlined methods. There’s a hypothesis that these suppressions
+should have been instead implemented as bug report visitors, which would
+still suppress false positives, but will not prevent us from inlining the 
+ethods, and therefore will not cause other false positives. Verifying this
+hypothesis would be a wonderful accomplishment. Previous understanding of
+the "inlined defensive checks" problem is a pre-requisite for this project.
+(Difficulty: Medium)
+
+
+Reimplement the representation for various symbolic values.
+https://clang.llvm.org/doxygen/classclang_1_1ento_1_1nonloc_1_1LocAsInteger.html";>
+LocAsInteger is annoying, but alternatives are vague. Casts into
+the opposite direction - integers to pointers - are completely unsupported.
+Pointer-to-pointer casts are a mess; modeling them with https://clang.llvm.org/doxygen/classclang_1_1ento_1_1ElementRegion.html";>
+ElementRegion  is a disaster and we are suffering a lot from this
+hack, but coming up with a significantly better solution is very hard, as
+there are a lot of corner-cases to cover, and it’s hard to maintain balance
+between richness of our representation of symbolic values and our ability to
+understand when the two different values in fact represent the same thing.
+(Difficulty: Hard)
+
+
+ Provide better alternatives to inlining.
+Sometimes instead of inlining, a much simpler behavior would be more
+efficient. For instance, if the function is pure, then a single bit of
+information “this function is pure” would already be much better than
+conservative evaluation, and sometimes good enough to make inlining not
+worth the effort. Gathering such snippets of information - “partial
+summaries" - automatically, from the more simple to the more complex
+summaries, and re-using them later, probably across translation units, might
+improve our analysis quite a lot, while 

[PATCH] D52906: [analyzer] allow plugins built as shared libraries to receive events

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Please reupload with full context (`-U`).




Comment at: lib/StaticAnalyzer/Core/Checker.cpp:20
 
+int ImplicitNullDerefEvent::Tag;
+

nit: Static fields initialize to 0 without out of line definition.


Repository:
  rC Clang

https://reviews.llvm.org/D52906



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


[PATCH] D52906: [analyzer] allow plugins built as shared libraries to receive events

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Core/Checker.cpp:20
 
+int ImplicitNullDerefEvent::Tag;
+

Szelethus wrote:
> nit: Static fields initialize to 0 without out of line definition.
Never mind, you still have to define it. It's been a while since I used 
`static` :).


Repository:
  rC Clang

https://reviews.llvm.org/D52906



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Please reupload with full context (`-U9`).


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


r344057 - [CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

2018-10-09 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Oct  9 08:53:14 2018
New Revision: 344057

URL: http://llvm.org/viewvc/llvm-project?rev=344057&view=rev
Log:
[CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

ShouldDeleteSpecialMember is called upon inherited constructors.
It calls inferCUDATargetForImplicitSpecialMember.

Normally the special member enum passed to ShouldDeleteSpecialMember
matches the constructor. However this is not true when inherited
constructor is passed, where DefaultConstructor is passed to treat
the inherited constructor as DefaultConstructor. However
inferCUDATargetForImplicitSpecialMember expects the special
member enum argument to match the constructor, which results
in assertion when this expection is not satisfied.

This patch checks whether the constructor is inherited. If true it will
get the real special member enum for the constructor and pass it
to inferCUDATargetForImplicitSpecialMember.

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

Added:
cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
cfe/trunk/test/SemaCUDA/inherited-ctor.cu
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=344057&r1=344056&r2=344057&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Oct  9 08:53:14 2018
@@ -7222,8 +7222,17 @@ bool Sema::ShouldDeleteSpecialMember(CXX
   if (getLangOpts().CUDA) {
 // We should delete the special member in CUDA mode if target inference
 // failed.
-return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, SMI.ConstArg,
-   Diagnose);
+// For inherited constructors (non-null ICI), CSM may be passed so that MD
+// is treated as certain special member, which may not reflect what special
+// member MD really is. However inferCUDATargetForImplicitSpecialMember
+// expects CSM to match MD, therefore recalculate CSM.
+assert(ICI || CSM == getSpecialMember(MD));
+auto RealCSM = CSM;
+if (ICI)
+  RealCSM = getSpecialMember(MD);
+
+return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
+   SMI.ConstArg, Diagnose);
   }
 
   return false;

Added: cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu?rev=344057&view=auto
==
--- cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu (added)
+++ cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu Tue Oct  9 
08:53:14 2018
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 
-Wno-defaulted-function-deleted
+
+#include "Inputs/cuda.h"
+
+//--
+// Test 1: infer inherited default ctor to be host.
+
+struct A1_with_host_ctor {
+  A1_with_host_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) 
not viable}}
+
+// The inherited default constructor is inferred to be host, so we'll encounter
+// an error when calling it from a __device__ function, but not from a __host__
+// function.
+struct B1_with_implicit_default_ctor : A1_with_host_ctor {
+  using A1_with_host_ctor::A1_with_host_ctor;
+};
+
+// expected-note@-4 {{call to __host__ function from __device__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) 
not viable}}
+// expected-note@-6 2{{constructor from base class 'A1_with_host_ctor' 
inherited here}}
+
+void hostfoo() {
+  B1_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo() {
+  B1_with_implicit_default_ctor b; // expected-error {{no matching 
constructor}}
+}
+
+//--
+// Test 2: infer inherited default ctor to be device.
+
+struct A2_with_device_ctor {
+  __device__ A2_with_device_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) 
not viable}}
+
+struct B2_with_implicit_default_ctor : A2_with_device_ctor {
+  using A2_with_device_ctor::A2_with_device_ctor;
+};
+
+// expected-note@-4 {{call to __device__ function from __host__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) 
not viable}}
+// expected-note@-6 2{{constructor from b

[PATCH] D51809: [CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

2018-10-09 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344057: [CUDA][HIP] Fix ShouldDeleteSpecialMember for 
inherited constructors (authored by yaxunl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51809?vs=168500&id=168811#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51809

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
  cfe/trunk/test/SemaCUDA/inherited-ctor.cu

Index: cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
===
--- cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
+++ cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -Wno-defaulted-function-deleted
+
+#include "Inputs/cuda.h"
+
+//--
+// Test 1: infer inherited default ctor to be host.
+
+struct A1_with_host_ctor {
+  A1_with_host_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
+
+// The inherited default constructor is inferred to be host, so we'll encounter
+// an error when calling it from a __device__ function, but not from a __host__
+// function.
+struct B1_with_implicit_default_ctor : A1_with_host_ctor {
+  using A1_with_host_ctor::A1_with_host_ctor;
+};
+
+// expected-note@-4 {{call to __host__ function from __device__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+// expected-note@-6 2{{constructor from base class 'A1_with_host_ctor' inherited here}}
+
+void hostfoo() {
+  B1_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo() {
+  B1_with_implicit_default_ctor b; // expected-error {{no matching constructor}}
+}
+
+//--
+// Test 2: infer inherited default ctor to be device.
+
+struct A2_with_device_ctor {
+  __device__ A2_with_device_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
+
+struct B2_with_implicit_default_ctor : A2_with_device_ctor {
+  using A2_with_device_ctor::A2_with_device_ctor;
+};
+
+// expected-note@-4 {{call to __device__ function from __host__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+// expected-note@-6 2{{constructor from base class 'A2_with_device_ctor' inherited here}}
+
+void hostfoo2() {
+  B2_with_implicit_default_ctor b;  // expected-error {{no matching constructor}}
+}
+
+__device__ void devicefoo2() {
+  B2_with_implicit_default_ctor b;
+}
+
+//--
+// Test 3: infer inherited copy ctor
+
+struct A3_with_device_ctors {
+  __host__ A3_with_device_ctors() {}
+  __device__ A3_with_device_ctors(const A3_with_device_ctors&) {}
+};
+
+struct B3_with_implicit_ctors : A3_with_device_ctors {
+  using A3_with_device_ctors::A3_with_device_ctors;
+};
+// expected-note@-3 2{{call to __device__ function from __host__ function}}
+// expected-note@-4 {{default constructor}}
+
+
+void hostfoo3() {
+  B3_with_implicit_ctors b;  // this is OK because the inferred inherited default ctor
+ // here is __host__
+  B3_with_implicit_ctors b2 = b; // expected-error {{no matching constructor}}
+
+}
+
+//--
+// Test 4: infer inherited default ctor from a field, not a base
+
+struct A4_with_host_ctor {
+  A4_with_host_ctor() {}
+};
+
+struct B4_with_inherited_host_ctor : A4_with_host_ctor{
+  using A4_with_host_ctor::A4_with_host_ctor;
+};
+
+struct C4_with_implicit_default_ctor {
+  B4_with_inherited_host_ctor field;
+};
+
+// expected-note@-4 {{call to __host__ function from __device__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+
+void hostfoo4() {
+  C4_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo4() {
+  C4_with_implicit_default_ctor b; // expected-error {{no matching constructor}}
+}
+
+//--
+// Test 5: inherited copy ctor with non-const param
+
+struct A5_copy_ctor_constness {
+  __host__ A5_copy_ctor_constness() {}
+  __host__ A5_copy_ctor_constness(A5_copy_ctor_constnes

[PATCH] D52989: [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:246
+   ASTContext *Ctx) {
+  std::function SkipParensParents =
+  [&](const Expr *E) {

hokein wrote:
> nit: I'd use `auto` to avoid this long type name, the type is clear to me, it 
> is a lambda function.
I first tried it with an `auto`, but the recursive call below didn't compile. 
Works fine without recursion though.



Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:250
+  if (const Expr *Parent = Node.get())
+return SkipParensParents(Parent);
+}

hokein wrote:
> nit: we can easily avoid the recursive call by using while here, I think.
Turned out that iterative approach here doesn't complicate code as much as I 
thought it would.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52989



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


[PATCH] D52989: [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 168812.
alexfh marked 2 inline comments as done.
alexfh added a comment.

- Remove recursion, use `auto`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52989

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  test/clang-tidy/modernize-make-shared.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -110,6 +110,19 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
   // CHECK-FIXES: auto P3 = std::make_unique();
 
+  std::unique_ptr P4 = std::unique_ptr((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P4 = std::make_unique();
+  P4.reset((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: P4 = std::make_unique();
+  std::unique_ptr P5 = std::unique_ptrnew int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P5 = std::make_unique();
+  P5.reset(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: P5 = std::make_unique();
+
   {
 // No std.
 using namespace std;
Index: test/clang-tidy/modernize-make-shared.cpp
===
--- test/clang-tidy/modernize-make-shared.cpp
+++ test/clang-tidy/modernize-make-shared.cpp
@@ -70,6 +70,18 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_shared instead
   // CHECK-FIXES: auto P3 = std::make_shared();
 
+  std::shared_ptr P4 = std::shared_ptr((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: std::shared_ptr P4 = std::make_shared();
+
+  P4.resetnew int();
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: P4 = std::make_shared();
+
+  P4 = std::shared_ptr(((new int)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: P4 = std::make_shared();
+
   {
 // No std.
 using namespace std;
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -44,25 +44,23 @@
   virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
 
   static const char PointerType[];
-  static const char ConstructorCall[];
-  static const char ResetCall[];
-  static const char NewExpression[];
 
 private:
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
   const bool IgnoreMacros;
 
-  void checkConstruct(SourceManager &SM, const CXXConstructExpr *Construct,
-  const QualType *Type, const CXXNewExpr *New);
-  void checkReset(SourceManager &SM, const CXXMemberCallExpr *Member,
-  const CXXNewExpr *New);
+  void checkConstruct(SourceManager &SM, ASTContext *Ctx,
+  const CXXConstructExpr *Construct, const QualType *Type,
+  const CXXNewExpr *New);
+  void checkReset(SourceManager &SM, ASTContext *Ctx,
+  const CXXMemberCallExpr *Member, const CXXNewExpr *New);
 
   /// Returns true when the fixes for replacing CXXNewExpr are generated.
   bool replaceNew(DiagnosticBuilder &Diag, const CXXNewExpr *New,
-  SourceManager &SM);
+  SourceManager &SM, ASTContext *Ctx);
   void insertHeader(DiagnosticBuilder &Diag, FileID FD);
 };
 
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -21,6 +21,9 @@
 namespace {
 
 constexpr char StdMemoryHeader[] = "memory";
+constexpr char ConstructorCall[] = "constructorCall";
+constexpr char ResetCall[] = "resetCall";
+constexpr char NewExpression[] = "newExpression";
 
 std::string GetNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
@@ -30,17 +33,14 @@
   NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
   SM, Lang);
   if (NewExpr->isArray()) {
-return WrittenName.str() + "[]";
+return (WrittenName + "[]").str();
   }
   return WrittenName.str();
 }
 
 } // namespace
 
 const char MakeSmartPtrCheck::PointerType[] = "

[clang-tools-extra] r344058 - [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Oct  9 08:58:18 2018
New Revision: 344058

URL: http://llvm.org/viewvc/llvm-project?rev=344058&view=rev
Log:
[clang-tidy] Fix handling of parens around new expressions in make_ 
checks.

Summary:
Extra parentheses around a new expression result in incorrect code
after applying fixes.

Reviewers: hokein

Reviewed By: hokein

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=344058&r1=344057&r2=344058&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Tue Oct  
9 08:58:18 2018
@@ -21,6 +21,9 @@ namespace modernize {
 namespace {
 
 constexpr char StdMemoryHeader[] = "memory";
+constexpr char ConstructorCall[] = "constructorCall";
+constexpr char ResetCall[] = "resetCall";
+constexpr char NewExpression[] = "newExpression";
 
 std::string GetNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
@@ -30,7 +33,7 @@ std::string GetNewExprName(const CXXNewE
   
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
   SM, Lang);
   if (NewExpr->isArray()) {
-return WrittenName.str() + "[]";
+return (WrittenName + "[]").str();
   }
   return WrittenName.str();
 }
@@ -38,9 +41,6 @@ std::string GetNewExprName(const CXXNewE
 } // namespace
 
 const char MakeSmartPtrCheck::PointerType[] = "pointerType";
-const char MakeSmartPtrCheck::ConstructorCall[] = "constructorCall";
-const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
-const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
 MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
  ClangTidyContext* Context,
@@ -68,8 +68,8 @@ bool MakeSmartPtrCheck::isLanguageVersio
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance &Compiler) {
   if (isLanguageVersionSupported(getLangOpts())) {
-Inserter.reset(new utils::IncludeInserter(
-Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
+Inserter = llvm::make_unique(
+Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
 Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
   }
 }
@@ -122,12 +122,12 @@ void MakeSmartPtrCheck::check(const Matc
 return;
 
   if (Construct)
-checkConstruct(SM, Construct, Type, New);
+checkConstruct(SM, Result.Context, Construct, Type, New);
   else if (Reset)
-checkReset(SM, Reset, New);
+checkReset(SM, Result.Context, Reset, New);
 }
 
-void MakeSmartPtrCheck::checkConstruct(SourceManager &SM,
+void MakeSmartPtrCheck::checkConstruct(SourceManager &SM, ASTContext *Ctx,
const CXXConstructExpr *Construct,
const QualType *Type,
const CXXNewExpr *New) {
@@ -154,7 +154,7 @@ void MakeSmartPtrCheck::checkConstruct(S
 return;
   }
 
-  if (!replaceNew(Diag, New, SM)) {
+  if (!replaceNew(Diag, New, SM, Ctx)) {
 return;
   }
 
@@ -193,7 +193,7 @@ void MakeSmartPtrCheck::checkConstruct(S
   insertHeader(Diag, SM.getFileID(ConstructCallStart));
 }
 
-void MakeSmartPtrCheck::checkReset(SourceManager &SM,
+void MakeSmartPtrCheck::checkReset(SourceManager &SM, ASTContext *Ctx,
const CXXMemberCallExpr *Reset,
const CXXNewExpr *New) {
   const auto *Expr = cast(Reset->getCallee());
@@ -224,7 +224,7 @@ void MakeSmartPtrCheck::checkReset(Sourc
 return;
   }
 
-  if (!replaceNew(Diag, New, SM)) {
+  if (!replaceNew(Diag, New, SM, Ctx)) {
 return;
   }
 
@@ -241,10 +241,24 @@ void MakeSmartPtrCheck::checkReset(Sourc
 }
 
 bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
-   const CXXNewExpr *New,
-   SourceManager& SM) {
-  SourceLocation NewStart = New->getSourceRange().getBegin();
-  SourceLocation NewEnd = New->getSourceRange().getEnd();
+   const CXXNewExpr *New, SourceManager &SM,
+   ASTContext *Ctx) {
+  auto SkipParensParents = [&](const Expr *E) {
+for (const Expr *OldE = nullptr; E != OldE;) {
+  OldE = E;
+  for (const auto &Node : Ctx->getParents(*E)) {
+if (const Expr *Parent = Node.

[PATCH] D52989: [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344058: [clang-tidy] Fix handling of parens around new 
expressions in make_… (authored by alexfh, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52989

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -44,25 +44,23 @@
   virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
 
   static const char PointerType[];
-  static const char ConstructorCall[];
-  static const char ResetCall[];
-  static const char NewExpression[];
 
 private:
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
   const bool IgnoreMacros;
 
-  void checkConstruct(SourceManager &SM, const CXXConstructExpr *Construct,
-  const QualType *Type, const CXXNewExpr *New);
-  void checkReset(SourceManager &SM, const CXXMemberCallExpr *Member,
-  const CXXNewExpr *New);
+  void checkConstruct(SourceManager &SM, ASTContext *Ctx,
+  const CXXConstructExpr *Construct, const QualType *Type,
+  const CXXNewExpr *New);
+  void checkReset(SourceManager &SM, ASTContext *Ctx,
+  const CXXMemberCallExpr *Member, const CXXNewExpr *New);
 
   /// Returns true when the fixes for replacing CXXNewExpr are generated.
   bool replaceNew(DiagnosticBuilder &Diag, const CXXNewExpr *New,
-  SourceManager &SM);
+  SourceManager &SM, ASTContext *Ctx);
   void insertHeader(DiagnosticBuilder &Diag, FileID FD);
 };
 
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -21,6 +21,9 @@
 namespace {
 
 constexpr char StdMemoryHeader[] = "memory";
+constexpr char ConstructorCall[] = "constructorCall";
+constexpr char ResetCall[] = "resetCall";
+constexpr char NewExpression[] = "newExpression";
 
 std::string GetNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
@@ -30,17 +33,14 @@
   NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
   SM, Lang);
   if (NewExpr->isArray()) {
-return WrittenName.str() + "[]";
+return (WrittenName + "[]").str();
   }
   return WrittenName.str();
 }
 
 } // namespace
 
 const char MakeSmartPtrCheck::PointerType[] = "pointerType";
-const char MakeSmartPtrCheck::ConstructorCall[] = "constructorCall";
-const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
-const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
 MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
  ClangTidyContext* Context,
@@ -68,8 +68,8 @@
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance &Compiler) {
   if (isLanguageVersionSupported(getLangOpts())) {
-Inserter.reset(new utils::IncludeInserter(
-Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
+Inserter = llvm::make_unique(
+Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
 Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
   }
 }
@@ -122,12 +122,12 @@
 return;
 
   if (Construct)
-checkConstruct(SM, Construct, Type, New);
+checkConstruct(SM, Result.Context, Construct, Type, New);
   else if (Reset)
-checkReset(SM, Reset, New);
+checkReset(SM, Result.Context, Reset, New);
 }
 
-void MakeSmartPtrCheck::checkConstruct(SourceManager &SM,
+void MakeSmartPtrCheck::checkConstruct(SourceManager &SM, ASTContext *Ctx,
const CXXConstructExpr *Construct,
const QualType *Type,
const CXXNewExpr *New) {
@@ -154,7 +154,7 @@
 return;
   }
 
-  if (!replaceNew(Diag, New, SM)) {
+  if (!replaceNew(Diag, New, SM, Ctx)) {
 return;
   }
 
@@ -193,7 +193,7 @@
   insertHeader(Diag, SM.getFileID(ConstructCallStart));
 }
 
-void MakeSmartPtrCheck::checkReset(SourceManager &SM,
+void MakeSmartPtrCheck::checkReset(SourceManager &SM, ASTContext *Ctx,
const CXXMemberCallExpr 

[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-09 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

Yes. I understand. At the moment, exception handling flags are generated based 
on `BENCHMARK_ENABLE_EXCEPTIONS`  in `utils/benchmark/CMakeLists.txt` .  
However, `_HAS_EXCEPTIONS` is not defined based on this (code below). The 
warnings are a result of this mismatch.

  if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
  add_cxx_compiler_flag(-EHs-)
  add_cxx_compiler_flag(-EHa-)
endif()

I think it makes most sense to add definition for `_HAS_EXCEPTIONS=0 `here as 
opposed to modifying `llvm/CMakeLists.txt`.  Please correct me if I'm wrong. 
I'm not too familiar with CMake. @kbobyrev Please let me know what you think as 
well since you had suggested `llvm/CMakeLists.txt`.


https://reviews.llvm.org/D52998



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech updated this revision to Diff 168815.
jranieri-grammatech added a comment.

Added more context.


Repository:
  rC Clang

https://reviews.llvm.org/D52905

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/TaintManager.cpp

Index: lib/StaticAnalyzer/Core/TaintManager.cpp
===
--- lib/StaticAnalyzer/Core/TaintManager.cpp
+++ lib/StaticAnalyzer/Core/TaintManager.cpp
@@ -0,0 +1,23 @@
+//== TaintManager.cpp -- -*- C++ -*--=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
+
+using namespace clang;
+using namespace ento;
+
+void *ProgramStateTrait::GDMIndex() {
+  static int index = 0;
+  return &index;
+}
+
+void *ProgramStateTrait::GDMIndex() {
+  static int index;
+  return &index;
+}
Index: lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -200,6 +200,11 @@
   }
 }
 
+void *ProgramStateTrait::GDMIndex() {
+  static int Index;
+  return &Index;
+}
+
 } // end of namespace ento
 
 } // end of namespace clang
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3106,3 +3106,8 @@
   llvm::errs() << "Warning: dumping graph requires assertions" << "\n";
   return "";
 }
+
+void *ProgramStateTrait::GDMIndex() {
+  static int index = 0;
+  return &index;
+}
Index: lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
===
--- lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
+++ lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
@@ -77,5 +77,10 @@
   }
 }
 
+void *ProgramStateTrait::GDMIndex() {
+  static int index = 0;
+  return &index;
+}
+
 } // namespace ento
 } // namespace clang
Index: lib/StaticAnalyzer/Core/CMakeLists.txt
===
--- lib/StaticAnalyzer/Core/CMakeLists.txt
+++ lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -52,6 +52,7 @@
   Store.cpp
   SubEngine.cpp
   SymbolManager.cpp
+  TaintManager.cpp
   WorkList.cpp
   Z3ConstraintManager.cpp
 
Index: include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
@@ -34,10 +34,7 @@
 
 template<> struct ProgramStateTrait
 :  public ProgramStatePartialTrait {
-  static void *GDMIndex() {
-static int index = 0;
-return &index;
-  }
+  static void *GDMIndex();
 };
 
 /// The GDM component mapping derived symbols' parent symbols to their
@@ -49,10 +46,7 @@
 
 template<> struct ProgramStateTrait
 :  public ProgramStatePartialTrait {
-  static void *GDMIndex() {
-static int index;
-return &index;
-  }
+  static void *GDMIndex();
 };
 
 class TaintManager {
Index: include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -131,7 +131,7 @@
 template <>
 struct ProgramStateTrait
   : public ProgramStatePartialTrait {
-  static void *GDMIndex() { static int Index; return &Index; }
+  static void *GDMIndex();
 };
 
 
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -832,7 +832,7 @@
 template <>
 struct ProgramStateTrait :
   public ProgramStatePartialTrait {
-  static void *GDMIndex() { static int index = 0; return &index; }
+  static void *GDMIndex();
 };
 
 } // namespace ento
Index: include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
===
--- include/clang/Stati

[PATCH] D51372: FENV_ACCESS support for libm-style constrained intrinsics

2018-10-09 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 168814.
kpn added a comment.

Update based on feedback to https://reviews.llvm.org/D52839: add missing AST 
(de)serialization support.

Ping.


https://reviews.llvm.org/D51372

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/Analysis/BodyFarm.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGen/fenv-access-pragma.c
  test/CodeGen/fenv-access-pragma.cpp
  test/CodeGen/fenv-math-builtins.c

Index: test/CodeGen/fenv-math-builtins.c
===
--- test/CodeGen/fenv-math-builtins.c
+++ test/CodeGen/fenv-math-builtins.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s 
+
+// Test codegen of math builtins when using FENV_ACCESS ON.
+// Derived from math-builtins.c and keeps calls in the same order.
+#pragma STDC FENV_ACCESS ON
+
+void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
+  __builtin_pow(f,f);__builtin_powf(f,f);   __builtin_powl(f,f);
+
+// CHECK: declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata) [[MATH_INTRINSIC:#[0-9]+]]
+// CHECK: declare float @llvm.experimental.constrained.pow.f32(float, float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.pow.f80(x86_fp80, x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_powi(f,f);__builtin_powif(f,f);   __builtin_powil(f,f);
+
+// CHECK: declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.powi.f32(float, i32, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.powi.f80(x86_fp80, i32, metadata, metadata) [[MATH_INTRINSIC]]
+
+  /* math */
+  __builtin_cos(f);__builtin_cosf(f);   __builtin_cosl(f); 
+// CHECK: declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.cos.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.cos.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_exp(f);__builtin_expf(f);   __builtin_expl(f);
+// CHECK: declare double @llvm.experimental.constrained.exp.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.exp.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.exp.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_exp2(f);   __builtin_exp2f(f);  __builtin_exp2l(f); 
+
+// CHECK: declare double @llvm.experimental.constrained.exp2.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.exp2.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.exp2.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_fma(f,f,f);__builtin_fmaf(f,f,f);   __builtin_fmal(f,f,f);
+
+// CHECK: declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.fma.f32(float, float, float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.fma.f80(x86_fp80, x86_fp80, x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_log(f);__builtin_logf(f);   __builtin_logl(f);
+
+// CHECK: declare double @llvm.experimental.constrained.log.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.log.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.log.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_log10(f);  __builtin_log10f(f); __builtin_log10l(f);
+
+// CHECK: declare double @llvm.experimental.constrained.log10.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.log10.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.log10.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_nearbyint(f);  __builtin_nearbyintf(f); __builtin_nearbyintl(f);
+
+// CHECK: declare double @llvm.experimental.constrained.nearbyint.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.exp

[PATCH] D52292: [Sema][OpenCL] Improve diagnostics for not viable overloadable function candidates

2018-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D52292



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


[PATCH] D51402: [OpenCL] Adding cl_intel_planar_yuv extension

2018-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D51402#1252619, @sidorovd wrote:

> @Anastasia , since there is a problem I described, wouldn't you mind if I 
> stay with the first iteration of the patch (adding the extension to 
> OpenCLExtensions.def) and after we'll investigate what is wrong with -cl-ext 
> approach?


I would prefer not to add it to Clang directly unless absolutely necessary. I 
think it's ok to add this in the header for now as is, but then investigate how 
we can add an architecture guard later. Please, could you just move the testing 
into `test/Headers/opencl-c-header.cl`, because 
`test/SemaOpenCL/extension-version.cl` is for Clang built in extensions.


https://reviews.llvm.org/D51402



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Mind you, there are some ideas I didn't add to the list -- I just don't know 
how to put them to words nicely, but I'm on it.

Also, a lot of these is outdated, but I joined the project relatively recently, 
so I'm not sure what's the state on all of them.


Repository:
  rC Clang

https://reviews.llvm.org/D53024



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


[PATCH] D52969: [analyzer][www] Update alpha_checks.html

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: www/analyzer/alpha_checks.html:352-405
+
+alpha.cplusplus.InvalidatedIterator
+(C++)
+Check for use of invalidated iterators.
+
+
 

@baloghadamsoftware Is this a good description of your checker(s)?


https://reviews.llvm.org/D52969



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: aaron.ballman, JonasToth, ioeric.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

Adds a new check readability-const-value-return, which checks for functions with
a ``const``-qualified return type and recommends removal of the `const` keyword.
Such use of ``const`` is superfluous, and prevents valuable compiler
optimizations.

Based in part on the (abandoned) review https://reviews.llvm.org/D33531.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { re

[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

GCC has -Wignored-qualifiers for long time, so may be better to implement it in 
Clang?




Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:66
+  llvm::Optional Loc = findConstToRemove(Def, Result);
+  if (!Loc) return;
+  DiagnosticBuilder Diagnostics = diag(*Loc,

Please split in two lines.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:74
+  // associate all fixes with the definition.
+  for (auto *Decl = Def->getPreviousDecl(); Decl != nullptr;
+   Decl = Decl->getPreviousDecl()) {

Please don't use auto, because type is not deducible from statement and it's 
not iterator over container.



Comment at: docs/ReleaseNotes.rst:60
 
+- New :doc:`readability-const-value-return
+  ` check.

Please use alphabetical order for list of new checks.



Comment at: docs/ReleaseNotes.rst:64
+  Checks for functions with a ``const``-qualified return type and recommends
+  removal of the `const` keyword.  Such use of ``const`` is superfluous, and
+  prevents valuable compiler optimizations.

Please enclose const in ``.

Once sentence is enough for Release Notes.



Comment at: docs/clang-tidy/checks/readability-const-value-return.rst:7
+Checks for functions with a ``const``-qualified return type and recommends
+removal of the `const` keyword.  Such use of ``const`` is superfluous, and
+prevents valuable compiler optimizations.

Please enclose const in ``.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D52673: [HIP] Remove disabled irif library

2018-10-09 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 168836.
ashi1 added a comment.

The device libraries has been updated, and the hip.amdgcn.bc library is now 
available there.


Repository:
  rC Clang

https://reviews.llvm.org/D52673

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-device-libs.hip


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,8 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" 
"{{.*}}irif.amdgcn.bc"
+// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" 
"{{.*}}hip.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -82,15 +82,15 @@
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

 BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "hip.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,8 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" "{{.*}}irif.amdgcn.bc"
+// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" "{{.*}}hip.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -82,15 +82,15 @@
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

 BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "hip.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52673: [HIP] Remove disabled irif library

2018-10-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Driver/ToolChains/HIP.cpp:85
   C.addTempFile(C.getArgs().MakeArgString(TmpName));
   CmdArgs.push_back(OutputFileName);
   SmallString<128> ExecPath(C.getDriver().Dir);

maybe we should put hip.amdgcn.bc at the beginning. In the future, it may 
depend on other bc's.


Repository:
  rC Clang

https://reviews.llvm.org/D52673



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


[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

It would be good to test your `CIndex` changes in `test/Index/opencl-types.cl`.




Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:26
+ char4 c4, event_t e, struct st ss) {
+  intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer 
for mce types
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with 
an expression of incompatible type 'int'}}

AlexeySachkov wrote:
> Anastasia wrote:
> > Would it make sense to add a check for non-zero constant?
> > 
> > Also can you assign variables of intel_sub_group_avc_mce_payload_t type 
> > from the same type? Any other restrictions on assignment (i.e. w integer 
> > literals) and operations over these types?
> > Also can you assign variables of intel_sub_group_avc_mce_payload_t type 
> > from the same type?
> 
> Yes, such assignment is allowed.
> 
> > Any other restrictions on assignment (i.e. w integer literals)
> 
> All of these types can only be initialized using call to a special built-ins 
> or using predefined macros like `CLK_AVC_REF_RESULT_INITIALIZE_INTEL`. Any 
> other assignment should lead to an error. 
> 
> I found that I'm able to assign variable of type 
> `intel_sub_group_avc_imc_payload_t` to variable of type 
> `intel_sub_group_avc_mce_payload_t`, so I will update the patch when I 
> implement such diagnostic message.
> 
> > and operations over these types?
> Variables of these types can only be used as return values or arguments for 
> built-in functions described in the specification. All other operations are 
> restricted
W/o the spec change it's really difficult to review properly. So are you 
testing 2 groups of types:
1. Init by zero in `bar`?
2. Init by builtin function in `foo`?




Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:34
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with 
an expression of incompatible type 'int'}}
+  intel_sub_group_avc_ime_payload_t payload_ime = b;
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_ime_payload_t' with 
an expression of incompatible type 'bool'}}

I am not sure it makes sense to iterate through all different types. You don't 
enumerate all of them and we don't do exhaustive testing in Clang tests anyway. 
I would just check integer literal and one other builtin type.


https://reviews.llvm.org/D51484



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


r344070 - PR39231: fix null dereference when diagnosing deduction failure due to

2018-10-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct  9 11:49:22 2018
New Revision: 344070

URL: http://llvm.org/viewvc/llvm-project?rev=344070&view=rev
Log:
PR39231: fix null dereference when diagnosing deduction failure due to
conflicting values for a non-type pack.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=344070&r1=344069&r2=344070&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Oct  9 11:49:22 2018
@@ -9984,7 +9984,7 @@ static void DiagnoseBadDeduction(Sema &S
   DeductionFailure.getFirstArg()->getNonTypeTemplateArgumentType();
   QualType T2 =
   DeductionFailure.getSecondArg()->getNonTypeTemplateArgumentType();
-  if (!S.Context.hasSameType(T1, T2)) {
+  if (!T1.isNull() && !T2.isNull() && !S.Context.hasSameType(T1, T2)) {
 S.Diag(Templated->getLocation(),
diag::note_ovl_candidate_inconsistent_deduction_types)
   << ParamD->getDeclName() << *DeductionFailure.getFirstArg() << T1

Modified: cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp?rev=344070&r1=344069&r2=344070&view=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp Tue Oct  9 11:49:22 2018
@@ -6,3 +6,19 @@ namespace deduce_pack_non_pack {
   template  void g(C>); // expected-note {{candidate template 
ignored: deduced type 'C>' of 1st parameter does not 
match adjusted type 'C>' of argument [with T = bool]}}
   void h(C> &x) { g(x); } // expected-error {{no matching 
function}}
 }
+
+namespace pr39231 {
+  template struct integer_sequence {};
+
+  template 
+  int operator^(integer_sequence a, // expected-note {{deduced 
conflicting values for parameter 'A' (<1, 2, 3> vs. <4, 5, 6>)}}
+integer_sequence b);
+
+  int v = integer_sequence{} ^ integer_sequence{}; 
// expected-error {{invalid operands}}
+
+  template 
+  integer_sequence operator+(integer_sequence a,
+  integer_sequence b);
+  integer_sequence w =
+  integer_sequence{} + integer_sequence{};
+}


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


[PATCH] D53032: [clangd] Minimal implementation of automatic static index, behind a flag.

2018-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ioeric.
Herald added subscribers: cfe-commits, jfb, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, mgorny.

See tinyurl.com/clangd-automatic-index for design and goals.

Lots of limitations to keep this patch smallish, TODOs everywhere:

- no serialization to disk
- no changes to dynamic index, which now has a much simpler job
- no partitioning of symbols by file to avoid duplication of header symbols
- no reindexing of edited files
- only a single worker thread
- compilation database is slurped synchronously (doesn't scale)
- uses memindex, rebuilds after every file (should be dex, periodically)

Still needs tests, but should be ready for review of the basic shape.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53032

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/Compiler.cpp
  clangd/Compiler.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -167,6 +167,14 @@
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
 
+static llvm::cl::opt AutoIndex(
+"auto-index",
+llvm::cl::desc(
+"Build a full index for the codebase containing edited files. "
+"Indexing will occur in the background. "
+"This option is still experimental, as the indexing is inefficient."),
+llvm::cl::init(false), llvm::cl::Hidden);
+
 enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
 static llvm::cl::opt CompileArgsFrom(
 "compile_args_from", llvm::cl::desc("The source of compile commands"),
@@ -316,9 +324,10 @@
   CCOpts.AllScopes = AllScopesCompletion;
 
   // Initialize and run ClangdLSPServer.
-  ClangdLSPServer LSPServer(
-  Out, CCOpts, CompileCommandsDirPath,
-  /*ShouldUseInMemoryCDB=*/CompileArgsFrom == LSPCompileArgs, Opts);
+  ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath,
+/*ShouldUseInMemoryCDB=*/CompileArgsFrom ==
+LSPCompileArgs,
+AutoIndex, Opts);
   constexpr int NoShutdownRequestErrorCode = 1;
   llvm::set_thread_name("clangd.main");
   // Change stdin to binary to not lose \r\n on windows.
Index: clangd/index/Background.h
===
--- /dev/null
+++ clangd/index/Background.h
@@ -0,0 +1,73 @@
+//===--- Background.h - Build an index in a background thread *- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H
+
+#include "Context.h"
+#include "FSProvider.h"
+#include "index/Index.h"
+#include "index/FileIndex.h"
+#include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/Support/SHA1.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+// Builds an in-memory index by by running the static indexer action over
+// all commands in a compilation database. Indexing happens in the background.
+// TODO: it should also persist its state on disk for fast start.
+class BackgroundIndex : public SwapIndex {
+public:
+  // TODO: FileSystemProvider is not const-correct.
+  // TODO: resource-dir injection should be hoisted somewhere common.
+  BackgroundIndex(Context BackgroundContext,
+  StringRef ResourceDir, FileSystemProvider *);
+  ~BackgroundIndex(); // Blocks while the current task finishes.
+
+  // Index all TUs described in the compilation database.
+  // The indexing happens in a background thread, so after enqueueing files
+  // for indexing their symbols will be available sometime later.
+  void enqueueAll(llvm::StringRef Directory,
+  const tooling::CompilationDatabase &);
+
+  // Cause background threads to stop after ther current task, any remaining
+  // tasks will be discarded.
+  void stop();
+
+private:
+  // configuration
+  std::string ResourceDir;
+  FileSystemProvider *FSProvider;
+  Context BackgroundContext;
+
+  // index state
+  llvm::Error index(tooling::CompileCommand);
+  FileSymbols IndexedSymbols; // Index contents.
+  using Hash = decltype(llvm::SHA1::hash({}));
+  llvm::StringMap FileHash; // Digest of indexed file.
+
+  // queue management
+  using Task = std::function; // TODO: use multiple worker threads.
+  void run(); // Main loop executed by Thread. Runs tasks from Queue.
+  void enqueueLocked(tooling::C

[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 168848.
mstorsjo added a comment.

Relying on a linker pragma in sanitizers and mingw lib name logic in lld.


https://reviews.llvm.org/D52990

Files:
  lib/CodeGen/TargetInfo.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -17,9 +17,11 @@
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN32
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64
+// RUN: %clang -target x86_64-w64-mingw32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64-MINGW
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined -x c++ %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // CHECK-UNDEFINED-WIN32: "--dependent-lib={{[^"]*}}ubsan_standalone-i386.lib"
 // CHECK-UNDEFINED-WIN64: 
"--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
+// CHECK-UNDEFINED-WIN64-MINGW: 
"--dependent-lib={{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a"
 // CHECK-UNDEFINED-WIN-CXX: 
"--dependent-lib={{[^"]*}}ubsan_standalone_cxx{{[^"]*}}.lib"
 // CHECK-UNDEFINED-WIN-SAME: 
"-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2337,7 +2337,7 @@
   bool Quote = (Lib.find(" ") != StringRef::npos);
   std::string ArgStr = Quote ? "\"" : "";
   ArgStr += Lib;
-  if (!Lib.endswith_lower(".lib"))
+  if (!Lib.endswith_lower(".lib") && !Lib.endswith_lower(".a"))
 ArgStr += ".lib";
   ArgStr += Quote ? "\"" : "";
   return ArgStr;


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -17,9 +17,11 @@
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64
+// RUN: %clang -target x86_64-w64-mingw32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64-MINGW
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // CHECK-UNDEFINED-WIN32: "--dependent-lib={{[^"]*}}ubsan_standalone-i386.lib"
 // CHECK-UNDEFINED-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
+// CHECK-UNDEFINED-WIN64-MINGW: "--dependent-lib={{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a"
 // CHECK-UNDEFINED-WIN-CXX: "--dependent-lib={{[^"]*}}ubsan_standalone_cxx{{[^"]*}}.lib"
 // CHECK-UNDEFINED-WIN-SAME: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2337,7 +2337,7 @@
   bool Quote = (Lib.find(" ") != StringRef::npos);
   std::string ArgStr = Quote ? "\"" : "";
   ArgStr += Lib;
-  if (!Lib.endswith_lower(".lib"))
+  if (!Lib.endswith_lower(".lib") && !Lib.endswith_lower(".a"))
 ArgStr += ".lib";
   ArgStr += Quote ? "\"" : "";
   return ArgStr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53013: [MinGW] Support MinGW style library names for default library pragmas

2018-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

If relying on logic in lld, this one can be discarded.


Repository:
  rC Clang

https://reviews.llvm.org/D53013



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


[PATCH] D53034: [clangd] Remove no-op crash handler, we never set a crash context.

2018-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: ioeric, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.

I think this was just copied from somewhere with the belief that it actually
did some crash handling.

Of course the question arises: *should* we set one? I don't think so:

- clangd used to crash a lot, now it's pretty stable, because we found and 
fixed the crashes. I think the long-term effects of crashing hard are good.
- the implementation can't do any magic, it just uses longjmp to return without 
running any destructors by default. This is unsafe in general (e.g. mutexes 
won't unlock) and will certainly end up leaking memory. Whatever UB caused the 
crash may still stomp all over global state, etc.

I think there's an argument for isolating the background indexer (autoindex)
because it's not directly under the user's control, the crash surface is larger,
and it doesn't particularly need to interact with the rest of clangd.
But there, fork() and communicate through the FS is safer.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53034

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -31,7 +31,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -141,10 +140,6 @@
   if (!Clang)
 return llvm::None;
 
-  // Recover resources if we crash before exiting this method.
-  llvm::CrashRecoveryContextCleanupRegistrar CICleanup(
-  Clang.get());
-
   auto Action = llvm::make_unique();
   const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0];
   if (!Action->BeginSourceFile(*Clang, MainInput)) {


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -31,7 +31,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -141,10 +140,6 @@
   if (!Clang)
 return llvm::None;
 
-  // Recover resources if we crash before exiting this method.
-  llvm::CrashRecoveryContextCleanupRegistrar CICleanup(
-  Clang.get());
-
   auto Action = llvm::make_unique();
   const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0];
   if (!Action->BeginSourceFile(*Clang, MainInput)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D52703: Allow ifunc resolvers to accept arguments

2018-10-09 Thread Eric Christopher via cfe-commits
SGTM.

On Tue, Oct 9, 2018, 7:57 AM James Y Knight via Phabricator <
revi...@reviews.llvm.org> wrote:

> jyknight accepted this revision.
> jyknight added a comment.
> This revision is now accepted and ready to land.
>
> Given that there's no technical reason for the compiler to prohibit this
> (it was just clang trying to diagnose a probable user-error, which turns
> out to not be as probable as ), this seems like the right solution to me.
>
>
> https://reviews.llvm.org/D52703
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52673: [HIP] Remove disabled irif library

2018-10-09 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 168855.
ashi1 marked an inline comment as done.
ashi1 added a comment.

I've moved the hip.amdgcn.bc to the top of the libs. Updated test as well.


https://reviews.llvm.org/D52673

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-device-libs.hip


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,9 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" 
"{{.*}}irif.amdgcn.bc"
+// COM-SAME: "{{.*}}hip.amdgcn.bc" "{{.*}}opencl.amdgcn.bc"
+// COM-SAME: "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -81,16 +81,16 @@
 else
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

-BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+BCLibs.append({"hip.amdgcn.bc", "opencl.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,9 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" "{{.*}}irif.amdgcn.bc"
+// COM-SAME: "{{.*}}hip.amdgcn.bc" "{{.*}}opencl.amdgcn.bc"
+// COM-SAME: "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -81,16 +81,16 @@
 else
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

-BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+BCLibs.append({"hip.amdgcn.bc", "opencl.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 168856.
ymandel added a comment.

Minor changes addressing comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { return &eight; }
+Klazz n9();
+const Klazz* n10();
+const Klazz& Clazz::n11(const Klazz) const {}
+const int n14();
+
+#define CONSTINT const int
+CONSTINT n12() {}
+
+// DEFFF in header.
+DEFFF n13() {}
Index: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
===
--- /dev/null
+++ t

[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 168857.
ymandel marked 2 inline comments as done.
ymandel added a comment.

Dropped unneeded clang qualifier.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { return &eight; }
+Klazz n9();
+const Klazz* n10();
+const Klazz& Clazz::n11(const Klazz) const {}
+const int n14();
+
+#define CONSTINT const int
+CONSTINT n12() {}
+
+// DEFFF in header.
+DEFFF n13() {}
Index: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
==

[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Cool, thanks! I'll commit.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> where `isStaticLocal` is defined as:

You can send this one as well if you like! It's weird that we don't already 
have it.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52906: [analyzer] allow plugins built as shared libraries to receive events

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Yup, this one looks great as well. I'll commit. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D52906



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 168858.
ymandel added a comment.

Add missing const.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { return &eight; }
+Klazz n9();
+const Klazz* n10();
+const Klazz& Clazz::n11(const Klazz) const {}
+const int n14();
+
+#define CONSTINT const int
+CONSTINT n12() {}
+
+// DEFFF in header.
+DEFFF n13() {}
Index: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
===
--- /dev/null
+++ test/clang-tidy/I

[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D52905#1259249, @NoQ wrote:

> > where `isStaticLocal` is defined as:
>
> You can send this one as well if you like! It's weird that we don't already 
> have it.


Or actually maybe it can be implemented as `allOf(hasStaticStorageDuration(), 
unless(hasGlobalStorage()))`.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52924: Make __builtin_object_size use the EM_IgnoreSideEffects evaluation mode.

2018-10-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, looks like this has been largely redundant since r294800 removed the 
only interesting thing that `EM_OffsetFold` did.


https://reviews.llvm.org/D52924



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 3 inline comments as done.
ymandel added a comment.

Thanks for the review. I've addressed the comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D52939: ExprConstant: Propagate correct return values from constant evaluation.

2018-10-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:12-32
 // Constant expression evaluation produces four main results:
 //
 //  * A success/failure flag indicating whether constant folding was 
successful.
 //This is the 'bool' return value used by most of the code in this file. A
 //'false' return value indicates that constant folding has failed, and any
 //appropriate diagnostic has already been produced.
 //

Is this comment still correct?



Comment at: clang/lib/AST/ExprConstant.cpp:682
 enum EvaluationMode {
-  /// Evaluate as a constant expression. Stop if we find that the 
expression
-  /// is not a constant expression.
+  /* The various EvaluationMode kinds vary in terms of what sorts of
+   * expressions they accept.

Nit: LLVM style avoids `/*...*/` comments even for long comment blocks like 
this (https://llvm.org/docs/CodingStandards.html#comment-formatting).



Comment at: clang/lib/AST/ExprConstant.cpp:686-687
+ Key for the following table:
+ * D = Diagnostic notes (about non-constexpr, but still evaluable
+   constructs) are OK (keepEvaluatingAfterNote)
+ * S = Failure to evaluate which only occurs in expressions used for

I think talking about diagnostic notes here distracts from the purpose, which 
is that this column indicates that we accept constructs that are not permitted 
by the language mode's constant expression rules.



Comment at: clang/lib/AST/ExprConstant.cpp:688-690
+ * S = Failure to evaluate which only occurs in expressions used for
+   side-effect are okay.  (keepEvaluatingAfterSideEffect)
+ * F = Failure to evaluate is okay. (keepEvaluatingAfterFailure)

"is okay" here is misleading, I think. The point of `keepEvaluatingAfter[...]` 
is that it's safe to stop evaluating if they return false, because later 
evaluations can't affect the overall result.



Comment at: clang/lib/AST/ExprConstant.cpp:692
+ * E = Eagerly evaluate certain builtins to a value which would 
normally
+   defer until after optimizations.
+

defer -> be deferred?



Comment at: clang/lib/AST/ExprConstant.cpp:706-707
+
+ TODO: Fix EM_ConstantExpression and EM_PotentialConstantExpression to
+ also eagerly evaluate. (and then delete
+ EM_PotentialConstantExpressionUnevaluated as a duplicate)

Allowing `EM_ConstantExpression` to evaluate expressions that `EM_ConstantFold` 
cannot evaluate would violate our invariants. We rely on being able to check up 
front that an expression is a constant expression and then later just ask for 
its value, and for the later query to always succeed and return the same value 
as the earlier one. (This is one of the reasons why I suggested in D52854 that 
we add an explicit AST representation for constant expressions.)



Comment at: clang/lib/AST/ExprConstant.cpp:711
+
+  /// Evaluate as a constant expression, as per C++11-and-later constexpr
+  /// rules. Stop if we find that the expression is not a constant

This is not the intent. The evaluator uses the rules of the current language 
mode. However, it doesn't enforce the C and C++98 syntactic restrictions on 
what can appear in a constant expression, because it turns out to be cleaner to 
check those separately rather than to interleave them with evaluation.

We should probably document this as evaluating following the evaluation (but 
not syntactic) constant expression rules of the current language mode.



Comment at: clang/lib/AST/ExprConstant.cpp:720-722
+  /// Like EM_ConstantFold, but eagerly attempt to evaluate some builtins
+  /// that'd otherwise fail constant evaluation to defer until after
+  /// optimization.  This affects __builtin_object_size (and in the future

This sentence is a little hard to read.



Comment at: clang/lib/AST/ExprConstant.cpp:891
 /// expression.
 ///
 OptionalDiagnostic CCEDiag(SourceLocation Loc, diag::kind DiagId

Nit: delete line



Comment at: clang/lib/AST/ExprConstant.cpp:952
+/// with diagnostics.
+bool keepEvaluatingAfterNote() {
   switch (EvalMode) {

"Note" is beside the point here. We should be talking about non-constant 
expressions; that's what matters.



Comment at: clang/lib/AST/ExprConstant.cpp:1227-1230
+diagnosePointerArithmetic(Info, E, N);
+setInvalid();
+if (!Info.keepEvaluatingAfterNote())
+  return false;

I would strongly prefer to keep the emission of the diagnostic and the 
corresponding `return false` adjacent whenever possible, so I'd prefer that we 
add a `bool` return value to `diagnoseP

[PATCH] D52983: [analyzer] Support Reinitializes attribute in MisusedMovedObject check

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D52983#1258499, @xazax.hun wrote:

> In https://reviews.llvm.org/D52983#1258466, @NoQ wrote:
>
> > Yay, these look useful. Is there also an attribute for methods that should 
> > never be called on a 'moved-from' object?
>
>
> I do not know about such attribute, but once contracts are implemented and 
> wide-spread, a precondition on a method/function is a strong suggestion that 
> it should not be used on a moved-from object.


Well, that actually sounds like a pretty good heuristic, as long as we know 
that a moved-from object cannot reliably satisfy these contracts. In other 
words, it'll probably be fine for most library classes, but my concern is that 
the more contracts do we document this way, the more false positives would we 
have, which is not a healthy correlation. Like, for example, if we add a 
contract "the object is in a consistent state" to all methods of an STL object, 
eg. something like `this->_length == strlen(this->_buf)` for `std::string` 
methods, it might be a valid contract, but all moved-from objects would 
trivially satisfy it (because they are guaranteed to be in a consistent albeit 
unspecified state), so we won't be able to all any method at all.


Repository:
  rL LLVM

https://reviews.llvm.org/D52983



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Whoa thanks! Will have a closer look again.




Comment at: www/analyzer/open_projects.html:33
+
+Handle aggregate construction.
+Aggregates are object that can be brace-initialized without calling a

I'll try to list other constructor kinds that i have in mind.



Comment at: www/analyzer/open_projects.html:76
+still suppress false positives, but will not prevent us from inlining the 
+ethods, and therefore will not cause other false positives. Verifying this
+hypothesis would be a wonderful accomplishment. Previous understanding of

Typo: methods.



Comment at: www/analyzer/open_projects.html:86-87
+the opposite direction - integers to pointers - are completely unsupported.
+Pointer-to-pointer casts are a mess; modeling them with https://clang.llvm.org/doxygen/classclang_1_1ento_1_1ElementRegion.html";>
+ElementRegion  is a disaster and we are suffering a lot from 
this
+hack, but coming up with a significantly better solution is very hard, as

I'll try to be more, emm, positive on the website :]



Comment at: www/analyzer/open_projects.html:234
+  Because LLVM doesn't have branches, unfinished checkers first land in
+  alpha, and are only moved out once they are production-ready. Howeever, over
+  the years many checkers got stuck in alpha, and their developtment have

Typo: However.



Comment at: www/analyzer/open_projects.html:235
+  alpha, and are only moved out once they are production-ready. Howeever, over
+  the years many checkers got stuck in alpha, and their developtment have
+  stalled.

Typo: Development.



Comment at: www/analyzer/open_projects.html:262
+same time, until the return value of pthread_mutex_destroy was checked by a
+branch in the code).
+(Difficulty: Easy)

Something is unfinished here.


Repository:
  rC Clang

https://reviews.llvm.org/D53024



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D52857#1258893, @steveire wrote:

> - The scripts will continue to work at least until `set output` is removed, 
> which is not going to happen soon.


Certainly, but given that deprecation implies eventual removal, people are 
still being asked to update their scripts. What's more, given that clang-output 
has no real documentation to speak of, how will users even *know* to update 
their scripts? Rather than invent ways to address these concerns, I'm much more 
in favor of making the feature work using a backwards compatible syntax. Then 
no one has to update their scripts to get identical functionality.

> - A comma-delimited list of options means that if I have `foo, bar, bat`  
> enabled and want to add `bang`, I need to `set output foo, bar, bat, bang`. 
> Or alternatively if I want to remove `bat`, I need to write out all the 
> others. I don't think that's suitable.

Correct -- if you want different output because new options are available, you 
need to opt into it. I'm not certain what the issue is with that; can you 
expound on your concerns? From what I'm seeing in the patch, it looks like you 
want user to write:

  set dump-output
  set diag-output
  match foo(bar(baz()))

and I'm asking for it to instead be:

  set output dump, diag
  match foo(bar(baz()))

Functionally, I believe these are equivalent. However, I think the latter is 
more clear for users as it implies a set of output options rather than leaving 
you to wonder whether `set blah-output` options are mutually exclusive or not.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52924: Make __builtin_object_size use the EM_IgnoreSideEffects evaluation mode.

2018-10-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv accepted this revision.
george.burgess.iv added a comment.

Thanks!


https://reviews.llvm.org/D52924



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


[PATCH] D53038: [Hexagon] Use GetLinkerPath method instead of hard-coded linker name.

2018-10-09 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: shankare, ruiu, kparzysz, bcain.
Herald added a subscriber: cfe-commits.

Use GetLinkerPath method instead of hard-coding linker name.

Change should allow -fuse-ld to work on the Hexagon target.


Repository:
  rC Clang

https://reviews.llvm.org/D53038

Files:
  lib/Driver/ToolChains/Hexagon.cpp
  lib/Driver/ToolChains/Hexagon.h


Index: lib/Driver/ToolChains/Hexagon.h
===
--- lib/Driver/ToolChains/Hexagon.h
+++ lib/Driver/ToolChains/Hexagon.h
@@ -81,6 +81,9 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+
+  const char *getDefaultLinker() const override { return "hexagon-link"; }
+
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const 
override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
Index: lib/Driver/ToolChains/Hexagon.cpp
===
--- lib/Driver/ToolChains/Hexagon.cpp
+++ lib/Driver/ToolChains/Hexagon.cpp
@@ -369,9 +369,8 @@
   constructHexagonLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
LinkingOutput);
 
-  std::string Linker = HTC.GetProgramPath("hexagon-link");
-  C.addCommand(llvm::make_unique(JA, *this, 
Args.MakeArgString(Linker),
-  CmdArgs, Inputs));
+  const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 // Hexagon tools end.
 


Index: lib/Driver/ToolChains/Hexagon.h
===
--- lib/Driver/ToolChains/Hexagon.h
+++ lib/Driver/ToolChains/Hexagon.h
@@ -81,6 +81,9 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+
+  const char *getDefaultLinker() const override { return "hexagon-link"; }
+
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
Index: lib/Driver/ToolChains/Hexagon.cpp
===
--- lib/Driver/ToolChains/Hexagon.cpp
+++ lib/Driver/ToolChains/Hexagon.cpp
@@ -369,9 +369,8 @@
   constructHexagonLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
LinkingOutput);
 
-  std::string Linker = HTC.GetProgramPath("hexagon-link");
-  C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
-  CmdArgs, Inputs));
+  const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 // Hexagon tools end.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Hi  ymandel,

welcome to the LLVM community and thank you very much for working on that check!
If you have any questions or other issues don't hesitate to ask ;)




Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:25
+
+// Finds the location of the relevant "const" token in `Def`.
+llvm::Optional findConstToRemove(

s/"const"/`const`



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:26
+// Finds the location of the relevant "const" token in `Def`.
+llvm::Optional findConstToRemove(
+const FunctionDecl *Def, const MatchFinder::MatchResult &Result) {

Please use a `static` function instead of a anonymous namespace. These are only 
used for local classes.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:37
+  if (FileRange.isInvalid())
+return {};
+

Please return `None` instead, same below



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:60
+  const auto *Def = Result.Nodes.getNodeAs("func");
+  if (!Def->getReturnType().isLocalConstQualified()) {
+return;

Please ellide the braces



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:64
+
+  // Fix the definition.
+  llvm::Optional Loc = findConstToRemove(Def, Result);

I feel that this comment doesn't add value. Could you please either make it 
more expressive or remove it?



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:65
+  // Fix the definition.
+  llvm::Optional Loc = findConstToRemove(Def, Result);
+  if (!Loc)

This check does not produce diagnostics if something in the lexing went wrong.
I think even if its not possible to do transformation the warning could still 
be emitted (at functionDecl location). What do you think?



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:71
+  diag(*Loc,
+   "avoid marking return types as ``const`` for values, as it often  "
+   "disables optimizations and causes unnecessary copies")

please shorten that warning a bit and use 'const'.

Maybe `'const'-qualified return values hinder compiler optimizations` or 
something in this direction?



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:79
+   Decl = Decl->getPreviousDecl()) {
+if (const llvm::Optional PrevLoc =
+findConstToRemove(Decl, Result)) {

The `const` is not common in llvm-code. Please use it only for references and 
pointers.

What do you think about emitting a `note` if this transformation can not be 
done? It is relevant for the user as he might need to do manual fix-up. It 
would complicate the code as there can only be one(?) diagnostic at the same 
time (90% sure only tbh).



Comment at: docs/clang-tidy/checks/list.rst:12
abseil-redundant-strcat-calls
-   abseil-string-find-startswith
abseil-str-cat-append

spurious change



Comment at: docs/clang-tidy/checks/readability-const-value-return.rst:19
+Note that this does not apply to returning pointers or references to const
+values.  These are fine:
+

please remove the double space



Comment at: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h:1
+#ifndef MACRO_DEF_H
+#define MACRO_DEF_H

You can define these macros directly in the test-case, or do you intend 
something special? Self-contained tests are prefered.



Comment at: test/clang-tidy/readability-const-value-return.cpp:4
+
+#include "macro-def.h"
+

Please add tests, were the `const` is hidden behind typedefs/using. 

I feel that there should be more test that try to break the lexing part as well.
E.g. `const /** I am a comment */ /* weird*/ int function();` be creative here 
;)

Could you please add a test-case `int ** const * multiple_ptr();` and `int 
*const & pointer_ref();`



Comment at: test/clang-tidy/readability-const-value-return.cpp:53
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+

Missing warning?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D52990: [MinGW] Fix passing a sanitizer lib name as dependent lib

2018-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D52990



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Thanks!

I admit that the difficulty was mostly chosen at random, so that could be 
brought closer to the actual difficulty of the project.




Comment at: www/analyzer/open_projects.html:86-87
+the opposite direction - integers to pointers - are completely unsupported.
+Pointer-to-pointer casts are a mess; modeling them with https://clang.llvm.org/doxygen/classclang_1_1ento_1_1ElementRegion.html";>
+ElementRegion  is a disaster and we are suffering a lot from 
this
+hack, but coming up with a significantly better solution is very hard, as

NoQ wrote:
> I'll try to be more, emm, positive on the website :]
Oh, right, sorry, I tried to "positivitize" most of these, but apparently 
missed this one O:)


Repository:
  rC Clang

https://reviews.llvm.org/D53024



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Thiago Macieira via Phabricator via cfe-commits
thiagomacieira created this revision.
thiagomacieira added reviewers: erichkeane, craig.topper.
Herald added a subscriber: cfe-commits.
craig.topper retitled this revision from "Remove FeatureRTM from Skylake 
processor list" to "[X86] Remove FeatureRTM from Skylake processor list".

There are a LOT of Skylakes and later without TSX-NI. Examples:

- SKL: 
https://ark.intel.com/products/136863/Intel-Core-i3-8121U-Processor-4M-Cache-up-to-3-20-GHz-
- KBL: 
https://ark.intel.com/products/97540/Intel-Core-i7-7560U-Processor-4M-Cache-up-to-3-80-GHz-
- KBL-R: 
https://ark.intel.com/products/149091/Intel-Core-i7-8565U-Processor-8M-Cache-up-to-4-60-GHz-
- CNL: 
https://ark.intel.com/products/136863/Intel-Core-i3-8121U-Processor-4M-Cache-up-to-3_20-GHz

This feature seems to be present only on high-end desktop and server
chips (I can't find any SKX without). This commit leaves it disabled
for all processors, but can be re-enabled for specific builds with
-mrtm.

Matches https://reviews.llvm.org/D53041


Repository:
  rC Clang

https://reviews.llvm.org/D53042

Files:
  lib/Basic/Targets/X86.cpp


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -169,7 +169,6 @@
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
-setFeatureEnabledImpl(Features, "rtm", true);
 setFeatureEnabledImpl(Features, "aes", true);
 LLVM_FALLTHROUGH;
   case CK_Broadwell:


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -169,7 +169,6 @@
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
-setFeatureEnabledImpl(Features, "rtm", true);
 setFeatureEnabledImpl(Features, "aes", true);
 LLVM_FALLTHROUGH;
   case CK_Broadwell:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D53042



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:169
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

> high-end desktop and server chips (I can't find any SKX without).

Are you sure you didn't want to move it into an else of this `if()` ?


Repository:
  rC Clang

https://reviews.llvm.org/D53042



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> there's a way to run clang-tidy over all of clang+llvm automatically

cmake should generate compile_commands.json by default, and then you could just 
point clang-tidy at that.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

> What's more, given that clang-output has no real documentation to speak of, 
> how will users even *know* to update their scripts?

The release notes will tell them.

But your comment also raises a different point: If there is so little 
clang-query documentation, what justification is there for relying on current 
behavior?

Also, what scripts are you referring to that rely on clang-query? Do we know of 
any that are expected to work long-term without maintenance (unlikely, as the 
AST itself is not stable), or is this concern imagined?

> can you expound on your concerns?

After this patch, the user writes

  set dump-output true

or `false`.

and after the follow-up (https://reviews.llvm.org/D52859) they write

  set matcher-output true

After more features I have in the pipeline they will write other similar 
commands.

With my command-design, if a user wants to enable dump output in addition to 
what they have, they just

  set dump-output true

In your design, they have to recall/find out what options are currently 
enabled, and add them in a comma separated list. That is not user-friendly.

> wonder whether set blah-output options are mutually exclusive or not.

These options are obviously and clearly toggles. There is definitely no reason 
to think that they are mutually exclusive any more than there is reason to 
think `set output dump` is mutually exclusive with `set bind-root false`.

And even if someone did wonder that, they would just try it and learn that they 
are toggles.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, rjmccall.
Herald added a subscriber: dexonsmith.

Clang used to error out on the attached testcase, due to multiple definitions 
of `foo`. The problem is that multiple FunctionTemplateDecl::Common 
pointers are created for the two FunctionTemplateDeclarations `foo` in the 
redeclaration chain, each with their own copy of the instantiation of `f`.

This patch fixes the problem by using the previous function template in a call 
to `FuntionTemplateDecl::getInjectedTemplateArgs()` (this was the call that 
caused the Common pointer to be allocated in the redeclaration). Most of this 
patch is just boilerplate to get the function template declaration down the 
stack to where it's needed.

Fixes rdar://44810129

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D53046

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/friend-template-redecl.cpp

Index: clang/test/SemaCXX/friend-template-redecl.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/friend-template-redecl.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++17 -verify -emit-llvm-only %s
+
+// expected-no-diagnostics
+
+template  void bar(const T &t) { foo(t); }
+
+template 
+struct HasFriend {
+  template 
+  friend void foo(const HasFriend &m) noexcept(false);
+};
+
+template 
+void foo(const HasFriend &m) noexcept(false) {}
+
+void f() {
+  HasFriend x;
+  foo(x);
+  bar(x);
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3575,7 +3575,8 @@
 }
 
 void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
-FunctionDecl *Decl) {
+FunctionDecl *Decl,
+FunctionDecl *OldDecl) {
   const FunctionProtoType *Proto = Decl->getType()->castAs();
   if (Proto->getExceptionSpecType() != EST_Uninstantiated)
 return;
@@ -3601,8 +3602,9 @@
   Sema::ContextRAII savedContext(*this, Decl);
   LocalInstantiationScope Scope(*this);
 
-  MultiLevelTemplateArgumentList TemplateArgs =
-getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true);
+  MultiLevelTemplateArgumentList TemplateArgs = getTemplateInstantiationArgs(
+  Decl, nullptr, /*RelativeToPrimary*/ true, nullptr,
+  !OldDecl ? nullptr : OldDecl->getDescribedFunctionTemplate());
 
   FunctionDecl *Template = Proto->getExceptionSpecTemplate();
   if (addInstantiatedParametersToScope(*this, Decl, Template, Scope,
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -51,11 +51,16 @@
 /// instantiating the definition of the given declaration, \p D. This is
 /// used to determine the proper set of template instantiation arguments for
 /// friend function template specializations.
+///
+/// \param PrevFunTmpl If non-NULL, D is a pattern declaration of a function
+/// template that hasn't yet been attached to the redeclaration chain of
+/// PrevFunTmpl's pattern.
 MultiLevelTemplateArgumentList
 Sema::getTemplateInstantiationArgs(NamedDecl *D,
const TemplateArgumentList *Innermost,
bool RelativeToPrimary,
-   const FunctionDecl *Pattern) {
+   const FunctionDecl *Pattern,
+   FunctionTemplateDecl *PrevFunTmpl) {
   // Accumulate the set of template argument lists in this structure.
   MultiLevelTemplateArgumentList Result;
 
@@ -151,6 +156,16 @@
 
   } else if (FunctionTemplateDecl *FunTmpl
= Function->getDescribedFunctionTemplate()) {
+if (PrevFunTmpl) {
+  // FunTmpl hasn't been linked into the same redecl chain as
+  // PrevFunTmpl yet, so we can't retreive it's injected template
+  // arguments just yet; use PrevFunTmpl's instead.
+  //
+  // Note that we don't need to verify that FunTmpl is the function
+  // template that is a redeclaration of PrevFunTmpl because only one
+  // function template decl can appear in this search.
+  FunTmpl = PrevFunTmpl;
+}
 // Add the "injected" template arguments.
 Result.addOuterTemplateArguments(FunTmpl->getInjectedTemplateArgs());
   }
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/

[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:10015
 // merged.
 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
   NewFD->setInvalidDecl();

The problem is here, MergeFunctionDecl() needs the injected template args, 
but...



Comment at: clang/lib/Sema/SemaDecl.cpp:10026
   auto *OldFD = OldTemplateDecl->getTemplatedDecl();
   NewFD->setPreviousDeclaration(OldFD);
   adjustDeclContextForDeclaratorDecl(NewFD, OldFD);

... we don't link the two declarations until here!


Repository:
  rC Clang

https://reviews.llvm.org/D53046



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


[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, aaron.ballman.
Herald added a subscriber: dexonsmith.

These two diagnostics are noisy, so its reasonable for users to opt-out of them 
when -Wconversion is enabled.

Fixes rdar://45058981

Thanks for taking a look!


Repository:
  rC Clang

https://reviews.llvm.org/D53048

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/implicit-int-conversion.c


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char 
-DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char 
-DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float 
-DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float 
-DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point 
precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_double_promotion : Warning<
   "implicit conversion increases floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3198,10 +3198,10 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_precision : Warning<
   "implicit conversion loses integer precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_high_order_zero_bits : Warning<
   "higher order bits are zeroes after implicit conversion">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_nonnegative_result : Warning<
   "the resulting value is always non-negative after implicit conversion">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -59,6 +59,8 @@
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
@@ -709,6 +711,8 @@
 FloatConversion,
 Shorten64To32,
 IntConversion,
+ImplicitIntConversion,
+ImplicitFloatConversion,
 LiteralConversion,
 NonLiteralNullConversion, // (1-1)->pointer (etc)
 NullConversion, // NULL->non-pointer


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char -DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_flo

[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 168885.
Szelethus added a comment.

Added new guards as recommended by @xazax.hun


https://reviews.llvm.org/D51866

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object-unguarded-access.cpp

Index: test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
===
--- /dev/null
+++ test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
@@ -0,0 +1,397 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:IgnoreGuardedFields=true \
+// RUN:   -std=c++11 -verify  %s
+
+//===--===//
+// Helper functions for tests.
+//===--===//
+void halt() __attribute__((__noreturn__));
+void assert(int b) {
+  if (!b)
+halt();
+}
+
+int rand();
+
+//===--===//
+// Tests for fields properly guarded by asserts.
+//===--===//
+
+class NoUnguardedFieldsTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area;
+  Kind K;
+
+public:
+  NoUnguardedFieldsTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0;
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+assert(K == Kind::V);
+(void)Volume;
+  }
+};
+
+void fNoUnguardedFieldsTest() {
+  NoUnguardedFieldsTest T1(NoUnguardedFieldsTest::Kind::A);
+  NoUnguardedFieldsTest T2(NoUnguardedFieldsTest::Kind::V);
+}
+
+class NoUnguardedFieldsWithUndefMethodTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area;
+  Kind K;
+
+public:
+  NoUnguardedFieldsWithUndefMethodTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0;
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+assert(K == Kind::V);
+(void)Volume;
+  }
+
+  // We're checking method definitions for guards, so this is a no-crash test
+  // whether we handle methods without definitions.
+  void methodWithoutDefinition();
+};
+
+void fNoUnguardedFieldsWithUndefMethodTest() {
+  NoUnguardedFieldsWithUndefMethodTest
+  T1(NoUnguardedFieldsWithUndefMethodTest::Kind::A);
+  NoUnguardedFieldsWithUndefMethodTest
+  T2(NoUnguardedFieldsWithUndefMethodTest::Kind::V);
+}
+
+class UnguardedFieldThroughMethodTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}}
+  Kind K;
+
+public:
+  UnguardedFieldThroughMethodTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0; // expected-warning {{1 uninitialized field}}
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+(void)Volume;
+  }
+};
+
+void fUnguardedFieldThroughMethodTest() {
+  UnguardedFieldThroughMethodTest T1(UnguardedFieldThroughMethodTest::Kind::A);
+}
+
+class UnguardedPublicFieldsTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+public:
+  // Note that fields are public.
+  int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}}
+  Kind K;
+
+public:
+  UnguardedPublicFieldsTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0; // expected-warning {{1 uninitialized field}}
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+assert(K == Kind::V);
+(void)Volume;
+  }
+};
+
+void fUnguardedPublicFieldsTest() {
+  UnguardedPublicFieldsTest T1(UnguardedPublicFieldsTest::Kind::A);
+}
+
+//===--===//
+// Highlights of some false negatives due to syntactic checking.
+//===--===//
+
+class UnguardedFalseNegativeTest1 {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area;
+  Kind K;
+
+public:
+  UnguardedFalseNegativeTest1(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0;
+  break;
+}
+  }
+
+  void operator-() {
+if (rand())
+  assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+if (rand())
+  assert(

[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:519
+
+if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
+  return true;

george.karpenkov wrote:
> Szelethus wrote:
> > xazax.hun wrote:
> > > I am not sure if this is a reliable way to check if the access is before 
> > > the guard.
> > > 
> > > Consider:
> > > ```
> > > switch(x): {
> > >case 2: guard; access; break;
> > >case 1: access break;
> > > }
> > > ```
> > > 
> > > Here, we have no particular ordering between the access in case 1 and the 
> > > guard in case 2 at runtime. But relying on the source locations we might 
> > > come to the false conclusion that there is. Loops, gotos can cause 
> > > similar problems.
> > > I do understand that this might not be too easy to solve without 
> > > traversing the cfg and we might not want to do that but I think we should 
> > > at least add a test/todo. 
> > > I am not sure if this is a reliable way to check if the access is before 
> > > the guard.
> > I'm 100% sure it isn't. Using the CFG instead of matchers sounds like a 
> > great and difficult to implement (at least to me, as I never touched them) 
> > idea. It should get rid of the false negatives, at least in part.
> > > [...]  I think we should at least add a test/todo.
> > There are some :)
> > Using the CFG instead of matchers sounds like a great and difficult to 
> > implement
> 
> That would also require building a dataflow framework, which we do not have 
> (yet)
Too bad :/ Makes me understand though why it would be valuable to implement it.


https://reviews.llvm.org/D51866



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


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D52998#1258962, @eandrews wrote:

> Yes. I understand. At the moment, exception handling flags are generated 
> based on `BENCHMARK_ENABLE_EXCEPTIONS`  in `utils/benchmark/CMakeLists.txt` . 
>  However, `_HAS_EXCEPTIONS` is not defined based on this (code below). The 
> warnings are a result of this mismatch.
>
>   if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
>   add_cxx_compiler_flag(-EHs-)
>   add_cxx_compiler_flag(-EHa-)
> endif()
>
>
> I think it makes most sense to add definition for `_HAS_EXCEPTIONS=0 `here as 
> opposed to modifying `llvm/CMakeLists.txt`.


Then i'd recommend/suggest to submit this upstream 
 first.

> Please correct me if I'm wrong. I'm not too familiar with CMake. @kbobyrev 
> Please let me know what you think as well since you had suggested 
> `llvm/CMakeLists.txt`.


https://reviews.llvm.org/D52998



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


[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

2018-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

LG other than the `hasCanonicalType()` vs `hasType()` question.


https://reviews.llvm.org/D52727



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


[PATCH] D51109: [cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 168898.
MaskRay retitled this revision from "[cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] "" to "[cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] file..."".
MaskRay removed a reviewer: clang.
MaskRay removed subscribers: sdardis, atanasyan.
MaskRay added a comment.

Refresh the commit and update title


Repository:
  rC Clang

https://reviews.llvm.org/D51109

Files:
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  tools/driver/cc1as_main.cpp


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/Sema/implicit-int-conversion.c:1-4
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char 
-DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char 
-DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float 
-DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float 
-DBIG=double

Are these RUN lines missing `-verify`?


Repository:
  rC Clang

https://reviews.llvm.org/D53048



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


[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/test/Sema/implicit-int-conversion.c:1-4
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char 
-DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char 
-DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float 
-DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float 
-DBIG=double

dexonsmith wrote:
> Are these RUN lines missing `-verify`?
Yep, also %s! Good catch.


https://reviews.llvm.org/D53048



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


[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 168912.
erik.pilkington added a comment.

Actually run the tests!


https://reviews.llvm.org/D53048

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/implicit-int-conversion.c


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-int-conversion 
-DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-conversion 
-DSMALL=char -DBIG=int
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-float-conversion 
-DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion 
-DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point 
precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_double_promotion : Warning<
   "implicit conversion increases floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3198,10 +3198,10 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_precision : Warning<
   "implicit conversion loses integer precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_high_order_zero_bits : Warning<
   "higher order bits are zeroes after implicit conversion">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_nonnegative_result : Warning<
   "the resulting value is always non-negative after implicit conversion">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -59,6 +59,8 @@
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
@@ -709,6 +711,8 @@
 FloatConversion,
 Shorten64To32,
 IntConversion,
+ImplicitIntConversion,
+ImplicitFloatConversion,
 LiteralConversion,
 NonLiteralNullConversion, // (1-1)->pointer (etc)
 NullConversion, // NULL->non-pointer


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-int-conversion -DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-conversion -DSMALL=char -DBIG=int
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-float-conversion -DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion -DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point precision:

[PATCH] D51109: [Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 168913.
MaskRay retitled this revision from "[cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] file..."" to "[Driver][cc1][cc1as] Call 
OptTable::PrintHelp with explicit " [options] file..."".
MaskRay added a comment.

Another reference in driver


Repository:
  rC Clang

https://reviews.llvm.org/D51109

Files:
  lib/Driver/Driver.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  tools/driver/cc1as_main.cpp


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-10-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

@ebevhan @rjmccall Seeing that the saturation intrinsic in 
https://reviews.llvm.org/D52286 should be put on hold for now, would it be fine 
to submit this patch as is? Then if the intrinsic is finished, come back to 
this and update this patch to use the intrinsic?


Repository:
  rC Clang

https://reviews.llvm.org/D50616



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


r344098 - [Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Tue Oct  9 17:15:33 2018
New Revision: 344098

URL: http://llvm.org/viewvc/llvm-project?rev=344098&view=rev
Log:
[Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

Summary: This is to accommodate a change in llvm/lib/Option/OptTable.cpp D51009

Reviewers: rupprecht, alexshap, jhenderson

Reviewed By: rupprecht

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=344098&r1=344097&r2=344098&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Oct  9 17:15:33 2018
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@ void Driver::PrintHelp(bool ShowHidden)
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=344098&r1=344097&r2=344098&view=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Tue Oct  9 
17:15:33 2018
@@ -183,7 +183,7 @@ bool ExecuteCompilerInvocation(CompilerI
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=344098&r1=344097&r2=344098&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Oct  9 17:15:33 2018
@@ -534,7 +534,8 @@ int cc1as_main(ArrayRef Ar
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;


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


[PATCH] D51109: [Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344098: [Driver][cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] file..." (authored by MaskRay, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51109

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/tools/driver/cc1as_main.cpp


Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }
Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;


Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }
Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
___
cf

[PATCH] D46441: [clang][CodeGenCXX] Noalias attr for 'this' parameter

2018-10-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I wonder if we should have a `-fno-strict-something` flag for this. I suppose 
there's no more effective way to find out than to try this and see what happens.




Comment at: lib/CodeGen/CGCall.cpp:2052
+//
+// We intentionally threat this behaviour as undefined by marking 
'this'
+// with noalias attribute and have recommended the Standard to be

thread -> treat


https://reviews.llvm.org/D46441



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


[PATCH] D52610: [Esan] Port cache frag to FreeBSD

2018-10-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:323
 Opts.ToolType = EfficiencySanitizerOptions::ESAN_CacheFrag;
-  else if (LangOpts.Sanitize.has(SanitizerKind::EfficiencyWorkingSet))
+  else if (T.getOS() == Triple::Linux &&
+LangOpts.Sanitize.has(SanitizerKind::EfficiencyWorkingSet))

Is it possible to port it to FreeBSD and skip some conditions in generic code?


Repository:
  rC Clang

https://reviews.llvm.org/D52610



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


[PATCH] D52949: [Diagnostics] Implement -Wsizeof-pointer-div

2018-10-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

ping


https://reviews.llvm.org/D52949



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


r344100 - clang: Allow ifunc resolvers to accept arguments

2018-10-09 Thread Ed Maste via cfe-commits
Author: emaste
Date: Tue Oct  9 17:34:17 2018
New Revision: 344100

URL: http://llvm.org/viewvc/llvm-project?rev=344100&view=rev
Log:
clang: Allow ifunc resolvers to accept arguments

When ifunc support was added to Clang (r265917) it did not allow
resolvers to take function arguments.  This was based on GCC's
documentation, which states resolvers return a pointer and take no
arguments.

However, GCC actually allows resolvers to take arguments, and glibc (on
non-x86 platforms) and FreeBSD (on x86 and arm64) pass some CPU
identification information as arguments to ifunc resolvers.  I believe
GCC's documentation is simply incorrect / out-of-date.

FreeBSD already removed the prohibition in their in-tree Clang copy.

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

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/Sema/attr-ifunc.c

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Oct  9 17:34:17 2018
@@ -3428,7 +3428,7 @@ def IFuncDocs : Documentation {
   let Content = [{
 ``__attribute__((ifunc("resolver")))`` is used to mark that the address of a 
declaration should be resolved at runtime by calling a resolver function.
 
-The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should take no arguments and return a 
pointer.
+The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should return a pointer.
 
 The ``ifunc`` attribute may only be used on a function declaration.  A 
function declaration with an ``ifunc`` attribute is considered to be a 
definition of the declared entity.  The entity must not have weak linkage; for 
example, in C++, it cannot be applied to a declaration if a definition at that 
location would be considered inline.
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct  9 17:34:17 
2018
@@ -2889,8 +2889,6 @@ def err_cyclic_alias : Error<
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<
   "ifunc resolver function must return a pointer">;
-def err_ifunc_resolver_params : Error<
-  "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type_str : Warning<
   "%0 attribute only applies to %1">, InGroup;
 def err_attribute_wrong_decl_type_str : Error<

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Oct  9 17:34:17 2018
@@ -322,8 +322,6 @@ void CodeGenModule::checkAliases() {
   assert(FTy);
   if (!FTy->getReturnType()->isPointerTy())
 Diags.Report(Location, diag::err_ifunc_resolver_return);
-  if (FTy->getNumParams())
-Diags.Report(Location, diag::err_ifunc_resolver_params);
 }
 
 llvm::Constant *Aliasee = Alias->getIndirectSymbol();

Modified: cfe/trunk/test/Sema/attr-ifunc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-ifunc.c?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/test/Sema/attr-ifunc.c (original)
+++ cfe/trunk/test/Sema/attr-ifunc.c Tue Oct  9 17:34:17 2018
@@ -27,10 +27,6 @@ void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
 //expected-error@-1 {{ifunc resolver function must return a pointer}}
 
-void* f5_ifunc(int i) { return 0; }
-void f5() __attribute__((ifunc("f5_ifunc")));
-//expected-error@-1 {{ifunc resolver function must have no parameters}}
-
 #else
 void f1a() __asm("f1");
 void f1a() {}


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


[PATCH] D52703: Allow ifunc resolvers to accept arguments

2018-10-09 Thread Ed Maste via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344100: clang: Allow ifunc resolvers to accept arguments 
(authored by emaste, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D52703

Files:
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenModule.cpp
  test/Sema/attr-ifunc.c


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2889,8 +2889,6 @@
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<
   "ifunc resolver function must return a pointer">;
-def err_ifunc_resolver_params : Error<
-  "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type_str : Warning<
   "%0 attribute only applies to %1">, InGroup;
 def err_attribute_wrong_decl_type_str : Error<
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3428,7 +3428,7 @@
   let Content = [{
 ``__attribute__((ifunc("resolver")))`` is used to mark that the address of a 
declaration should be resolved at runtime by calling a resolver function.
 
-The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should take no arguments and return a 
pointer.
+The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should return a pointer.
 
 The ``ifunc`` attribute may only be used on a function declaration.  A 
function declaration with an ``ifunc`` attribute is considered to be a 
definition of the declared entity.  The entity must not have weak linkage; for 
example, in C++, it cannot be applied to a declaration if a definition at that 
location would be considered inline.
 
Index: test/Sema/attr-ifunc.c
===
--- test/Sema/attr-ifunc.c
+++ test/Sema/attr-ifunc.c
@@ -27,10 +27,6 @@
 void f4() __attribute__((ifunc("f4_ifunc")));
 //expected-error@-1 {{ifunc resolver function must return a pointer}}
 
-void* f5_ifunc(int i) { return 0; }
-void f5() __attribute__((ifunc("f5_ifunc")));
-//expected-error@-1 {{ifunc resolver function must have no parameters}}
-
 #else
 void f1a() __asm("f1");
 void f1a() {}
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -322,8 +322,6 @@
   assert(FTy);
   if (!FTy->getReturnType()->isPointerTy())
 Diags.Report(Location, diag::err_ifunc_resolver_return);
-  if (FTy->getNumParams())
-Diags.Report(Location, diag::err_ifunc_resolver_params);
 }
 
 llvm::Constant *Aliasee = Alias->getIndirectSymbol();


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2889,8 +2889,6 @@
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<
   "ifunc resolver function must return a pointer">;
-def err_ifunc_resolver_params : Error<
-  "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type_str : Warning<
   "%0 attribute only applies to %1">, InGroup;
 def err_attribute_wrong_decl_type_str : Error<
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3428,7 +3428,7 @@
   let Content = [{
 ``__attribute__((ifunc("resolver")))`` is used to mark that the address of a declaration should be resolved at runtime by calling a resolver function.
 
-The symbol name of the resolver function is given in quotes.  A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``.  The resolver function should take no arguments and return a pointer.
+The symbol name of the resolver function is given in quotes.  A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``.  The resolver function should return a pointer.
 
 The ``ifunc`` attribute may only be used on a function declaration.  A function declaration with an ``ifunc`` attribute is considered to be a definition of the declared entity.  The entity must not have weak linkage; for example, in C++, it cannot be applied to a declaration if a definition at that location w

  1   2   >