[PATCH] D45835: Add new driver mode for dumping compiler options

2018-04-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D45835#1073883, @efriedma wrote:

> > If any of those options we care about wind up being changed, there's a good 
> > chance we may need to change something on our end anyway, so breaking us is 
> > actually useful.
>
> I'm not sure I follow.  The language options have specific consequences you 
> could check some other way, so they're "stable" in the sense that the same 
> flags will produce the same result (e.g. LangOpts.FastMath represents whether 
> __FAST_MATH__ is defined).  So it should be possible to provide the data 
> somehow; I'm more concerned about taking names and enum values from 
> LangOptions.def itself.


When a name or enum value from LangOptions.def changes, that generally signals 
some behavior may have changed (we don't often rename things just for the sake 
of renaming them, but that seems a less likely scenario) and we might want to 
react to that in our product. That's why the list of names from LangOptions.def 
directly is somewhat of a benefit (but it is not a design requirement).

How do you envision surfacing a list of language options that isn't tied to 
values from LangOptions.def itself? Would it still be tied in to the syntax in 
LangOptions.def (and others) so that there's not a substantial increase in 
maintenance burden when modifying options?


https://reviews.llvm.org/D45835



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


[PATCH] D45891: [clang-tidy] Improve bugprone-unused-return-value check

2018-04-23 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/D45891



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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-04-23 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

If anybody can land for me, I would appreciate. Thanks regardless :-)


Repository:
  rC Clang

https://reviews.llvm.org/D45177



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


[PATCH] D45319: [Atomics] warn about misaligned atomic accesses using libcalls

2018-04-23 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover updated this revision to Diff 143506.
t.p.northover added a comment.

Moved diagnostic emission next to where the decision is made.


Repository:
  rC Clang

https://reviews.llvm.org/D45319

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGAtomic.cpp
  clang/test/CodeGen/atomics-sema-alignment.c


Index: clang/test/CodeGen/atomics-sema-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/atomics-sema-alignment.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu %s -emit-llvm -o /dev/null -verify
+
+typedef struct {
+  int a, b;
+} IntPair;
+
+typedef struct {
+  long long a;
+} LongStruct;
+
+typedef int __attribute__((aligned(1))) unaligned_int;
+
+void func(IntPair *p) {
+  IntPair res;
+  __atomic_load(p, &res, 0); // expected-warning {{misaligned or large atomic 
operation may incur significant performance penalty}}
+  __atomic_store(p, &res, 0); // expected-warning {{misaligned or large atomic 
operation may incur significant performance penalty}}
+  __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning 
{{misaligned or large atomic operation may incur significant performance 
penalty}}
+  __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning 
{{misaligned or large atomic operation may incur significant performance 
penalty}}
+}
+
+void func1(LongStruct *p) {
+  LongStruct res;
+  __atomic_load(p, &res, 0);
+  __atomic_store(p, &res, 0);
+  __atomic_fetch_add((int *)p, 1, 2);
+  __atomic_fetch_sub((int *)p, 1, 3);
+}
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -18,6 +18,7 @@
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
@@ -751,19 +752,22 @@
   Address Dest = Address::invalid();
   Address Ptr = EmitPointerWithAlignment(E->getPtr());
 
+  if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
+  E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
+LValue lvalue = MakeAddrLValue(Ptr, AtomicTy);
+EmitAtomicInit(E->getVal1(), lvalue);
+return RValue::get(nullptr);
+  }
+
   CharUnits sizeChars, alignChars;
   std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
   uint64_t Size = sizeChars.getQuantity();
   unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
   bool UseLibcall = ((Ptr.getAlignment() % sizeChars) != 0 ||
  getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
-  if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
-  E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
-LValue lvalue = MakeAddrLValue(Ptr, AtomicTy);
-EmitAtomicInit(E->getVal1(), lvalue);
-return RValue::get(nullptr);
-  }
+  if (UseLibcall)
+CGM.getDiags().Report(E->getLocStart(), diag::warn_atomic_op_misaligned);
 
   llvm::Value *Order = EmitScalarExpr(E->getOrder());
   llvm::Value *Scope =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7111,6 +7111,9 @@
   InGroup>;
 def err_atomic_op_has_invalid_synch_scope : Error<
   "synchronization scope argument to atomic operation is invalid">;
+def warn_atomic_op_misaligned : Warning<
+  "misaligned or large atomic operation may incur significant performance 
penalty">,
+  InGroup>;
 
 def err_overflow_builtin_must_be_int : Error<
   "operand argument to overflow builtin must be an integer (%0 invalid)">;


Index: clang/test/CodeGen/atomics-sema-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/atomics-sema-alignment.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu %s -emit-llvm -o /dev/null -verify
+
+typedef struct {
+  int a, b;
+} IntPair;
+
+typedef struct {
+  long long a;
+} LongStruct;
+
+typedef int __attribute__((aligned(1))) unaligned_int;
+
+void func(IntPair *p) {
+  IntPair res;
+  __atomic_load(p, &res, 0); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}}
+  __atomic_store(p, &res, 0); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}}
+  __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}}
+  __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}}
+}
+
+void func1(LongStruct *p) {
+  LongStruct res;
+  __atomic_load(p, &res, 0);
+  __atomic_s

r330566 - [Atomics] warn about atomic accesses using libcalls

2018-04-23 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Mon Apr 23 01:16:24 2018
New Revision: 330566

URL: http://llvm.org/viewvc/llvm-project?rev=330566&view=rev
Log:
[Atomics] warn about atomic accesses using libcalls

If an atomic variable is misaligned (and that suspicion is why Clang emits
libcalls at all) the runtime support library will have to use a lock to safely
access it, with potentially very bad performance consequences. There's a very
good chance this is unintentional so it makes sense to issue a warning.

Also give it a named group so people can promote it to an error, or disable it
if they really don't care.

Added:
cfe/trunk/test/CodeGen/atomics-sema-alignment.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGAtomic.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=330566&r1=330565&r2=330566&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 23 01:16:24 
2018
@@ -7111,6 +7111,9 @@ def warn_atomic_op_has_invalid_memory_or
   InGroup>;
 def err_atomic_op_has_invalid_synch_scope : Error<
   "synchronization scope argument to atomic operation is invalid">;
+def warn_atomic_op_misaligned : Warning<
+  "misaligned or large atomic operation may incur significant performance 
penalty">,
+  InGroup>;
 
 def err_overflow_builtin_must_be_int : Error<
   "operand argument to overflow builtin must be an integer (%0 invalid)">;

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=330566&r1=330565&r2=330566&view=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Apr 23 01:16:24 2018
@@ -18,6 +18,7 @@
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
@@ -751,6 +752,13 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   Address Dest = Address::invalid();
   Address Ptr = EmitPointerWithAlignment(E->getPtr());
 
+  if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
+  E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
+LValue lvalue = MakeAddrLValue(Ptr, AtomicTy);
+EmitAtomicInit(E->getVal1(), lvalue);
+return RValue::get(nullptr);
+  }
+
   CharUnits sizeChars, alignChars;
   std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
   uint64_t Size = sizeChars.getQuantity();
@@ -758,12 +766,8 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   bool UseLibcall = ((Ptr.getAlignment() % sizeChars) != 0 ||
  getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
-  if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
-  E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
-LValue lvalue = MakeAddrLValue(Ptr, AtomicTy);
-EmitAtomicInit(E->getVal1(), lvalue);
-return RValue::get(nullptr);
-  }
+  if (UseLibcall)
+CGM.getDiags().Report(E->getLocStart(), diag::warn_atomic_op_misaligned);
 
   llvm::Value *Order = EmitScalarExpr(E->getOrder());
   llvm::Value *Scope =

Added: cfe/trunk/test/CodeGen/atomics-sema-alignment.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomics-sema-alignment.c?rev=330566&view=auto
==
--- cfe/trunk/test/CodeGen/atomics-sema-alignment.c (added)
+++ cfe/trunk/test/CodeGen/atomics-sema-alignment.c Mon Apr 23 01:16:24 2018
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu %s -emit-llvm -o /dev/null -verify
+
+typedef struct {
+  int a, b;
+} IntPair;
+
+typedef struct {
+  long long a;
+} LongStruct;
+
+typedef int __attribute__((aligned(1))) unaligned_int;
+
+void func(IntPair *p) {
+  IntPair res;
+  __atomic_load(p, &res, 0); // expected-warning {{misaligned or large atomic 
operation may incur significant performance penalty}}
+  __atomic_store(p, &res, 0); // expected-warning {{misaligned or large atomic 
operation may incur significant performance penalty}}
+  __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning 
{{misaligned or large atomic operation may incur significant performance 
penalty}}
+  __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning 
{{misaligned or large atomic operation may incur significant performance 
penalty}}
+}
+
+void func1(LongStruct *p) {
+  LongStruct res;
+  __atomic_load(p, &res, 0);
+  __atomic_store(p, &res, 0);
+  __atomic_fetch_add((int *)p, 1, 2);
+  __atomic_fetch_sub((int *)p, 1, 3);
+}


___
cfe-commits mailing

[PATCH] D45319: [Atomics] warn about misaligned atomic accesses using libcalls

2018-04-23 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover closed this revision.
t.p.northover added a comment.

Ah, I see you approved it before, presumably with the suggested changes. I've 
committed as r330566.


Repository:
  rC Clang

https://reviews.llvm.org/D45319



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


r330569 - Revert "[clang-format] Improve Incomplete detection for (text) protos"

2018-04-23 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Apr 23 01:50:36 2018
New Revision: 330569

URL: http://llvm.org/viewvc/llvm-project?rev=330569&view=rev
Log:
Revert "[clang-format] Improve Incomplete detection for (text) protos"

This reverts commit r330016.
The incomplete detection has too many false positives, picking up typos
for hard failures and refusing to format anything in that case.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=330569&r1=330568&r2=330569&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Apr 23 01:50:36 2018
@@ -592,8 +592,7 @@ private:
   return false;
   }
 }
-// There are no top-level unbalanced braces in text protos.
-return Style.Language != FormatStyle::LK_TextProto;
+return true;
   }
 
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
@@ -713,11 +712,6 @@ private:
   } else if (Contexts.back().ContextKind == tok::l_paren) {
 Tok->Type = TT_InlineASMColon;
   }
-  // Detects trailing pieces like key:
-  if ((Style.Language == FormatStyle::LK_Proto ||
-   Style.Language == FormatStyle::LK_TextProto) &&
-  !CurrentToken)
-return false;
   break;
 case tok::pipe:
 case tok::amp:
@@ -804,10 +798,6 @@ private:
   if (Previous && Previous->Type != TT_DictLiteral)
 Previous->Type = TT_SelectorName;
 }
-  } else if (Style.Language == FormatStyle::LK_TextProto ||
- Style.Language == FormatStyle::LK_Proto) {
-// In TT_Proto and TT_TextProto, tok::less cannot be a binary operator.
-return false;
   } else {
 Tok->Type = TT_BinaryOperator;
 NonTemplateLess.insert(Tok);
@@ -819,16 +809,13 @@ private:
 case tok::r_square:
   return false;
 case tok::r_brace:
-  // Lines can start with '}' except in text protos.
-  if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)
+  // Lines can start with '}'.
+  if (Tok->Previous)
 return false;
   break;
 case tok::greater:
-  // In protos and text protos tok::greater cannot be a binary operator.
-  if (Style.Language == FormatStyle::LK_Proto ||
-  Style.Language == FormatStyle::LK_TextProto)
-return false;
-  Tok->Type = TT_BinaryOperator;
+  if (Style.Language != FormatStyle::LK_TextProto)
+Tok->Type = TT_BinaryOperator;
   break;
 case tok::kw_operator:
   if (Style.Language == FormatStyle::LK_TextProto ||

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=330569&r1=330568&r2=330569&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Apr 23 01:50:36 2018
@@ -18,21 +18,13 @@ namespace clang {
 namespace format {
 
 class FormatTestProto : public ::testing::Test {
-  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete };
-
 protected:
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style,
-StatusCheck CheckComplete = SC_ExpectComplete) {
+unsigned Length, const FormatStyle &Style) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-FormattingAttemptStatus Status;
-tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &Status);
-bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
-EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
-<< Code << "\n\n";
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -49,12 +41,6 @@ protected:
 EXPECT_EQ(Code.str(), format(Code)) << "Expected code is not stable";
 EXPECT_EQ(Code.str(), format(test::messUp(Code)));
   }
-
-  static void verifyIncompleteFormat(llvm::StringRef Code) {
-FormatStyle Style = getGoogleStyle(FormatStyle::LK_Proto);
-EXPECT_EQ(Code.str(),
-  format(Code, 0, Code.size(), Style, SC_ExpectIncomplete));
-  }
 };
 
 TEST_F(FormatTestProto, FormatsMessages) {
@@ -506,12 +492,5 @@ TEST_F(FormatTestProto, AcceptsOperatorA
"};");
 }
 
-TEST_F(FormatTestProto, IncompleteFormat) {

[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-23 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

@george.karpenkov @NoQ `bugprone.` as a category sounds nice. It also nicely 
corresponds to the Clang-Tidy `bugprone-` category. It would not be nice to 
further fragment the "top levels" of checker categories.

I can say with confidence that CodeChecker does not break if the same category 
name is used by two different analyzers. Does the same stand for XCode / 
Scan-Build? In this case, introducing the `bugprone` category with the same 
principle that is behind Tidy's one is a good step.




Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:162
+/// We can't know the type of the region that a void pointer points to, so FD
+/// can't be analyzed if this function return true for it.
+bool isVoidPointer(const FieldDecl *FD);

george.karpenkov wrote:
> "returns"
Actually, this explanation is superfluous. I believe

Returns if FD can be (transitively) dereferenced to a void* (void**, ...). 
The type of the region behind a void pointer isn't known, and thus FD can not 
be analyzed.

should suffice?



Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:212
+
+  std::string WarningMsg = std::to_string(UninitFields.size()) +
+   " uninitialized field" +

george.karpenkov wrote:
> nitpicking: llvm::Twine is normally used for such constructs
I have also suggested the usage of Twine for this line (it's just the diff that 
got out of sync with the line numbers!), but I don't recall what @Szelethus' 
concern was about them. In case we have move semantics enabled, this line will 
compile into using the moving concatenator.


https://reviews.llvm.org/D45532



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


[PATCH] D45717: [clangd] Using index for GoToDefinition.

2018-04-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 143508.
hokein marked 7 inline comments as done.
hokein added a comment.

Refine the patch and address all review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45717

Files:
  clangd/ClangdServer.cpp
  clangd/XRefs.cpp
  clangd/XRefs.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -13,11 +13,13 @@
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "XRefs.h"
+#include "gmock/gmock.h"
+#include "index/SymbolCollector.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Frontend/Utils.h"
+#include "clang/Index/IndexingAction.h"
 #include "llvm/Support/Path.h"
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -37,17 +39,51 @@
 };
 
 // FIXME: this is duplicated with FileIndexTests. Share it.
-ParsedAST build(StringRef Code) {
-  auto CI = createInvocationFromCommandLine(
-  {"clang", "-xc++", testPath("Foo.cpp").c_str()});
-  auto Buf = MemoryBuffer::getMemBuffer(Code);
+ParsedAST build(StringRef MainCode, StringRef HeaderCode = "",
+StringRef BaseName = "Main",
+llvm::IntrusiveRefCntPtr
+InMemoryFileSystem = nullptr) {
+  auto HeaderPath = testPath((BaseName + ".h").str());
+  auto MainPath = testPath((BaseName + ".cpp").str());
+  if (!InMemoryFileSystem)
+InMemoryFileSystem = new vfs::InMemoryFileSystem();
+
+  std::vector Cmd = {"clang", "-xc++", MainPath.c_str()};
+  if (!HeaderCode.empty()) {
+InMemoryFileSystem->addFile(HeaderPath, 0,
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
+std::vector args = {"-include", HeaderPath.c_str()};
+Cmd.insert(Cmd.begin() + 1, args.begin(), args.end());
+  }
+
+  InMemoryFileSystem->addFile(MainPath, 0,
+  llvm::MemoryBuffer::getMemBuffer(MainCode));
+
+  auto CI = createInvocationFromCommandLine(Cmd);
+
+  auto Buf = MemoryBuffer::getMemBuffer(MainCode);
   auto AST = ParsedAST::Build(std::move(CI), nullptr, std::move(Buf),
   std::make_shared(),
-  vfs::getRealFileSystem());
+  InMemoryFileSystem);
   assert(AST.hasValue());
   return std::move(*AST);
 }
 
+std::unique_ptr buildIndexFromAST(ParsedAST *AST) {
+  SymbolCollector::Options CollectorOpts;
+  CollectorOpts.CollectIncludePath = false;
+  CollectorOpts.CountReferences = false;
+  index::IndexingOptions IndexOpts;
+  IndexOpts.SystemSymbolFilter =
+  index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly;
+  IndexOpts.IndexFunctionLocals = false;
+  auto Collector = std::make_shared(std::move(CollectorOpts));
+  Collector->setPreprocessor(AST->getPreprocessorPtr());
+  index::indexTopLevelDecls(AST->getASTContext(), AST->getTopLevelDecls(),
+Collector, IndexOpts);
+  return MemIndex::build(Collector->takeSymbols());
+}
+
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -106,6 +142,80 @@
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
 
+TEST(GoToDefinition, WithIndex) {
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+  Annotations SymbolHeader(R"cpp(
+class $forward[[Forward]];
+class $foo[[Foo]] {};
+
+void $f1[[f1]]();
+
+inline void $f2[[f2]]() {}
+  )cpp");
+  Annotations SymbolCpp(R"cpp(
+  class $forward[[forward]] {};
+  void  $f1[[f1]]() {}
+)cpp");
+
+  // Build index.
+  auto IndexAST = build(SymbolCpp.code(), SymbolHeader.code(), "symbol",
+InMemoryFileSystem);
+  auto Index = buildIndexFromAST(&IndexAST);
+
+  auto runFindDefinitionsWithIndex =
+  [&Index, &InMemoryFileSystem](const Annotations &Main) {
+auto AST = build(/*MainCode=*/Main.code(),
+ /*HeaderCode=*/"",
+ /*BasePath=*/"main", InMemoryFileSystem);
+return clangd::findDefinitions(AST, Main.point(), Index.get());
+  };
+
+  Annotations Test(R"cpp(// only declaration in AST.
+void [[f1]]();
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(SymbolCpp.range("f1")), RangeIs(Test.range())}));
+
+  Test = Annotations(R"cpp(// definition in AST.
+void [[f1]]() {}
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(Test.range()), RangeIs(SymbolHeader.range("f1"))}));
+
+  Test = Anno

[PATCH] D45717: [clangd] Using index for GoToDefinition.

2018-04-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

I have updated the patch according to offline discussion -- for each symbol, we 
will return both decl and def locations (if available, def first) as they seems 
to be most sensible to users. We always prefer location from AST over Index 
when conflicts.




Comment at: clangd/XRefs.cpp:261
+
+  for (auto It : ResultCandidates)
+Result.push_back(It.second);

sammccall wrote:
> Here we're returning exactly one candidate per symbol we identified as a 
> candidate. There are other choices - why this one?
Yeah, this was one **definition** location per  symbol, made a change according 
to our discussion.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45717



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Andrew V. Tischenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330571: Use special new Clang flag 
'FrontendTimesIsEnabled' instead of 'llvm… (authored by avt77, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45619?vs=143311&id=143511#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45619

Files:
  cfe/trunk/include/clang/Frontend/Utils.h
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/lib/Frontend/CMakeLists.txt
  cfe/trunk/lib/Frontend/FrontendTiming.cpp
  cfe/trunk/test/Frontend/ftime-report-template-decl.cpp

Index: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp
@@ -126,7 +126,7 @@
   Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
-  llvm::TimePassesIsEnabled = TimePasses;
+  FrontendTimesIsEnabled = TimePasses;
 }
 llvm::Module *getModule() const { return Gen->GetModule(); }
 std::unique_ptr takeModule() {
@@ -144,12 +144,12 @@
 
   Context = &Ctx;
 
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.startTimer();
 
   Gen->Initialize(Ctx);
 
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
 
@@ -159,15 +159,15 @@
  "LLVM IR generation of declaration");
 
   // Recurse.
-  if (llvm::TimePassesIsEnabled) {
+  if (FrontendTimesIsEnabled) {
 LLVMIRGenerationRefCount += 1;
 if (LLVMIRGenerationRefCount == 1)
   LLVMIRGeneration.startTimer();
   }
 
   Gen->HandleTopLevelDecl(D);
 
-  if (llvm::TimePassesIsEnabled) {
+  if (FrontendTimesIsEnabled) {
 LLVMIRGenerationRefCount -= 1;
 if (LLVMIRGenerationRefCount == 0)
   LLVMIRGeneration.stopTimer();
@@ -180,12 +180,12 @@
   PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
  Context->getSourceManager(),
  "LLVM IR generation of inline function");
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.startTimer();
 
   Gen->HandleInlineFunctionDefinition(D);
 
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
 
@@ -227,15 +227,15 @@
 void HandleTranslationUnit(ASTContext &C) override {
   {
 PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
-if (llvm::TimePassesIsEnabled) {
+if (FrontendTimesIsEnabled) {
   LLVMIRGenerationRefCount += 1;
   if (LLVMIRGenerationRefCount == 1)
 LLVMIRGeneration.startTimer();
 }
 
 Gen->HandleTranslationUnit(C);
 
-if (llvm::TimePassesIsEnabled) {
+if (FrontendTimesIsEnabled) {
   LLVMIRGenerationRefCount -= 1;
   if (LLVMIRGenerationRefCount == 0)
 LLVMIRGeneration.stopTimer();
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -728,7 +728,7 @@
 
 void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
   std::unique_ptr OS) {
-  TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr);
+  TimeRegion Region(FrontendTimesIsEnabled ? &CodeGenerationTime : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
 
@@ -858,7 +858,7 @@
 /// `EmitAssembly` at some point in the future when the default switches.
 void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 BackendAction Action, std::unique_ptr OS) {
-  TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr);
+  TimeRegion Region(FrontendTimesIsEnabled ? &CodeGenerationTime : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
   // The new pass manager always makes a target machine available to passes
Index: cfe/trunk/lib/Frontend/CMakeLists.txt
===
--- cfe/trunk/lib/Frontend/CMakeLists.txt
+++ cfe/trunk/lib/Frontend/CMakeLists.txt
@@ -29,6 +29,7 @@
   FrontendAction.cpp
   FrontendActions.cpp
   FrontendOptions.cpp
+  FrontendTiming.cpp
   HeaderIncludeGen.cpp
   InitHeaderSearch.cpp
   InitPreprocessor.cpp
Index: cfe/trunk/lib/Frontend/FrontendTiming.cpp
===
--- cfe/trunk/lib/Frontend/FrontendTiming.cpp
+++ cfe/trunk/lib/Frontend/FrontendTiming.cpp
@@ -0,0 +1,20 @@
+//===- FronendTiming.cpp - Implements Frontend timing utils

r330571 - Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature.

2018-04-23 Thread Andrew V. Tischenko via cfe-commits
Author: avt77
Date: Mon Apr 23 02:22:30 2018
New Revision: 330571

URL: http://llvm.org/viewvc/llvm-project?rev=330571&view=rev
Log:
Use special new Clang flag 'FrontendTimesIsEnabled' instead of 
'llvm::TimePassesIsEnabled' inside -ftime-report feature.
Differential Revision: https://reviews.llvm.org/D45619

Added:
cfe/trunk/lib/Frontend/FrontendTiming.cpp
cfe/trunk/test/Frontend/ftime-report-template-decl.cpp
Modified:
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=330571&r1=330570&r2=330571&view=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Mon Apr 23 02:22:30 2018
@@ -234,6 +234,12 @@ template  void BuryPointer(s
   BuryPointer(Ptr.release());
 }
 
+// Frontend timing utils
+
+/// If the user specifies the -ftime-report argument on an Clang command line
+/// then the value of this boolean will be true, otherwise false.
+extern bool FrontendTimesIsEnabled;
+
 } // namespace clang
 
 #endif // LLVM_CLANG_FRONTEND_UTILS_H

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=330571&r1=330570&r2=330571&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Apr 23 02:22:30 2018
@@ -728,7 +728,7 @@ bool EmitAssemblyHelper::AddEmitPasses(l
 
 void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
   std::unique_ptr OS) {
-  TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr);
+  TimeRegion Region(FrontendTimesIsEnabled ? &CodeGenerationTime : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
 
@@ -858,7 +858,7 @@ static PassBuilder::OptimizationLevel ma
 /// `EmitAssembly` at some point in the future when the default switches.
 void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 BackendAction Action, std::unique_ptr OS) {
-  TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr);
+  TimeRegion Region(FrontendTimesIsEnabled ? &CodeGenerationTime : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
   // The new pass manager always makes a target machine available to passes

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=330571&r1=330570&r2=330571&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Apr 23 02:22:30 2018
@@ -126,7 +126,7 @@ namespace clang {
   Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
-  llvm::TimePassesIsEnabled = TimePasses;
+  FrontendTimesIsEnabled = TimePasses;
 }
 llvm::Module *getModule() const { return Gen->GetModule(); }
 std::unique_ptr takeModule() {
@@ -144,12 +144,12 @@ namespace clang {
 
   Context = &Ctx;
 
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.startTimer();
 
   Gen->Initialize(Ctx);
 
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
 
@@ -159,7 +159,7 @@ namespace clang {
  "LLVM IR generation of declaration");
 
   // Recurse.
-  if (llvm::TimePassesIsEnabled) {
+  if (FrontendTimesIsEnabled) {
 LLVMIRGenerationRefCount += 1;
 if (LLVMIRGenerationRefCount == 1)
   LLVMIRGeneration.startTimer();
@@ -167,7 +167,7 @@ namespace clang {
 
   Gen->HandleTopLevelDecl(D);
 
-  if (llvm::TimePassesIsEnabled) {
+  if (FrontendTimesIsEnabled) {
 LLVMIRGenerationRefCount -= 1;
 if (LLVMIRGenerationRefCount == 0)
   LLVMIRGeneration.stopTimer();
@@ -180,12 +180,12 @@ namespace clang {
   PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
  Context->getSourceManager(),
  "LLVM IR generation of inline function");
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.startTimer();
 
   Gen->HandleInlineFunctionDefinition(D);
 
-  if (llvm::TimePassesIsEnabled)
+  if (FrontendTimesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
 
@@ -227,7 +227,7 @@ namespace clang {
 void HandleTranslationUnit(ASTContext &C) override {

[PATCH] D41240: [Solaris] __float128 is supported on Solaris/x86

2018-04-23 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330572: [Solaris] __float128 is supported on Solaris/x86 
(authored by ro, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D41240?vs=127348&id=143514#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41240

Files:
  cfe/trunk/lib/Basic/Targets/OSTargets.h
  cfe/trunk/test/CodeGenCXX/float128-declarations.cpp


Index: cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
===
--- cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
+++ cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
@@ -12,6 +12,10 @@
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 // RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple i386-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 //
 /*  Various contexts where type __float128 can appear. The different check
 prefixes are due to different mangling on X86 and different calling
Index: cfe/trunk/lib/Basic/Targets/OSTargets.h
===
--- cfe/trunk/lib/Basic/Targets/OSTargets.h
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h
@@ -552,12 +552,22 @@
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");
 Builder.defineMacro("_REENTRANT");
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
   }
 
 public:
   SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 // FIXME: WIntType should be SignedLong
+switch (Triple.getArch()) {
+default:
+  break;
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
+  break;
+}
   }
 };
 


Index: cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
===
--- cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
+++ cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
@@ -12,6 +12,10 @@
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 // RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple i386-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 //
 /*  Various contexts where type __float128 can appear. The different check
 prefixes are due to different mangling on X86 and different calling
Index: cfe/trunk/lib/Basic/Targets/OSTargets.h
===
--- cfe/trunk/lib/Basic/Targets/OSTargets.h
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h
@@ -552,12 +552,22 @@
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");
 Builder.defineMacro("_REENTRANT");
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
   }
 
 public:
   SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 // FIXME: WIntType should be SignedLong
+switch (Triple.getArch()) {
+default:
+  break;
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
+  break;
+}
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45726: Format closing braces when reformatting the line containing theopening brace.

2018-04-23 Thread Manuel Klimek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330573: Format closing braces when reformatting the line 
containing the opening brace. (authored by klimek, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45726

Files:
  cfe/trunk/lib/Format/AffectedRangeManager.cpp
  cfe/trunk/lib/Format/AffectedRangeManager.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
  cfe/trunk/lib/Format/SortJavaScriptImports.cpp
  cfe/trunk/lib/Format/TokenAnnotator.h
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.h
  cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
  cfe/trunk/unittests/Format/FormatTestSelective.cpp

Index: cfe/trunk/lib/Format/AffectedRangeManager.h
===
--- cfe/trunk/lib/Format/AffectedRangeManager.h
+++ cfe/trunk/lib/Format/AffectedRangeManager.h
@@ -30,10 +30,9 @@
   : SourceMgr(SourceMgr), Ranges(Ranges.begin(), Ranges.end()) {}
 
   // Determines which lines are affected by the SourceRanges given as input.
-  // Returns \c true if at least one line between I and E or one of their
+  // Returns \c true if at least one line in \p Lines or one of their
   // children is affected.
-  bool computeAffectedLines(SmallVectorImpl::iterator I,
-SmallVectorImpl::iterator E);
+  bool computeAffectedLines(SmallVectorImpl &Lines);
 
   // Returns true if 'Range' intersects with one of the input ranges.
   bool affectsCharSourceRange(const CharSourceRange &Range);
@@ -54,8 +53,8 @@
 
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.
-  bool nonPPLineAffected(AnnotatedLine *Line,
- const AnnotatedLine *PreviousLine);
+  bool nonPPLineAffected(AnnotatedLine *Line, const AnnotatedLine *PreviousLine,
+ SmallVectorImpl &Lines);
 
   const SourceManager &SourceMgr;
   const SmallVector Ranges;
Index: cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
===
--- cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
+++ cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
@@ -187,8 +187,7 @@
 TokenAnnotator &Annotator, SmallVectorImpl &AnnotatedLines,
 FormatTokenLexer &Tokens) {
   const SourceManager &SourceMgr = Env.getSourceManager();
-  AffectedRangeMgr.computeAffectedLines(AnnotatedLines.begin(),
-AnnotatedLines.end());
+  AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
   tooling::Replacements Fixes;
   SmallVector UsingDeclarations;
   for (size_t I = 0, E = AnnotatedLines.size(); I != E; ++I) {
Index: cfe/trunk/lib/Format/TokenAnnotator.h
===
--- cfe/trunk/lib/Format/TokenAnnotator.h
+++ cfe/trunk/lib/Format/TokenAnnotator.h
@@ -40,6 +40,7 @@
   AnnotatedLine(const UnwrappedLine &Line)
   : First(Line.Tokens.front().Tok), Level(Line.Level),
 MatchingOpeningBlockLineIndex(Line.MatchingOpeningBlockLineIndex),
+MatchingClosingBlockLineIndex(Line.MatchingClosingBlockLineIndex),
 InPPDirective(Line.InPPDirective),
 MustBeDeclaration(Line.MustBeDeclaration), MightBeFunctionDecl(false),
 IsMultiVariableDeclStmt(false), Affected(false),
@@ -112,6 +113,7 @@
   LineType Type;
   unsigned Level;
   size_t MatchingOpeningBlockLineIndex;
+  size_t MatchingClosingBlockLineIndex;
   bool InPPDirective;
   bool MustBeDeclaration;
   bool MightBeFunctionDecl;
Index: cfe/trunk/lib/Format/AffectedRangeManager.cpp
===
--- cfe/trunk/lib/Format/AffectedRangeManager.cpp
+++ cfe/trunk/lib/Format/AffectedRangeManager.cpp
@@ -21,8 +21,9 @@
 namespace format {
 
 bool AffectedRangeManager::computeAffectedLines(
-SmallVectorImpl::iterator I,
-SmallVectorImpl::iterator E) {
+SmallVectorImpl &Lines) {
+  SmallVectorImpl::iterator I = Lines.begin();
+  SmallVectorImpl::iterator E = Lines.end();
   bool SomeLineAffected = false;
   const AnnotatedLine *PreviousLine = nullptr;
   while (I != E) {
@@ -48,7 +49,7 @@
   continue;
 }
 
-if (nonPPLineAffected(Line, PreviousLine))
+if (nonPPLineAffected(Line, PreviousLine, Lines))
   SomeLineAffected = true;
 
 PreviousLine = Line;
@@ -99,10 +100,10 @@
 }
 
 bool AffectedRangeManager::nonPPLineAffected(
-AnnotatedLine *Line, const AnnotatedLine *PreviousLine) {
+AnnotatedLine *Line, const AnnotatedLine *PreviousLine,
+SmallVectorImpl &Lines) {
   bool SomeLineAffected = false;
-  Line->ChildrenAffected =
-  computeAffectedLines(Line->Children.begin(), Line->Children.end());
+  Line->ChildrenAffected = computeAffectedL

r330573 - Format closing braces when reformatting the line containing the opening brace.

2018-04-23 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Mon Apr 23 02:34:26 2018
New Revision: 330573

URL: http://llvm.org/viewvc/llvm-project?rev=330573&view=rev
Log:
Format closing braces when reformatting the line containing the opening brace.

This required a couple of yaks to be shaved:
1. MatchingOpeningBlockLineIndex was misused to also store the
   closing index; instead, use a second variable, as this doesn't
   work correctly for "} else {".
2. We needed to change the API of AffectedRangeManager to not
   use iterators; we always passed in begin / end for the whole
   container before, so there was no mismatch in generality.
3. We need an extra check to discontinue formatting at the top
   level, as we now sometimes change the indent of the closing
   brace, but want to bail out immediately afterwards, for
   example:
 void f() {
   if (a) {
 }
 void g();
   Previously:
 void f() {
   if (a) {
 }
 void g();
   Now:
 void f() {
   if (a) {
   }
 void g();

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

Modified:
cfe/trunk/lib/Format/AffectedRangeManager.cpp
cfe/trunk/lib/Format/AffectedRangeManager.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
cfe/trunk/lib/Format/SortJavaScriptImports.cpp
cfe/trunk/lib/Format/TokenAnnotator.h
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/lib/Format/AffectedRangeManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/AffectedRangeManager.cpp?rev=330573&r1=330572&r2=330573&view=diff
==
--- cfe/trunk/lib/Format/AffectedRangeManager.cpp (original)
+++ cfe/trunk/lib/Format/AffectedRangeManager.cpp Mon Apr 23 02:34:26 2018
@@ -21,8 +21,9 @@ namespace clang {
 namespace format {
 
 bool AffectedRangeManager::computeAffectedLines(
-SmallVectorImpl::iterator I,
-SmallVectorImpl::iterator E) {
+SmallVectorImpl &Lines) {
+  SmallVectorImpl::iterator I = Lines.begin();
+  SmallVectorImpl::iterator E = Lines.end();
   bool SomeLineAffected = false;
   const AnnotatedLine *PreviousLine = nullptr;
   while (I != E) {
@@ -48,7 +49,7 @@ bool AffectedRangeManager::computeAffect
   continue;
 }
 
-if (nonPPLineAffected(Line, PreviousLine))
+if (nonPPLineAffected(Line, PreviousLine, Lines))
   SomeLineAffected = true;
 
 PreviousLine = Line;
@@ -99,10 +100,10 @@ void AffectedRangeManager::markAllAsAffe
 }
 
 bool AffectedRangeManager::nonPPLineAffected(
-AnnotatedLine *Line, const AnnotatedLine *PreviousLine) {
+AnnotatedLine *Line, const AnnotatedLine *PreviousLine,
+SmallVectorImpl &Lines) {
   bool SomeLineAffected = false;
-  Line->ChildrenAffected =
-  computeAffectedLines(Line->Children.begin(), Line->Children.end());
+  Line->ChildrenAffected = computeAffectedLines(Line->Children);
   if (Line->ChildrenAffected)
 SomeLineAffected = true;
 
@@ -138,8 +139,13 @@ bool AffectedRangeManager::nonPPLineAffe
   Line->First->NewlinesBefore < 2 && PreviousLine &&
   PreviousLine->Affected && PreviousLine->Last->is(tok::comment);
 
+  bool IsAffectedClosingBrace =
+  Line->First->is(tok::r_brace) &&
+  Line->MatchingOpeningBlockLineIndex != UnwrappedLine::kInvalidIndex &&
+  Lines[Line->MatchingOpeningBlockLineIndex]->Affected;
+
   if (SomeTokenAffected || SomeFirstChildAffected || LineMoved ||
-  IsContinuedComment) {
+  IsContinuedComment || IsAffectedClosingBrace) {
 Line->Affected = true;
 SomeLineAffected = true;
   }

Modified: cfe/trunk/lib/Format/AffectedRangeManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/AffectedRangeManager.h?rev=330573&r1=330572&r2=330573&view=diff
==
--- cfe/trunk/lib/Format/AffectedRangeManager.h (original)
+++ cfe/trunk/lib/Format/AffectedRangeManager.h Mon Apr 23 02:34:26 2018
@@ -30,10 +30,9 @@ public:
   : SourceMgr(SourceMgr), Ranges(Ranges.begin(), Ranges.end()) {}
 
   // Determines which lines are affected by the SourceRanges given as input.
-  // Returns \c true if at least one line between I and E or one of their
+  // Returns \c true if at least one line in \p Lines or one of their
   // children is affected.
-  bool computeAffectedLines(SmallVectorImpl::iterator I,
-SmallVectorImpl::iterator E);
+  bool computeAffectedLines(SmallVectorImpl &Lines);
 
   // Returns true if 'Range' intersects with one of the input ranges.
   bool affectsCharSourceRange(const CharSourceRange &Range);
@@ -54,8 +53,8 @@ private:
 
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line o

r330574 - [clang-format] Fix clang-tidy readability problems, NFCI

2018-04-23 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Apr 23 03:02:59 2018
New Revision: 330574

URL: http://llvm.org/viewvc/llvm-project?rev=330574&view=rev
Log:
[clang-format] Fix clang-tidy readability problems, NFCI

Modified:
cfe/trunk/lib/Format/BreakableToken.h
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
cfe/trunk/lib/Format/TokenAnnotator.h

Modified: cfe/trunk/lib/Format/BreakableToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.h?rev=330574&r1=330573&r2=330574&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.h (original)
+++ cfe/trunk/lib/Format/BreakableToken.h Mon Apr 23 03:02:59 2018
@@ -242,7 +242,7 @@ public:
  encoding::Encoding Encoding, const FormatStyle 
&Style);
 
   Split getSplit(unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit,
- unsigned ReflowColumn,
+ unsigned ContentStartColumn,
  llvm::Regex &CommentPragmasRegex) const override;
   void insertBreak(unsigned LineIndex, unsigned TailOffset, Split Split,
WhitespaceManager &Whitespaces) const override;
@@ -284,7 +284,7 @@ public:
   bool supportsReflow() const override { return true; }
   unsigned getLineCount() const override;
   Split getSplit(unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit,
- unsigned ReflowColumn,
+ unsigned ContentStartColumn,
  llvm::Regex &CommentPragmasRegex) const override;
   void compressWhitespace(unsigned LineIndex, unsigned TailOffset, Split Split,
   WhitespaceManager &Whitespaces) const override;

Modified: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp?rev=330574&r1=330573&r2=330574&view=diff
==
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp (original)
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp Mon Apr 23 03:02:59 2018
@@ -110,11 +110,11 @@ void updateEndComment(const FormatToken
 } // namespace
 
 const FormatToken *
-getNamespaceToken(const AnnotatedLine *line,
+getNamespaceToken(const AnnotatedLine *Line,
   const SmallVectorImpl &AnnotatedLines) {
-  if (!line->Affected || line->InPPDirective || 
!line->startsWith(tok::r_brace))
+  if (!Line->Affected || Line->InPPDirective || 
!Line->startsWith(tok::r_brace))
 return nullptr;
-  size_t StartLineIndex = line->MatchingOpeningBlockLineIndex;
+  size_t StartLineIndex = Line->MatchingOpeningBlockLineIndex;
   if (StartLineIndex == UnwrappedLine::kInvalidIndex)
 return nullptr;
   assert(StartLineIndex < AnnotatedLines.size());

Modified: cfe/trunk/lib/Format/TokenAnnotator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.h?rev=330574&r1=330573&r2=330574&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.h (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.h Mon Apr 23 03:02:59 2018
@@ -161,7 +161,7 @@ private:
   bool spaceRequiredBetween(const AnnotatedLine &Line, const FormatToken &Left,
 const FormatToken &Right);
 
-  bool spaceRequiredBefore(const AnnotatedLine &Line, const FormatToken &Tok);
+  bool spaceRequiredBefore(const AnnotatedLine &Line, const FormatToken 
&Right);
 
   bool mustBreakBefore(const AnnotatedLine &Line, const FormatToken &Right);
 


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


r330575 - [CodeGen] Reland r330442: Add an option to suppress output of llvm.ident

2018-04-23 Thread Mikhail Maltsev via cfe-commits
Author: miyuki
Date: Mon Apr 23 03:08:46 2018
New Revision: 330575

URL: http://llvm.org/viewvc/llvm-project?rev=330575&view=rev
Log:
[CodeGen] Reland r330442: Add an option to suppress output of llvm.ident

The test case in the original patch was overly contrained and
failed on PPC targets.

Added:
cfe/trunk/test/CodeGen/no-ident-version.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330575&r1=330574&r2=330575&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Apr 23 03:08:46 2018
@@ -396,7 +396,10 @@ def O_flag : Flag<["-"], "O">, Flags<[CC
 def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>;
 def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group,
   HelpText<"Disable linemarker output in -E mode">;
-def Qn : Flag<["-"], "Qn">, IgnoredGCCCompat;
+def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>,
+  HelpText<"Emit metadata containing compiler name and version">;
+def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>,
+  HelpText<"Do not emit metadata containing compiler name and version">;
 def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, 
CoreOption]>,
   HelpText<"Don't emit warning for unused driver arguments">;
 def Q : Flag<["-"], "Q">, IgnoredGCCCompat;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=330575&r1=330574&r2=330575&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Apr 23 03:08:46 2018
@@ -69,6 +69,7 @@ CODEGENOPT(EmitDeclMetadata  , 1, 0) ///
  ///< Decl* various IR entities came from.
  ///< Only useful when running CodeGen as a
  ///< subroutine.
+CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version 
metadata.
 CODEGENOPT(EmitGcovArcs  , 1, 0) ///< Emit coverage data files, aka. GCDA.
 CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka 
GCNO.
 CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=330575&r1=330574&r2=330575&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 23 03:08:46 2018
@@ -577,7 +577,8 @@ void CGDebugInfo::CreateCompileUnit() {
   remapDIPath(getCurrentDirname()),
   CSInfo,
   getSource(SM, SM.getMainFileID())),
-  Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
+  CGOpts.EmitVersionIdentMetadata ? Producer : "",
+  LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
   CGOpts.DwarfDebugFlags, RuntimeVers,
   CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind,
   0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=330575&r1=330574&r2=330575&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Apr 23 03:08:46 2018
@@ -571,7 +571,8 @@ void CodeGenModule::Release() {
   if (DebugInfo)
 DebugInfo->finalize();
 
-  EmitVersionIdentMetadata();
+  if (getCodeGenOpts().EmitVersionIdentMetadata)
+EmitVersionIdentMetadata();
 
   EmitTargetMetadata();
 }

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=330575&r1=330574&r2=330575&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Apr 23 03:08:46 2018
@@ -4408,6 +4408,9 @@ void Clang::ConstructJob(Compilation &C,
 }
   }
 
+  if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true))
+CmdArgs.push_back("-Qn");
+
   // -fcommon is the default unless compiling kernel

[PATCH] D45944: Disallow pointers to const in __sync_fetch_and_xxx

2018-04-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie.

The following code is currently accepted without a diagnostic when it should be 
prohibited:

  void f(const int *ptr) {
__sync_fetch_and_add(ptr, 1);
  }

NB: the above code is diagnosed by GCC and ICC. However, Clang attempts to 
modify the underlying object, which seems dangerous.


https://reviews.llvm.org/D45944

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/builtins.c


Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,7 @@
 
 return buf;
 }
+
+void test21(const int *ptr) {
+  __sync_fetch_and_add(ptr, 1); // expected-error{{address argument to atomic 
builtin cannot be const-qualified ('const int *' invalid)}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3428,6 +3428,12 @@
 return ExprError();
   }
 
+  if (ValType.isConstQualified()) {
+Diag(DRE->getLocStart(), diag::err_atomic_builtin_cannot_be_const)
+<< FirstArg->getType() << FirstArg->getSourceRange();
+return ExprError();
+  }
+
   switch (ValType.getObjCLifetime()) {
   case Qualifiers::OCL_None:
   case Qualifiers::OCL_ExplicitNone:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7079,6 +7079,8 @@
 def err_atomic_builtin_must_be_pointer_intptr : Error<
   "address argument to atomic builtin must be a pointer to integer or pointer"
   " (%0 invalid)">;
+def err_atomic_builtin_cannot_be_const : Error<
+  "address argument to atomic builtin cannot be const-qualified (%0 invalid)">;
 def err_atomic_builtin_must_be_pointer_intfltptr : Error<
   "address argument to atomic builtin must be a pointer to integer,"
   " floating-point or pointer (%0 invalid)">;


Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,7 @@
 
 return buf;
 }
+
+void test21(const int *ptr) {
+  __sync_fetch_and_add(ptr, 1); // expected-error{{address argument to atomic builtin cannot be const-qualified ('const int *' invalid)}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3428,6 +3428,12 @@
 return ExprError();
   }
 
+  if (ValType.isConstQualified()) {
+Diag(DRE->getLocStart(), diag::err_atomic_builtin_cannot_be_const)
+<< FirstArg->getType() << FirstArg->getSourceRange();
+return ExprError();
+  }
+
   switch (ValType.getObjCLifetime()) {
   case Qualifiers::OCL_None:
   case Qualifiers::OCL_ExplicitNone:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7079,6 +7079,8 @@
 def err_atomic_builtin_must_be_pointer_intptr : Error<
   "address argument to atomic builtin must be a pointer to integer or pointer"
   " (%0 invalid)">;
+def err_atomic_builtin_cannot_be_const : Error<
+  "address argument to atomic builtin cannot be const-qualified (%0 invalid)">;
 def err_atomic_builtin_must_be_pointer_intfltptr : Error<
   "address argument to atomic builtin must be a pointer to integer,"
   " floating-point or pointer (%0 invalid)">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330572 - [Solaris] __float128 is supported on Solaris/x86

2018-04-23 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Apr 23 02:28:08 2018
New Revision: 330572

URL: http://llvm.org/viewvc/llvm-project?rev=330572&view=rev
Log:
[Solaris] __float128 is supported on Solaris/x86

When rebasing https://reviews.llvm.org/D40898 with GCC 5.4 on Solaris 11.4, I 
ran
into a few instances of

In file included from 
/vol/llvm/src/compiler-rt/local/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc:19:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/string:40:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/char_traits.h:39:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/stl_algobase.h:64:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/stl_pair.h:59:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/move.h:57:
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/type_traits:311:39:
 error: __float128 is not supported on this target

  struct __is_floating_point_helper<__float128>
^

during make check-all.  The line above is inside

#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)

  template<>
struct __is_floating_point_helper<__float128>
: public true_type { };

#endif

While the libstdc++ header indicates support for __float128, clang does not, but
should.  The following patch implements this and fixed those errors.

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

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/CodeGenCXX/float128-declarations.cpp

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=330572&r1=330571&r2=330572&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Mon Apr 23 02:28:08 2018
@@ -552,12 +552,22 @@ protected:
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");
 Builder.defineMacro("_REENTRANT");
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
   }
 
 public:
   SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 // FIXME: WIntType should be SignedLong
+switch (Triple.getArch()) {
+default:
+  break;
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
+  break;
+}
   }
 };
 

Modified: cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/float128-declarations.cpp?rev=330572&r1=330571&r2=330572&view=diff
==
--- cfe/trunk/test/CodeGenCXX/float128-declarations.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/float128-declarations.cpp Mon Apr 23 02:28:08 2018
@@ -12,6 +12,10 @@
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 // RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple i386-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 //
 /*  Various contexts where type __float128 can appear. The different check
 prefixes are due to different mangling on X86 and different calling


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


[PATCH] D44932: [CodeComplete] Fix completion in the middle of ident in ctor lists.

2018-04-23 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, modulo a tiny commenting nit.




Comment at: lib/Lex/Lexer.cpp:1667
+  // Note that code completion token is not added as a separate character
+  // when completion point is at the end of the buffer. Therefore, we need
+  // to check if the buffer has ended.

when completion -> when the completion


Repository:
  rC Clang

https://reviews.llvm.org/D44932



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


r330579 - [OpenCL] Reject virtual functions for OpenCL C++

2018-04-23 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Apr 23 04:23:47 2018
New Revision: 330579

URL: http://llvm.org/viewvc/llvm-project?rev=330579&view=rev
Log:
[OpenCL] Reject virtual functions for OpenCL C++

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

Added:
cfe/trunk/test/Parser/opencl-cxx-virtual.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 23 04:23:47 
2018
@@ -1073,6 +1073,10 @@ def err_opencl_taking_function_address_p
 def err_opencl_logical_exclusive_or : Error<
   "^^ is a reserved operator in OpenCL">;
 
+// OpenCL C++.
+def err_openclcxx_virtual_function : Error<
+  "virtual functions are not supported in OpenCL C++">;
+
 // OpenMP support.
 def warn_pragma_omp_ignored : Warning<
   "unexpected '#pragma omp ...' in program">, InGroup, 
DefaultIgnore;

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Apr 23 04:23:47 2018
@@ -189,6 +189,7 @@ LANGOPT(ShortEnums, 1, 0, "short
 
 LANGOPT(OpenCL, 1, 0, "OpenCL")
 LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
+LANGOPT(OpenCLCPlusPlus   , 1, 0, "OpenCL C++")
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "OpenCL C++ version")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")
 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Apr 23 04:23:47 2018
@@ -1927,6 +1927,7 @@ void CompilerInvocation::setLangDefaults
 Opts.setDefaultFPContractMode(LangOptions::FPC_On);
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
+Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
 // Include default header file for OpenCL.
 if (Opts.IncludeDefaultHeader) {
   PPOpts.Includes.push_back("opencl-c.h");

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 23 04:23:47 2018
@@ -3466,7 +3466,15 @@ void Parser::ParseDeclarationSpecifiers(
   isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID);
   break;
 case tok::kw_virtual:
-  isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID);
+  // OpenCL C++ v1.0 s2.9: the virtual function qualifier is not supported.
+  if (getLangOpts().OpenCLCPlusPlus) {
+DiagID = diag::err_openclcxx_virtual_function;
+PrevSpec = Tok.getIdentifierInfo()->getNameStart();
+isInvalid = true;
+  }
+  else {
+isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID);
+  }
   break;
 case tok::kw_explicit:
   isInvalid = DS.setFunctionSpecExplicit(Loc, PrevSpec, DiagID);

Added: cfe/trunk/test/Parser/opencl-cxx-virtual.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-cxx-virtual.cl?rev=330579&view=auto
==
--- cfe/trunk/test/Parser/opencl-cxx-virtual.cl (added)
+++ cfe/trunk/test/Parser/opencl-cxx-virtual.cl Mon Apr 23 04:23:47 2018
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -fsyntax-only 
-verify
+
+// Test that virtual functions and abstract classes are rejected.
+class virtual_functions {
+  virtual void bad1() {}
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+
+  virtual void bad2() = 0;
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+  //expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}}
+};
+
+template 
+class X {
+  virtual T f();
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+};
+
+// Test 

[PATCH] D45873: [OpenCL] Reject virtual functions for OpenCL C++

2018-04-23 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330579: [OpenCL] Reject virtual functions for OpenCL C++ 
(authored by svenvh, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45873?vs=143330&id=143524#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45873

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/LangOptions.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Parse/ParseDecl.cpp
  test/Parser/opencl-cxx-virtual.cl

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -3466,7 +3466,15 @@
   isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID);
   break;
 case tok::kw_virtual:
-  isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID);
+  // OpenCL C++ v1.0 s2.9: the virtual function qualifier is not supported.
+  if (getLangOpts().OpenCLCPlusPlus) {
+DiagID = diag::err_openclcxx_virtual_function;
+PrevSpec = Tok.getIdentifierInfo()->getNameStart();
+isInvalid = true;
+  }
+  else {
+isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID);
+  }
   break;
 case tok::kw_explicit:
   isInvalid = DS.setFunctionSpecExplicit(Loc, PrevSpec, DiagID);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1927,6 +1927,7 @@
 Opts.setDefaultFPContractMode(LangOptions::FPC_On);
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
+Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
 // Include default header file for OpenCL.
 if (Opts.IncludeDefaultHeader) {
   PPOpts.Includes.push_back("opencl-c.h");
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -1073,6 +1073,10 @@
 def err_opencl_logical_exclusive_or : Error<
   "^^ is a reserved operator in OpenCL">;
 
+// OpenCL C++.
+def err_openclcxx_virtual_function : Error<
+  "virtual functions are not supported in OpenCL C++">;
+
 // OpenMP support.
 def warn_pragma_omp_ignored : Warning<
   "unexpected '#pragma omp ...' in program">, InGroup, DefaultIgnore;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -189,6 +189,7 @@
 
 LANGOPT(OpenCL, 1, 0, "OpenCL")
 LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
+LANGOPT(OpenCLCPlusPlus   , 1, 0, "OpenCL C++")
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "OpenCL C++ version")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")
 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
Index: test/Parser/opencl-cxx-virtual.cl
===
--- test/Parser/opencl-cxx-virtual.cl
+++ test/Parser/opencl-cxx-virtual.cl
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -fsyntax-only -verify
+
+// Test that virtual functions and abstract classes are rejected.
+class virtual_functions {
+  virtual void bad1() {}
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+
+  virtual void bad2() = 0;
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+  //expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}}
+};
+
+template 
+class X {
+  virtual T f();
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+};
+
+// Test that virtual base classes are allowed.
+struct A {
+  int a;
+  void foo();
+};
+
+struct B : virtual A {
+  int b;
+};
+
+struct C : public virtual A {
+  int c;
+};
+
+struct D : B, C {
+  int d;
+};
+
+kernel void virtual_inheritance() {
+  D d;
+
+  d.foo();
+  d.a = 11;
+  d.b = 22;
+  d.c = 33;
+  d.d = 44;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45944: Disallow pointers to const in __sync_fetch_and_xxx

2018-04-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please always upload all patches with full context (`-U9`)


https://reviews.llvm.org/D45944



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-04-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:226
+DiagnosticBuilder &Diag) {
+  if (getLangOpts().CPlusPlus11) {
+StringRef NewFuncName = (Name[0] != 'w') ? "strncpy_s" : "wcsncpy_s";

Charusso wrote:
> aaron.ballman wrote:
> > What about C?
> The `else` part would fire.
I think this comment got moved to an unrelated area. I was talking about 
`NotNullTerminatedResultCheck::memmoveFix()`, where there is no `else` clause. 
However, I'm also not entirely certain why you are assuming the _s versions of 
those functions are available in C++ (they're in Annex K for C, which is an 
optional annex).


https://reviews.llvm.org/D45050



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


[PATCH] D45944: Disallow pointers to const in __sync_fetch_and_xxx

2018-04-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 143526.
aaron.ballman added a comment.

Updated with more context.


https://reviews.llvm.org/D45944

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/builtins.c


Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,7 @@
 
 return buf;
 }
+
+void test21(const int *ptr) {
+  __sync_fetch_and_add(ptr, 1); // expected-error{{address argument to atomic 
builtin cannot be const-qualified ('const int *' invalid)}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3428,6 +3428,12 @@
 return ExprError();
   }
 
+  if (ValType.isConstQualified()) {
+Diag(DRE->getLocStart(), diag::err_atomic_builtin_cannot_be_const)
+<< FirstArg->getType() << FirstArg->getSourceRange();
+return ExprError();
+  }
+
   switch (ValType.getObjCLifetime()) {
   case Qualifiers::OCL_None:
   case Qualifiers::OCL_ExplicitNone:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7079,6 +7079,8 @@
 def err_atomic_builtin_must_be_pointer_intptr : Error<
   "address argument to atomic builtin must be a pointer to integer or pointer"
   " (%0 invalid)">;
+def err_atomic_builtin_cannot_be_const : Error<
+  "address argument to atomic builtin cannot be const-qualified (%0 invalid)">;
 def err_atomic_builtin_must_be_pointer_intfltptr : Error<
   "address argument to atomic builtin must be a pointer to integer,"
   " floating-point or pointer (%0 invalid)">;


Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,7 @@
 
 return buf;
 }
+
+void test21(const int *ptr) {
+  __sync_fetch_and_add(ptr, 1); // expected-error{{address argument to atomic builtin cannot be const-qualified ('const int *' invalid)}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3428,6 +3428,12 @@
 return ExprError();
   }
 
+  if (ValType.isConstQualified()) {
+Diag(DRE->getLocStart(), diag::err_atomic_builtin_cannot_be_const)
+<< FirstArg->getType() << FirstArg->getSourceRange();
+return ExprError();
+  }
+
   switch (ValType.getObjCLifetime()) {
   case Qualifiers::OCL_None:
   case Qualifiers::OCL_ExplicitNone:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7079,6 +7079,8 @@
 def err_atomic_builtin_must_be_pointer_intptr : Error<
   "address argument to atomic builtin must be a pointer to integer or pointer"
   " (%0 invalid)">;
+def err_atomic_builtin_cannot_be_const : Error<
+  "address argument to atomic builtin cannot be const-qualified (%0 invalid)">;
 def err_atomic_builtin_must_be_pointer_intfltptr : Error<
   "address argument to atomic builtin must be a pointer to integer,"
   " floating-point or pointer (%0 invalid)">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45944: Disallow pointers to const in __sync_fetch_and_xxx

2018-04-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D45944#1075055, @lebedev.ri wrote:

> Please always upload all patches with full context (`-U9`)


I'm not keen on uploading patches with that much context. For instance, it 
disables syntax highlighting in Phab for many of our files. However, perhaps 
100 lines of context was a bit optimistic.


https://reviews.llvm.org/D45944



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


[clang-tools-extra] r330580 - Fix tests after changes to clang-format in r330573.

2018-04-23 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Mon Apr 23 04:47:59 2018
New Revision: 330580

URL: http://llvm.org/viewvc/llvm-project?rev=330580&view=rev
Log:
Fix tests after changes to clang-format in r330573.

We do now both:
- stop reformatting a sequence after a closing brace in more cases, in
  order to not misindent after an incorrect closing brace
- format the closing brace when formatting the line containing the
  opening brace

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp?rev=330580&r1=330579&r2=330580&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
 Mon Apr 23 04:47:59 2018
@@ -19,15 +19,15 @@ void test() {
   // CHECK-MESSAGES: :[[@LINE-3]]:26: warning: statement should be inside 
braces
   // CHECK-MESSAGES: :[[@LINE-4]]:35: warning: statement should be inside 
braces
   // CHECK-MESSAGES: :[[@LINE-5]]:38: warning: statement should be inside 
braces
-  // CHECK-FIXES:  {{^}}   if (1) {{{$}}
-  // CHECK-FIXES-NEXT: {{^}}  while (2) {
-  // CHECK-FIXES-NEXT: {{^}} if (3) {
-  // CHECK-FIXES-NEXT: {{^}}for (;;) {
-  // CHECK-FIXES-NEXT: {{^}}   do {
-  // CHECK-FIXES-NEXT: {{^}}  ;
-  // CHECK-FIXES-NEXT: {{^}}   } while (false) /**/; /**/
-  // CHECK-FIXES-NEXT: {{^}}}
-  // CHECK-FIXES-NEXT: {{^}} }
-  // CHECK-FIXES-NEXT: {{^}}  }
-  // CHECK-FIXES-NEXT: {{^}}   }
+  // CHECK-FIXES:  {{^}}  if (1) {{{$}}
+  // CHECK-FIXES-NEXT: {{^}} while (2) {
+  // CHECK-FIXES-NEXT: {{^}}if (3) {
+  // CHECK-FIXES-NEXT: {{^}}   for (;;) {
+  // CHECK-FIXES-NEXT: {{^}}  do {
+  // CHECK-FIXES-NEXT: {{^}} ;
+  // CHECK-FIXES-NEXT: {{^}}  } while (false) /**/; /**/
+  // CHECK-FIXES-NEXT: {{^}}   }
+  // CHECK-FIXES-NEXT: {{^}}}
+  // CHECK-FIXES-NEXT: {{^}} }
+  // CHECK-FIXES-NEXT: {{^}}  }
 }

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=330580&r1=330579&r2=330580&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Mon 
Apr 23 04:47:59 2018
@@ -196,7 +196,8 @@ TEST(IncludeFixer, ScopedNamespaceSymbol
 runIncludeFixer("namespace a {\nb::bar b;\n}"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace A {\na::b::bar b;\n}",
 runIncludeFixer("namespace A {\na::b::bar b;\n}"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nvoid func() { b::bar b; }\n}",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nvoid func() { b::bar b; }\n} "
+"// namespace a",
 runIncludeFixer("namespace a {\nvoid func() { b::bar b; }\n}"));
   EXPECT_EQ("namespace A { c::b::bar b; }\n",
 runIncludeFixer("namespace A { c::b::bar b; }\n"));
@@ -258,7 +259,8 @@ TEST(IncludeFixer, FixNamespaceQualifier
 runIncludeFixer("namespace a {\nb::bar b;\n}\n"));
   EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}\n",
 runIncludeFixer("namespace a {\nbar b;\n}\n"));
-  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nnamespace b{\nbar b;\n}\n}\n",
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nnamespace b{\nbar b;\n}\n} "
+"// namespace a\n",
 runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n"));
   EXPECT_EQ("c::b::bar b;\n",
 runIncludeFixer("c::b::bar b;\n"));
@@ -268,12 +270,12 @@ TEST(IncludeFixer, FixNamespaceQualifier
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
   // Test common qualifers reduction.
-  EXPECT_EQ(
-  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
-  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
-  EXPECT_EQ(
-  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
-  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n} 
"
+"// namespace a\n",
+runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar "
+"b;\n}\n} // n

[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 reopened this revision.
avt77 added a comment.
This revision is now accepted and ready to land.

It's terrible but my new test was failed again as result of commit of this 
patch!

///b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Frontend/ftime-report-template-decl.cpp:155:11:
 error: expected string not found in input
// CHECK: Code Generation Time
//  ^

I don't understand how it's possible. The same problem raised when I committed 
D43578 . Obviously, there is a situation when 
this  test work w/o Code Generation and as result this test is fail because 
code generation time is zerro. Could anyone help me? How should I change the 
test? The simplest way is to remove this line but I don't like this idea.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D41240: [Solaris] __float128 is supported on Solaris/x86

2018-04-23 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added subscribers: joerg, krytarowski.
krytarowski added a comment.

Does it work for you for 32-bit? @joerg opposed adoption of 32-bit version as 
it seemed to be unimplemented..


Repository:
  rL LLVM

https://reviews.llvm.org/D41240



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


r330589 - [analyzer] CStringChecker.cpp - Code refactoring on bug report.

2018-04-23 Thread Henry Wong via cfe-commits
Author: henrywong
Date: Mon Apr 23 06:36:51 2018
New Revision: 330589

URL: http://llvm.org/viewvc/llvm-project?rev=330589&view=rev
Log:
[analyzer] CStringChecker.cpp - Code refactoring on bug report.

Reviewers: NoQ, george.karpenkov, xazax.hun

Reviewed By: george.karpenkov   

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

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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=330589&r1=330588&r2=330589&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Mon Apr 23 
06:36:51 2018
@@ -194,6 +194,14 @@ public:
   const Stmt *First,
   const Stmt *Second) const;
 
+  void emitNullArgBug(CheckerContext &C, ProgramStateRef State, const Stmt *S,
+  StringRef WarningMsg) const;
+  void emitOutOfBoundsBug(CheckerContext &C, ProgramStateRef State,
+  const Stmt *S, StringRef WarningMsg) const;
+  void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
+ const Stmt *S, StringRef WarningMsg) const;
+  void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -239,30 +247,14 @@ ProgramStateRef CStringChecker::checkNon
   std::tie(stateNull, stateNonNull) = assumeZero(C, state, l, S->getType());
 
   if (stateNull && !stateNonNull) {
-if (!Filter.CheckCStringNullArg)
-  return nullptr;
-
-ExplodedNode *N = C.generateErrorNode(stateNull);
-if (!N)
-  return nullptr;
-
-if (!BT_Null)
-  BT_Null.reset(new BuiltinBug(
-  Filter.CheckNameCStringNullArg, categories::UnixAPI,
-  "Null pointer argument in call to byte string function"));
+if (Filter.CheckCStringNullArg) {
+  SmallString<80> buf;
+  llvm::raw_svector_ostream os(buf);
+  assert(CurrentFunctionDescription);
+  os << "Null pointer argument in call to " << CurrentFunctionDescription;
 
-SmallString<80> buf;
-llvm::raw_svector_ostream os(buf);
-assert(CurrentFunctionDescription);
-os << "Null pointer argument in call to " << CurrentFunctionDescription;
-
-// Generate a report for this bug.
-BuiltinBug *BT = static_cast(BT_Null.get());
-auto report = llvm::make_unique(*BT, os.str(), N);
-
-report->addRange(S->getSourceRange());
-bugreporter::trackNullOrUndefValue(N, S, *report);
-C.emitReport(std::move(report));
+  emitNullArgBug(C, stateNull, S, os.str());
+}
 return nullptr;
   }
 
@@ -305,31 +297,14 @@ ProgramStateRef CStringChecker::CheckLoc
   ProgramStateRef StInBound = state->assumeInBound(Idx, Size, true);
   ProgramStateRef StOutBound = state->assumeInBound(Idx, Size, false);
   if (StOutBound && !StInBound) {
-ExplodedNode *N = C.generateErrorNode(StOutBound);
-if (!N)
-  return nullptr;
-
-CheckName Name;
 // These checks are either enabled by the CString out-of-bounds checker
 // explicitly or the "basic" CStringNullArg checker support that Malloc
 // checker enables.
 assert(Filter.CheckCStringOutOfBounds || Filter.CheckCStringNullArg);
-if (Filter.CheckCStringOutOfBounds)
-  Name = Filter.CheckNameCStringOutOfBounds;
-else
-  Name = Filter.CheckNameCStringNullArg;
 
-if (!BT_Bounds) {
-  BT_Bounds.reset(new BuiltinBug(
-  Name, "Out-of-bound array access",
-  "Byte string function accesses out-of-bound array element"));
-}
-BuiltinBug *BT = static_cast(BT_Bounds.get());
-
-// Generate a report for this bug.
-std::unique_ptr report;
+// Emit a bug report.
 if (warningMsg) {
-  report = llvm::make_unique(*BT, warningMsg, N);
+  emitOutOfBoundsBug(C, StOutBound, S, warningMsg);
 } else {
   assert(CurrentFunctionDescription);
   assert(CurrentFunctionDescription[0] != '\0');
@@ -339,15 +314,8 @@ ProgramStateRef CStringChecker::CheckLoc
   os << toUppercase(CurrentFunctionDescription[0])
  << &CurrentFunctionDescription[1]
  << " accesses out-of-bound array element";
-  report = llvm::make_unique(*BT, os.str(), N);
+  emitOutOfBoundsBug(C, StOutBound, S, os.str());
 }
-
-// FIXME: It would be nice to eventually make this diagnostic more clear,
-// e.g., by referencing the original declaration or by saying *why* this
-// reference is outside the range.
-
-report->addRange(S->getSourceRange());
-C.emitReport(std::move(report));
 return nullptr;
   }
 
@@ -567,6 +535,79 @@ void CStringChecker::

[PATCH] D44557: [analyzer] CStringChecker.cpp - Code refactoring on bug report.

2018-04-23 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330589: [analyzer] CStringChecker.cpp - Code refactoring on 
bug report. (authored by henrywong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44557?vs=138682&id=143545#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44557

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -194,6 +194,14 @@
   const Stmt *First,
   const Stmt *Second) const;
 
+  void emitNullArgBug(CheckerContext &C, ProgramStateRef State, const Stmt *S,
+  StringRef WarningMsg) const;
+  void emitOutOfBoundsBug(CheckerContext &C, ProgramStateRef State,
+  const Stmt *S, StringRef WarningMsg) const;
+  void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
+ const Stmt *S, StringRef WarningMsg) const;
+  void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -239,30 +247,14 @@
   std::tie(stateNull, stateNonNull) = assumeZero(C, state, l, S->getType());
 
   if (stateNull && !stateNonNull) {
-if (!Filter.CheckCStringNullArg)
-  return nullptr;
-
-ExplodedNode *N = C.generateErrorNode(stateNull);
-if (!N)
-  return nullptr;
-
-if (!BT_Null)
-  BT_Null.reset(new BuiltinBug(
-  Filter.CheckNameCStringNullArg, categories::UnixAPI,
-  "Null pointer argument in call to byte string function"));
+if (Filter.CheckCStringNullArg) {
+  SmallString<80> buf;
+  llvm::raw_svector_ostream os(buf);
+  assert(CurrentFunctionDescription);
+  os << "Null pointer argument in call to " << CurrentFunctionDescription;
 
-SmallString<80> buf;
-llvm::raw_svector_ostream os(buf);
-assert(CurrentFunctionDescription);
-os << "Null pointer argument in call to " << CurrentFunctionDescription;
-
-// Generate a report for this bug.
-BuiltinBug *BT = static_cast(BT_Null.get());
-auto report = llvm::make_unique(*BT, os.str(), N);
-
-report->addRange(S->getSourceRange());
-bugreporter::trackNullOrUndefValue(N, S, *report);
-C.emitReport(std::move(report));
+  emitNullArgBug(C, stateNull, S, os.str());
+}
 return nullptr;
   }
 
@@ -305,31 +297,14 @@
   ProgramStateRef StInBound = state->assumeInBound(Idx, Size, true);
   ProgramStateRef StOutBound = state->assumeInBound(Idx, Size, false);
   if (StOutBound && !StInBound) {
-ExplodedNode *N = C.generateErrorNode(StOutBound);
-if (!N)
-  return nullptr;
-
-CheckName Name;
 // These checks are either enabled by the CString out-of-bounds checker
 // explicitly or the "basic" CStringNullArg checker support that Malloc
 // checker enables.
 assert(Filter.CheckCStringOutOfBounds || Filter.CheckCStringNullArg);
-if (Filter.CheckCStringOutOfBounds)
-  Name = Filter.CheckNameCStringOutOfBounds;
-else
-  Name = Filter.CheckNameCStringNullArg;
-
-if (!BT_Bounds) {
-  BT_Bounds.reset(new BuiltinBug(
-  Name, "Out-of-bound array access",
-  "Byte string function accesses out-of-bound array element"));
-}
-BuiltinBug *BT = static_cast(BT_Bounds.get());
 
-// Generate a report for this bug.
-std::unique_ptr report;
+// Emit a bug report.
 if (warningMsg) {
-  report = llvm::make_unique(*BT, warningMsg, N);
+  emitOutOfBoundsBug(C, StOutBound, S, warningMsg);
 } else {
   assert(CurrentFunctionDescription);
   assert(CurrentFunctionDescription[0] != '\0');
@@ -339,15 +314,8 @@
   os << toUppercase(CurrentFunctionDescription[0])
  << &CurrentFunctionDescription[1]
  << " accesses out-of-bound array element";
-  report = llvm::make_unique(*BT, os.str(), N);
+  emitOutOfBoundsBug(C, StOutBound, S, os.str());
 }
-
-// FIXME: It would be nice to eventually make this diagnostic more clear,
-// e.g., by referencing the original declaration or by saying *why* this
-// reference is outside the range.
-
-report->addRange(S->getSourceRange());
-C.emitReport(std::move(report));
 return nullptr;
   }
 
@@ -567,6 +535,79 @@
   C.emitReport(std::move(report));
 }
 
+void CStringChecker::emitNullArgBug(CheckerContext &C, ProgramStateRef State,
+const Stmt *S, StringRef WarningMsg) const {
+  if (ExplodedNode *N = C.generateErrorNode(State)) {
+if (!BT_Null)
+  BT_Null.reset(new BuiltinBug(
+  Filter.CheckNameCStringNullArg, categories::UnixAPI,

[PATCH] D44079: [ASTImporter] Allow testing of import sequences; fix import of typedefs for anonymous decls

2018-04-23 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin marked 2 inline comments as done.
a.sidorin added a comment.

Thank you Gabor!




Comment at: unittests/AST/ASTImporterTest.cpp:356
+  ImportAction(StringRef FromFilename, StringRef ToFilename,
+   const std::string &DeclName)
+  : FromFilename(FromFilename), ToFilename(ToFilename),

xazax.hun wrote:
> Maybe using StringRef for DeclName too?
I don't think it has too much sense - `hasName()` matcher's argument is `const 
std::string &` anyway.



Comment at: unittests/AST/ASTImporterTest.cpp:416
+  AllASTUnits[Filename] = Found->getValue().createASTUnits(Filename);
+  BuiltASTs[Filename] = true;
+}

xazax.hun wrote:
> Do we need this? Can't we just say if a filename is in `AllASTUnits`, it is 
> built?
Yes, that's actually redundant.


Repository:
  rC Clang

https://reviews.llvm.org/D44079



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


Re: [PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Nico Weber via cfe-commits
In any case, when you see a test failing on bots and the fix isn't obvious,
revert first to get the bots back green.

On Mon, Apr 23, 2018 at 8:54 AM, Andrew V. Tischenko via Phabricator via
cfe-commits  wrote:

> avt77 reopened this revision.
> avt77 added a comment.
> This revision is now accepted and ready to land.
>
> It's terrible but my new test was failed again as result of commit of this
> patch!
>
> ///b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/
> clang/test/Frontend/ftime-report-template-decl.cpp:155:11: error:
> expected string not found in input
> // CHECK: Code Generation Time
> //  ^
>
> I don't understand how it's possible. The same problem raised when I
> committed D43578 . Obviously, there is a
> situation when this  test work w/o Code Generation and as result this test
> is fail because code generation time is zerro. Could anyone help me? How
> should I change the test? The simplest way is to remove this line but I
> don't like this idea.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D45619
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45717: [clangd] Using index for GoToDefinition.

2018-04-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for the changes! I still find the logic quite confusing. Happy to chat 
offline if useful.




Comment at: clangd/XRefs.cpp:137
+
+IdentifiedSymbol getSymbolAtPosition(ParsedAST &AST, SourceLocation Pos) {
+  auto DeclMacrosFinder = std::make_shared(

this is a nice abstraction - consider hiding the DeclarationAndMacrosFinder 
inside it!



Comment at: clangd/XRefs.cpp:215
 
-  indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
- DeclMacrosFinder, IndexOpts);
+  // Handle goto definition for macros.
+  if (!Symbols.Macros.empty()) {

So now you're early-out if there are macros.
This means if you have

```
void log(string s) { cout << s; }
#define LOG log
LOG("hello");
```

You'll offer only line 2 as an option, and not line 1.
I'm not sure that's bad, but it's non-obvious - I think it's the thing that the 
comment should call out.
e.g. "If the cursor is on a macro, go to the macro's definition without trying 
to resolve the code it expands to"
(The current comment just echoes the code)



Comment at: clangd/XRefs.cpp:226
 
-  std::vector Decls = DeclMacrosFinder->takeDecls();
-  std::vector MacroInfos = DeclMacrosFinder->takeMacroInfos();
+  // Handle goto definition for typical declarations.
+  //

I'm not sure this line adds anything unless you are more specific about what 
"typical" means, maybe just drop it.

(nit: go to, not goto)



Comment at: clangd/XRefs.cpp:233
+  //  - We use the location from AST and index (if available) to provide the
+  //final results. Prefer AST over index.
+  //

because it's more up-to-date?



Comment at: clangd/XRefs.cpp:235
+  //
+  //  - For each symbol, we will return a location of the cannonical 
declaration
+  //(e.g. function declaration in header), and a location of definition if

nit: canonical



Comment at: clangd/XRefs.cpp:237
+  //(e.g. function declaration in header), and a location of definition if
+  //they are available, definition comes first.
+  struct CandidateLocation {

first why?



Comment at: clangd/XRefs.cpp:246
+
+  for (auto D : Symbols.Decls) {
+llvm::SmallString<128> USR;

nit: the body of this loop handles building the query and getting the AST 
locations, but they're interleaved in a confusing way - please separate them, 
or even make these two separate loops.

In the latter case you could put QueryRequest inside the if(Index) block, which 
would be easier to follow.



Comment at: clangd/XRefs.cpp:248
+llvm::SmallString<128> USR;
+if (index::generateUSRForDecl(D, USR))
+  continue;

why are we skipping the AST location if we can't generate a USR?



Comment at: clangd/XRefs.cpp:256
+CandidateLocation &Candidate = ResultCandidates[ID];
+bool IsDef = GetDefinition(D) == D;
+// Populate one of the slots with location for the AST.

why do you not use GetDefinition(D) as the definition, in the case where it's 
not equal to D?



Comment at: clangd/XRefs.cpp:265
+  if (Index) {
+log("query index...");
+std::string HintPath;

remove this log message or make it more useful :-)



Comment at: clangd/XRefs.cpp:277
+// it.
+auto ToLSPLocation = [&HintPath](
+const SymbolLocation &Loc) -> llvm::Optional 
{

(The double-nested lambda is somewhat hard to read, can this just be a 
top-level function? That's what's needed to share it, right?)



Comment at: clangd/XRefs.cpp:516
 
   SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, FE);
   auto DeclMacrosFinder = std::make_shared(

can you also use `getSymbolAtPosition` here?



Comment at: unittests/clangd/XRefsTests.cpp:42
 // FIXME: this is duplicated with FileIndexTests. Share it.
-ParsedAST build(StringRef Code) {
-  auto CI = createInvocationFromCommandLine(
-  {"clang", "-xc++", testPath("Foo.cpp").c_str()});
-  auto Buf = MemoryBuffer::getMemBuffer(Code);
+ParsedAST build(StringRef MainCode, StringRef HeaderCode = "",
+StringRef BaseName = "Main",

this is too complicated, please find a way to make it simpler.
Take a look in TestFS.h for the filesystem stuff.



Comment at: unittests/clangd/XRefsTests.cpp:43
+ParsedAST build(StringRef MainCode, StringRef HeaderCode = "",
+StringRef BaseName = "Main",
+llvm::IntrusiveRefCntPtr

why allow BaseName to be chosen?



Comment at: unittests/clangd/XRefsTests.cpp:44
+StringRef BaseName = "Main",
+llvm::IntrusiveRefCn

r330595 - [index] Fix methods that take a shared_ptr to just take a reference.

2018-04-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Apr 23 07:30:21 2018
New Revision: 330595

URL: http://llvm.org/viewvc/llvm-project?rev=330595&view=rev
Log:
[index] Fix methods that take a shared_ptr to just take a reference.

There is no ownership here, passing a shared_ptr just adds confusion. No
functionality change intended.

Modified:
cfe/trunk/include/clang/Index/IndexingAction.h
cfe/trunk/lib/Index/IndexingAction.cpp
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/include/clang/Index/IndexingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexingAction.h?rev=330595&r1=330594&r2=330595&view=diff
==
--- cfe/trunk/include/clang/Index/IndexingAction.h (original)
+++ cfe/trunk/include/clang/Index/IndexingAction.h Mon Apr 23 07:30:21 2018
@@ -46,17 +46,14 @@ createIndexingAction(std::shared_ptr WrappedAction);
 
-void indexASTUnit(ASTUnit &Unit,
-  std::shared_ptr DataConsumer,
+void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
   IndexingOptions Opts);
 
 void indexTopLevelDecls(ASTContext &Ctx, ArrayRef Decls,
-std::shared_ptr DataConsumer,
-IndexingOptions Opts);
+IndexDataConsumer &DataConsumer, IndexingOptions Opts);
 
 void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
- std::shared_ptr DataConsumer,
- IndexingOptions Opts);
+ IndexDataConsumer &DataConsumer, IndexingOptions Opts);
 
 } // namespace index
 } // namespace clang

Modified: cfe/trunk/lib/Index/IndexingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingAction.cpp?rev=330595&r1=330594&r2=330595&view=diff
==
--- cfe/trunk/lib/Index/IndexingAction.cpp (original)
+++ cfe/trunk/lib/Index/IndexingAction.cpp Mon Apr 23 07:30:21 2018
@@ -173,40 +173,38 @@ static void indexTranslationUnit(ASTUnit
   Unit.visitLocalTopLevelDecls(&IndexCtx, topLevelDeclVisitor);
 }
 
-void index::indexASTUnit(ASTUnit &Unit,
- std::shared_ptr DataConsumer,
+void index::indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
  IndexingOptions Opts) {
-  IndexingContext IndexCtx(Opts, *DataConsumer);
+  IndexingContext IndexCtx(Opts, DataConsumer);
   IndexCtx.setASTContext(Unit.getASTContext());
-  DataConsumer->initialize(Unit.getASTContext());
-  DataConsumer->setPreprocessor(Unit.getPreprocessorPtr());
+  DataConsumer.initialize(Unit.getASTContext());
+  DataConsumer.setPreprocessor(Unit.getPreprocessorPtr());
   indexTranslationUnit(Unit, IndexCtx);
-  DataConsumer->finish();
+  DataConsumer.finish();
 }
 
 void index::indexTopLevelDecls(ASTContext &Ctx, ArrayRef Decls,
-   std::shared_ptr DataConsumer,
+   IndexDataConsumer &DataConsumer,
IndexingOptions Opts) {
-  IndexingContext IndexCtx(Opts, *DataConsumer);
+  IndexingContext IndexCtx(Opts, DataConsumer);
   IndexCtx.setASTContext(Ctx);
 
-  DataConsumer->initialize(Ctx);
+  DataConsumer.initialize(Ctx);
   for (const Decl *D : Decls)
 IndexCtx.indexTopLevelDecl(D);
-  DataConsumer->finish();
+  DataConsumer.finish();
 }
 
-void index::indexModuleFile(serialization::ModuleFile &Mod,
-ASTReader &Reader,
-std::shared_ptr DataConsumer,
+void index::indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
+IndexDataConsumer &DataConsumer,
 IndexingOptions Opts) {
   ASTContext &Ctx = Reader.getContext();
-  IndexingContext IndexCtx(Opts, *DataConsumer);
+  IndexingContext IndexCtx(Opts, DataConsumer);
   IndexCtx.setASTContext(Ctx);
-  DataConsumer->initialize(Ctx);
+  DataConsumer.initialize(Ctx);
 
   for (const Decl *D : Reader.getModuleFileLevelDecls(Mod)) {
 IndexCtx.indexTopLevelDecl(D);
   }
-  DataConsumer->finish();
+  DataConsumer.finish();
 }

Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=330595&r1=330594&r2=330595&view=diff
==
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Mon Apr 23 07:30:21 2018
@@ -195,7 +195,7 @@ static bool printSourceSymbols(ArrayRef<
 if (auto Reader = Unit->getASTReader()) {
   Reader->getModuleManager().visit([&](serialization::ModuleFile &Mod) -> 
bool {
 OS << " Module " << Mod.ModuleName << " \n";
-indexModuleFile(Mod, *Reader, DataConsumer, IndexOpts);
+indexModuleFile(Mod, *Reader, *Dat

[clang-tools-extra] r330595 - [index] Fix methods that take a shared_ptr to just take a reference.

2018-04-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Apr 23 07:30:21 2018
New Revision: 330595

URL: http://llvm.org/viewvc/llvm-project?rev=330595&view=rev
Log:
[index] Fix methods that take a shared_ptr to just take a reference.

There is no ownership here, passing a shared_ptr just adds confusion. No
functionality change intended.

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

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=330595&r1=330594&r2=330595&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Mon Apr 23 07:30:21 2018
@@ -182,9 +182,9 @@ std::vector findDefinitions(Pa
   if (!Result.empty())
 return Result;
 
-  auto DeclMacrosFinder = std::make_shared(
-  llvm::errs(), SourceLocationBeg, AST.getASTContext(),
-  AST.getPreprocessor());
+  DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg,
+  AST.getASTContext(),
+  AST.getPreprocessor());
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::All;
@@ -193,8 +193,8 @@ std::vector findDefinitions(Pa
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
  DeclMacrosFinder, IndexOpts);
 
-  std::vector Decls = DeclMacrosFinder->takeDecls();
-  std::vector MacroInfos = DeclMacrosFinder->takeMacroInfos();
+  std::vector Decls = DeclMacrosFinder.takeDecls();
+  std::vector MacroInfos = DeclMacrosFinder.takeMacroInfos();
 
   for (auto D : Decls) {
 auto Loc = findNameLoc(D);
@@ -286,9 +286,9 @@ std::vector findDocum
 
   SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, FE);
 
-  auto DeclMacrosFinder = std::make_shared(
-  llvm::errs(), SourceLocationBeg, AST.getASTContext(),
-  AST.getPreprocessor());
+  DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg,
+  AST.getASTContext(),
+  AST.getPreprocessor());
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::All;
@@ -298,15 +298,15 @@ std::vector findDocum
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
  DeclMacrosFinder, IndexOpts);
 
-  std::vector SelectedDecls = DeclMacrosFinder->takeDecls();
+  std::vector SelectedDecls = DeclMacrosFinder.takeDecls();
 
-  auto DocHighlightsFinder = std::make_shared(
+  DocumentHighlightsFinder DocHighlightsFinder(
   llvm::errs(), AST.getASTContext(), AST.getPreprocessor(), SelectedDecls);
 
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
  DocHighlightsFinder, IndexOpts);
 
-  return DocHighlightsFinder->takeHighlights();
+  return DocHighlightsFinder.takeHighlights();
 }
 
 static PrintingPolicy PrintingPolicyForDecls(PrintingPolicy Base) {
@@ -418,9 +418,9 @@ Hover getHover(ParsedAST &AST, Position
 return Hover();
 
   SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, FE);
-  auto DeclMacrosFinder = std::make_shared(
-  llvm::errs(), SourceLocationBeg, AST.getASTContext(),
-  AST.getPreprocessor());
+  DeclarationAndMacrosFinder DeclMacrosFinder(llvm::errs(), SourceLocationBeg,
+  AST.getASTContext(),
+  AST.getPreprocessor());
 
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
@@ -430,11 +430,11 @@ Hover getHover(ParsedAST &AST, Position
   indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(),
  DeclMacrosFinder, IndexOpts);
 
-  std::vector Macros = DeclMacrosFinder->takeMacroInfos();
+  std::vector Macros = DeclMacrosFinder.takeMacroInfos();
   if (!Macros.empty())
 return getHoverContents(Macros[0].Name);
 
-  std::vector Decls = DeclMacrosFinder->takeDecls();
+  std::vector Decls = DeclMacrosFinder.takeDecls();
   if (!Decls.empty())
 return getHoverContents(Decls[0]);
 

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=330595&r1=330594&r2=330595&view=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Mon Apr 23 07:30:21 2018
@@ -28,8 +28,8 @@ std::unique_ptr indexAST(AST
   CollectorOpts.CollectIncludePath = false;
   CollectorOpts.CountReferences = false;
 
-  auto Collector = std::make_shared(std::move(CollectorOpts));
-  Collector->setPr

[PATCH] D45505: [GCC] Match a GCC version with a patch suffix without a third version component

2018-04-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 143558.
mstorsjo retitled this revision from "[WIP] [GCC] Match a GCC version with a 
patch suffix without a third version component" to "[GCC] Match a GCC version 
with a patch suffix without a third version component".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Added a driver test case with a fake directory tree, with a gcc directory with 
such a name.


https://reviews.llvm.org/D45505

Files:
  lib/Driver/ToolChains/Gnu.cpp
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include-fixed/.keep
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/backward/.keep
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/include/c++/x86_64-w64-mingw32/.keep
  
test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32/include/.keep
  test/Driver/mingw.cpp


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -49,3 +49,10 @@
 // CHECK_MINGW_UBUNTU_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}include{{/|}}c++{{/|}}4.8{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}include{{/|}}c++{{/|}}4.8{{/|}}backward"
 // CHECK_MINGW_UBUNTU_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+
+// RUN: %clang -target x86_64-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ 
-c -### --sysroot=%S/Inputs/mingw_ubuntu_posix_tree/usr %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_UBUNTU_POSIX_TREE %s
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++"
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1591,21 +1591,29 @@
   GoodVersion.MajorStr = First.first.str();
   if (First.second.empty())
 return GoodVersion;
-  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 
0)
+  StringRef MinorStr = Second.first;
+  if (Second.second.empty()) {
+if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
+  GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
+  MinorStr = MinorStr.slice(0, EndNumber);
+}
+  }
+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
 return BadVersion;
-  GoodVersion.MinorStr = Second.first.str();
+  GoodVersion.MinorStr = MinorStr.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
   //   5(handled above)
   //   4.4
+  //   4.4-patched
   //   4.4.0
   //   4.4.x
   //   4.4.2-rc4
   //   4.4.x-patched
   // And retains any patch number it finds.
-  StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
+  StringRef PatchText = Second.second.str();
   if (!PatchText.empty()) {
 if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
   // Try to parse the number and any suffix.


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -49,3 +49,10 @@
 // CHECK_MINGW_UBUNTU_TREE: "{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}include{{/|}}c++{{/|}}4.8{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_TREE: "{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}include{{/|}}c++{{/|}}4.8{{/|}}backward"
 // CHECK_MINGW_UBUNTU_TREE: "{{.*}}/Inputs/mingw_ubuntu_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+
+// RUN: %clang -target x86_64-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_ubuntu_posix_tree/usr %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_UBUNTU_POSIX_TREE %s
+// CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++"
+// CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}

[PATCH] D45964: [Driver] Fix implicit config files from prefixed symlinks

2018-04-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: sepavloff, hfinkel, hans, rnk.

If -no-canonical-prefixes isn't used, the clang executable name used is the one 
of the actual executable, not the name of the symlink  that the user invoked.

In these cases, the target prefix was overridden based on the clang executable 
name. (On the other hand the implicit -target option that such a symlink adds, 
is added as an actual command line parameter in tools/driver/driver.cop, before 
resolving the symlink and finding the actual clang executable.

Use the original ClangNameParts (set from argv[0] in tools/driver/driver.cpp) 
if it seems to be initialized propery.

All existing tests of this feature used -no-canonical-prefixes (possibly 
because it also makes the driver look in the directory of the symlink instead 
of the directory of the executable); add another one that uses 
--config-user-dir= to specify the directory instead. (For actual users of such 
symlinks, outisde of the test suite, the directory is probably the same for 
both.)

This makes this feature work more like what the documentation describes.


Repository:
  rC Clang

https://reviews.llvm.org/D45964

Files:
  lib/Driver/Driver.cpp
  test/Driver/config-file3.c


Index: test/Driver/config-file3.c
===
--- test/Driver/config-file3.c
+++ test/Driver/config-file3.c
@@ -27,6 +27,14 @@
 // FULL-NAME: -Wundefined-func-template
 // FULL-NAME-NOT: -Werror
 //
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg 
even without -no-canonical-prefixes.
+// (As the clang executable and symlink are in different directories, this
+// requires specifying the path via --config-*-dir= though.)
+//
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= 
--config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix 
SYMLINK
+//
+// SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+//
 //--- File specified by --config overrides config inferred from clang 
executable.
 //
 // RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config 
--config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | 
FileCheck %s -check-prefix CHECK-EXPLICIT
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -129,7 +129,8 @@
 
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
-  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  if (ClangNameParts.TargetPrefix.empty() && ClangNameParts.DriverMode == 
nullptr)
+ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
   setDriverModeFromOption(ClangNameParts.DriverMode);
 
   for (const char *ArgPtr : Args) {


Index: test/Driver/config-file3.c
===
--- test/Driver/config-file3.c
+++ test/Driver/config-file3.c
@@ -27,6 +27,14 @@
 // FULL-NAME: -Wundefined-func-template
 // FULL-NAME-NOT: -Werror
 //
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes.
+// (As the clang executable and symlink are in different directories, this
+// requires specifying the path via --config-*-dir= though.)
+//
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix SYMLINK
+//
+// SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+//
 //--- File specified by --config overrides config inferred from clang executable.
 //
 // RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -129,7 +129,8 @@
 
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
-  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  if (ClangNameParts.TargetPrefix.empty() && ClangNameParts.DriverMode == nullptr)
+ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
   setDriverModeFromOption(ClangNameParts.DriverMode);
 
   for (const char *ArgPtr : Args) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

In https://reviews.llvm.org/D45619#1075089, @avt77 wrote:

> It's terrible but my new test was failed again as result of commit of this 
> patch!
>
> ///b/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/test/Frontend/ftime-report-template-decl.cpp:155:11:
>  error: expected string not found in input
>  // CHECK: Code Generation Time
>  //  ^
>
> I don't understand how it's possible. The same problem raised when I 
> committed D43578 . Obviously, there is a 
> situation when this  test work w/o Code Generation and as result this test is 
> fail because code generation time is zerro. Could anyone help me? How should 
> I change the test? The simplest way is to remove this line but I don't like 
> this idea.


Not sure, but is perhaps the order in which timers are printed not 100% 
deterministic?
When I run the test "manually" without pipe to FileCheck I get:

  
===-===
   Miscellaneous Ungrouped Timers
  
===-===
  
 --System Time--   --User+System--   ---Wall Time---  --- Name ---
 0.0040 (100.0%)   0.0040 (100.0%)   0.0021 ( 70.7%)  Code Generation Time
 0. (  0.0%)   0. (  0.0%)   0.0009 ( 29.3%)  LLVM IR Generation 
Time
 0.0040 (100.0%)   0.0040 (100.0%)   0.0030 (100.0%)  Total

So when I run it without the pipe "Code Generation Time" is printed before 
"LLVM IR Generation Time".
However, the CHECK:s in the test case are in opposite order.
So I can't really understand why the test passes when I pipe it to FileCheck.

Anyway, if the order isn't deteministic, then a solution could be to use 
CHECK-DAG instead of CHECK for the checks that may be reordered. For example:

  // CHECK: Miscellaneous Ungrouped Timers
  // CHECK-DAG: Code Generation Time
  // CHECK-DAG: LLVM IR Generation Time
  // CHECK: Total
  // CHECK: Clang front-end time report
  // CHECK: Clang front-end timer
  // CHECK: Total

Unless the timers are supposed to be printed in a certain order, then I guess 
you need to add a sort somewhere in the code.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D45682: [analyzer] Move `TaintBugVisitor` from `GenericTaintChecker.cpp` to `BugReporterVisitors.h`.

2018-04-23 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330596: [analyzer] Move `TaintBugVisitor` from 
`GenericTaintChecker.cpp` to… (authored by henrywong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45682?vs=142621&id=143561#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45682

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -343,6 +343,22 @@
  BugReport &BR) override;
 };
 
+/// The bug visitor prints a diagnostic message at the location where a given
+/// variable was tainted.
+class TaintBugVisitor final : public BugReporterVisitorImpl {
+private:
+  const SVal V;
+
+public:
+  TaintBugVisitor(const SVal V) : V(V) {}
+  void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(V); }
+
+  std::shared_ptr VisitNode(const ExplodedNode *N,
+ const ExplodedNode *PrevN,
+ BugReporterContext &BRC,
+ BugReport &BR) override;
+};
+
 namespace bugreporter {
 
 /// Attempts to add visitors to trace a null or undefined value back to its
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2333,3 +2333,24 @@
 
   return std::move(Piece);
 }
+
+std::shared_ptr
+TaintBugVisitor::VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN,
+   BugReporterContext &BRC, BugReport &BR) {
+
+  // Find the ExplodedNode where the taint was first introduced
+  if (!N->getState()->isTainted(V) || PrevN->getState()->isTainted(V))
+return nullptr;
+
+  const Stmt *S = PathDiagnosticLocation::getStmt(N);
+  if (!S)
+return nullptr;
+
+  const LocationContext *NCtx = N->getLocationContext();
+  PathDiagnosticLocation L =
+  PathDiagnosticLocation::createBegin(S, BRC.getSourceManager(), NCtx);
+  if (!L.isValid() || !L.asLocation().isValid())
+return nullptr;
+
+  return std::make_shared(L, "Taint originated here");
+}
Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -100,23 +100,6 @@
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  /// The bug visitor prints a diagnostic message at the location where a given
-  /// variable was tainted.
-  class TaintBugVisitor
-  : public BugReporterVisitorImpl {
-  private:
-const SVal V;
-
-  public:
-TaintBugVisitor(const SVal V) : V(V) {}
-void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(V); }
-
-std::shared_ptr VisitNode(const ExplodedNode *N,
-   const ExplodedNode *PrevN,
-   BugReporterContext &BRC,
-   BugReport &BR) override;
-  };
-
   typedef SmallVector ArgVector;
 
   /// \brief A struct used to specify taint propagation rules for a function.
@@ -214,28 +197,6 @@
 /// points to data, which should be tainted on return.
 REGISTER_SET_WITH_PROGRAMSTATE(TaintArgsOnPostVisit, unsigned)
 
-std::shared_ptr
-GenericTaintChecker::TaintBugVisitor::VisitNode(const ExplodedNode *N,
-const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) {
-
-  // Find the ExplodedNode where the taint was first introduced
-  if (!N->getState()->isTainted(V) || PrevN->getState()->isTainted(V))
-return nullptr;
-
-  const Stmt *S = PathDiagnosticLocation::getStmt(N);
-  if (!S)
-return nullptr;
-
-  const LocationContext *NCtx = N->getLocationContext();
-  PathDiagnosticLocation L =
-  PathDiagnosticLocation::createBegin(S, BRC.getSourceManager(), NCtx);
-  if (!L.isValid() || !L.asLocation().isValid())
-return nullptr;
-
-  return std::make_shared(
-  L, "Taint originated here");
-}
-
 GenericTaintChecker::TaintPropagationRule
 GenericTaintChecker::TaintPropagationRule::getTaintPropagationRule(
  const FunctionDecl *FDecl,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330596 - [analyzer] Move `TaintBugVisitor` from `GenericTaintChecker.cpp` to `BugReporterVisitors.h`.

2018-04-23 Thread Henry Wong via cfe-commits
Author: henrywong
Date: Mon Apr 23 07:41:17 2018
New Revision: 330596

URL: http://llvm.org/viewvc/llvm-project?rev=330596&view=rev
Log:
[analyzer] Move `TaintBugVisitor` from `GenericTaintChecker.cpp` to 
`BugReporterVisitors.h`.

Summary: `TaintBugVisitor` is a universal visitor, and many checkers rely on 
it, such as `ArrayBoundCheckerV2.cpp`, `DivZeroChecker.cpp` and 
`VLASizeChecker.cpp`. Moving `TaintBugVisitor` to `BugReporterVisitors.h` 
enables other checker can also track where `tainted` value came from.

Reviewers: NoQ, george.karpenkov, xazax.hun

Reviewed By: george.karpenkov

Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits, MTC

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h?rev=330596&r1=330595&r2=330596&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
Mon Apr 23 07:41:17 2018
@@ -343,6 +343,22 @@ public:
  BugReport &BR) override;
 };
 
+/// The bug visitor prints a diagnostic message at the location where a given
+/// variable was tainted.
+class TaintBugVisitor final : public BugReporterVisitorImpl {
+private:
+  const SVal V;
+
+public:
+  TaintBugVisitor(const SVal V) : V(V) {}
+  void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(V); }
+
+  std::shared_ptr VisitNode(const ExplodedNode *N,
+ const ExplodedNode *PrevN,
+ BugReporterContext &BRC,
+ BugReport &BR) override;
+};
+
 namespace bugreporter {
 
 /// Attempts to add visitors to trace a null or undefined value back to its

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp?rev=330596&r1=330595&r2=330596&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp Mon Apr 23 
07:41:17 2018
@@ -100,23 +100,6 @@ private:
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  /// The bug visitor prints a diagnostic message at the location where a given
-  /// variable was tainted.
-  class TaintBugVisitor
-  : public BugReporterVisitorImpl {
-  private:
-const SVal V;
-
-  public:
-TaintBugVisitor(const SVal V) : V(V) {}
-void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(V); }
-
-std::shared_ptr VisitNode(const ExplodedNode *N,
-   const ExplodedNode *PrevN,
-   BugReporterContext &BRC,
-   BugReport &BR) override;
-  };
-
   typedef SmallVector ArgVector;
 
   /// \brief A struct used to specify taint propagation rules for a function.
@@ -214,28 +197,6 @@ const char GenericTaintChecker::MsgTaint
 /// points to data, which should be tainted on return.
 REGISTER_SET_WITH_PROGRAMSTATE(TaintArgsOnPostVisit, unsigned)
 
-std::shared_ptr
-GenericTaintChecker::TaintBugVisitor::VisitNode(const ExplodedNode *N,
-const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) {
-
-  // Find the ExplodedNode where the taint was first introduced
-  if (!N->getState()->isTainted(V) || PrevN->getState()->isTainted(V))
-return nullptr;
-
-  const Stmt *S = PathDiagnosticLocation::getStmt(N);
-  if (!S)
-return nullptr;
-
-  const LocationContext *NCtx = N->getLocationContext();
-  PathDiagnosticLocation L =
-  PathDiagnosticLocation::createBegin(S, BRC.getSourceManager(), NCtx);
-  if (!L.isValid() || !L.asLocation().isValid())
-return nullptr;
-
-  return std::make_shared(
-  L, "Taint originated here");
-}
-
 GenericTaintChecker::TaintPropagationRule
 GenericTaintChecker::TaintPropagationRule::getTaintPropagationRule(
  const FunctionDecl *FDecl,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=330596&r1=330595&r2=330596&view=diff

[PATCH] D45965: [Targets] Implement getConstraintRegister for ARM and AArch64

2018-04-23 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added a reviewer: eli.friedman.
Herald added subscribers: chrib, kristof.beyls, eraman, rengolin.
Herald added a reviewer: javed.absar.

The getConstraintRegister method is used by semantic checking of
inline assembly statements in order to diagnose conflicts between
clobber list and input/output lists. Currently ARM and AArch64 don't
override getConstraintRegister, so conflicts between registers
assigned to variables in asm labels and clobber lists are not
diagnosed. Such conflicts can cause assertion failures in the back end
and even miscompilations.

This patch implements getConstraintRegister for ARM and AArch64
targets. Since these targets don't have single-register constraints,
the implementation is trivial and just returns the register specified
in an asm label (if any).


https://reviews.llvm.org/D45965

Files:
  lib/Basic/Targets/AArch64.h
  lib/Basic/Targets/ARM.h
  test/Sema/arm-asm.c
  test/Sema/arm64-inline-asm.c


Index: test/Sema/arm64-inline-asm.c
===
--- test/Sema/arm64-inline-asm.c
+++ test/Sema/arm64-inline-asm.c
@@ -7,3 +7,9 @@
 
   asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not 
match register size specified by the constraint and modifier}} expected-note 
{{use constraint modifier "w"}}
 }
+
+void test_clobber_conflict(void) {
+  register long x asm("x1");
+  asm volatile("nop" :: "r"(x) : "%x1"); // expected-error {{conflicts with 
asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%x1"); // expected-error {{conflicts with 
asm clobber list}}
+}
Index: test/Sema/arm-asm.c
===
--- test/Sema/arm-asm.c
+++ test/Sema/arm-asm.c
@@ -10,3 +10,10 @@
   long long foo = 0, bar = 0;
   asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
 }
+
+void test_clobber_conflict(void) {
+  register int x asm("r1");
+  asm volatile("nop" :: "r"(x) : "%r1"); // expected-error {{conflicts with 
asm clobber list}}
+  asm volatile("nop" :: "l"(x) : "%r1"); // expected-error {{conflicts with 
asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%r1"); // expected-error {{conflicts with 
asm clobber list}}
+}
Index: lib/Basic/Targets/ARM.h
===
--- lib/Basic/Targets/ARM.h
+++ lib/Basic/Targets/ARM.h
@@ -155,6 +155,11 @@
  std::string &SuggestedModifier) const override;
   const char *getClobbers() const override;
 
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 
   int getEHDataRegisterNumber(unsigned RegNo) const override;
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -82,6 +82,11 @@
  std::string &SuggestedModifier) const override;
   const char *getClobbers() const override;
 
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+
   int getEHDataRegisterNumber(unsigned RegNo) const override;
 };
 


Index: test/Sema/arm64-inline-asm.c
===
--- test/Sema/arm64-inline-asm.c
+++ test/Sema/arm64-inline-asm.c
@@ -7,3 +7,9 @@
 
   asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
 }
+
+void test_clobber_conflict(void) {
+  register long x asm("x1");
+  asm volatile("nop" :: "r"(x) : "%x1"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%x1"); // expected-error {{conflicts with asm clobber list}}
+}
Index: test/Sema/arm-asm.c
===
--- test/Sema/arm-asm.c
+++ test/Sema/arm-asm.c
@@ -10,3 +10,10 @@
   long long foo = 0, bar = 0;
   asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
 }
+
+void test_clobber_conflict(void) {
+  register int x asm("r1");
+  asm volatile("nop" :: "r"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("nop" :: "l"(x) : "%r1"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("nop" : "=r"(x) :: "%r1"); // expected-error {{conflicts with asm clobber list}}
+}
Index: lib/Basic/Targets/ARM.h
===
--- lib/Basic/Targets/ARM.h
+++ lib/Basic/Targets/ARM.h
@@ -155,6 +155,11 @@
  std::string &SuggestedModifier) const override;
   const char *getClobbers() const override;
 
+  StringRef getConstraintRegister(StringRef Constr

[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-04-23 Thread Daniel Dunbar via Phabricator via cfe-commits
ddunbar added a comment.

In https://reviews.llvm.org/D30882#1074822, @dexonsmith wrote:

> I don't think this is quite right.  I know at least `make`-based incremental 
> builds wouldn't deal well with this.


This is actually not a novel problem w.r.t. this patch. The exact same 
situation comes up with Makefile-included .d files and when one of the 
referenced headers is removed.

This is typically solved somewhere in the build system, for example Make has 
`-include`, and Ninja and llbuild have explicit support for this situation.

I agree we might want to tread cautiously on how we change the .d output, but 
in this case I think it might be safe.

If we decide this isn't safe, then we may want to consider a new flag which 
tracks *all* anti-dependencies (file's for which Clang checked existence but 
did not exist), and include that here. The major concern with that approach is 
it is a much larger list, and while it would support being substantially more 
correct, it is also well beyond what people currently expect out of the build 
system + compiler generated deps approaches.

> Given t.cpp:
> 
>   #if __has_include("missing.h")
>   #endif
> 
> 
> t.d will be:
> 
>   t.o: missing.h
> 
> 
> Since the build system doesn't know how to generate missing.h, when t.cpp 
> changes the build system will stop dead in its tracks.
> 
> Knowing the list of files that are //potential// inputs to `t.o` seems 
> useful, but we should probably do that under a separate flag.  And if it's a 
> separate flag, we might consider giving it a better name than `-MF`...


https://reviews.llvm.org/D30882



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


[PATCH] D45966: Remove LLVM_INSTALL_CCTOOLS_SYMLINKS

2018-04-23 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: JDevlieghere.
Herald added a subscriber: mgorny.

It used to symlink `dsymutil` to `llvm-dsymutil`, but after r327790 llvm's 
dsymutil binary is now called dsymutil without prefix.

r327792 then reversed the direction of the symlink if 
LLVM_INSTALL_CCTOOLS_SYMLINKS was set, but that looks like a buildfix and not 
like something anyone should need.


https://reviews.llvm.org/D45966

Files:
  CMakeLists.txt
  docs/CMake.rst
  tools/dsymutil/CMakeLists.txt


Index: tools/dsymutil/CMakeLists.txt
===
--- tools/dsymutil/CMakeLists.txt
+++ tools/dsymutil/CMakeLists.txt
@@ -25,8 +25,3 @@
 if(APPLE)
   target_link_libraries(dsymutil PRIVATE "-framework CoreFoundation")
 endif(APPLE)
-
-if(LLVM_INSTALL_CCTOOLS_SYMLINKS)
-  add_llvm_tool_symlink(llvm-dsymutil dsymutil)
-endif()
-
Index: docs/CMake.rst
===
--- docs/CMake.rst
+++ docs/CMake.rst
@@ -228,10 +228,6 @@
   Install symlinks from the binutils tool names to the corresponding LLVM 
tools.
   For example, ar will be symlinked to llvm-ar.
 
-**LLVM_INSTALL_CCTOOLS_SYMLINKS**:BOOL
-  Install symliks from the cctools tool names to the corresponding LLVM tools.
-  For example, dsymutil will be symlinked to llvm-dsymutil.
-
 **LLVM_BUILD_EXAMPLES**:BOOL
   Build LLVM examples. Defaults to OFF. Targets for building each example are
   generated in any case. See documentation for *LLVM_BUILD_TOOLS* above for 
more
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -194,9 +194,6 @@
 option(LLVM_INSTALL_BINUTILS_SYMLINKS
   "Install symlinks from the binutils tool names to the corresponding LLVM 
tools." OFF)
 
-option(LLVM_INSTALL_CCTOOLS_SYMLINKS
-  "Install symlinks from the cctools tool names to the corresponding LLVM 
tools." OFF)
-
 option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." 
OFF)
 
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)


Index: tools/dsymutil/CMakeLists.txt
===
--- tools/dsymutil/CMakeLists.txt
+++ tools/dsymutil/CMakeLists.txt
@@ -25,8 +25,3 @@
 if(APPLE)
   target_link_libraries(dsymutil PRIVATE "-framework CoreFoundation")
 endif(APPLE)
-
-if(LLVM_INSTALL_CCTOOLS_SYMLINKS)
-  add_llvm_tool_symlink(llvm-dsymutil dsymutil)
-endif()
-
Index: docs/CMake.rst
===
--- docs/CMake.rst
+++ docs/CMake.rst
@@ -228,10 +228,6 @@
   Install symlinks from the binutils tool names to the corresponding LLVM tools.
   For example, ar will be symlinked to llvm-ar.
 
-**LLVM_INSTALL_CCTOOLS_SYMLINKS**:BOOL
-  Install symliks from the cctools tool names to the corresponding LLVM tools.
-  For example, dsymutil will be symlinked to llvm-dsymutil.
-
 **LLVM_BUILD_EXAMPLES**:BOOL
   Build LLVM examples. Defaults to OFF. Targets for building each example are
   generated in any case. See documentation for *LLVM_BUILD_TOOLS* above for more
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -194,9 +194,6 @@
 option(LLVM_INSTALL_BINUTILS_SYMLINKS
   "Install symlinks from the binutils tool names to the corresponding LLVM tools." OFF)
 
-option(LLVM_INSTALL_CCTOOLS_SYMLINKS
-  "Install symlinks from the cctools tool names to the corresponding LLVM tools." OFF)
-
 option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF)
 
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r330599 - [clangd] Prune some dead declarations. No functionality change.

2018-04-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Apr 23 07:58:18 2018
New Revision: 330599

URL: http://llvm.org/viewvc/llvm-project?rev=330599&view=rev
Log:
[clangd] Prune some dead declarations. No functionality change.

Modified:
clang-tools-extra/trunk/clangd/Diagnostics.h
clang-tools-extra/trunk/clangd/Trace.h

Modified: clang-tools-extra/trunk/clangd/Diagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.h?rev=330599&r1=330598&r2=330599&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.h (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.h Mon Apr 23 07:58:18 2018
@@ -85,16 +85,11 @@ public:
 const clang::Diagnostic &Info) override;
 
 private:
-  bool shouldIgnore(DiagnosticsEngine::Level DiagLevel,
-const clang::Diagnostic &Info);
-
   void flushLastDiag();
 
   std::vector Output;
   llvm::Optional LangOpts;
   llvm::Optional LastDiag;
-  /// Is any diag or note from LastDiag in the main file?
-  bool LastDiagMentionsMainFile = false;
 };
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/Trace.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Trace.h?rev=330599&r1=330598&r2=330599&view=diff
==
--- clang-tools-extra/trunk/clangd/Trace.h (original)
+++ clang-tools-extra/trunk/clangd/Trace.h Mon Apr 23 07:58:18 2018
@@ -93,10 +93,6 @@ private:
   WithContext RestoreCtx;
 };
 
-/// Returns mutable span metadata if this span is interested.
-/// Prefer to use SPAN_ATTACH rather than accessing this directly.
-json::obj *spanArgs();
-
 /// Attach a key-value pair to a Span event.
 /// This is not threadsafe when used with the same Span.
 #define SPAN_ATTACH(S, Name, Expr) 
\


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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D45619#1075260, @thakis wrote:

> In any case, when you see a test failing on bots and the fix isn't obvious,
>  revert first to get the bots back green.


I reverted it immediatly.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D45619#1075385, @bjope wrote:

> Anyway, if the order isn't deteministic, then a solution could be to use 
> CHECK-DAG instead of CHECK for the checks that may be reordered. For example:


Thank you very much! I'll try to fix it in this way.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-04-23 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 143566.
yvvan added a comment.

Use wrapped FixItHint to keep corrections.

Can be quite easily changed from Optional to some container if required.


https://reviews.llvm.org/D41537

Files:
  include/clang-c/Index.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/CodeCompleteOptions.h
  include/clang/Sema/Sema.h
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/FixIt/fixit.cpp
  test/Index/complete-arrow-dot.cpp
  test/SemaCXX/member-expr.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndexCodeCompletion.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -171,6 +171,7 @@
 clang_getCompletionChunkCompletionString
 clang_getCompletionChunkKind
 clang_getCompletionChunkText
+clang_getCompletionCorrection
 clang_getCompletionNumAnnotations
 clang_getCompletionParent
 clang_getCompletionPriority
Index: tools/libclang/CIndexCodeCompletion.cpp
===
--- tools/libclang/CIndexCodeCompletion.cpp
+++ tools/libclang/CIndexCodeCompletion.cpp
@@ -16,6 +16,7 @@
 #include "CIndexDiagnostic.h"
 #include "CLog.h"
 #include "CXCursor.h"
+#include "CXSourceLocation.h"
 #include "CXString.h"
 #include "CXTranslationUnit.h"
 #include "clang/AST/Decl.h"
@@ -306,6 +307,31 @@
 
 } // end anonymous namespace
 
+CXString clang_getCompletionCorrection(CXCompletionString completion_string,
+   CXSourceRange *replacement_range) {
+  CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
+
+  if (!CCStr) {
+if (replacement_range)
+  *replacement_range = clang_getNullRange();
+return cxstring::createNull();
+  }
+
+  const Optional &Correction = CCStr->getCorrection();
+  if (!Correction) {
+if (replacement_range)
+  *replacement_range = clang_getNullRange();
+return cxstring::createNull();
+  }
+
+  if (replacement_range) {
+*replacement_range = cxloc::translateSourceRange(
+*Correction->SourceMgr, Correction->LangOpts, Correction->RemoveRange);
+  }
+
+  return cxstring::createRef(Correction->CodeToInsert.c_str());
+}
+
 /// \brief Tracks the number of code-completion result objects that are 
 /// currently active.
 ///
@@ -644,6 +670,7 @@
   unsigned options) {
   bool IncludeBriefComments = options & CXCodeComplete_IncludeBriefComments;
   bool SkipPreamble = options & CXCodeComplete_SkipPreamble;
+  bool IncludeCorrections = options & CXCodeComplete_IncludeCorrections;
 
 #ifdef UDP_CODE_COMPLETION_LOGGER
 #ifdef UDP_CODE_COMPLETION_LOGGER_PORT
@@ -650,7 +677,6 @@
   const llvm::TimeRecord &StartTime =  llvm::TimeRecord::getCurrentTime();
 #endif
 #endif
-
   bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != nullptr;
 
   if (cxtu::isNotUsableTU(TU)) {
@@ -691,6 +717,7 @@
   CodeCompleteOptions Opts;
   Opts.IncludeBriefComments = IncludeBriefComments;
   Opts.LoadExternal = !SkipPreamble;
+  Opts.IncludeCorrections = IncludeCorrections;
   CaptureCompletionResults Capture(Opts, *Results, &TU);
 
   // Perform completion.
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -2276,6 +2276,7 @@
   CXString ParentName;
   CXString BriefComment;
   CXString Annotation;
+  CXString Corr;
   const char *BriefCommentCString;
   
   fprintf(file, "%s:", clang_getCString(ks));
@@ -2337,7 +2338,12 @@
 fprintf(file, "(brief comment: %s)", BriefCommentCString);
   }
   clang_disposeString(BriefComment);
-  
+
+  CXSourceRange correction_range;
+  Corr = clang_getCompletionCorrection(completion_result->CompletionString,
+   &correction_range);
+  fprintf(file, " (requires correction to \"%s\")", clang_getCString(Corr));
+
   fprintf(file, "\n");
 }
 
@@ -2436,6 +2442,8 @@
 completionOptions |= CXCodeComplete_IncludeBriefComments;
   if (getenv("CINDEXTEST_COMPLETION_SKIP_PREAMBLE"))
 completionOptions |= CXCodeComplete_SkipPreamble;
+  if (getenv("CINDEXTEST_COMPLETION_INCLUDE_CORRECTIONS"))
+completionOptions |= CXCodeComplete_IncludeCorrections;
   
   if (timing_only)
 input += strlen("-code-completion-timing=");
Index: test/SemaCXX/member-expr.cpp
===
--- test/SemaCXX/member-expr.cpp
+++ test/SemaCXX/member-expr.cpp
@@ -188,6 +188,11 @@
 return c->a;  // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; did you mean to use '.'?}}
   }
 
+  int g() {
+Cl0* c;
+return c.a;  // expected-error {{member reference type 'PR1

[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

I can't see that it has been reverted.
But I guess that the table maybe is sorted based on time spent in each pass? So 
that is why it might be sorted differently on different buildbots (or when 
using pipe etc).

So I think a quick fix is to add -DAG to the checks that can be reorder and 
submit that fix.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-04-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D30882#1075407, @ddunbar wrote:

> In https://reviews.llvm.org/D30882#1074822, @dexonsmith wrote:
>
> > I don't think this is quite right.  I know at least `make`-based 
> > incremental builds wouldn't deal well with this.
>
>
> This is actually not a novel problem w.r.t. this patch. The exact same 
> situation comes up with Makefile-included .d files and when one of the 
> referenced headers is removed.
>
> This is typically solved somewhere in the build system, for example Make has 
> `-include`, and Ninja and llbuild have explicit support for this situation.


Of course, yes, I was wrong.  Thanks for the correction.

> I agree we might want to tread cautiously on how we change the .d output, but 
> in this case I think it might be safe.
> 
> If we decide this isn't safe, then we may want to consider a new flag which 
> tracks *all* anti-dependencies (file's for which Clang checked existence but 
> did not exist), and include that here. The major concern with that approach 
> is it is a much larger list, and while it would support being substantially 
> more correct, it is also well beyond what people currently expect out of the 
> build system + compiler generated deps approaches.

Even though this is likely safe, it seems really noisy.  Consider the case 
where someone has `__has_include()` -- we'll get an entry for every 
`-I`, `-F`, `-isystem`, and `-iframework`.  If we're going to add that noise, I 
prefer a separate flag that covers all anti-dependencies.




Comment at: test/Frontend/dependency-gen-has-include.c:11-15
+// RUN: %clang -MD -MF %t.dir/file.deps %s -fsyntax-only -I %t.dir
+// RUN: FileCheck -input-file=%t.dir/file.deps %s
+// CHECK: dependency-gen-has-include.o
+// CHECK: dependency-gen-has-include.c
+// CHECK: a/header.h

This covers quoted includes when there is a single `-I`.  I think there are a 
couple of other cases worth testing:
- Multiple `-I` arguments: all should be listed.
- Angle includes: all `-isystem` should be listed too.
- Also `-F` and `-iframework`.


https://reviews.llvm.org/D30882



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


r330601 - Remove unused code (made unused by r161073, and later more so by r248043).

2018-04-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Apr 23 08:26:15 2018
New Revision: 330601

URL: http://llvm.org/viewvc/llvm-project?rev=330601&view=rev
Log:
Remove unused code (made unused by r161073, and later more so by r248043).

Modified:
cfe/trunk/tools/diagtool/CMakeLists.txt

Modified: cfe/trunk/tools/diagtool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/CMakeLists.txt?rev=330601&r1=330600&r2=330601&view=diff
==
--- cfe/trunk/tools/diagtool/CMakeLists.txt (original)
+++ cfe/trunk/tools/diagtool/CMakeLists.txt Mon Apr 23 08:26:15 2018
@@ -17,9 +17,3 @@ target_link_libraries(diagtool
   clangBasic
   clangFrontend
   )
-
-if(UNIX)
-  set(CLANGXX_LINK_OR_COPY create_symlink)
-else()
-  set(CLANGXX_LINK_OR_COPY copy)
-endif()


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


[clang-tools-extra] r330602 - [clangd] Fix Context::derive to actually call the right method.

2018-04-23 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Apr 23 08:27:42 2018
New Revision: 330602

URL: http://llvm.org/viewvc/llvm-project?rev=330602&view=rev
Log:
[clangd] Fix Context::derive to actually call the right method.

C++ is weird.

Modified:
clang-tools-extra/trunk/clangd/Context.h

Modified: clang-tools-extra/trunk/clangd/Context.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Context.h?rev=330602&r1=330601&r2=330602&view=diff
==
--- clang-tools-extra/trunk/clangd/Context.h (original)
+++ clang-tools-extra/trunk/clangd/Context.h Mon Apr 23 08:27:42 2018
@@ -146,7 +146,7 @@ public:
 
   template  Context derive(Type &&Value) && {
 static Key::type> Private;
-return std::move(this)->derive(Private, std::forward(Value));
+return std::move(*this).derive(Private, std::forward(Value));
   }
 
   /// Clone this context object.


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


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-04-23 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 143572.
yvvan added a comment.

Use vector instead of optional as Ilya suggested


https://reviews.llvm.org/D41537

Files:
  include/clang-c/Index.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/CodeCompleteOptions.h
  include/clang/Sema/Sema.h
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/FixIt/fixit.cpp
  test/Index/complete-arrow-dot.cpp
  test/SemaCXX/member-expr.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndexCodeCompletion.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -171,6 +171,8 @@
 clang_getCompletionChunkCompletionString
 clang_getCompletionChunkKind
 clang_getCompletionChunkText
+clang_getCompletionNumCorrections
+clang_getCompletionCorrection
 clang_getCompletionNumAnnotations
 clang_getCompletionParent
 clang_getCompletionPriority
Index: tools/libclang/CIndexCodeCompletion.cpp
===
--- tools/libclang/CIndexCodeCompletion.cpp
+++ tools/libclang/CIndexCodeCompletion.cpp
@@ -16,6 +16,7 @@
 #include "CIndexDiagnostic.h"
 #include "CLog.h"
 #include "CXCursor.h"
+#include "CXSourceLocation.h"
 #include "CXString.h"
 #include "CXTranslationUnit.h"
 #include "clang/AST/Decl.h"
@@ -306,6 +307,42 @@
 
 } // end anonymous namespace
 
+unsigned
+clang_getCompletionNumCorrections(CXCompletionString completion_string) {
+  CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
+
+  if (!CCStr)
+return 0;
+  return static_cast(CCStr->getCorrections().size());
+}
+
+CXString clang_getCompletionCorrection(CXCompletionString completion_string,
+   unsigned correction_index,
+   CXSourceRange *replacement_range) {
+  CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
+
+  if (!CCStr) {
+if (replacement_range)
+  *replacement_range = clang_getNullRange();
+return cxstring::createNull();
+  }
+
+  const std::vector &Corrections = CCStr->getCorrections();
+  if (Corrections.size() <= correction_index) {
+if (replacement_range)
+  *replacement_range = clang_getNullRange();
+return cxstring::createNull();
+  }
+
+  const FullFixItHint &Correction = Corrections[correction_index];
+  if (replacement_range) {
+*replacement_range = cxloc::translateSourceRange(
+*Correction.SourceMgr, Correction.LangOpts, Correction.RemoveRange);
+  }
+
+  return cxstring::createRef(Correction.CodeToInsert.c_str());
+}
+
 /// \brief Tracks the number of code-completion result objects that are 
 /// currently active.
 ///
@@ -644,6 +681,7 @@
   unsigned options) {
   bool IncludeBriefComments = options & CXCodeComplete_IncludeBriefComments;
   bool SkipPreamble = options & CXCodeComplete_SkipPreamble;
+  bool IncludeCorrections = options & CXCodeComplete_IncludeCorrections;
 
 #ifdef UDP_CODE_COMPLETION_LOGGER
 #ifdef UDP_CODE_COMPLETION_LOGGER_PORT
@@ -650,7 +688,6 @@
   const llvm::TimeRecord &StartTime =  llvm::TimeRecord::getCurrentTime();
 #endif
 #endif
-
   bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != nullptr;
 
   if (cxtu::isNotUsableTU(TU)) {
@@ -691,6 +728,7 @@
   CodeCompleteOptions Opts;
   Opts.IncludeBriefComments = IncludeBriefComments;
   Opts.LoadExternal = !SkipPreamble;
+  Opts.IncludeCorrections = IncludeCorrections;
   CaptureCompletionResults Capture(Opts, *Results, &TU);
 
   // Perform completion.
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -2276,6 +2276,7 @@
   CXString ParentName;
   CXString BriefComment;
   CXString Annotation;
+  CXString Corr;
   const char *BriefCommentCString;
   
   fprintf(file, "%s:", clang_getCString(ks));
@@ -2337,7 +2338,14 @@
 fprintf(file, "(brief comment: %s)", BriefCommentCString);
   }
   clang_disposeString(BriefComment);
-  
+
+  if (clang_getCompletionNumCorrections(completion_result->CompletionString)) {
+CXSourceRange correction_range;
+Corr = clang_getCompletionCorrection(completion_result->CompletionString, 0,
+ &correction_range);
+fprintf(file, " (requires correction to \"%s\")", clang_getCString(Corr));
+  }
+
   fprintf(file, "\n");
 }
 
@@ -2436,6 +2444,8 @@
 completionOptions |= CXCodeComplete_IncludeBriefComments;
   if (getenv("CINDEXTEST_COMPLETION_SKIP_PREAMBLE"))
 completionOptions |= CXCodeComplete_SkipPreamble;
+  if (getenv("CINDEXTEST_COMPLETION_INCLUDE_CORRECTIONS"))
+completionOptions |= CXCodeComplete_IncludeCorrections;
   

r330604 - Fix case of LLVM library names.

2018-04-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Apr 23 08:41:08 2018
New Revision: 330604

URL: http://llvm.org/viewvc/llvm-project?rev=330604&view=rev
Log:
Fix case of LLVM library names.

Modified:
cfe/trunk/tools/clang-import-test/CMakeLists.txt

Modified: cfe/trunk/tools/clang-import-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/CMakeLists.txt?rev=330604&r1=330603&r2=330604&view=diff
==
--- cfe/trunk/tools/clang-import-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-import-test/CMakeLists.txt Mon Apr 23 08:41:08 2018
@@ -1,7 +1,7 @@
 set(LLVM_LINK_COMPONENTS
-  core
-  support
-)
+  Core
+  Support
+  )
 
 if(NOT CLANG_BUILT_STANDALONE)
   set(tablegen_deps intrinsics_gen)


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


r330605 - [analyzer] Don't crash on printing ConcreteInt of size >64 bits

2018-04-23 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Mon Apr 23 08:41:44 2018
New Revision: 330605

URL: http://llvm.org/viewvc/llvm-project?rev=330605&view=rev
Log:
[analyzer] Don't crash on printing ConcreteInt of size >64 bits

Printing of ConcreteInts with size >64 bits resulted in assertion failure
in get[Z|S]ExtValue() because these methods are only allowed to be used
with integers of 64 max bit width. This patch fixes the issue.


Added:
cfe/trunk/test/Analysis/sval-dump-int128.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp?rev=330605&r1=330604&r2=330605&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp Mon Apr 23 08:41:44 2018
@@ -300,13 +300,9 @@ void SVal::dumpToStream(raw_ostream &os)
 void NonLoc::dumpToStream(raw_ostream &os) const {
   switch (getSubKind()) {
 case nonloc::ConcreteIntKind: {
-  const nonloc::ConcreteInt& C = castAs();
-  if (C.getValue().isUnsigned())
-os << C.getValue().getZExtValue();
-  else
-os << C.getValue().getSExtValue();
-  os << ' ' << (C.getValue().isUnsigned() ? 'U' : 'S')
- << C.getValue().getBitWidth() << 'b';
+  const auto &Value = castAs().getValue();
+  os << Value << ' ' << (Value.isSigned() ? 'S' : 'U')
+ << Value.getBitWidth() << 'b';
   break;
 }
 case nonloc::SymbolValKind:

Added: cfe/trunk/test/Analysis/sval-dump-int128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/sval-dump-int128.c?rev=330605&view=auto
==
--- cfe/trunk/test/Analysis/sval-dump-int128.c (added)
+++ cfe/trunk/test/Analysis/sval-dump-int128.c Mon Apr 23 08:41:44 2018
@@ -0,0 +1,7 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection %s -verify
+
+void clang_analyzer_dump(unsigned __int128 x);
+
+void testDumpInt128() {
+  clang_analyzer_dump((unsigned __int128)5 << 64); // 
expected-warning{{92233720368547758080 U128b}}
+}


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


[PATCH] D45417: [analyzer] Don't crash on printing ConcreteInt of size >64 bits

2018-04-23 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin closed this revision.
a.sidorin added a comment.

Closed with https://reviews.llvm.org/rC330605. Forgot to mention the 
Differential Revision, sorry.


Repository:
  rC Clang

https://reviews.llvm.org/D45417



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D45619#1075437, @bjope wrote:

> I can't see that it has been reverted.
>  But I guess that the table maybe is sorted based on time spent in each pass? 
> So that is why it might be sorted differently on different buildbots (or when 
> using pipe etc).
>
> So I think a quick fix is to add -DAG to the checks that can be reorder and 
> submit that fix.


I don't see revert as well. But I did the following:

svn merge -c -330571 .

And everything was OK.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D45284: [RISCV] More validations on the input value of -march=

2018-04-23 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In https://reviews.llvm.org/D45284#1074282, @apazos wrote:

> Hi Alex, it seems the table expects these extensions in a canonical order 
> too: all x extensions, followed by all s extensions, and then all sx 
> extensions.
>
> I can make the change, no problem. I have also coded other error situations 
> described below.
>
> But f I cannot push a test we can enable, because we error out when we find 
> the first non-supported extension in the string with unsupported extension 
> message, and stop parsing the string.


In the best case we would first parse the string and give errors based on the 
string being malformed before determining which extensions the compiler 
supports and complaining if the extension is not supported. This would probably 
move us towards a two-pass scheme where structs are are generated from the 
string, (parsing stage) which are then processed. e.g. `{ enum ExtType Type; 
StringRef name; int MajorVersion; int MinorVersion; }`. The parser can issue 
errors encountered when extracting this struct (e.g. malformed version 
identifiers), including erroring if the ordering of the ExtType relative to the 
previous ExtType is unexpected. The next step is complaining about semantic 
issues (clashing extensions or extensions with missing dependencies) as well as 
extensions that aren't supported.

However I realise that might be a larger refactoring. This is already the most 
complete RISC-V ISA string parser in existence (as far as I know), which goes 
some way beyond our near-term requirements. I'd be happy to merge this current 
version and evolve it in-tree if you prefer, or of course I'll happily review 
further updates to this patch.


https://reviews.llvm.org/D45284



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


[clang-tools-extra] r330608 - [clangd][tests] Fix handling of EOF in delimited input

2018-04-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Apr 23 08:55:07 2018
New Revision: 330608

URL: http://llvm.org/viewvc/llvm-project?rev=330608&view=rev
Log:
[clangd][tests] Fix handling of EOF in delimited input

Request in delimited input ended by EOF shouldn't be an error state.
Comments at the end of test file shouldn't be logged as an error state.
Input mirroring should work for the last request in delimited test file.

Added:
clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=330608&r1=330607&r2=330608&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Apr 23 08:55:07 
2018
@@ -277,21 +277,19 @@ static llvm::Optional readD
 if (LineRef.startswith("#")) // comment
   continue;
 
-bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
-if (!IsDelim) // Line is part of a JSON message.
-  JSON += Line;
-if (IsDelim) {
-  Out.mirrorInput(
-  llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
-  return std::move(JSON);
-}
+// found a delimiter
+if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+  break;
+
+JSON += Line;
   }
 
   if (In.bad()) {
 log("Input error while reading message!");
 return llvm::None;
   } else {
-log("Input message terminated by EOF");
+Out.mirrorInput(
+llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
 return std::move(JSON);
   }
 }

Added: 
clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test?rev=330608&view=auto
==
--- clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test 
(added)
+++ clang-tools-extra/trunk/test/clangd/delimited-input-comment-at-the-end.test 
Mon Apr 23 08:55:07 2018
@@ -0,0 +1,12 @@
+# RUN: clangd -input-style=delimited -run-synchronously -input-mirror-file %t 
< %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+# RUN: clangd -lit-test -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# comment at the end


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


[clang-tools-extra] r330609 - [clangd][tests] Fix delimiter handling

2018-04-23 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Apr 23 08:58:42 2018
New Revision: 330609

URL: http://llvm.org/viewvc/llvm-project?rev=330609&view=rev
Log:
[clangd][tests] Fix delimiter handling

Empty line shouldn't be considered a delimiter

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

Added:
clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=330609&r1=330608&r2=330609&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Apr 23 08:58:42 
2018
@@ -278,7 +278,7 @@ static llvm::Optional readD
   continue;
 
 // found a delimiter
-if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+if (LineRef.rtrim() == "---")
   break;
 
 JSON += Line;

Added: clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test?rev=330609&view=auto
==
--- clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test (added)
+++ clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test Mon Apr 
23 08:58:42 2018
@@ -0,0 +1,13 @@
+# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck 
%s
+# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# CHECK-NOT: JSON parse error


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


[PATCH] D45764: [clangd][tests] Fix delimiter handling

2018-04-23 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330609: [clangd][tests] Fix delimiter handling (authored by 
jkorous, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D45764?vs=142918&id=143573#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45764

Files:
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
  clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test


Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
===
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
@@ -278,7 +278,7 @@
   continue;
 
 // found a delimiter
-if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+if (LineRef.rtrim() == "---")
   break;
 
 JSON += Line;
Index: clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
===
--- clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
+++ clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
@@ -0,0 +1,13 @@
+# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck 
%s
+# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# CHECK-NOT: JSON parse error


Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
===
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
@@ -278,7 +278,7 @@
   continue;
 
 // found a delimiter
-if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+if (LineRef.rtrim() == "---")
   break;
 
 JSON += Line;
Index: clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
===
--- clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
+++ clang-tools-extra/trunk/test/clangd/spaces-in-delimited-input.test
@@ -0,0 +1,13 @@
+# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck %s
+# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# CHECK-NOT: JSON parse error
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45763: [clangd][tests] Fix handling of EOF in delimited input

2018-04-23 Thread Jan Korous via Phabricator via cfe-commits
jkorous closed this revision.
jkorous added a comment.

I forgot to mention review in commit message.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@330608 
91177308-0d34-0410-b5e6-96231b3b80d8


https://reviews.llvm.org/D45763



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


[PATCH] D45965: [Targets] Implement getConstraintRegister for ARM and AArch64

2018-04-23 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added inline comments.



Comment at: lib/Basic/Targets/AArch64.h:85-89
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+

From what I understood of the original patch, getConstraintRegister is a sort 
of a more comprehensive version of convertRegister. On ARM convertRegister 
handles U and p constraint specially, should this do the same?


https://reviews.llvm.org/D45965



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


r330613 - Quick fix for rC330605: specify a target arch for test

2018-04-23 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Mon Apr 23 09:38:29 2018
New Revision: 330613

URL: http://llvm.org/viewvc/llvm-project?rev=330613&view=rev
Log:
Quick fix for rC330605: specify a target arch for test


Modified:
cfe/trunk/test/Analysis/sval-dump-int128.c

Modified: cfe/trunk/test/Analysis/sval-dump-int128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/sval-dump-int128.c?rev=330613&r1=330612&r2=330613&view=diff
==
--- cfe/trunk/test/Analysis/sval-dump-int128.c (original)
+++ cfe/trunk/test/Analysis/sval-dump-int128.c Mon Apr 23 09:38:29 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection %s -verify
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=debug.ExprInspection %s -verify
 
 void clang_analyzer_dump(unsigned __int128 x);
 


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


[PATCH] D45917: Pass -Oz/-Os along to the backend

2018-04-23 Thread Jessica Paquette via Phabricator via cfe-commits
paquette updated this revision to Diff 143584.
paquette added a comment.

Add context to diff.


https://reviews.llvm.org/D45917

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/arm64-outline.c


Index: test/CodeGen/arm64-outline.c
===
--- /dev/null
+++ test/CodeGen/arm64-outline.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple arm64--- -Oz -S -mllvm 
-debug-pass=Structure %s -o /dev/null 2> FileCheck %s
+// CHECK: Machine Outliner
+// RUN: %clang_cc1 -emit-llvm -Oz -S -mllvm -debug-pass=Structure %s -o 
/dev/null 2> FileCheck %s
+// CHECK-NOT: Machine Outliner
+// Ensure that -Oz is properly passed down to the backend by checking if the 
+// Machine Outliner is only added by default in ARM64.
+
+void foo(void) {
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -354,6 +354,19 @@
   }
 }
 
+static CodeGenSizeOpt::Level getCGSizeOptLevel(const CodeGenOptions 
&CodeGenOpts) {
+  switch (CodeGenOpts.OptimizeSize) {
+default:
+  llvm_unreachable("Invalid size optimization level!");
+case 0:
+  return CodeGenSizeOpt::None;
+case 1:
+  return CodeGenSizeOpt::OptSize; // Os
+case 2:
+  return CodeGenSizeOpt::MinSize; // Oz
+  }
+}
+
 static Optional
 getCodeModel(const CodeGenOptions &CodeGenOpts) {
   unsigned CodeModel = llvm::StringSwitch(CodeGenOpts.CodeModel)
@@ -692,11 +705,12 @@
   llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
   llvm::Reloc::Model RM = CodeGenOpts.RelocationModel;
   CodeGenOpt::Level OptLevel = getCGOptLevel(CodeGenOpts);
-
+  CodeGenSizeOpt::Level SizeOptLevel = getCGSizeOptLevel(CodeGenOpts);
   llvm::TargetOptions Options;
   initTargetOptions(Options, CodeGenOpts, TargetOpts, LangOpts, HSOpts);
   TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,
-  Options, RM, CM, OptLevel));
+  Options, RM, CM, OptLevel,
+  SizeOptLevel));
 }
 
 bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses,


Index: test/CodeGen/arm64-outline.c
===
--- /dev/null
+++ test/CodeGen/arm64-outline.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple arm64--- -Oz -S -mllvm -debug-pass=Structure %s -o /dev/null 2> FileCheck %s
+// CHECK: Machine Outliner
+// RUN: %clang_cc1 -emit-llvm -Oz -S -mllvm -debug-pass=Structure %s -o /dev/null 2> FileCheck %s
+// CHECK-NOT: Machine Outliner
+// Ensure that -Oz is properly passed down to the backend by checking if the 
+// Machine Outliner is only added by default in ARM64.
+
+void foo(void) {
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -354,6 +354,19 @@
   }
 }
 
+static CodeGenSizeOpt::Level getCGSizeOptLevel(const CodeGenOptions &CodeGenOpts) {
+  switch (CodeGenOpts.OptimizeSize) {
+default:
+  llvm_unreachable("Invalid size optimization level!");
+case 0:
+  return CodeGenSizeOpt::None;
+case 1:
+  return CodeGenSizeOpt::OptSize; // Os
+case 2:
+  return CodeGenSizeOpt::MinSize; // Oz
+  }
+}
+
 static Optional
 getCodeModel(const CodeGenOptions &CodeGenOpts) {
   unsigned CodeModel = llvm::StringSwitch(CodeGenOpts.CodeModel)
@@ -692,11 +705,12 @@
   llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
   llvm::Reloc::Model RM = CodeGenOpts.RelocationModel;
   CodeGenOpt::Level OptLevel = getCGOptLevel(CodeGenOpts);
-
+  CodeGenSizeOpt::Level SizeOptLevel = getCGSizeOptLevel(CodeGenOpts);
   llvm::TargetOptions Options;
   initTargetOptions(Options, CodeGenOpts, TargetOpts, LangOpts, HSOpts);
   TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,
-  Options, RM, CM, OptLevel));
+  Options, RM, CM, OptLevel,
+  SizeOptLevel));
 }
 
 bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-04-23 Thread Pete Cooper via Phabricator via cfe-commits
pete added a comment.

In https://reviews.llvm.org/D30882#1075461, @dexonsmith wrote:

> In https://reviews.llvm.org/D30882#1075407, @ddunbar wrote:
>
> > In https://reviews.llvm.org/D30882#1074822, @dexonsmith wrote:
> >
> > > I don't think this is quite right.  I know at least `make`-based 
> > > incremental builds wouldn't deal well with this.
> >
> >
> > This is actually not a novel problem w.r.t. this patch. The exact same 
> > situation comes up with Makefile-included .d files and when one of the 
> > referenced headers is removed.
> >
> > This is typically solved somewhere in the build system, for example Make 
> > has `-include`, and Ninja and llbuild have explicit support for this 
> > situation.
>
>
> Of course, yes, I was wrong.  Thanks for the correction.
>
> > I agree we might want to tread cautiously on how we change the .d output, 
> > but in this case I think it might be safe.
> > 
> > If we decide this isn't safe, then we may want to consider a new flag which 
> > tracks *all* anti-dependencies (file's for which Clang checked existence 
> > but did not exist), and include that here. The major concern with that 
> > approach is it is a much larger list, and while it would support being 
> > substantially more correct, it is also well beyond what people currently 
> > expect out of the build system + compiler generated deps approaches.
>
> Even though this is likely safe, it seems really noisy.  Consider the case 
> where someone has `__has_include()` -- we'll get an entry for every 
> `-I`, `-F`, `-isystem`, and `-iframework`.  If we're going to add that noise, 
> I prefer a separate flag that covers all anti-dependencies.


Oh, that actually wasn't my intention when I wrote it.

Honestly I didn't expect it to log anything for missing paths at all, as we 
don't currently log all the missing (but attempted) paths for regular 
#include's.

Would it be ok to turn this on by default, without a flag, only in the case of 
the path actually existing, and only the found path being the one we add to the 
.d?


https://reviews.llvm.org/D30882



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


[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-04-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D30882#1075576, @pete wrote:

> Oh, that actually wasn't my intention when I wrote it.
>
> Honestly I didn't expect it to log anything for missing paths at all, as we 
> don't currently log all the missing (but attempted) paths for regular 
> #include's.


Then I misunderstood the patch.  Maybe add a test or two that confirms it only 
adds dependencies, not anti-dependencies?

> Would it be ok to turn this on by default, without a flag, only in the case 
> of the path actually existing, and only the found path being the one we add 
> to the .d?

I think that pessimizes some incremental builds:

- You have a `__has_include("missing.h")`, but don't include missing.h.
- Change "missing.h" (but don't delete it).
- An incremental build now has to rebuild the object file, even though nothing 
will have changed.

However, it's fixing an actual bug, so it makes sense to me to be more 
conservative.


https://reviews.llvm.org/D30882



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


[PATCH] D45722: [X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (clang side)

2018-04-23 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8426
+  llvm::Type *BTy = llvm::VectorType::get(CGF.Builder.getInt8Ty(), N * 8);
+  SmallVector ShuffleMask;
+  for (unsigned i = 0; i < N; ++i)

Size the ShuffleMask to N when it's created. Then you can use just direct 
assign each array entry in the loops. This will remove the need for the clear() 
in the later loop. It will also remove the hidden code that checks if we need 
to grow on every call to push_back.


https://reviews.llvm.org/D45722



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


[PATCH] D45722: [X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (clang side)

2018-04-23 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8431
+  CGF.Builder.CreateZExt(CGF.Builder.CreateShuffleVector(
+ AD, llvm::UndefValue::get(BTy), ShuffleMask),
+ VTy);

You can just pass AD twice. You don't need to create an Undef value. It will 
get optimized later.


https://reviews.llvm.org/D45722



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


r330620 - [OPENMP] Do not cast captured by value variables with pointer types in

2018-04-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Apr 23 10:33:41 2018
New Revision: 330620

URL: http://llvm.org/viewvc/llvm-project?rev=330620&view=rev
Log:
[OPENMP] Do not cast captured by value variables with pointer types in
NVPTX target.

When generating the wrapper function for the offloading region, we need
to call the outlined function and cast the arguments correctly to follow
the ABI. Usually, variables captured by value are casted to `uintptr_t`
type. But this should not performed for the variables with pointer type.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=330620&r1=330619&r2=330620&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Apr 23 10:33:41 2018
@@ -3037,7 +3037,8 @@ llvm::Function *CGOpenMPRuntimeNVPTX::cr
   /*Volatile=*/false,
   
CGFContext.getPointerType(ElemTy),
   CI->getLocation());
-  if (CI->capturesVariableByCopy()) {
+  if (CI->capturesVariableByCopy() &&
+  !CI->getCapturedVar()->getType()->isAnyPointerType()) {
 Arg = castValueToType(CGF, Arg, ElemTy, CGFContext.getUIntPtrType(),
   CI->getLocation());
   }

Modified: 
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp?rev=330620&r1=330619&r2=330620&view=diff
==
--- 
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp 
(original)
+++ 
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp 
Mon Apr 23 10:33:41 2018
@@ -9,10 +9,11 @@
 #define HEADER
 
 // Check that the execution mode of all 2 target regions on the gpu is set to 
SPMD Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l30}}_exec_mode = weak constant i8 0
-// CHECK-DAG: {{@__omp_offloading_.+l36}}_exec_mode = weak constant i8 0
-// CHECK-DAG: {{@__omp_offloading_.+l41}}_exec_mode = weak constant i8 0
-// CHECK-DAG: {{@__omp_offloading_.+l46}}_exec_mode = weak constant i8 0
+// CHECK-DAG: {{@__omp_offloading_.+l32}}_exec_mode = weak constant i8 0
+// CHECK-DAG: {{@__omp_offloading_.+l38}}_exec_mode = weak constant i8 0
+// CHECK-DAG: {{@__omp_offloading_.+l43}}_exec_mode = weak constant i8 0
+// CHECK-DAG: {{@__omp_offloading_.+l48}}_exec_mode = weak constant i8 0
+// CHECK-DAG: {{@__omp_offloading_.+l56}}_exec_mode = weak constant i8 0
 
 #define N 1000
 #define M 10
@@ -26,6 +27,7 @@ tx ftemplate(int n) {
   tx f = n;
   tx l;
   int k;
+  tx *v;
 
 #pragma omp target teams distribute parallel for lastprivate(l) 
dist_schedule(static,128) schedule(static,32)
   for(int i = 0; i < n; i++) {
@@ -51,6 +53,9 @@ tx ftemplate(int n) {
 }
   }
 
+#pragma omp target teams distribute parallel for map(a, v[:N])
+  for(int i = 0; i < n; i++)
+a[i] = v[i];
   return a[0];
 }
 
@@ -120,4 +125,8 @@ int bar(int n){
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
+// CHECK: define void @__omp_offloading_{{.*}}_l56(i[[SZ:64|32]] %{{[^,]+}}, 
[1000 x i32]* dereferenceable{{.*}}, i32* %{{[^)]+}})
+// CHECK: call void [[OUTLINED:@__omp_outlined.*]](i32* %{{.+}}, i32* %{{.+}}, 
i[[SZ]] %{{.*}}, i[[SZ]] %{{.*}}, i[[SZ]] %{{.*}}, [1000 x i32]* %{{.*}}, i32* 
%{{.*}})
+// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.*}}, i32* noalias 
%{{.*}} i[[SZ]] %{{.+}}, i[[SZ]] %{{.+}}, i[[SZ]] %{{.+}}, [1000 x i32]* 
dereferenceable{{.*}}, i32* %{{.*}})
+
 #endif


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


[PATCH] D45715: [libcxx] [test] Remove nonportable that errc::is_a_directory produces "Is a directory" from ios_base::failure tests

2018-04-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I'm fine with this change, but I'm wondering:

- if there are similar tests in the filesystem test suite, and you haven't 
tripped over them because you spelled your error message the same as we did.
- Should part of this test be moved into test/libcxx


https://reviews.llvm.org/D45715



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


[PATCH] D41148: [libcxx] implement declarations based on P0214R7.

2018-04-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: bixia.

This looks ready to land to me.




Comment at: 
libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp:122
+static_assert(is_simd_mask_v>, "");
+static_assert(is_simd_mask_v>, "");
+

Minor formatting nit. When I have stacks of tests like this, I usually leave a 
space after the '(', so that positive and negative tests line up, and so I can 
see at a glance which are which.

Example:
static_assert( is_simd_mask_v>, "");
static_assert(!is_simd_mask_v, "");




https://reviews.llvm.org/D41148



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


[PATCH] D45451: [ItaniumMangle] Undeduced auto type doesn't belong in the substitution table

2018-04-23 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2342
+  if (isa(Ty))
+return false;
   return true;

erik.pilkington wrote:
> rjmccall wrote:
> > rjmccall wrote:
> > > rjmccall wrote:
> > > > I agree with your analysis that this shouldn't be a substitution 
> > > > candidate.  However, I think this probably needs an ABI-compatibility 
> > > > guard.
> > > You should probably add a comment like "Prior to LLVM v6, Clang 
> > > accidentally treated deduced auto types as substitution candidates."
> > Er, not "prior to", I guess.  "through", maybe, or "up to and including".
> Sure, I added that comment into the new patch. You meant to say "undeduced 
> auto types", right? Deduced auto types should have been desugared to their 
> underlying type before this function get called in mangleType().
Yes, right, thanks.  LGTM.


https://reviews.llvm.org/D45451



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

buildbots have been failing all day (and were still failing). So I pushed my 
suggested fix.
I hope that was OK.


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-04-23 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D30882#1075589, @dexonsmith wrote:

> In https://reviews.llvm.org/D30882#1075576, @pete wrote:
>
> > Would it be ok to turn this on by default, without a flag, only in the case 
> > of the path actually existing, and only the found path being the one we add 
> > to the .d?
>
>
> I think that pessimizes some incremental builds:
>
> - You have a `__has_include("missing.h")`, but don't include missing.h.
> - Change "missing.h" (but don't delete it).
> - An incremental build now has to rebuild the object file, even though 
> nothing will have changed.
>
>   However, it's fixing an actual bug, so it makes sense to me to be more 
> conservative.


To be clear, I meant "yes" by that!


https://reviews.llvm.org/D30882



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


[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:70-72
+  if (Bytes.find_if([](char C) {
+return static_cast(C) > 0x7Fu;
+  }) != StringRef::npos)

I think you can use `isASCII()` from CharInfo.h rather than reimplement it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45932



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


r330622 - Improve checks in test/Frontend/ftime-report-template-decl.cpp

2018-04-23 Thread Bjorn Pettersson via cfe-commits
Author: bjope
Date: Mon Apr 23 11:05:35 2018
New Revision: 330622

URL: http://llvm.org/viewvc/llvm-project?rev=330622&view=rev
Log:
Improve checks in test/Frontend/ftime-report-template-decl.cpp

Some buildbots seems to have problems with the CHECKs in
test/Frontend/ftime-report-template-decl.cpp.

I this the problem is that the order in which timers are printed
is based on consumed wall time. So there is no guarantee in which
order the timers are printed.

This patch uses CHECK-DAG instead of CHECK to make the test
case less sensitive to the actual time used by the different
passes.

The (sometimes) failing test cases where introduced in trunk@330571.

Modified:
cfe/trunk/test/Frontend/ftime-report-template-decl.cpp

Modified: cfe/trunk/test/Frontend/ftime-report-template-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/ftime-report-template-decl.cpp?rev=330622&r1=330621&r2=330622&view=diff
==
--- cfe/trunk/test/Frontend/ftime-report-template-decl.cpp (original)
+++ cfe/trunk/test/Frontend/ftime-report-template-decl.cpp Mon Apr 23 11:05:35 
2018
@@ -151,8 +151,8 @@ struct _Wrap_alloc {
 _Wrap_alloc::rebind w;
 
 // CHECK: Miscellaneous Ungrouped Timers
-// CHECK: LLVM IR Generation Time
-// CHECK: Code Generation Time
+// CHECK-DAG: LLVM IR Generation Time
+// CHECK-DAG: Code Generation Time
 // CHECK: Total
 // CHECK: Clang front-end time report
 // CHECK: Clang front-end timer


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


[PATCH] D45865: [Sema] Emit -Warray-bounds for multiple levels of subscript expressions.

2018-04-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:11284
+  case Stmt::MemberExprClass: {
+const MemberExpr *ME = cast(expr);
+expr = ME->getBase();

Can use `const auto *` here instead of spelling the type out twice. 
Alternatively, you could skip the local variable entirely if you want.



Comment at: test/SemaCXX/array-bounds.cpp:275
+int test_multiarray() {
+  return multi[2][0][0]; // expected-warning {{array index 2 is past the end 
of the array (which contains 2 elements)}}
+}

Can you also add tests for `multi[0][2][0]` and `multi[0][0][2]` to more 
clearly demonstrate that all levels of array indexing are checked?


Repository:
  rC Clang

https://reviews.llvm.org/D45865



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


[PATCH] D45715: [libcxx] [test] Remove nonportable that errc::is_a_directory produces "Is a directory" from ios_base::failure tests

2018-04-23 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added a comment.

In https://reviews.llvm.org/D45715#1075665, @mclow.lists wrote:

> - if there are similar tests in the filesystem test suite, and you haven't 
> tripped over them because you spelled your error message the same as we did.


Almost certainly. But we aren't running your filesystem tests yet because they 
are still under experimental. There are probably a lot of POSIX assumptions 
everywhere in there given the root_name parsing business.

In https://reviews.llvm.org/D45715#1075665, @mclow.lists wrote:

> - Should part of this test be moved into test/libcxx


That one's up to you. I don't think the specific message matters to this test; 
clearly the existing asserts for `io_errc::stream` don't care about a specific 
message (which is why they worked on our implementation).


https://reviews.llvm.org/D45715



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


r330626 - DR727: remove wrong assertion for use of class-scope explicit

2018-04-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 23 11:38:30 2018
New Revision: 330626

URL: http://llvm.org/viewvc/llvm-project?rev=330626&view=rev
Log:
DR727: remove wrong assertion for use of class-scope explicit
specialization without -fms-extensions.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/drs/dr7xx.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=330626&r1=330625&r2=330626&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Apr 23 11:38:30 2018
@@ -7561,10 +7561,6 @@ Sema::ActOnClassTemplateSpecialization(S
   ClassTemplate->AddSpecialization(Specialization, InsertPos);
 
 if (CurContext->isDependentContext()) {
-  // -fms-extensions permits specialization of nested classes without
-  // fully specializing the outer class(es).
-  assert(getLangOpts().MicrosoftExt &&
- "Only possible with -fms-extensions!");
   TemplateName CanonTemplate = Context.getCanonicalTemplateName(Name);
   CanonType = Context.getTemplateSpecializationType(
   CanonTemplate, Converted);

Modified: cfe/trunk/test/CXX/drs/dr7xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr7xx.cpp?rev=330626&r1=330625&r2=330626&view=diff
==
--- cfe/trunk/test/CXX/drs/dr7xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr7xx.cpp Mon Apr 23 11:38:30 2018
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
-namespace dr727 { // dr727: 7
+namespace dr727 { // dr727: partial
   struct A {
 template struct C; // expected-note 6{{here}}
 template void f(); // expected-note {{here}}
@@ -48,6 +48,33 @@ namespace dr727 { // dr727: 7
 template struct A::C; // expected-error {{not in class 
'A' or an enclosing namespace}}
 template int A::N; // expected-error {{not in class 
'A' or an enclosing namespace}}
   }
+
+  template
+  struct D {
+template struct C { typename T::error e; }; // expected-error 
{{no members}}
+template void f() { T::error; } // expected-error {{no 
members}}
+template static const int N = T::error; // expected-error 
2{{no members}} expected-error 0-1{{C++14}}
+
+template<> struct C {};
+template<> void f() {}
+template<> static const int N;
+
+template struct C {};
+template static const int N;
+  };
+
+  void d(D di) {
+D::C();
+di.f();
+int a = D::N; // FIXME: expected-note {{instantiation of}}
+
+D::C();
+int b = D::N;
+
+D::C(); // expected-note {{instantiation of}}
+di.f(); // expected-note {{instantiation of}}
+int c = D::N; // expected-note {{instantiation of}}
+  }
 }
 
 namespace dr777 { // dr777: 3.7


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


[PATCH] D41148: [libcxx] implement declarations based on P0214R7.

2018-04-23 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 143610.
timshen added a comment.

Update formatting on static_asserts.


https://reviews.llvm.org/D41148

Files:
  libcxx/include/experimental/__config
  libcxx/include/experimental/simd
  libcxx/include/module.modulemap
  libcxx/test/libcxx/double_include.sh.cpp
  libcxx/test/std/experimental/simd/nothing_to_do.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/genertor.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
@@ -0,0 +1,133 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.traits]
+// template  struct is_simd_mask;
+// template  inline constexpr bool is_simd_mask_v = is_simd_mask::value;
+
+#include 
+#include 
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+struct UserType {};
+
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+static_assert( is_simd_mask>::value, "");
+
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask::value, "");
+static_assert(!is_simd_mask>::value, "");
+static_assert(!is_simd_mask>::value, "");
+static_assert(!is_simd_mask::value, "");
+
+#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\
+!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES)
+
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+static_assert( is_simd_mask_v>, "");
+sta

[libcxx] r330627 - [libcxx] implement declarations based on P0214R7.

2018-04-23 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Apr 23 11:47:07 2018
New Revision: 330627

URL: http://llvm.org/viewvc/llvm-project?rev=330627&view=rev
Log:
[libcxx] implement  declarations based on P0214R7.

Summary:
The patch includes all declarations, and also implements the following features:
* ABI.
* narrowing-conversion related SFIANE, including simd<> ctors and 
(static_)simd_cast.

Reviewers: mclow.lists, EricWF

Subscribers: lichray, sanjoy, MaskRay, cfe-commits

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

Added:
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/
libcxx/trunk/test/std/experimental/simd/nothing_to_do.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/
libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/
libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/genertor.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/
libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp

libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
Modified:
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=330627&r1=330626&r2=330627&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Apr 23 11:47:07 2018
@@ -54,4 +54,16 @@
 
 #define _VSTD_FS ::std::experimental::filesystem::v1
 
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
+} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+
 #endif

Added: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=330627&view=auto
==
--- libcxx/trunk/include/experimental/simd (added)
+++ libcxx/trunk/include/experimental/simd Mon Apr 23 11:47:07 2018
@@ -0,0 +1,1285 @@
+// -*- C++ -*-
+//===--- simd 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef _LIBCPP_EXPERIMENTAL_SIMD
+#define _LIBCPP_EXPERIMENTAL_SIMD
+
+/*
+experimental/simd synopsis
+
+namespace std::experimental {
+
+inline namespace parallelism_v2 {
+
+namespace simd_abi {
+
+struct scalar {};
+template  struct fixed_size {};
+template  inline constexpr int max_fixed_size = 
implementation-defined;
+template  using compatible = implementation-defined;
+template  using native = implementation-defined;
+
+} // simd_abi
+
+struct element_aligned_tag {};
+struct vector_aligned_tag {};
+template  struct overaligned_tag {};
+inline constexpr element_aligned_tag element_aligned{};
+inline constexpr vector_aligned_tag vector_aligned{};
+template  inline constexpr overaligned_tag overaligned{};
+
+// traits [simd.traits]
+template  struct is_abi_tag;
+template  inline constexpr bool is_abi_tag_v = is_abi_tag::value;
+
+template  struct is_simd;
+template  inline constexpr bool is_simd_v = is_simd::value;
+
+template  struct is_simd_mask;
+template  inline constexpr bool is_simd_mask_v = 
is_simd_mask::value;
+
+template  struct is_simd_flag_type;
+template  inline constexpr bool is_simd_flag_type_v = 
is_simd_flag_type::value;
+
+template  struct abi_for_size { using type = see below; };
+template  using abi_for_size_t = typename abi_for_size::type;
+
+template > struct simd_size;
+template >
+inline constexpr size_t simd_size_v = simd_size::value;
+
+template  struct memory_alignment;
+template 
+inline constexpr size_t memory_alignment_v = memory_alignment::value;
+
+// class template simd [simd.class]
+template > class simd;
+template  using native_simd = simd>;
+template  using fixed_size

[PATCH] D41148: [libcxx] implement declarations based on P0214R7.

2018-04-23 Thread Tim Shen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330627: [libcxx] implement  
declarations based on P0214R7. (authored by timshen, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D41148?vs=143610&id=143611#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41148

Files:
  libcxx/trunk/include/experimental/__config
  libcxx/trunk/include/experimental/simd
  libcxx/trunk/include/module.modulemap
  libcxx/trunk/test/libcxx/double_include.sh.cpp
  libcxx/trunk/test/std/experimental/simd/nothing_to_do.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.cons/genertor.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
  libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Index: libcxx/trunk/include/module.modulemap
===
--- libcxx/trunk/include/module.modulemap
+++ libcxx/trunk/include/module.modulemap
@@ -550,6 +550,10 @@
   header "experimental/regex"
   export *
 }
+module simd {
+  header "experimental/simd"
+  export *
+}
 module set {
   header "experimental/set"
   export *
Index: libcxx/trunk/include/experimental/simd
===
--- libcxx/trunk/include/experimental/simd
+++ libcxx/trunk/include/experimental/simd
@@ -0,0 +1,1285 @@
+// -*- C++ -*-
+//===--- simd -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef _LIBCPP_EXPERIMENTAL_SIMD
+#define _LIBCPP_EXPERIMENTAL_SIMD
+
+/*
+experimental/simd synopsis
+
+namespace std::experimental {
+
+inline namespace parallelism_v2 {
+
+namespace simd_abi {
+
+struct scalar {};
+template  struct fixed_size {};
+template  inline constexpr int max_fixed_size = implementation-defined;
+template  using compatible = implementation-defined;
+template  using native = implementation-defined;
+
+} // simd_abi
+
+struct element_aligned_tag {};
+struct vector_aligned_tag {};
+template  struct overaligned_tag {};
+inline constexpr element_aligned_tag element_aligned{};
+inline constexpr vector_aligned_tag vector_aligned{};
+template  inline constexpr overaligned_tag overaligned{};
+
+// traits [simd.traits]
+template  struct is_abi_tag;
+template  inline constexpr bool is_abi_tag_v = is_abi_tag::value;
+
+template  struct is_simd;
+template  inline constexpr bool is_simd_v = is_simd::value;
+
+template  struct is_simd_mask;
+template  inline constexpr bool is_simd_mask_v = is_simd_mask::value;
+
+template  struct is_simd_flag_type;
+template  inline constexpr bool is_simd_flag_type_v = is_simd_flag_type::value;
+
+template  struct abi_for_size { using type = see below; };
+template  using abi_for_size_t = typename abi_for_size::type;
+
+template > struct simd_size;
+template >
+inline constexpr size_t simd_size_v = simd_size::value;
+
+template  struct memory_alignment;
+template 
+inline constexpr size_t memory_alignment_v = memory_alignment::value;
+
+// class template simd [simd.class]
+template > class simd;
+template  using native_simd = simd>;
+template  using fixed_size_simd = simd>;
+
+// class template simd_mask [simd.mask.class]
+template > class simd_mask;
+template  using native_simd_mask = simd_mask>;
+template  using fixed_size_simd_mask = simd_mask>;
+
+// casts [simd.casts]
+template  see below simd_cast(const simd&);
+template  see below static_simd_cast(const simd&);
+
+template 
+fixed_size_simd> to_fixed_size(const simd&) noexcept;
+template 
+fixed_size_simd_mask> to_fixed_size(const simd_mask&) noexcept;
+template  native_simd to_native(const fixed_size_simd&) noexcept;
+template 
+native_simd_mask to_native(const fixed_size_simd_mask> &) noexcept;
+template  simd to_compatible(const fixed_size_simd&) noexcept;
+template  simd_mask to_compatible(const fixed_size_simd_mask&) noexcept;
+
+template 
+tuple>...> split(const simd&);
+template 
+tuple>...> split(const simd_mask&);
+template 
+array / V::size()> split(
+const simd&);
+template 
+array / V::size()> split(
+const simd_mask&);
+
+template 
+simd + ...)>> concat(const simd&...);
+template 
+simd_mask + ...)>> con

[PATCH] D41240: [Solaris] __float128 is supported on Solaris/x86

2018-04-23 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Things are different for a libgcc-based toolchain and a compiler-rt based 
toolchain.


Repository:
  rL LLVM

https://reviews.llvm.org/D41240



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


[PATCH] D45291: [Driver] Infer Android sysroot location.

2018-04-23 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45291



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


[PATCH] D45597: [Driver] Android triples are not aliases for other triples.

2018-04-23 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45597



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


[PATCH] D45292: [Driver] Obey computed sysroot when finding libc++ headers.

2018-04-23 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45292



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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Guys, what do you think about a checker that warns on uninitialized fields only 
when at least one field is initialized? I'd be much more confident about 
turning such check on by default. We can still keep a `pedantic` version.

> I can say with confidence that CodeChecker does not break if the same 
> category name is used by two different analyzers. Does the same stand for 
> XCode / Scan-Build?

XCode and Scan-Build only support one analyzer, so it won't be a problem (at 
least not until more analyzers get supported).

But in general if we do overlapping names, we must be super sure that they mean 
the same thing in both analyzers, so that we didn't end up with a user 
interface in which one of the relatively common task would be to enable 
clang-tidy "bugprone" checkers and disable static analyzer "bugprone" checkers 
but the user would have to list all checkers by name in order to accomplish 
that because they all stay in the same package.


https://reviews.llvm.org/D45532



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


[PATCH] D45920: [analyzer] Move RangeSet related declarations into the RangedConstraintManager header.

2018-04-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/RangedConstraintManager.h:130
+template <>
+struct ProgramStateTrait
+  : public ProgramStatePartialTrait {

george.karpenkov wrote:
> Why not also `REGISTER_TRAIT_WITH_PROGRAMSTATE` here?
```
   33   /// The macro should not be used inside namespaces, or for traits that 
must
   34   /// be accessible from more than one translation unit.
   35   #define REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, Type) \
   36   ...
```
I don't remember why.


Repository:
  rC Clang

https://reviews.llvm.org/D45920



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


[PATCH] D45920: [analyzer] Move RangeSet related declarations into the RangedConstraintManager header.

2018-04-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D45920#1074439, @george.karpenkov wrote:

> Another approach would be to instead teach `RangedConstraintManager` to 
> convert it's constraints to Z3. That would be an unwanted dependency, but the 
> change would be much smaller, and the internals of the solver would not have 
> to be exposed. @NoQ thoughts?


Dunno. Obviously, the adaptor code between the constraint manager and the 
refutation manager (i think the word "solver" is causing confusion now) would 
have to access internals of both managers, so the situation is quite symmetric.


Repository:
  rC Clang

https://reviews.llvm.org/D45920



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


r330633 - Fix typo in comment.

2018-04-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Apr 23 12:22:52 2018
New Revision: 330633

URL: http://llvm.org/viewvc/llvm-project?rev=330633&view=rev
Log:
Fix typo in comment.

Modified:
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=330633&r1=330632&r2=330633&view=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Mon Apr 23 12:22:52 2018
@@ -67,7 +67,7 @@ option(LIBCLANG_BUILD_STATIC
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang.exports)
 
 if(MSVC)
-  # Avoid LNK4197 not to spceify libclang.def here.
+  # Avoid LNK4197 by not specifying libclang.exports here.
   # Each functions is exported as "dllexport" in include/clang-c.
   # KB835326
   set(LLVM_EXPORTED_SYMBOL_FILE)


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


[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-23 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: test/clang-tidy/modernize-raw-string-literal.cpp:44
+char const *const MultibyteSnowman("\xE2\x98\x83");
+// CHECK-FIXES: {{^}}char const *const MultibyteSnowman("\xE2\x98\x83");{{$}}
 

IIRC, the default behavior is that if no matching CHECK-FIXES line is found, 
then it is considered a failure.  Have you tried your test code without your 
change to verify that this is the case?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45932



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


Re: [PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-23 Thread Nico Weber via cfe-commits
On Mon, Apr 23, 2018 at 11:53 AM, Andrew V. Tischenko via Phabricator via
cfe-commits  wrote:

> avt77 added a comment.
>
> In https://reviews.llvm.org/D45619#1075437, @bjope wrote:
>
> > I can't see that it has been reverted.
> >  But I guess that the table maybe is sorted based on time spent in each
> pass? So that is why it might be sorted differently on different buildbots
> (or when using pipe etc).
> >
> > So I think a quick fix is to add -DAG to the checks that can be reorder
> and submit that fix.
>
>
> I don't see revert as well. But I did the following:
>
> svn merge -c -330571 .
>

That only prepares a revert locally. You need to run `svn commit` after
that to actually land the revert.


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


[PATCH] D45517: [analyzer] WIP: False positive refutation with Z3

2018-04-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D45517#1074422, @rnkovacs wrote:

> In https://reviews.llvm.org/D45517#1074057, @NoQ wrote:
>
> > So, yeah, that's a good optimization that we're not invoking the solver on 
> > every node. But i don't think we should focus on improving this 
> > optimization further; instead, i think the next obvious step here is to 
> > implement it in such a way that we only needed to call the solver //once// 
> > for every report. We could simply collect all constraints from all states 
> > along the path and put them into the solver all together. This will work 
> > because symbols are not mutable and they don't reincarnate.
>
>
> Won't collecting all constraints and solving a ~100ish equations at once take 
> a long time? Maybe the timeout limit for Z3 will need to be slightly 
> increased for refutation then.


Well, in the worst case we would still be able to split our full system of 
equations into smaller chunks, and it'd most likely still be better than 
solving roughly-the-same system of equations ~100ish times.


https://reviews.llvm.org/D45517



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


[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".

2018-04-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 2 inline comments as done.
NoQ added inline comments.



Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:145-147
+  if (Name.endswith_lower(".c") || Name.endswith_lower(".cpp") ||
+  Name.endswith_lower(".cc") || Name.endswith_lower(".cxx") ||
+  Name.endswith_lower(".m") || Name.endswith_lower(".mm")) {

george.karpenkov wrote:
> NoQ wrote:
> > majnemer wrote:
> > > C++ source code is also found in files which end in .C, this code will 
> > > match against strange file endings like .cXx and .mM
> > > 
> > > I think the above logic should be changed to match 
> > > https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/FrontendOptions.cpp#L27
> > Aha, yeah, thanks, that's the place i was looking for.
> Why not just use the included function then? It's static.
Because it has a different purpose:
> `for now it doesn't discriminate between code and header files`


https://reviews.llvm.org/D45839



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


r330634 - [OPENMP] Formatting and code improvement, NFC.

2018-04-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Apr 23 12:53:05 2018
New Revision: 330634

URL: http://llvm.org/viewvc/llvm-project?rev=330634&view=rev
Log:
[OPENMP] Formatting and code improvement, NFC.

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=330634&r1=330633&r2=330634&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Mon Apr 23 12:53:05 2018
@@ -80,51 +80,56 @@ static unsigned getOpenMPDirectiveKindEx
   .Default(OMPD_unknown);
 }
 
-static OpenMPDirectiveKind ParseOpenMPDirectiveKind(Parser &P) {
+static OpenMPDirectiveKind parseOpenMPDirectiveKind(Parser &P) {
   // Array of foldings: F[i][0] F[i][1] ===> F[i][2].
   // E.g.: OMPD_for OMPD_simd ===> OMPD_for_simd
   // TODO: add other combined directives in topological order.
   static const unsigned F[][3] = {
-{ OMPD_cancellation, OMPD_point, OMPD_cancellation_point },
-{ OMPD_declare, OMPD_reduction, OMPD_declare_reduction },
-{ OMPD_declare, OMPD_simd, OMPD_declare_simd },
-{ OMPD_declare, OMPD_target, OMPD_declare_target },
-{ OMPD_distribute, OMPD_parallel, OMPD_distribute_parallel },
-{ OMPD_distribute_parallel, OMPD_for, OMPD_distribute_parallel_for },
-{ OMPD_distribute_parallel_for, OMPD_simd, 
-  OMPD_distribute_parallel_for_simd },
-{ OMPD_distribute, OMPD_simd, OMPD_distribute_simd },
-{ OMPD_end, OMPD_declare, OMPD_end_declare },
-{ OMPD_end_declare, OMPD_target, OMPD_end_declare_target },
-{ OMPD_target, OMPD_data, OMPD_target_data },
-{ OMPD_target, OMPD_enter, OMPD_target_enter },
-{ OMPD_target, OMPD_exit, OMPD_target_exit },
-{ OMPD_target, OMPD_update, OMPD_target_update },
-{ OMPD_target_enter, OMPD_data, OMPD_target_enter_data },
-{ OMPD_target_exit, OMPD_data, OMPD_target_exit_data },
-{ OMPD_for, OMPD_simd, OMPD_for_simd },
-{ OMPD_parallel, OMPD_for, OMPD_parallel_for },
-{ OMPD_parallel_for, OMPD_simd, OMPD_parallel_for_simd },
-{ OMPD_parallel, OMPD_sections, OMPD_parallel_sections },
-{ OMPD_taskloop, OMPD_simd, OMPD_taskloop_simd },
-{ OMPD_target, OMPD_parallel, OMPD_target_parallel },
-{ OMPD_target, OMPD_simd, OMPD_target_simd },
-{ OMPD_target_parallel, OMPD_for, OMPD_target_parallel_for },
-{ OMPD_target_parallel_for, OMPD_simd, OMPD_target_parallel_for_simd },
-{ OMPD_teams, OMPD_distribute, OMPD_teams_distribute },
-{ OMPD_teams_distribute, OMPD_simd, OMPD_teams_distribute_simd },
-{ OMPD_teams_distribute, OMPD_parallel, OMPD_teams_distribute_parallel },
-{ OMPD_teams_distribute_parallel, OMPD_for, 
OMPD_teams_distribute_parallel_for },
-{ OMPD_teams_distribute_parallel_for, OMPD_simd, 
OMPD_teams_distribute_parallel_for_simd },
-{ OMPD_target, OMPD_teams, OMPD_target_teams },
-{ OMPD_target_teams, OMPD_distribute, OMPD_target_teams_distribute },
-{ OMPD_target_teams_distribute, OMPD_parallel, 
OMPD_target_teams_distribute_parallel },
-{ OMPD_target_teams_distribute, OMPD_simd, 
OMPD_target_teams_distribute_simd },
-{ OMPD_target_teams_distribute_parallel, OMPD_for, 
OMPD_target_teams_distribute_parallel_for },
-{ OMPD_target_teams_distribute_parallel_for, OMPD_simd, 
OMPD_target_teams_distribute_parallel_for_simd }
-  };
+  {OMPD_cancellation, OMPD_point, OMPD_cancellation_point},
+  {OMPD_declare, OMPD_reduction, OMPD_declare_reduction},
+  {OMPD_declare, OMPD_simd, OMPD_declare_simd},
+  {OMPD_declare, OMPD_target, OMPD_declare_target},
+  {OMPD_distribute, OMPD_parallel, OMPD_distribute_parallel},
+  {OMPD_distribute_parallel, OMPD_for, OMPD_distribute_parallel_for},
+  {OMPD_distribute_parallel_for, OMPD_simd,
+   OMPD_distribute_parallel_for_simd},
+  {OMPD_distribute, OMPD_simd, OMPD_distribute_simd},
+  {OMPD_end, OMPD_declare, OMPD_end_declare},
+  {OMPD_end_declare, OMPD_target, OMPD_end_declare_target},
+  {OMPD_target, OMPD_data, OMPD_target_data},
+  {OMPD_target, OMPD_enter, OMPD_target_enter},
+  {OMPD_target, OMPD_exit, OMPD_target_exit},
+  {OMPD_target, OMPD_update, OMPD_target_update},
+  {OMPD_target_enter, OMPD_data, OMPD_target_enter_data},
+  {OMPD_target_exit, OMPD_data, OMPD_target_exit_data},
+  {OMPD_for, OMPD_simd, OMPD_for_simd},
+  {OMPD_parallel, OMPD_for, OMPD_parallel_for},
+  {OMPD_parallel_for, OMPD_simd, OMPD_parallel_for_simd},
+  {OMPD_parallel, OMPD_sections, OMPD_parallel_sections},
+  {OMPD_taskloop, OMPD_simd, OMPD_taskloop_simd},
+  {OMPD_target, OMPD_parallel, OMPD_target_parallel},
+  {OMPD_target, OMPD_simd, OMPD_target_simd},
+  {OMPD_target_parallel, OMPD_for, OMPD_target_parallel_for},
+  {OMPD_target_parallel_for, OMPD_simd, OMPD_target_parallel_for_simd},
+  {OMPD_team

[PATCH] D45382: [CodeGen] Avoid destructing a struct type that has already been destructed by a delegated constructor

2018-04-23 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 143624.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D45382

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
  test/CodeGenObjCXX/arc-special-member-functions.mm
  test/CodeGenObjCXX/lambda-expressions.mm

Index: test/CodeGenObjCXX/lambda-expressions.mm
===
--- test/CodeGenObjCXX/lambda-expressions.mm
+++ test/CodeGenObjCXX/lambda-expressions.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks -fobjc-arc | FileCheck -check-prefix=ARC %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks -fobjc-arc -fobjc-runtime-has-weak -DWEAK_SUPPORTED | FileCheck -check-prefix=ARC %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks | FileCheck -check-prefix=MRC %s
 
 typedef int (^fp)();
@@ -138,5 +138,31 @@
 }
 @end
 
+// Check that the delegating invoke function doesn't destruct the Weak object
+// that is passed.
+
+// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvEN3$_58__invokeENS_4WeakE"(
+// ARC: call void @"_ZZN14LambdaDelegate4testEvENK3$_5clENS_4WeakE"(
+// ARC-NEXT: ret void
+
+// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvENK3$_5clENS_4WeakE"(
+// ARC: call void @_ZN14LambdaDelegate4WeakD1Ev(
+
+#ifdef WEAK_SUPPORTED
+
+namespace LambdaDelegate {
+
+struct Weak {
+  __weak id x;
+};
+
+void test() {
+  void (*p)(Weak) = [](Weak a) { };
+}
+
+};
+
+#endif
+
 // ARC: attributes [[NUW]] = { noinline nounwind{{.*}} }
 // MRC: attributes [[NUW]] = { noinline nounwind{{.*}} }
Index: test/CodeGenObjCXX/arc-special-member-functions.mm
===
--- test/CodeGenObjCXX/arc-special-member-functions.mm
+++ test/CodeGenObjCXX/arc-special-member-functions.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fobjc-arc -fblocks -triple x86_64-apple-darwin10.0.0 -fobjc-runtime-has-weak -emit-llvm -o - %s | FileCheck %s
 
 struct ObjCMember {
   id member;
@@ -12,6 +12,59 @@
   int (^bp)(int);
 };
 
+// CHECK: %[[STRUCT_CONTAINSWEAK:.*]] = type { %[[STRUCT_WEAK:.*]] }
+// CHECK: %[[STRUCT_WEAK]] = type { i8* }
+
+// The Weak object that is passed is destructed in this constructor.
+
+// CHECK: define void @_ZN12ContainsWeakC2E4Weak(
+// CHECK: call void @_ZN4WeakC1ERKS_(
+// CHECK: call void @_ZN4WeakD1Ev(
+
+// Check that the Weak object passed to this constructor is not destructed after
+// the delegate constructor is called.
+
+// CHECK: define void @_ZN12ContainsWeakC1E4Weak(
+// CHECK: call void @_ZN12ContainsWeakC2E4Weak(
+// CHECK-NEXT: ret void
+
+struct Weak {
+  Weak(id);
+  __weak id x;
+};
+
+struct ContainsWeak {
+  ContainsWeak(Weak);
+  Weak w;
+};
+
+ContainsWeak::ContainsWeak(Weak a) : w(a) {}
+
+// The Weak object that is passed is destructed in this constructor.
+
+// CHECK: define void @_ZN4BaseC2E4Weak(
+// CHECK: call void @_ZN4WeakD1Ev(
+// CHECK: ret void
+
+// Check that the Weak object passed to this constructor is not destructed after
+// the delegate constructor is called.
+
+// CHECK: define linkonce_odr void @_ZN7DerivedCI14BaseE4Weak(
+// CHECK: call void @_ZN7DerivedCI24BaseE4Weak(
+// CHECK-NEXT: ret void
+
+struct Base {
+  Base(Weak);
+};
+
+Base::Base(Weak a) {}
+
+struct Derived : Base {
+  using Base::Base;
+};
+
+Derived d(Weak(0));
+
 // CHECK-LABEL: define void @_Z42test_ObjCMember_default_construct_destructv(
 void test_ObjCMember_default_construct_destruct() {
   // CHECK: call void @_ZN10ObjCMemberC1Ev
@@ -111,6 +164,13 @@
 // CHECK-NEXT: call void @objc_release(i8* [[T7]])
 // CHECK-NEXT: ret
 
+// Check that the Weak object passed to this constructor is not destructed after
+// the delegate constructor is called.
+
+// CHECK: define linkonce_odr void @_ZN7DerivedCI24BaseE4Weak(
+// CHECK: call void @_ZN4BaseC2E4Weak(
+// CHECK-NEXT: ret void
+
 // Implicitly-generated default constructor for ObjCMember
 // CHECK-LABEL: define linkonce_odr void @_ZN10ObjCMemberC2Ev
 // CHECK-NOT: objc_release
Index: test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
===
--- test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
+++ test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
@@ -10,6 +10,17 @@
   // CHECK-NEXT: ret i8* [[T2]]
 }
 
+// Check that the delegating block invoke function doesn't destruct the Weak
+// object that is passed.
+
+// CHECK-LABEL: define internal void @___Z8testWeakv_block_invoke(
+// CHECK: call void @"_ZZ8testWeakvENK3$_2clE4W

[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-04-23 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In https://reviews.llvm.org/D45015#1064930, @EricWF wrote:

> In https://reviews.llvm.org/D45015#1064922, @vsapsai wrote:
>
> > Another approach is `__has_feature` but I don't think it is applicable in 
> > this case.
> >
> > Is there a way right now to detect that aligned allocation is supported by 
> > clang, regardless of link time? Asking to make sure we are consistent.
>
>
> There is a C++ feature test macro, as specified by the standard, 
> `__cpp_aligned_new`.  But I'm not sure how to be consistent with that.


After more thinking I believe a predefined macro is the best option. And in 
spirit it is consistent with SD-6: SG10 Feature Test Recommendations 
.

As for the naming, I see it is consistent with `-faligned-alloc-unavailable` 
but for me it is hard to tell immediately if "unavailable" means "unsupported 
at all" or "supported but unavailable on the target". Maybe it is just me and 
others don't have such problem but probably including "runtime" in the macro 
name would help. Something like `__ALIGNED_ALLOCATION_UNAVAILABLE_RUNTIME__`.

For the overall aligned allocation plan overall. We also need to keep in mind 
users who provide their own aligned allocation / deallocation functions, so 
they can still do that. So far everything seems to be OK but we need to be 
careful.




Comment at: lib/Frontend/InitPreprocessor.cpp:1059-1060
 
+  if (!LangOpts.AlignedAllocation || LangOpts.AlignedAllocationUnavailable)
+Builder.defineMacro("__ALIGNED_ALLOCATION_UNAVAILABLE__");
+

Don't know what the macro will be in the end, please consider adding a comment 
clarifying runtime availability.



Comment at: test/Preprocessor/predefined-macros.c:288
+// RUN: %clang_cc1 %s -x c++ -E -dM -faligned-allocation 
-faligned-alloc-unavailable  \
+// RUN: | FileCheck %s -match-full-lines 
-check-prefix=CHECK-ALIGNED-ALLOC-UNAVAILABLE
+

Would it be useful to test `-fno-aligned-allocation` too? Extensive testing in 
different combinations doesn't add much value but `-std=c++17 
-fno-aligned-allocation` can be useful.


Repository:
  rC Clang

https://reviews.llvm.org/D45015



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


[libcxx] r330636 - Revert "[libcxx] implement declarations based on P0214R7."

2018-04-23 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Apr 23 12:56:20 2018
New Revision: 330636

URL: http://llvm.org/viewvc/llvm-project?rev=330636&view=rev
Log:
Revert "[libcxx] implement  declarations based on P0214R7."

This reverts commit r330627.

This causes several bots to freak out.

Removed:
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/
Modified:
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=330636&r1=330635&r2=330636&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Apr 23 12:56:20 2018
@@ -54,16 +54,4 @@
 
 #define _VSTD_FS ::std::experimental::filesystem::v1
 
-#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
-_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
-
-#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
-} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
-
-#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
-_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
-
-#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
-} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
-
 #endif

Removed: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=330635&view=auto
==
--- libcxx/trunk/include/experimental/simd (original)
+++ libcxx/trunk/include/experimental/simd (removed)
@@ -1,1285 +0,0 @@
-// -*- C++ -*-
-//===--- simd 
-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-#ifndef _LIBCPP_EXPERIMENTAL_SIMD
-#define _LIBCPP_EXPERIMENTAL_SIMD
-
-/*
-experimental/simd synopsis
-
-namespace std::experimental {
-
-inline namespace parallelism_v2 {
-
-namespace simd_abi {
-
-struct scalar {};
-template  struct fixed_size {};
-template  inline constexpr int max_fixed_size = 
implementation-defined;
-template  using compatible = implementation-defined;
-template  using native = implementation-defined;
-
-} // simd_abi
-
-struct element_aligned_tag {};
-struct vector_aligned_tag {};
-template  struct overaligned_tag {};
-inline constexpr element_aligned_tag element_aligned{};
-inline constexpr vector_aligned_tag vector_aligned{};
-template  inline constexpr overaligned_tag overaligned{};
-
-// traits [simd.traits]
-template  struct is_abi_tag;
-template  inline constexpr bool is_abi_tag_v = is_abi_tag::value;
-
-template  struct is_simd;
-template  inline constexpr bool is_simd_v = is_simd::value;
-
-template  struct is_simd_mask;
-template  inline constexpr bool is_simd_mask_v = 
is_simd_mask::value;
-
-template  struct is_simd_flag_type;
-template  inline constexpr bool is_simd_flag_type_v = 
is_simd_flag_type::value;
-
-template  struct abi_for_size { using type = see below; };
-template  using abi_for_size_t = typename abi_for_size::type;
-
-template > struct simd_size;
-template >
-inline constexpr size_t simd_size_v = simd_size::value;
-
-template  struct memory_alignment;
-template 
-inline constexpr size_t memory_alignment_v = memory_alignment::value;
-
-// class template simd [simd.class]
-template > class simd;
-template  using native_simd = simd>;
-template  using fixed_size_simd = simd>;
-
-// class template simd_mask [simd.mask.class]
-template > class simd_mask;
-template  using native_simd_mask = simd_mask>;
-template  using fixed_size_simd_mask = simd_mask>;
-
-// casts [simd.casts]
-template  see below simd_cast(const simd&);
-template  see below static_simd_cast(const 
simd&);
-
-template 
-fixed_size_simd> to_fixed_size(const simd&) 
noexcept;
-template 
-fixed_size_simd_mask> to_fixed_size(const simd_mask&) noexcept;
-template  native_simd to_native(const fixed_size_simd&) noexcept;
-template 
-native_simd_mask to_native(const fixed_size_simd_mask> &) noexcept;
-template  simd to_compatible(const fixed_size_simd&) noexcept;
-template  simd_mask to_compatible(const 
fixed_size_simd_mask&) noexcept;
-
-template 
-tuple>...> split(const simd&);
-template 
-tuple>...> split(const simd_mask&);
-template 
-array / V::size()> split(
-const simd&);
-template 
-array / V::size()> split(
-const simd_mask&);
-
-template 
-simd + ...)>> concat(const simd&...);
-template 
-simd_mask + ...)>> concat(const 
simd_mask&...);
-
-// reductions [simd.mask.reductions]
-template  bool all_of(const simd_mask&) noexcept;
-template  bool any_of(

[PATCH] D45920: [analyzer] Move RangeSet related declarations into the RangedConstraintManager header.

2018-04-23 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.

In https://reviews.llvm.org/D45920#1074437, @george.karpenkov wrote:

> > I could also move RangedConstraintManager.h under include
>
> We probably don't want to do that: currently it can only be imported by files 
> in `Core`, and we probably should keep it that way


I believe that many of our warning messages could be improved by presenting 
ranges to the user. Eg., `ArrayBoundChecker` could benefit from something like 
"index is within range [11, 12] and array size is equal to 10", and then a 
visitor that explains all the places in which the index was constrained to a 
smaller range. So in long term i'll be in favor of providing a way of 
explaining constraints to the users, which means partially exposing constraint 
manager internals to the checkers in a certain way (not necessarily *this* 
way). So for now i have no opinion on this issue :)


Repository:
  rC Clang

https://reviews.llvm.org/D45920



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


  1   2   >