[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-18 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

In https://reviews.llvm.org/D45177#1103781, @alexfh wrote:

> In https://reviews.llvm.org/D45177#1103774, @devnexen wrote:
>
> > In https://reviews.llvm.org/D45177#1103162, @alexfh wrote:
> >
> > > See https://bugs.llvm.org/show_bug.cgi?id=37503 for a test case.
> >
> >
> > I was unable to reproduce both FreeBSD and Linux. Plus my changes come 
> > after checkNonNull.
>
>
> I'm not 100% sure this was caused by your patch, but the stack trace looks 
> suspiciously similar to what was changed here. As for not being able to 
> reproduce: do you build Clang with assertions enabled?


I was able to reproduce but also with the revision before when it has been 
reverted.


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] D46835: [ASTImporter] Do not try to remove invisible Decls from DeclContext

2018-05-18 Thread Gabor Marton via Phabricator via cfe-commits
martong closed this revision.
martong added a comment.

Closed by commit: https://reviews.llvm.org/rL332699


Repository:
  rC Clang

https://reviews.llvm.org/D46835



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


[PATCH] D44954: [clangd] Add "member" symbols to the index

2018-05-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D44954#1103664, @malaperle wrote:

> It's probably better to consider this in a future patch. Maybe something like 
> the first suggestion: vector::push_back and match both. Otherwise, I would 
> think it might be a bit too verbose to have to spell out all of the 
> specialization. Maybe we could allow it too. So... all of the above? :)


This certainly does not have to be addressed in this patch. Just wanted to 
collect opinions on what the behavior we want in the long term.
My thoughts would be towards allowing only `vector::push_back` and make it 
match both `push_back`s: in `vector` and `vector`.
Other cases might work too, but I wouldn't try implementing something that 
matches specializations. It's just too complicated in the general case. This 
will only be used in workspaceSymbol and it's fine to give a few more results 
there...

>> What scopes will non-scoped enum members have?
> 
> Hmm. I think all of them, since you can refer them like that in code too. 
> Case #1 doesn't work but that was the case before this patch so it can 
> probably be addressed separately. I'll add some tests though!

I would vote for making queries `En::A` and `A` match the enumerator, but 
**not** `::A`. The reasoning is: yes, you can reference it this way in a C++ 
file, but `workspaceSymbol` is not a real C++ resolve and I think it should 
match the outline of the code rather than the actual C++ lookup rules.
E.g. I wouldn't expect it to match symbols from base classes, etc. This should 
also simplify implementation too.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[clang-tools-extra] r332701 - Re-enable a clang-move test on windows.

2018-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 18 02:25:36 2018
New Revision: 332701

URL: http://llvm.org/viewvc/llvm-project?rev=332701&view=rev
Log:
Re-enable a clang-move test on windows.

This was fixed by r332612.

Modified:
clang-tools-extra/trunk/test/clang-move/move-class.cpp

Modified: clang-tools-extra/trunk/test/clang-move/move-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-class.cpp?rev=332701&r1=332700&r2=332701&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-class.cpp Fri May 18 02:25:36 
2018
@@ -1,7 +1,3 @@
-// UNSUPPORTED: system-windows
-// new_test.cpp contains #include of old test.h when running on windows. This 
is
-// probably by a bug for path handling in clang-move.
-//
 // RUN: mkdir -p %T/clang-move/build
 // RUN: mkdir -p %T/clang-move/include
 // RUN: mkdir -p %T/clang-move/src


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


[PATCH] D46998: [XRay][compiler-rt] Limit reliance on C++ ABI features

2018-05-18 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 147451.
dberris retitled this revision from "[XRay][clang+compiler-rt] Make XRay depend 
on a C++ standard lib" to "[XRay][compiler-rt] Limit reliance on C++ ABI 
features".
dberris edited the summary of this revision.
dberris added a comment.

Retitle, and update to limit only to compiler-rt changes.

This is still a work in progress, but working towards a cleaner solution.


https://reviews.llvm.org/D46998

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/xray/xray_basic_logging.cc
  compiler-rt/test/xray/TestCases/Posix/c-test.cc

Index: compiler-rt/test/xray/TestCases/Posix/c-test.cc
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Posix/c-test.cc
@@ -0,0 +1,4 @@
+// RUN: %clang_xray -g -o %t %s
+// REQUIRES: x86_64-target-arch
+// REQUIRES: built-in-llvm-tree
+int main() {}
Index: compiler-rt/lib/xray/xray_basic_logging.cc
===
--- compiler-rt/lib/xray/xray_basic_logging.cc
+++ compiler-rt/lib/xray/xray_basic_logging.cc
@@ -16,7 +16,6 @@
 //===--===//
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -39,16 +38,16 @@
 
 namespace __xray {
 
-__sanitizer::SpinMutex LogMutex;
+SpinMutex LogMutex;
 
 // We use elements of this type to record the entry TSC of every function ID we
 // see as we're tracing a particular thread's execution.
 struct alignas(16) StackEntry {
   int32_t FuncId;
   uint16_t Type;
   uint8_t CPU;
   uint8_t Padding;
-  uint64_t TSC;
+  u64 TSC;
 };
 
 static_assert(sizeof(StackEntry) == 16, "Wrong size for StackEntry");
@@ -66,38 +65,35 @@
 
 static pthread_key_t PThreadKey;
 
-static __sanitizer::atomic_uint8_t BasicInitialized{0};
+static atomic_uint8_t BasicInitialized{0};
 
 BasicLoggingOptions GlobalOptions;
 
 thread_local volatile bool RecursionGuard = false;
 
-static uint64_t thresholdTicks() XRAY_NEVER_INSTRUMENT {
-  static uint64_t TicksPerSec = probeRequiredCPUFeatures()
-? getTSCFrequency()
-: __xray::NanosecondsPerSecond;
-  static const uint64_t ThresholdTicks =
-  TicksPerSec * GlobalOptions.DurationFilterMicros / 100;
-  return ThresholdTicks;
-}
+static atomic_uint8_t UseRealTSC{0};
+static atomic_uint64_t ThresholdTicks{0};
+static atomic_uint64_t TicksPerSec{0};
+static atomic_uint64_t CycleFrequency{__xray::NanosecondsPerSecond};
 
 static int openLogFile() XRAY_NEVER_INSTRUMENT {
   int F = getLogFD();
   if (F == -1)
 return -1;
 
-  // Test for required CPU features and cache the cycle frequency
-  static bool TSCSupported = probeRequiredCPUFeatures();
-  static uint64_t CycleFrequency =
-  TSCSupported ? getTSCFrequency() : __xray::NanosecondsPerSecond;
+  static pthread_once_t DetectOnce;
+  pthread_once(&DetectOnce, +[] {
+if (atomic_load(&UseRealTSC, memory_order_relaxed))
+  atomic_store(&CycleFrequency, getTSCFrequency(), memory_order_release);
+  });
 
   // Since we're here, we get to write the header. We set it up so that the
   // header will only be written once, at the start, and let the threads
   // logging do writes which just append.
   XRayFileHeader Header;
   Header.Version = 2; // Version 2 includes tail exit records.
   Header.Type = FileTypes::NAIVE_LOG;
-  Header.CycleFrequency = CycleFrequency;
+  Header.CycleFrequency = atomic_load(&CycleFrequency, memory_order_relaxed);
 
   // FIXME: Actually check whether we have 'constant_tsc' and 'nonstop_tsc'
   // before setting the values in the header.
@@ -108,29 +104,31 @@
   return F;
 }
 
-int getGlobalFd() XRAY_NEVER_INSTRUMENT {
-  static int Fd = openLogFile();
+static int getGlobalFd() XRAY_NEVER_INSTRUMENT {
+  static pthread_once_t OnceInit;
+  static int Fd = 0;
+  pthread_once(&OnceInit, +[] { Fd = openLogFile(); });
   return Fd;
 }
 
 ThreadLocalData &getThreadLocalData() XRAY_NEVER_INSTRUMENT {
   thread_local ThreadLocalData TLD;
   thread_local bool UNUSED TOnce = [] {
 if (GlobalOptions.ThreadBufferSize == 0) {
-  if (__sanitizer::Verbosity())
+  if (Verbosity())
 Report("Not initializing TLD since ThreadBufferSize == 0.\n");
   return false;
 }
-TLD.TID = __sanitizer::GetTid();
+TLD.TID = GetTid();
 pthread_setspecific(PThreadKey, &TLD);
 TLD.Fd = getGlobalFd();
 TLD.InMemoryBuffer = reinterpret_cast(
 InternalAlloc(sizeof(XRayRecord) * GlobalOptions.ThreadBufferSize,
   nullptr, alignof(XRayRecord)));
 TLD.BufferSize = GlobalOptions.ThreadBufferSize;
 TLD.BufferOffset = 0;
 if (GlobalOptions.MaxStackDepth == 0) {
-  if (__sanitizer::Verbosity())
+  if (Verbosity())
 Report("Not initializing the ShadowStack since MaxStackDepth == 0.\n");
   TLD.StackSize = 0;
   TLD.StackEntries = 0;
@@ -142,13 +140,6 @@

[PATCH] D46998: [XRay][compiler-rt] Limit reliance on C++ ABI features

2018-05-18 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 147453.
dberris added a comment.

- fixup: revert unnecessary change to clang


https://reviews.llvm.org/D46998

Files:
  compiler-rt/lib/xray/xray_basic_logging.cc
  compiler-rt/test/xray/TestCases/Posix/c-test.cc

Index: compiler-rt/test/xray/TestCases/Posix/c-test.cc
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Posix/c-test.cc
@@ -0,0 +1,4 @@
+// RUN: %clang_xray -g -o %t %s
+// REQUIRES: x86_64-target-arch
+// REQUIRES: built-in-llvm-tree
+int main() {}
Index: compiler-rt/lib/xray/xray_basic_logging.cc
===
--- compiler-rt/lib/xray/xray_basic_logging.cc
+++ compiler-rt/lib/xray/xray_basic_logging.cc
@@ -16,7 +16,6 @@
 //===--===//
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -39,16 +38,16 @@
 
 namespace __xray {
 
-__sanitizer::SpinMutex LogMutex;
+SpinMutex LogMutex;
 
 // We use elements of this type to record the entry TSC of every function ID we
 // see as we're tracing a particular thread's execution.
 struct alignas(16) StackEntry {
   int32_t FuncId;
   uint16_t Type;
   uint8_t CPU;
   uint8_t Padding;
-  uint64_t TSC;
+  u64 TSC;
 };
 
 static_assert(sizeof(StackEntry) == 16, "Wrong size for StackEntry");
@@ -66,38 +65,35 @@
 
 static pthread_key_t PThreadKey;
 
-static __sanitizer::atomic_uint8_t BasicInitialized{0};
+static atomic_uint8_t BasicInitialized{0};
 
 BasicLoggingOptions GlobalOptions;
 
 thread_local volatile bool RecursionGuard = false;
 
-static uint64_t thresholdTicks() XRAY_NEVER_INSTRUMENT {
-  static uint64_t TicksPerSec = probeRequiredCPUFeatures()
-? getTSCFrequency()
-: __xray::NanosecondsPerSecond;
-  static const uint64_t ThresholdTicks =
-  TicksPerSec * GlobalOptions.DurationFilterMicros / 100;
-  return ThresholdTicks;
-}
+static atomic_uint8_t UseRealTSC{0};
+static atomic_uint64_t ThresholdTicks{0};
+static atomic_uint64_t TicksPerSec{0};
+static atomic_uint64_t CycleFrequency{__xray::NanosecondsPerSecond};
 
 static int openLogFile() XRAY_NEVER_INSTRUMENT {
   int F = getLogFD();
   if (F == -1)
 return -1;
 
-  // Test for required CPU features and cache the cycle frequency
-  static bool TSCSupported = probeRequiredCPUFeatures();
-  static uint64_t CycleFrequency =
-  TSCSupported ? getTSCFrequency() : __xray::NanosecondsPerSecond;
+  static pthread_once_t DetectOnce;
+  pthread_once(&DetectOnce, +[] {
+if (atomic_load(&UseRealTSC, memory_order_relaxed))
+  atomic_store(&CycleFrequency, getTSCFrequency(), memory_order_release);
+  });
 
   // Since we're here, we get to write the header. We set it up so that the
   // header will only be written once, at the start, and let the threads
   // logging do writes which just append.
   XRayFileHeader Header;
   Header.Version = 2; // Version 2 includes tail exit records.
   Header.Type = FileTypes::NAIVE_LOG;
-  Header.CycleFrequency = CycleFrequency;
+  Header.CycleFrequency = atomic_load(&CycleFrequency, memory_order_relaxed);
 
   // FIXME: Actually check whether we have 'constant_tsc' and 'nonstop_tsc'
   // before setting the values in the header.
@@ -108,29 +104,31 @@
   return F;
 }
 
-int getGlobalFd() XRAY_NEVER_INSTRUMENT {
-  static int Fd = openLogFile();
+static int getGlobalFd() XRAY_NEVER_INSTRUMENT {
+  static pthread_once_t OnceInit;
+  static int Fd = 0;
+  pthread_once(&OnceInit, +[] { Fd = openLogFile(); });
   return Fd;
 }
 
 ThreadLocalData &getThreadLocalData() XRAY_NEVER_INSTRUMENT {
   thread_local ThreadLocalData TLD;
   thread_local bool UNUSED TOnce = [] {
 if (GlobalOptions.ThreadBufferSize == 0) {
-  if (__sanitizer::Verbosity())
+  if (Verbosity())
 Report("Not initializing TLD since ThreadBufferSize == 0.\n");
   return false;
 }
-TLD.TID = __sanitizer::GetTid();
+TLD.TID = GetTid();
 pthread_setspecific(PThreadKey, &TLD);
 TLD.Fd = getGlobalFd();
 TLD.InMemoryBuffer = reinterpret_cast(
 InternalAlloc(sizeof(XRayRecord) * GlobalOptions.ThreadBufferSize,
   nullptr, alignof(XRayRecord)));
 TLD.BufferSize = GlobalOptions.ThreadBufferSize;
 TLD.BufferOffset = 0;
 if (GlobalOptions.MaxStackDepth == 0) {
-  if (__sanitizer::Verbosity())
+  if (Verbosity())
 Report("Not initializing the ShadowStack since MaxStackDepth == 0.\n");
   TLD.StackSize = 0;
   TLD.StackEntries = 0;
@@ -142,13 +140,6 @@
   alignof(StackEntry)));
 TLD.StackSize = GlobalOptions.MaxStackDepth;
 TLD.StackEntries = 0;
-if (__sanitizer::Verbosity() >= 2) {
-  static auto UNUSED Once = [] {
-auto ticks = thresholdTicks();
-Report("Ticks threshold: %d\n", ticks);
-return false;
-  }();
-}
 retur

[PATCH] D47057: [ASTImporter] Fix missing implict CXXRecordDecl in ClassTemplateSpecializationDecl

2018-05-18 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a.sidorin, xazax.hun, r.stahl.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.

Currently we do not import the implicit CXXRecordDecl of a
ClassTemplateSpecializationDecl. This patch fixes it.


Repository:
  rC Clang

https://reviews.llvm.org/D47057

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1367,7 +1367,7 @@
 
 TEST_P(
 ASTImporterTestBase,
-
DISABLED_ShouldImportImplicitCXXRecordDeclOfClassTemplateSpecializationDecl) {
+ShouldImportImplicitCXXRecordDeclOfClassTemplateSpecializationDecl) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   R"(
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1959,7 +1959,7 @@
   // but this particular declaration is not that definition, import the
   // definition and map to that.
   TagDecl *Definition = D->getDefinition();
-  if (Definition && Definition != D) {
+  if (!D->isImplicit() && Definition && Definition != D) {
 Decl *ImportedDef = Importer.Import(Definition);
 if (!ImportedDef)
   return nullptr;


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1367,7 +1367,7 @@
 
 TEST_P(
 ASTImporterTestBase,
-DISABLED_ShouldImportImplicitCXXRecordDeclOfClassTemplateSpecializationDecl) {
+ShouldImportImplicitCXXRecordDeclOfClassTemplateSpecializationDecl) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   R"(
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1959,7 +1959,7 @@
   // but this particular declaration is not that definition, import the
   // definition and map to that.
   TagDecl *Definition = D->getDefinition();
-  if (Definition && Definition != D) {
+  if (!D->isImplicit() && Definition && Definition != D) {
 Decl *ImportedDef = Importer.Import(Definition);
 if (!ImportedDef)
   return nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47058: [ASTImporter] Fix ClassTemplateSpecialization in wrong DC

2018-05-18 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a.sidorin, r.stahl, xazax.hun.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.

ClassTemplateSpecialization is put in the wrong DeclContex if implicitly
instantiated. This patch fixes it.


Repository:
  rC Clang

https://reviews.llvm.org/D47058

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1246,7 +1246,7 @@
 
 TEST_P(
 ASTImporterTestBase,
-
DISABLED_TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
+TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
 
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -4298,9 +4298,13 @@
 
 D2->setTemplateSpecializationKind(D->getTemplateSpecializationKind());
 
-// Add the specialization to this context.
+// Set the context of this specialization/instantiation.
 D2->setLexicalDeclContext(LexicalDC);
-LexicalDC->addDeclInternal(D2);
+
+// Add to the DC only if it was an explicit specialization/instantiation.
+if (D2->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
+  LexicalDC->addDeclInternal(D2);
+}
   }
   Importer.Imported(D, D2);
   if (D->isCompleteDefinition() && ImportDefinition(D, D2))


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1246,7 +1246,7 @@
 
 TEST_P(
 ASTImporterTestBase,
-DISABLED_TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
+TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
 
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -4298,9 +4298,13 @@
 
 D2->setTemplateSpecializationKind(D->getTemplateSpecializationKind());
 
-// Add the specialization to this context.
+// Set the context of this specialization/instantiation.
 D2->setLexicalDeclContext(LexicalDC);
-LexicalDC->addDeclInternal(D2);
+
+// Add to the DC only if it was an explicit specialization/instantiation.
+if (D2->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
+  LexicalDC->addDeclInternal(D2);
+}
   }
   Importer.Imported(D, D2);
   if (D->isCompleteDefinition() && ImportDefinition(D, D2))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46871: [AMDGPU] Add interpolation builtins

2018-05-18 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: include/clang/Basic/BuiltinsAMDGPU.def:103-107
+BUILTIN(__builtin_amdgcn_interp_p1_f16, "ffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2_f16, "hffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p1, "ffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2, "fffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_mov, "fUiUiUiUi", "nc")

timcorringham wrote:
> arsenm wrote:
> > You will also need C++ handling for these when the intrinsics are fixed to 
> > use name mangling
> Can you expand on that please, I don't know what needs to be done here?
In the other review I commented you should change the existing intrinsics to 
use name mangling instead of adding a second set. Once you do that, GCCBuiltin 
no longer works. You have to add some code like the other type mangled 
intrinsics in lib/CodeGen/CGBuiltin.cpp



Comment at: test/CodeGenOpenCL/builtins-amdgcn-interp.cl:2-28
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S -o - 
%s | FileCheck %s --check-prefixes=CHECK,GFX9,BANK32
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu fiji -S -o - %s 
| FileCheck %s --check-prefixes=CHECK,GFX8,BANK32
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx810 -S -o - 
%s | FileCheck %s --check-prefixes=CHECK,GFX8,BANK16
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: test_interp_f16

timcorringham wrote:
> arsenm wrote:
> > These should be emitting / checking the IR, not the output asm
> Checking the IR doesn't allow you to check the behavior very well, as there 
> are differences depending on the target-cpu which are not apparent in the IR.
That is a codegen test which we have (or should have) in the backend. I know we 
have some for the f32 variants.

Clang tests should only be checking that the produced IR is correct


Repository:
  rC Clang

https://reviews.llvm.org/D46871



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


r332699 - Do not try to remove invisible Decls from DeclContext

2018-05-18 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri May 18 02:08:47 2018
New Revision: 332699

URL: http://llvm.org/viewvc/llvm-project?rev=332699&view=rev
Log:
Do not try to remove invisible Decls from DeclContext

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

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=332699&r1=332698&r2=332699&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri May 18 02:08:47 2018
@@ -1347,6 +1347,32 @@ bool DeclContext::containsDecl(Decl *D)
   (D->NextInContextAndBits.getPointer() || D == LastDecl));
 }
 
+/// shouldBeHidden - Determine whether a declaration which was declared
+/// within its semantic context should be invisible to qualified name lookup.
+static bool shouldBeHidden(NamedDecl *D) {
+  // Skip unnamed declarations.
+  if (!D->getDeclName())
+return true;
+
+  // Skip entities that can't be found by name lookup into a particular
+  // context.
+  if ((D->getIdentifierNamespace() == 0 && !isa(D)) ||
+  D->isTemplateParameter())
+return true;
+
+  // Skip template specializations.
+  // FIXME: This feels like a hack. Should DeclarationName support
+  // template-ids, or is there a better way to keep specializations
+  // from being visible?
+  if (isa(D))
+return true;
+  if (auto *FD = dyn_cast(D))
+if (FD->isFunctionTemplateSpecialization())
+  return true;
+
+  return false;
+}
+
 void DeclContext::removeDecl(Decl *D) {
   assert(D->getLexicalDeclContext() == this &&
  "decl being removed from non-lexical context");
@@ -1369,7 +1395,7 @@ void DeclContext::removeDecl(Decl *D) {
   }
 }
   }
-  
+
   // Mark that D is no longer in the decl chain.
   D->NextInContextAndBits.setPointer(nullptr);
 
@@ -1377,8 +1403,14 @@ void DeclContext::removeDecl(Decl *D) {
   if (isa(D)) {
 auto *ND = cast(D);
 
+// Do not try to remove the declaration if that is invisible to qualified
+// lookup.  E.g. template specializations are skipped.
+if (shouldBeHidden(ND))
+  return;
+
 // Remove only decls that have a name
-if (!ND->getDeclName()) return;
+if (!ND->getDeclName())
+  return;
 
 auto *DC = D->getDeclContext();
 do {
@@ -1435,32 +1467,6 @@ void DeclContext::addDeclInternal(Decl *
 makeDeclVisibleInContextWithFlags(ND, true, true);
 }
 
-/// shouldBeHidden - Determine whether a declaration which was declared
-/// within its semantic context should be invisible to qualified name lookup.
-static bool shouldBeHidden(NamedDecl *D) {
-  // Skip unnamed declarations.
-  if (!D->getDeclName())
-return true;
-
-  // Skip entities that can't be found by name lookup into a particular
-  // context.
-  if ((D->getIdentifierNamespace() == 0 && !isa(D)) ||
-  D->isTemplateParameter())
-return true;
-
-  // Skip template specializations.
-  // FIXME: This feels like a hack. Should DeclarationName support
-  // template-ids, or is there a better way to keep specializations
-  // from being visible?
-  if (isa(D))
-return true;
-  if (auto *FD = dyn_cast(D))
-if (FD->isFunctionTemplateSpecialization())
-  return true;
-
-  return false;
-}
-
 /// buildLookup - Build the lookup data structure with all of the
 /// declarations in this DeclContext (and any other contexts linked
 /// to it or transparent contexts nested within it) and return it.

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=332699&r1=332698&r2=332699&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Fri May 18 02:08:47 2018
@@ -1797,5 +1797,38 @@ TEST(ImportExpr, UnresolvedMemberExpr) {
  compoundStmt(has(callExpr(has(unresolvedMemberExpr());
 }
 
+struct DeclContextTest : ASTImporterTestBase {};
+
+TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) {
+  Decl *TU = getTuDecl(
+  R"(
+  namespace NS {
+
+  template 
+  struct S {};
+  template struct S;
+
+  inline namespace INS {
+template 
+struct S {};
+template struct S;
+  }
+
+  }
+  )", Lang_CXX11, "input0.cc");
+  auto *NS = FirstDeclMatcher().match(
+  TU, namespaceDecl());
+  auto *Spec = FirstDeclMatcher().match(
+  TU, classTemplateSpecializationDecl());
+  ASSERT_TRUE(NS->containsDecl(Spec));
+
+  NS->removeDecl(Spec);
+  EXPECT_FALSE(NS->containsDecl(Spec));
+}
+
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, DeclContextTest,
+::testing::Values(ArgVector(), ArgVector{"-fdelayed-template-parsing"}),);
+
 } // end namespace ast_matchers
 } // end namespace clang



[PATCH] D46871: [AMDGPU] Add interpolation builtins

2018-05-18 Thread Tim Corringham via Phabricator via cfe-commits
timcorringham updated this revision to Diff 147460.
timcorringham added a comment.

[AMDGPU] Add interpolation builtins

Updated LIT test so that it only tests for the existence of the builtins
by checking the IR.


Repository:
  rC Clang

https://reviews.llvm.org/D46871

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  test/CodeGenOpenCL/builtins-amdgcn-interp.cl


Index: test/CodeGenOpenCL/builtins-amdgcn-interp.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/builtins-amdgcn-interp.cl
@@ -0,0 +1,34 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S 
-emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: test_interp_f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+void test_interp_f16(global half* out, float i, float j, int m0)
+{
+  float p1_0 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, false, m0);
+  half p2_0 = __builtin_amdgcn_interp_p2_f16(p1_0, j, 2, 3, false, m0);
+  float p1_1 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, true, m0);
+  half p2_1 = __builtin_amdgcn_interp_p2_f16(p1_1, j, 2, 3, true, m0);
+  *out = p2_0 + p2_1;
+}
+
+// CHECK-LABEL: test_interp_f32
+// CHECK: call float @llvm.amdgcn.interp.p1
+// CHECK: call float @llvm.amdgcn.interp.p2
+void test_interp_f32(global float* out, float i, float j, int m0)
+{
+  float p1 = __builtin_amdgcn_interp_p1(i, 1, 4, m0);
+  *out = __builtin_amdgcn_interp_p2(p1, j, 1, 4, m0);
+}
+
+// CHECK-LABEL: test_interp_mov
+// CHECK: call float @llvm.amdgcn.interp.mov
+void test_interp_mov(global float* out, float i, float j, int m0)
+{
+  *out = __builtin_amdgcn_interp_mov(2, 3, 4, m0);
+}
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -98,6 +98,15 @@
 BUILTIN(__builtin_amdgcn_ds_fmax, "ff*3fiib", "n")
 
 
//===--===//
+// Interpolation builtins.
+//===--===//
+BUILTIN(__builtin_amdgcn_interp_p1_f16, "ffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2_f16, "hffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p1, "ffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2, "fffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_mov, "fUiUiUiUi", "nc")
+
+//===--===//
 // VI+ only builtins.
 
//===--===//
 


Index: test/CodeGenOpenCL/builtins-amdgcn-interp.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/builtins-amdgcn-interp.cl
@@ -0,0 +1,34 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S -emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: test_interp_f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+void test_interp_f16(global half* out, float i, float j, int m0)
+{
+  float p1_0 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, false, m0);
+  half p2_0 = __builtin_amdgcn_interp_p2_f16(p1_0, j, 2, 3, false, m0);
+  float p1_1 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, true, m0);
+  half p2_1 = __builtin_amdgcn_interp_p2_f16(p1_1, j, 2, 3, true, m0);
+  *out = p2_0 + p2_1;
+}
+
+// CHECK-LABEL: test_interp_f32
+// CHECK: call float @llvm.amdgcn.interp.p1
+// CHECK: call float @llvm.amdgcn.interp.p2
+void test_interp_f32(global float* out, float i, float j, int m0)
+{
+  float p1 = __builtin_amdgcn_interp_p1(i, 1, 4, m0);
+  *out = __builtin_amdgcn_interp_p2(p1, j, 1, 4, m0);
+}
+
+// CHECK-LABEL: test_interp_mov
+// CHECK: call float @llvm.amdgcn.interp.mov
+void test_interp_mov(global float* out, float i, float j, int m0)
+{
+  *out = __builtin_amdgcn_interp_mov(2, 3, 4, m0);
+}
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -98,6 +98,15 @@
 BUILTIN(__builtin_amdgcn_ds_fmax, "ff*3fiib", "n")
 
 //===--===//
+// Interpolation builtins.
+//===--===//
+BUILTIN(__builtin_amdgcn_interp_p1_f16, "ffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2_f16, "hffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p1, "ffUiUiUi", "nc")
+BUILTIN(__b

[PATCH] D46881: [X86][CET] Changing -fcf-protection behavior to comply with gcc (clang part)

2018-05-18 Thread Alexander Ivchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332704: This patch aims to match the changes introduced 
(authored by aivchenk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46881?vs=147292&id=147476#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46881

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/attributes.c
  test/CodeGen/builtins-x86.c
  test/CodeGen/x86-cf-protection.c
  test/Driver/x86-target-features.c
  test/Preprocessor/x86_target_features.c
  test/Sema/attr-nocf_check.c
  test/Sema/attr-nocf_check.cpp

Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LangOptions.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/STLExtras.h"
@@ -115,6 +116,18 @@
 // Out of line virtual dtor for TargetInfo.
 TargetInfo::~TargetInfo() {}
 
+bool
+TargetInfo::checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const {
+  Diags.Report(diag::err_opt_not_valid_on_target) << "cf-protection=branch";
+  return false;
+}
+
+bool
+TargetInfo::checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const {
+  Diags.Report(diag::err_opt_not_valid_on_target) << "cf-protection=return";
+  return false;
+}
+
 /// getTypeName - Return the user string for the specified integer type enum.
 /// For example, SignedShort -> "short".
 const char *TargetInfo::getTypeName(IntType T) {
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -81,7 +81,6 @@
   bool HasSHA = false;
   bool HasMPX = false;
   bool HasSHSTK = false;
-  bool HasIBT = false;
   bool HasSGX = false;
   bool HasCX16 = false;
   bool HasFXSR = false;
@@ -171,10 +170,15 @@
   bool validateInputSize(StringRef Constraint, unsigned Size) const override;
 
   virtual bool
-  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override;
+  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override {
+return true;
+  };
 
   virtual bool
-  checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override;
+  checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override {
+return true;
+  };
+
 
   virtual bool validateOperandSize(StringRef Constraint, unsigned Size) const;
 
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -102,26 +102,6 @@
   return false;
 }
 
-bool X86TargetInfo::checkCFProtectionReturnSupported(
-DiagnosticsEngine &Diags) const {
-  if (HasSHSTK)
-return true;
-
-  Diags.Report(diag::err_opt_not_valid_without_opt) << "cf-protection=return"
-<< "-mshstk";
-  return false;
-}
-
-bool X86TargetInfo::checkCFProtectionBranchSupported(
-DiagnosticsEngine &Diags) const {
-  if (HasIBT)
-return true;
-
-  Diags.Report(diag::err_opt_not_valid_without_opt) << "cf-protection=branch"
-<< "-mibt";
-  return false;
-}
-
 bool X86TargetInfo::initFeatureMap(
 llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
 const std::vector &FeaturesVec) const {
@@ -781,8 +761,6 @@
   HasMPX = true;
 } else if (Feature == "+shstk") {
   HasSHSTK = true;
-} else if (Feature == "+ibt") {
-  HasIBT = true;
 } else if (Feature == "+movbe") {
   HasMOVBE = true;
 } else if (Feature == "+sgx") {
@@ -1175,8 +1153,6 @@
 Builder.defineMacro("__MPX__");
   if (HasSHSTK)
 Builder.defineMacro("__SHSTK__");
-  if (HasIBT)
-Builder.defineMacro("__IBT__");
   if (HasSGX)
 Builder.defineMacro("__SGX__");
   if (HasPREFETCHWT1)
@@ -1394,7 +1370,6 @@
   .Case("fsgsbase", HasFSGSBASE)
   .Case("fxsr", HasFXSR)
   .Case("gfni", HasGFNI)
-  .Case("ibt", HasIBT)
   .Case("lwp", HasLWP)
   .Case("lzcnt", HasLZCNT)
   .Case("mm3dnow", MMX3DNowLevel >= AMD3DNow)
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2829,6 +2829,17 @@
 }
   }
 
+  // Add the __CET__ macro if a CFProtection option is set.
+  if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
+StringRef Name = A->getValue();
+if (Name == "branch")
+  Opts.addMacroDe

r332704 - This patch aims to match the changes introduced

2018-05-18 Thread Alexander Ivchenko via cfe-commits
Author: aivchenk
Date: Fri May 18 04:56:21 2018
New Revision: 332704

URL: http://llvm.org/viewvc/llvm-project?rev=332704&view=rev
Log:
This patch aims to match the changes introduced
in gcc by https://gcc.gnu.org/ml/gcc-cvs/2018-04/msg00534.html.
The -mibt feature flag is being removed, and the -fcf-protection
option now also defines a CET macro and causes errors when used
on non-X86 targets, while X86 targets no longer check for -mibt
and -mshstk to determine if -fcf-protection is supported. -mshstk
is now used only to determine availability of shadow stack intrinsics.

Comes with an LLVM patch (D46882).

Patch by mike.dvoretsky

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


Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/attributes.c
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/x86-cf-protection.c
cfe/trunk/test/Driver/x86-target-features.c
cfe/trunk/test/Preprocessor/x86_target_features.c
cfe/trunk/test/Sema/attr-nocf_check.c
cfe/trunk/test/Sema/attr-nocf_check.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=332704&r1=332703&r2=332704&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Fri May 18 04:56:21 2018
@@ -2486,8 +2486,6 @@ X86
 
 .. option:: -mgfni, -mno-gfni
 
-.. option:: -mibt, -mno-ibt
-
 .. option:: -mlwp, -mno-lwp
 
 .. option:: -mlzcnt, -mno-lzcnt

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=332704&r1=332703&r2=332704&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Fri May 18 04:56:21 
2018
@@ -206,6 +206,8 @@ def err_opt_not_valid_with_opt : Error<
   "option '%0' cannot be specified with '%1'">;
 def err_opt_not_valid_without_opt : Error<
   "option '%0' cannot be specified without '%1'">;
+def err_opt_not_valid_on_target : Error<
+  "option '%0' cannot be specified on this target">;
 
 // Source manager
 def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=332704&r1=332703&r2=332704&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri May 18 04:56:21 2018
@@ -1075,15 +1075,11 @@ public:
 
   /// Check if the target supports CFProtection branch.
   virtual bool
-  checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const {
-return false;
-  }
+  checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const;
 
   /// Check if the target supports CFProtection branch.
   virtual bool
-  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const {
-return false;
-  }
+  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const;
 
   /// Whether target allows to overalign ABI-specified preferred alignment
   virtual bool allowsLargerPreferedTypeAlignment() const { return true; }

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=332704&r1=332703&r2=332704&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri May 18 04:56:21 2018
@@ -2747,8 +2747,6 @@ def mxsaves : Flag<["-"], "mxsaves">, Gr
 def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
 def mshstk : Flag<["-"], "mshstk">, Group;
 def mno_shstk : Flag<["-"], "mno-shstk">, Group;
-def mibt : Flag<["-"], "mibt">, Group;
-def mno_ibt : Flag<["-"], "mno-ibt">, Group;
 def mretpoline : Flag<["-"], "mretpoline">, Group;
 def mno_retpoline : Flag<["-"], "mno-retpoline">, Group;
 def mretpoline_external_thunk : Flag<["-"], "mretpoline-external-thunk">, 
Group;

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=332704&r1=332703&r2=332704&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-05-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:21-25
+  for (const auto *Init : Node.capture_inits()) {
+if (Init == E)
+  return true;
+  }
+  return false;

This can be replaced with `return llvm::find(Node.capture_inits(), E);`



Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:34-38
+const ast_matchers::internal::VariadicDynCastAllOfMatcher
+cxxTypeidExpr;
+
+const ast_matchers::internal::VariadicDynCastAllOfMatcher
+cxxNoexceptExpr;

I think these should be exposed as public AST matchers, as they're both 
generally useful. It can be done in a follow-up patch, or done before landing 
this patch, either is fine by me.



Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:67
+
+bool ExprMutationAnalyzer::isUnevaluated(const Expr *Exp) {
+  return selectFirst(

What about other unevaluated expressions, like `typeof`, `_Generic`, etc? You 
should search for `ExpressionEvaluationContext::Unevaluated` in Clang to see 
where we set up an unevaluated expression evaluation context to find all of the 
situations.



Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:72
+ findAll(expr(equalsNode(Exp),
+  anyOf(hasAncestor(typeLoc()),
+hasAncestor(expr(anyOf(

What is this trying to match with the `typeLoc()` matcher?



Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:74-75
+hasAncestor(expr(anyOf(
+unaryExprOrTypeTraitExpr(),
+cxxTypeidExpr(), cxxNoexceptExpr())
+ .bind("expr")),

I think these are only approximations to testing whether it's unevaluated. For 
instance, won't this match these expressions, despite them being evaluated?
```
// C++
#include 

struct B {
  virtual ~B() = default;
};

struct D : B {};

B& get() {
  static B *b = new D;
  return *b;
}

void f() {
  (void)typeid(get()); // Evaluated, calls get()
}

/* C99 and later */
#include 

void f(size_t n) {
  (void)sizeof(int[++n]); // Evaluated, increments n
}
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45679



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


[PATCH] D47060: [VFS] Implement getRealPath for OverlayFileSystem.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: bkramer.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D47060

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp


Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,20 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  StringRef SymlinkPath("/symlink");
+  Output.assign(SymlinkPath.begin(), SymlinkPath.end());
+  return std::error_code();
+}
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +210,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Upper(new DummyFileSystem());
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(Upper);
+
+  // Regular file.
+  SmallString<16> RealPath;
+  EXPECT_FALSE(O->getRealPath("/foo", RealPath));
+  EXPECT_EQ(RealPath.str(), "/foo");
+
+  // Expect no error getting real path for symlink in lower overlay.
+  EXPECT_FALSE(O->getRealPath("/lower_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+
+  // Try a non-existing link.
+  EXPECT_EQ(O->getRealPath("/upper_link", RealPath),
+errc::no_such_file_or_directory);
+
+  // Add a new symlink in upper.
+  Upper->addSymlink("/upper_link");
+  EXPECT_FALSE(O->getRealPath("/upper_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+}
+
 TEST(VirtualFileSystemTest, OverlayFiles) {
   IntrusiveRefCntPtr Base(new DummyFileSystem());
   IntrusiveRefCntPtr Middle(new DummyFileSystem());
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -381,6 +381,19 @@
   return {};
 }
 
+std::error_code
+OverlayFileSystem::getRealPath(const Twine &Path,
+   SmallVectorImpl &Output) const {
+  // Not using overlays_begin/end because this method is const.
+  for (auto I = FSList.rbegin(), E = FSList.rend(); I != E; ++I) {
+auto &FS = *I;
+if (!FS->exists(Path))
+continue;
+return FS->getRealPath(Path, Output);
+  }
+  return errc::no_such_file_or_directory;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {
Index: include/clang/Basic/VirtualFileSystem.h
===
--- include/clang/Basic/VirtualFileSystem.h
+++ include/clang/Basic/VirtualFileSystem.h
@@ -304,6 +304,8 @@
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 
   using iterator = FileSystemList::reverse_iterator;
   


Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,20 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  StringRef SymlinkPath("/symlink");
+  Output.assign(SymlinkPath.begin(), SymlinkPath.end());
+  return std::error_code();
+}
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +210,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Low

[PATCH] D47060: [VFS] Implement getRealPath for OverlayFileSystem.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 147487.
ioeric added a comment.

Minor cleanup


Repository:
  rC Clang

https://reviews.llvm.org/D47060

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp


Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,19 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +209,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Upper(new DummyFileSystem());
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(Upper);
+
+  // Regular file.
+  SmallString<16> RealPath;
+  EXPECT_FALSE(O->getRealPath("/foo", RealPath));
+  EXPECT_EQ(RealPath.str(), "/foo");
+
+  // Expect no error getting real path for symlink in lower overlay.
+  EXPECT_FALSE(O->getRealPath("/lower_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+
+  // Try a non-existing link.
+  EXPECT_EQ(O->getRealPath("/upper_link", RealPath),
+errc::no_such_file_or_directory);
+
+  // Add a new symlink in upper.
+  Upper->addSymlink("/upper_link");
+  EXPECT_FALSE(O->getRealPath("/upper_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+}
+
 TEST(VirtualFileSystemTest, OverlayFiles) {
   IntrusiveRefCntPtr Base(new DummyFileSystem());
   IntrusiveRefCntPtr Middle(new DummyFileSystem());
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -381,6 +381,19 @@
   return {};
 }
 
+std::error_code
+OverlayFileSystem::getRealPath(const Twine &Path,
+   SmallVectorImpl &Output) const {
+  // Not using overlays_begin/end because this method is const.
+  for (auto I = FSList.rbegin(), E = FSList.rend(); I != E; ++I) {
+auto &FS = *I;
+if (!FS->exists(Path))
+continue;
+return FS->getRealPath(Path, Output);
+  }
+  return errc::no_such_file_or_directory;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {
Index: include/clang/Basic/VirtualFileSystem.h
===
--- include/clang/Basic/VirtualFileSystem.h
+++ include/clang/Basic/VirtualFileSystem.h
@@ -304,6 +304,8 @@
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 
   using iterator = FileSystemList::reverse_iterator;
   


Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,19 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +209,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Upper(new DummyFileSystem());
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSyst

[PATCH] D47060: [VFS] Implement getRealPath for OverlayFileSystem.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 147488.
ioeric added a comment.

Fix test...


Repository:
  rC Clang

https://reviews.llvm.org/D47060

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp


Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,21 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Output.clear();
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Output.clear();
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +211,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Upper(new DummyFileSystem());
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(Upper);
+
+  // Regular file.
+  SmallString<16> RealPath;
+  EXPECT_FALSE(O->getRealPath("/foo", RealPath));
+  EXPECT_EQ(RealPath.str(), "/foo");
+
+  // Expect no error getting real path for symlink in lower overlay.
+  EXPECT_FALSE(O->getRealPath("/lower_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+
+  // Try a non-existing link.
+  EXPECT_EQ(O->getRealPath("/upper_link", RealPath),
+errc::no_such_file_or_directory);
+
+  // Add a new symlink in upper.
+  Upper->addSymlink("/upper_link");
+  EXPECT_FALSE(O->getRealPath("/upper_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+}
+
 TEST(VirtualFileSystemTest, OverlayFiles) {
   IntrusiveRefCntPtr Base(new DummyFileSystem());
   IntrusiveRefCntPtr Middle(new DummyFileSystem());
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -381,6 +381,19 @@
   return {};
 }
 
+std::error_code
+OverlayFileSystem::getRealPath(const Twine &Path,
+   SmallVectorImpl &Output) const {
+  // Not using overlays_begin/end because this method is const.
+  for (auto I = FSList.rbegin(), E = FSList.rend(); I != E; ++I) {
+auto &FS = *I;
+if (!FS->exists(Path))
+continue;
+return FS->getRealPath(Path, Output);
+  }
+  return errc::no_such_file_or_directory;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {
Index: include/clang/Basic/VirtualFileSystem.h
===
--- include/clang/Basic/VirtualFileSystem.h
+++ include/clang/Basic/VirtualFileSystem.h
@@ -304,6 +304,8 @@
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 
   using iterator = FileSystemList::reverse_iterator;
   


Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,21 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Output.clear();
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Output.clear();
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +211,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Up

[PATCH] D47060: [VFS] Implement getRealPath for OverlayFileSystem.

2018-05-18 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg




Comment at: lib/Basic/VirtualFileSystem.cpp:387
+   SmallVectorImpl &Output) const {
+  // Not using overlays_begin/end because this method is const.
+  for (auto I = FSList.rbegin(), E = FSList.rend(); I != E; ++I) {

Those should probably get const overloads. Doesn't have to be in this change 
though.


Repository:
  rC Clang

https://reviews.llvm.org/D47060



___
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-05-18 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 147485.
Szelethus added a comment.

In this diff, I preferred placing `TODO`s in places where the logic of the 
checker would have changed too much. While I didn't have a strict rule for this 
in mind, I tried changing as little as possible in order to implement the fixes 
in smaller followup patches.

Now with that being said, I still did make numerous changes to address the 
inline comments, so here is a complete list of them:

- I placed the checker back in `alpha.cplusplus`
- While the main logic of the checker is unchanged, I did make some small 
additions: it turned out (thanks to @NoQ) that objects I wrongly referred to as 
fundamental were in fact of `BuiltinType` or `EnumeralType`. In the checker I 
defined these types as "primitive", as neither clang or the C++ standard 
defines a type called "primitive"
- A new node is added to the directed tree: objects of `MemberPointerType`. I 
updated the documentation, and added a function to `FindUninitializedFields` 
but left the implementation to be done in a followup patch
- String concatenations are all done with streams
- `FieldChainInfo` now uses `llvm::ImmutableList`
- `FieldChainInfo` is now completely immutable
- `FindUninitializedFields` no longer checks lazily, and has only a single 
`getUninitFields` public non-special member function.
- `FindUninitializedFields` now has a `ProgramStateRef` field instead of a 
bunch of managers (this added a dependency https://reviews.llvm.org/D46891)
- Added asserts and `llvm_unreachable` at numerous locations
- More comments for easier reading

For the test files:

- Changed all non-member function names to eliminate numbering
- Split `cxx-uninitialized-object.cpp` up, and placed pointer/reference tests 
in a different file
- Added tests for
  - `loc::ConcreteInt`
  - Member pointers
  - `BuiltinType` and `EnumeralType`
  - Constructorcall within a constructor, without the two constructors being in 
relation, to highlight a false negative
  - C++11 member initializers.

I'll be the first to admit that I'm not 100% sure I implemented the change to 
`llvm::ImmutableList` perfectly, so I guess maybe it's worth taking a deeper 
look at (but it certainly works!). Shall I tie its lifetime to the checker 
object's lifetime?
Of course, I rechecked the entire LLVM/Clang project and I'm happy to report 
that no crashes occured, and it emitted almost the same amount of warning 
(almost, because I used a newer version of clang).


https://reviews.llvm.org/D45532

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  test/Analysis/Inputs/system-header-simulator-for-cxx-uninitialized-object.h
  test/Analysis/cxx-uninitialized-object-inheritance.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  test/Analysis/cxx-uninitialized-object.cpp

Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- /dev/null
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -0,0 +1,1058 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+
+//===--===//
+// Default constructor test.
+//===--===//
+
+class CompilerGeneratedConstructorTest {
+  int a, b, c, d, e, f, g, h, i, j;
+
+public:
+  CompilerGeneratedConstructorTest() = default;
+};
+
+void fCompilerGeneratedConstructorTest() {
+  CompilerGeneratedConstructorTest();
+}
+
+#ifdef PEDANTIC
+class DefaultConstructorTest {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+
+public:
+  DefaultConstructorTest();
+};
+
+DefaultConstructorTest::DefaultConstructorTest() = default;
+
+void fDefaultConstructorTest() {
+  DefaultConstructorTest(); // expected-warning{{1 uninitialized field}}
+}
+#else
+class DefaultConstructorTest {
+  int a;
+
+public:
+  DefaultConstructorTest();
+};
+
+DefaultConstructorTest::DefaultConstructorTest() = default;
+
+void fDefaultConstructorTest() {
+  DefaultConstructorTest();
+}
+#endif // PEDANTIC
+
+//===--===//
+// Initializer list test.
+//===--===//
+
+class InitListTest1 {
+  int a;
+  int b;
+
+public:
+  InitListTest1()
+  : a(1),
+b(2) {
+// All good!
+  }
+};
+
+void fInitListTest1() {
+  InitListTest1();
+}
+
+class InitListTest2 {
+  int a;
+  int b; // expected-note{{uninitialized field 'this->b'}}
+
+public:
+  InitListTest2()
+  : a(3) {} // expected-warning{{1 uninitialized field}}
+};

[PATCH] D47060: [VFS] Implement getRealPath for OverlayFileSystem.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 147491.
ioeric marked an inline comment as done.
ioeric added a comment.

- Add and use const_iterator.


Repository:
  rC Clang

https://reviews.llvm.org/D47060

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,21 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Output.clear();
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Output.clear();
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +211,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Upper(new DummyFileSystem());
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(Upper);
+
+  // Regular file.
+  SmallString<16> RealPath;
+  EXPECT_FALSE(O->getRealPath("/foo", RealPath));
+  EXPECT_EQ(RealPath.str(), "/foo");
+
+  // Expect no error getting real path for symlink in lower overlay.
+  EXPECT_FALSE(O->getRealPath("/lower_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+
+  // Try a non-existing link.
+  EXPECT_EQ(O->getRealPath("/upper_link", RealPath),
+errc::no_such_file_or_directory);
+
+  // Add a new symlink in upper.
+  Upper->addSymlink("/upper_link");
+  EXPECT_FALSE(O->getRealPath("/upper_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+}
+
 TEST(VirtualFileSystemTest, OverlayFiles) {
   IntrusiveRefCntPtr Base(new DummyFileSystem());
   IntrusiveRefCntPtr Middle(new DummyFileSystem());
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -381,6 +381,15 @@
   return {};
 }
 
+std::error_code
+OverlayFileSystem::getRealPath(const Twine &Path,
+   SmallVectorImpl &Output) const {
+  for (auto &FS : FSList)
+if (FS->exists(Path))
+  return FS->getRealPath(Path, Output);
+  return errc::no_such_file_or_directory;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {
Index: include/clang/Basic/VirtualFileSystem.h
===
--- include/clang/Basic/VirtualFileSystem.h
+++ include/clang/Basic/VirtualFileSystem.h
@@ -304,15 +304,20 @@
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 
   using iterator = FileSystemList::reverse_iterator;
-  
+  using const_iterator = FileSystemList::const_reverse_iterator;
+
   /// Get an iterator pointing to the most recently added file system.
   iterator overlays_begin() { return FSList.rbegin(); }
+  const_iterator overlays_begin() const { return FSList.rbegin(); }
 
   /// Get an iterator pointing one-past the least recently added file
   /// system.
   iterator overlays_end() { return FSList.rend(); }
+  const_iterator overlays_end() const { return FSList.rend(); }
 };
 
 namespace detail {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:35
+  hasSourceExpression(IsFloatExpr),
+  unless(hasParent(castExpr(
+ .bind("cast"),

I believe this code will not diagnose under this check -- is that intended as a 
way to silence the check?
```
i += (double)0.5;
```



Comment at: 
docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst:10-11
+
+This rule is part of the "Expressions and statements" profile of the C++ Core
+Guidelines, corresponding to rule ES.46. See
+

More exposition is needed because this is only a very small part of the core 
guideline. You should be explicit about where we deviate (or what we support, 
depending on which is the clearest exposition).



Comment at: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp:81
+
+}  // namespace floats

What should happen in cases like the following:
```
template 
void f(T1 one, T2 two) {
  one += two;
}

void g() {
  f(1, 2);
  f(1, .5);
}

#define DERP(i, j) (i += j)

void h() {
  int i = 0;
  DERP(1, 2);
  DERP(i, .5);
}
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


[clang-tools-extra] r332716 - Silence a truncation warning; NFC.

2018-05-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 18 06:18:41 2018
New Revision: 332716

URL: http://llvm.org/viewvc/llvm-project?rev=332716&view=rev
Log:
Silence a truncation warning; NFC.

Modified:
clang-tools-extra/trunk/clangd/Quality.cpp

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=332716&r1=332715&r2=332716&view=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Fri May 18 06:18:41 2018
@@ -42,7 +42,7 @@ float SymbolQualitySignals::evaluate() c
 Score *= 2 - std::min(80, SemaCCPriority) / 40;
 
   if (Deprecated)
-Score *= 0.1;
+Score *= 0.1f;
 
   return Score;
 }


___
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-05-18 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus marked 28 inline comments as done.
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:181-182
+/// Returns whether FD can be (transitively) dereferenced to a void pointer 
type
+/// (void*, void**, ...). The type of the region behind a void pointer isn't
+/// known, and thus FD can not be analyzed.
+bool isVoidPointer(const FieldDecl *FD);

NoQ wrote:
> Type of an object pointed to by a void pointer is something that our 
> path-sensitive engine is sometimes able to provide. It is not uncommon that a 
> void pointer points to a concrete variable on the current path, and we may 
> know it in the analyzer. I'm not sure this sort of check is necessary (i.e. 
> require more information).
> 
> You may also want to have a look at `getDynamicTypeInfo()` which is sometimes 
> capable of retrieving the dynamic type of the object pointed to by a pointer 
> or a reference - i.e. even if it's different from the pointee type of the 
> pointer.
I took a look at it, but I found that it'd change the implementation of 
`isPointerOrReferenceUninit` so much, I'd be a lot more comfortable if I could 
implement it in a smaller followup patch. I placed some `TODO`s in the code 
about this.



Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:223-225
+  ExplodedNode *Node = Context.generateNonFatalErrorNode(Context.getState());
+  if (!Node)
+return;

NoQ wrote:
> I suspect that a fatal error is better here. We don't want the user to 
> receive duplicate report from other checkers that catch uninitialized values; 
> just one report is enough.
I think that would be a bad idea. For example, this checker shouts so loudly 
while checking the LLVM project, it would practically halt the analysis of the 
code, reducing the coverage, which means that checkers other then uninit value 
checkers would "suffer" from it.

However, I also think that having multiple uninit reports for the same object 
might be good, especially with this checker, as it would be very easy to see 
where the problem originated from.

What do you think?



Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:405-406
+  SVal DerefdV = StoreMgr.getBinding(S, V.castAs());
+  while (Optional L = DerefdV.getAs())
+DerefdV = StoreMgr.getBinding(S, *L);
+

NoQ wrote:
> Is this loop guaranteed to terminate? Is something like `void *v; v = &v;` 
> possible?
> 
> I think this loop should unwrap the AST type on every iteration and 
> dereference the pointer accordingly.
> 
> In general, i believe that every symbolic pointer dereference should be made 
> with awareness of the type of the object we're trying to retrieve. Which is 
> an optional argument for `State->getSVal(R, ...)`, but it seems that it 
> should be made mandatory because in a lot of cases omitting it causes 
> problems.
> Is this loop guaranteed to terminate? Is something like void *v; v = &v; 
> possible?
I looked this up, and I am confident that it is not possible for a pointer to 
point to itself. Only a `void**` object may point to a `void*`. The loop 
terminates even if you do something evil like `v = 
reinterpret_cast(&v);` (I have tried this with `int`s).

>I think this loop should unwrap the AST type on every iteration and 
>dereference the pointer accordingly.
>
>In general, i believe that every symbolic pointer dereference should be made 
>with awareness of the type of the object we're trying to retrieve. Which is an 
>optional argument for State->getSVal(R, ...), but it seems that it should be 
>made mandatory because in a lot of cases omitting it causes problems.

I invested some serious effort into `getDynamicType`, but I think it'll require 
more time and some serious refactoring of this (`isPointerOrReferenceUninit`) 
function, so I'd post it separately.



Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:432
+  if (isUnionUninit(R)) {
+LocalChain.dereference();
+return addFieldToUninits(std::move(LocalChain));

NoQ wrote:
> Needs a comment on why the `IsDereferenced` flag on this path.
Added a comment at the line where I dereference the field that after that point 
we'll check the pointee.



Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:559-560
+  while (LC) {
+if (isa(LC->getDecl()))
+  return true;
+

NoQ wrote:
> This doesn't check that the constructor on the parent stack frame is anyhow 
> related to the current constructor, so it may introduce false negatives. For 
> instance, a class may lazy-initialize a singleton but never store a reference 
> to it within itself (because, well, it's a singleton, you can always obtain 
> the reference to it). In this case we'll never find the bug in the 
> constructor of the singleton.
Added a TODO and a test c

[PATCH] D45927: [clang-tidy] [modernize-use-auto] Correct way to calculate a type name length for multi-token types

2018-05-18 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked an inline comment as done.
zinovy.nis added a comment.

Alexander, can you please have a look at the latest patch? Thanks.


https://reviews.llvm.org/D45927



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


r332717 - [VFS] Implement getRealPath for OverlayFileSystem.

2018-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 18 06:22:49 2018
New Revision: 332717

URL: http://llvm.org/viewvc/llvm-project?rev=332717&view=rev
Log:
[VFS] Implement getRealPath for OverlayFileSystem.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=332717&r1=332716&r2=332717&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri May 18 06:22:49 2018
@@ -304,15 +304,20 @@ public:
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 
   using iterator = FileSystemList::reverse_iterator;
-  
+  using const_iterator = FileSystemList::const_reverse_iterator;
+
   /// Get an iterator pointing to the most recently added file system.
   iterator overlays_begin() { return FSList.rbegin(); }
+  const_iterator overlays_begin() const { return FSList.rbegin(); }
 
   /// Get an iterator pointing one-past the least recently added file
   /// system.
   iterator overlays_end() { return FSList.rend(); }
+  const_iterator overlays_end() const { return FSList.rend(); }
 };
 
 namespace detail {

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=332717&r1=332716&r2=332717&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri May 18 06:22:49 2018
@@ -381,6 +381,15 @@ OverlayFileSystem::setCurrentWorkingDire
   return {};
 }
 
+std::error_code
+OverlayFileSystem::getRealPath(const Twine &Path,
+   SmallVectorImpl &Output) const {
+  for (auto &FS : FSList)
+if (FS->exists(Path))
+  return FS->getRealPath(Path, Output);
+  return errc::no_such_file_or_directory;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=332717&r1=332716&r2=332717&view=diff
==
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Fri May 18 06:22:49 2018
@@ -67,6 +67,21 @@ public:
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Output.clear();
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Output.clear();
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +211,35 @@ TEST(VirtualFileSystemTest, BaseOnlyOver
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Upper(new DummyFileSystem());
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(Upper);
+
+  // Regular file.
+  SmallString<16> RealPath;
+  EXPECT_FALSE(O->getRealPath("/foo", RealPath));
+  EXPECT_EQ(RealPath.str(), "/foo");
+
+  // Expect no error getting real path for symlink in lower overlay.
+  EXPECT_FALSE(O->getRealPath("/lower_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+
+  // Try a non-existing link.
+  EXPECT_EQ(O->getRealPath("/upper_link", RealPath),
+errc::no_such_file_or_directory);
+
+  // Add a new symlink in upper.
+  Upper->addSymlink("/upper_link");
+  EXPECT_FALSE(O->getRealPath("/upper_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+}
+
 TEST(VirtualFileSystemTest, OverlayFiles) {
   IntrusiveRefCntPtr Base(new DummyFileSystem());
   IntrusiveRefCntPtr Middle

[PATCH] D47060: [VFS] Implement getRealPath for OverlayFileSystem.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332717: [VFS] Implement getRealPath for OverlayFileSystem. 
(authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47060

Files:
  cfe/trunk/include/clang/Basic/VirtualFileSystem.h
  cfe/trunk/lib/Basic/VirtualFileSystem.cpp
  cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -381,6 +381,15 @@
   return {};
 }
 
+std::error_code
+OverlayFileSystem::getRealPath(const Twine &Path,
+   SmallVectorImpl &Output) const {
+  for (auto &FS : FSList)
+if (FS->exists(Path))
+  return FS->getRealPath(Path, Output);
+  return errc::no_such_file_or_directory;
+}
+
 clang::vfs::detail::DirIterImpl::~DirIterImpl() = default;
 
 namespace {
Index: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
===
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
@@ -67,6 +67,21 @@
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
 return std::error_code();
   }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Output.clear();
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Output.clear();
+Path.toVector(Output);
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -196,6 +211,35 @@
   EXPECT_TRUE(Status->equivalent(*Status2));
 }
 
+TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addRegularFile("/foo");
+  Lower->addSymlink("/lower_link");
+  IntrusiveRefCntPtr Upper(new DummyFileSystem());
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(Upper);
+
+  // Regular file.
+  SmallString<16> RealPath;
+  EXPECT_FALSE(O->getRealPath("/foo", RealPath));
+  EXPECT_EQ(RealPath.str(), "/foo");
+
+  // Expect no error getting real path for symlink in lower overlay.
+  EXPECT_FALSE(O->getRealPath("/lower_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+
+  // Try a non-existing link.
+  EXPECT_EQ(O->getRealPath("/upper_link", RealPath),
+errc::no_such_file_or_directory);
+
+  // Add a new symlink in upper.
+  Upper->addSymlink("/upper_link");
+  EXPECT_FALSE(O->getRealPath("/upper_link", RealPath));
+  EXPECT_EQ(RealPath.str(), "/symlink");
+}
+
 TEST(VirtualFileSystemTest, OverlayFiles) {
   IntrusiveRefCntPtr Base(new DummyFileSystem());
   IntrusiveRefCntPtr Middle(new DummyFileSystem());
Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
===
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h
@@ -304,15 +304,20 @@
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 
   using iterator = FileSystemList::reverse_iterator;
-  
+  using const_iterator = FileSystemList::const_reverse_iterator;
+
   /// Get an iterator pointing to the most recently added file system.
   iterator overlays_begin() { return FSList.rbegin(); }
+  const_iterator overlays_begin() const { return FSList.rbegin(); }
 
   /// Get an iterator pointing one-past the least recently added file
   /// system.
   iterator overlays_end() { return FSList.rend(); }
+  const_iterator overlays_end() const { return FSList.rend(); }
 };
 
 namespace detail {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r294879 - [Driver] Use stem() and not filename().

2018-05-18 Thread Nico Weber via cfe-commits
I think this code is probably dead since the stem is "ld.lld" for lld, not
"lld".

On Sat, Feb 11, 2017 at 7:22 PM, Davide Italiano via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Sat, Feb 11, 2017 at 4:19 PM, Rui Ueyama  wrote:
> > On Sat, Feb 11, 2017 at 3:44 PM, Davide Italiano via cfe-commits
> >  wrote:
> >>
> >> Author: davide
> >> Date: Sat Feb 11 17:44:37 2017
> >> New Revision: 294879
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=294879&view=rev
> >> Log:
> >> [Driver] Use stem() and not filename().
> >>
> >> On Windows the filename might have an extension, namely
> >> `.exe`, so the search will fail. Sorry, I don't have a
> >> good way to test this as it seems to fail only in some
> >> weird configurations. r284430 has the same modification
> >> for Fuchsia.
> >>
> >> Modified:
> >> cfe/trunk/lib/Driver/Tools.cpp
> >>
> >> Modified: cfe/trunk/lib/Driver/Tools.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> Tools.cpp?rev=294879&r1=294878&r2=294879&view=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> >> +++ cfe/trunk/lib/Driver/Tools.cpp Sat Feb 11 17:44:37 2017
> >> @@ -10163,7 +10163,7 @@ void gnutools::Linker::ConstructJob(Comp
> >>Args.ClaimAllArgs(options::OPT_w);
> >>
> >>const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
> >> -  if (llvm::sys::path::filename(Exec) == "lld") {
> >> +  if (llvm::sys::path::stem(Exec) == "lld") {
> >>  CmdArgs.push_back("-flavor");
> >>  CmdArgs.push_back("old-gnu");
> >
>
> Probably not, I'm just reducing diffs with out local branch. I think
> we can remove it altogether.
>
> --
> Davide
>
> "There are no solved problems; there are only problems that are more
> or less solved" -- Henri Poincare
> ___
> 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] D47063: [clangd] Keep only a limited number of idle ASTs in memory

2018-05-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: jkorous, MaskRay, ioeric, javed.absar, klimek.

After this commit, clangd will only keep the last 3 accessed ASTs in
memory. Preambles for each of the opened files are still kept in
memory to make completion and AST rebuilds fast.

AST rebuilds are usually fast enough, but having the last ASTs in
memory still considerably improves latency of operations like
findDefinition and documeneHighlight, which are often sent multiple
times a second when moving around the code. So keeping some of the last
accessed ASTs in memory seems like a reasonable tradeoff.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47063

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  test/clangd/trace.test

Index: test/clangd/trace.test
===
--- test/clangd/trace.test
+++ test/clangd/trace.test
@@ -8,14 +8,14 @@
 # CHECK:   "args": {
 # CHECK: "File": "{{.*(/|\\)}}foo.c"
 # CHECK:   },
-# CHECK:   "name": "Preamble",
+# CHECK:   "name": "BuildPreamble",
 # CHECK:   "ph": "X",
 # CHECK: }
 # CHECK: {
 # CHECK:   "args": {
 # CHECK: "File": "{{.*(/|\\)}}foo.c"
 # CHECK:   },
-# CHECK:   "name": "Build",
+# CHECK:   "name": "BuildAST",
 # CHECK:   "ph": "X",
 # CHECK: }
 # CHECK: },
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -42,6 +42,15 @@
 /// within a bounded amount of time.
 };
 
+/// Configuration of the AST retention policy. This only covers retention of
+/// *idle* ASTs. If queue has operations requiring the AST, they might be
+/// kept in memory.
+struct ASTRetentionParams {
+  /// Maximum number of ASTs to be retained in memory when there are no pending
+  /// requests for them.
+  unsigned MaxRetainedASTs = 3;
+};
+
 /// Handles running tasks for ClangdServer and managing the resources (e.g.,
 /// preambles and ASTs) for opened files.
 /// TUScheduler is not thread-safe, only one thread should be providing updates
@@ -53,7 +62,8 @@
 public:
   TUScheduler(unsigned AsyncThreadsCount, bool StorePreamblesInMemory,
   ASTParsedCallback ASTCallback,
-  std::chrono::steady_clock::duration UpdateDebounce);
+  std::chrono::steady_clock::duration UpdateDebounce,
+  ASTRetentionParams RetentionConfig = {});
   ~TUScheduler();
 
   /// Returns estimated memory usage for each of the currently open files.
@@ -98,12 +108,17 @@
 private:
   /// This class stores per-file data in the Files map.
   struct FileData;
-
+public:
+  /// Responsible for retaining and rebuilding idle ASTs. An implementation is
+  /// an LRU cache.
+  class IdleASTs;
+private:
   const bool StorePreamblesInMemory;
   const std::shared_ptr PCHOps;
   const ASTParsedCallback ASTCallback;
   Semaphore Barrier;
   llvm::StringMap> Files;
+  std::unique_ptr ASTCache;
   // None when running tasks synchronously and non-None when running tasks
   // asynchronously.
   llvm::Optional PreambleTasks;
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -45,7 +45,9 @@
 #include "TUScheduler.h"
 #include "Logger.h"
 #include "Trace.h"
+#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
 #include 
@@ -55,6 +57,172 @@
 namespace clang {
 namespace clangd {
 using std::chrono::steady_clock;
+namespace {
+class ASTWorker;
+}
+
+/// Provides an LRU cache of ASTs.
+class TUScheduler::IdleASTs {
+  struct CachedAST;
+
+public:
+  using Key = const ASTWorker *;
+
+  IdleASTs(unsigned MaxRetainedASTs) : MaxRetainedASTs(MaxRetainedASTs) {}
+
+  /// Update a function used to compute an AST for \p K.
+  void update(Key K, std::function()> BuildAST) {
+std::unique_lock Lock(Mut);
+auto &Item = Items[K];
+assert(!Item.Active);
+llvm::Optional ForCleanup = Item.removeCached();
+Item.BuildAST = std::move(BuildAST);
+// Run AST destructor outside the lock.
+Lock.unlock();
+ForCleanup.reset();
+  }
+
+  /// Get the size of the AST.
+  std::size_t getASTBytes(Key K) {
+std::unique_lock Lock(Mut);
+auto It = Items.find(K);
+assert(It != Items.end());
+return It->second.ASTUsedBytes;
+  }
+
+  /// Runs user-provided function over the cached AST for \p K.
+  /// - If AST is currently available in the cache, it is reused.
+  /// - If AST was evicted, it is recomputed.
+  /// Also marks the AST for \p K as most recently used.
+  void runOnAST(Key K, llvm::function_ref F) {
+std::unique_lock Lock(Mut);
+auto &Item = findNonActive(K)->second;
+// Mark item as active for the duration of this operation.
+

[PATCH] D46472: [HIP] Support offloading by linker script

2018-05-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D46472#1103577, @t-tye wrote:

> LGTM except for minor suggestions.


Thanks. Will make changes when committing.


https://reviews.llvm.org/D46472



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


[PATCH] D47063: [clangd] Keep only a limited number of idle ASTs in memory

2018-05-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Another alternative that I've considered was evicting the ASTs from memory 
after a certain period of time, e.g. after 30 seconds of inactivity for some 
file. This might be simpler and also cover the use-case of speeding up multiple 
code navigation requests (findDefinition/documentHighlight) in a row.
Yet another thing that came to mind: walking over **all** of the AST to find 
reference under the cursor is terribly inefficient, we should be able to build 
a cheap data structure that speeds up this operation. Maybe we can even store 
enough information to not need the AST for navigation at all and build it only 
for features like refactorings.
@sammccall, let me know what are your thoughts on all of this.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47063



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


[PATCH] D47065: [clangd] Enable parsing of non-doxygen comments in global-symbol-builder

2018-05-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: ioeric, sammccall.
Herald added subscribers: jkorous, MaskRay, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47065

Files:
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp


Index: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -73,6 +73,12 @@
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance &CI) override {
+// We want all comments, not just the doxygen ones.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
   void EndSourceFileAction() override {
 WrapperFrontendAction::EndSourceFileAction();
 


Index: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -73,6 +73,12 @@
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance &CI) override {
+// We want all comments, not just the doxygen ones.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
   void EndSourceFileAction() override {
 WrapperFrontendAction::EndSourceFileAction();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47066: [clangd] Remove ignored Preamble::CanReuse call from completion

2018-05-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: ioeric, sammccall.
Herald added subscribers: jkorous, MaskRay, klimek.

Now that the clients who relied on stats for files from preamble are
gone.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47066

Files:
  clangd/CodeComplete.cpp


Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -654,21 +654,11 @@
   std::unique_ptr ContentsBuffer =
   llvm::MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName);
 
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   // We reuse the preamble whether it's valid or not. This is a
   // correctness/performance tradeoff: building without a preamble is slow, and
   // completion is latency-sensitive.
-  if (Input.Preamble) {
-auto Bounds =
-ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
-// FIXME(ibiryukov): Remove this call to CanReuse() after we'll fix
-// clients relying on getting stats for preamble files during code
-// completion.
-// Note that results of CanReuse() are ignored, see the comment above.
-Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
- Input.VFS.get());
-  }
-  // The diagnostic options must be set before creating a CompilerInstance.
-  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), Input.Preamble, std::move(ContentsBuffer),
   std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);


Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -654,21 +654,11 @@
   std::unique_ptr ContentsBuffer =
   llvm::MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName);
 
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   // We reuse the preamble whether it's valid or not. This is a
   // correctness/performance tradeoff: building without a preamble is slow, and
   // completion is latency-sensitive.
-  if (Input.Preamble) {
-auto Bounds =
-ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
-// FIXME(ibiryukov): Remove this call to CanReuse() after we'll fix
-// clients relying on getting stats for preamble files during code
-// completion.
-// Note that results of CanReuse() are ignored, see the comment above.
-Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
- Input.VFS.get());
-  }
-  // The diagnostic options must be set before creating a CompilerInstance.
-  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), Input.Preamble, std::move(ContentsBuffer),
   std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47067: Update NRVO logic to support early return

2018-05-18 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik created this revision.
Herald added a subscriber: cfe-commits.

The previous implementation misses an opportunity to apply NRVO (Named Return 
Value

Optimization) below. That discourages user to write early return code.
--

struct Foo {};

Foo f(bool b) {

  if (b)
return Foo();
  Foo oo;
  return oo;

}
-

That is, we can/should apply RVO for a return statement if it refers a 
non-parameter local variable,
and the variable is referred by all return statements reachable from the 
variable declaration.
While, the previous implementation disables the RVO in a scope if there are 
multiple return
statements that refers different variables.

On the new algorithm, local variables are in NRVO_Candidate state at first, and 
a return
statement changes it to NRVO_Disabled for all visible variables but the return 
statement refers.
Then, at the end of the function AST traversal, NRVO is enabled for variables 
in NRVO_Candidate
state and refers from at least one return statement.


Repository:
  rC Clang

https://reviews.llvm.org/D47067

Files:
  include/clang/AST/Decl.h
  include/clang/Sema/Scope.h
  lib/Sema/Scope.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenCXX/nrvo.cpp

Index: test/CodeGenCXX/nrvo.cpp
===
--- test/CodeGenCXX/nrvo.cpp
+++ test/CodeGenCXX/nrvo.cpp
@@ -130,17 +130,13 @@
 }
 
 // CHECK-LABEL: define void @_Z5test3b
-X test3(bool B) {
+X test3(bool B, X x) {
   // CHECK: tail call {{.*}} @_ZN1XC1Ev
-  // CHECK-NOT: call {{.*}} @_ZN1XC1ERKS_
-  // CHECK: call {{.*}} @_ZN1XC1Ev
-  // CHECK: call {{.*}} @_ZN1XC1ERKS_
   if (B) {
 X y;
 return y;
   }
-  // FIXME: we should NRVO this variable too.
-  X x;
+  // CHECK: tail call {{.*}} @_ZN1XC1ERKS_
   return x;
 }
 
@@ -222,3 +218,16 @@
 // CHECK: tail call {{.*}} @_ZN1YIiEC1Ev
 
 // CHECK-EH-03: attributes [[NR_NUW]] = { noreturn nounwind }
+
+
+// CHECK-LABEL: define void @_Z6test10b
+X test10(bool B, X x) {
+  if (B) {
+// CHECK: tail call {{.*}} @_ZN1XC1ERKS_
+return x;
+  }
+  // CHECK: tail call {{.*}} @_ZN1XC1Ev
+  // CHECK-NOT: call {{.*}} @_ZN1XC1ERKS_
+  X y;
+  return y;
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -918,7 +918,7 @@
   if (!isa(D)) {
 Record.push_back(D->isThisDeclarationADemotedDefinition());
 Record.push_back(D->isExceptionVariable());
-Record.push_back(D->isNRVOVariable());
+Record.push_back(D->getNRVOMode());
 Record.push_back(D->isCXXForRangeDecl());
 Record.push_back(D->isObjCForDecl());
 Record.push_back(D->isARCPseudoStrong());
@@ -2031,7 +2031,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // NRVOMode
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isObjCForDecl
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1326,7 +1326,7 @@
 VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition =
 Record.readInt();
 VD->NonParmVarDeclBits.ExceptionVar = Record.readInt();
-VD->NonParmVarDeclBits.NRVOVariable = Record.readInt();
+VD->NonParmVarDeclBits.NRVOMode = Record.readInt();
 VD->NonParmVarDeclBits.CXXForRangeDecl = Record.readInt();
 VD->NonParmVarDeclBits.ObjCForDecl = Record.readInt();
 VD->NonParmVarDeclBits.ARCPseudoStrong = Record.readInt();
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -3455,12 +3455,9 @@
ExpressionEvaluationContext::DiscardedStatement)
 return R;
 
-  if (VarDecl *VD =
-  const_cast(cast(R.get())->getNRVOCandidate())) {
-CurScope->addNRVOCandidate(VD);
-  } else {
-CurScope->setNoNRVO();
-  }
+  VarDecl *VD =
+  const_cast(cast(R.get())->getNRVOCandidate());
+  CurScope->setNRVOCandidate(VD);
 
   CheckJumpOutOfSEHFinally(*this, ReturnLoc, *CurScope->getFnParent());
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1798,8 +1798,6 @@
 }
 
 void Sem

[PATCH] D47068: Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, mgorny, klimek.

clangToolingCore is linked into almost everything (incl. clang), but
not few tools need #include manipulation at this point. So pull this into a
separate library in Tooling.


Repository:
  rC Clang

https://reviews.llvm.org/D47068

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/HeaderIncludes.h
  include/clang/Tooling/Core/IncludeStyle.h
  include/clang/Tooling/Inclusions/HeaderIncludes.h
  include/clang/Tooling/Inclusions/IncludeStyle.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/HeaderIncludes.cpp
  lib/Tooling/Core/IncludeStyle.cpp
  lib/Tooling/Inclusions/CMakeLists.txt
  lib/Tooling/Inclusions/HeaderIncludes.cpp
  lib/Tooling/Inclusions/IncludeStyle.cpp
  unittests/Tooling/HeaderIncludesTest.cpp

Index: unittests/Tooling/HeaderIncludesTest.cpp
===
--- unittests/Tooling/HeaderIncludesTest.cpp
+++ unittests/Tooling/HeaderIncludesTest.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "../Tooling/ReplacementTest.h"
 #include "../Tooling/RewriterTestContext.h"
 #include "clang/Format/Format.h"
Index: lib/Tooling/Inclusions/IncludeStyle.cpp
===
--- lib/Tooling/Inclusions/IncludeStyle.cpp
+++ lib/Tooling/Inclusions/IncludeStyle.cpp
@@ -7,8 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/IncludeStyle.h"
-
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
 
 using clang::tooling::IncludeStyle;
 
Index: lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 
Index: lib/Tooling/Inclusions/CMakeLists.txt
===
--- lib/Tooling/Inclusions/CMakeLists.txt
+++ lib/Tooling/Inclusions/CMakeLists.txt
@@ -1,15 +1,12 @@
 set(LLVM_LINK_COMPONENTS support)
 
-add_clang_library(clangToolingCore
-  Diagnostic.cpp
+add_clang_library(clangToolingInclusions
   HeaderIncludes.cpp
   IncludeStyle.cpp
-  Lookup.cpp
-  Replacement.cpp
 
   LINK_LIBS
-  clangAST
   clangBasic
   clangLex
   clangRewrite
+  clangToolingCore
   )
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -2,8 +2,6 @@
 
 add_clang_library(clangToolingCore
   Diagnostic.cpp
-  HeaderIncludes.cpp
-  IncludeStyle.cpp
   Lookup.cpp
   Replacement.cpp
 
Index: lib/Tooling/CMakeLists.txt
===
--- lib/Tooling/CMakeLists.txt
+++ lib/Tooling/CMakeLists.txt
@@ -4,6 +4,7 @@
   )
 
 add_subdirectory(Core)
+add_subdirectory(Inclusions)
 add_subdirectory(Refactoring)
 add_subdirectory(ASTDiff)
 
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -31,7 +31,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
Index: lib/Format/CMakeLists.txt
===
--- lib/Format/CMakeLists.txt
+++ lib/Format/CMakeLists.txt
@@ -20,4 +20,5 @@
   clangBasic
   clangLex
   clangToolingCore
+  clangToolingInclusions
   )
Index: include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- include/clang/Tooling/Inclusions/IncludeStyle.h
+++ include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -7,8 +7,8 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_TOOLING_CORE_INCLUDESTYLE_H
-#define LLVM_CLANG_TOOLING_CORE_INCLUDESTYLE_H
+#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_INCLUDESTYLE_H
+#define LLVM_CLANG_TOOLING_INCLUSIONS_INCLUDESTYLE_H
 
 #include "llvm/Support/YAMLTraits.h"
 #include 
@@ -130,4 +130,4 @@
 } // namespace yaml
 } // namespace llvm
 
-#endif // LLVM_CLANG_TOOLING_CORE_INCLUDESTY

[PATCH] D47068: Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM with a minor naming suggestion.




Comment at: include/clang/Format/Format.h:20
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"

Maybe `Tooling/Includes`?
I think inclusions is somewhat uncommon, while includes is more widely used. 
Don't have a strong opinion, though.


Repository:
  rC Clang

https://reviews.llvm.org/D47068



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


[PATCH] D47068: Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric marked an inline comment as done.
ioeric added inline comments.



Comment at: include/clang/Format/Format.h:20
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"

ilya-biryukov wrote:
> Maybe `Tooling/Includes`?
> I think inclusions is somewhat uncommon, while includes is more widely used. 
> Don't have a strong opinion, though.
I decided to use `Inclusions` over `Includes` or `Headers` because those two 
can be confused with directories that contain headers for the library.


Repository:
  rC Clang

https://reviews.llvm.org/D47068



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


[PATCH] D47069: [ASTImporter] Enable disabled but passing test

2018-05-18 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a.sidorin, r.stahl, xazax.hun.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.

There is a test which passes since https://reviews.llvm.org/D32947, but it was 
forgotten to be enabled.
This patch enables that disabled test.


Repository:
  rC Clang

https://reviews.llvm.org/D47069

Files:
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1399,7 +1399,7 @@
   EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace());
 }
 
-TEST_P(ASTImporterTestBase, DISABLED_IDNSOfNonmemberOperator) {
+TEST_P(ASTImporterTestBase, IDNSOfNonmemberOperator) {
   Decl *FromTU = getTuDecl(
   R"(
   struct X {};


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1399,7 +1399,7 @@
   EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace());
 }
 
-TEST_P(ASTImporterTestBase, DISABLED_IDNSOfNonmemberOperator) {
+TEST_P(ASTImporterTestBase, IDNSOfNonmemberOperator) {
   Decl *FromTU = getTuDecl(
   R"(
   struct X {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 18 07:16:37 2018
New Revision: 332720

URL: http://llvm.org/viewvc/llvm-project?rev=332720&view=rev
Log:
Move #include manipulation code to new lib/Tooling/Inclusions.

Summary:
clangToolingCore is linked into almost everything (incl. clang), but
not few tools need #include manipulation at this point. So pull this into a
separate library in Tooling.

Reviewers: ilya-biryukov

Subscribers: klimek, mgorny, cfe-commits, thakis

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

Added:
cfe/trunk/include/clang/Tooling/Inclusions/
cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
  - copied, changed from r332717, 
cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
  - copied, changed from r332717, 
cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
cfe/trunk/lib/Tooling/Inclusions/
cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
  - copied, changed from r332717, cfe/trunk/lib/Tooling/Core/CMakeLists.txt
cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
  - copied, changed from r332717, 
cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
  - copied, changed from r332717, 
cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
Removed:
cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/CMakeLists.txt
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Tooling/CMakeLists.txt
cfe/trunk/lib/Tooling/Core/CMakeLists.txt
cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=332720&r1=332719&r2=332720&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Fri May 18 07:16:37 2018
@@ -16,8 +16,8 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Tooling/Core/IncludeStyle.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Regex.h"
 #include 

Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?rev=332719&view=auto
==
--- cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (removed)
@@ -1,137 +0,0 @@
-//===--- HeaderIncludes.h - Insert/Delete #includes for C++ code--*- 
C++-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
-#define LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
-
-#include "clang/Basic/SourceManager.h"
-#include "clang/Tooling/Core/Replacement.h"
-#include "clang/Tooling/Core/IncludeStyle.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/Regex.h"
-#include 
-
-namespace clang {
-namespace tooling {
-
-/// This class manages priorities of C++ #include categories and calculates
-/// priorities for headers.
-/// FIXME(ioeric): move this class into implementation file when clang-format's
-/// include sorting functions are also moved here.
-class IncludeCategoryManager {
-public:
-  IncludeCategoryManager(const IncludeStyle &Style, StringRef FileName);
-
-  /// Returns the priority of the category which \p IncludeName belongs to.
-  /// If \p CheckMainHeader is true and \p IncludeName is a main header, 
returns
-  /// 0. Otherwise, returns the priority of the matching category or INT_MAX.
-  /// NOTE: this API is not thread-safe!
-  int getIncludePriority(StringRef IncludeName, bool CheckMainHeader) const;
-
-private:
-  bool isMainHeader(StringRef IncludeName) const;
-
-  const IncludeStyle Style;
-  bool IsMainFile;
-  std::string FileName;
-  // This refers to a substring in FileName.
-  StringRef FileStem;
-  // Regex is not thread-safe.
-  mutable SmallVector CategoryRegexs;
-};
-
-/// Generates replacements for inserting or deleting #include directives in a
-/// file.
-class HeaderIncludes {
-public:
-  HeaderIncludes(llvm::StringRef FileName, llvm::StringRef Code,
- const IncludeStyle &Style);
-
-  /// Inserts an #include directive of \p Header into the code. If \p IsAngled
-  /// is true, \p Header will be quoted with <> in 

[PATCH] D47068: Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ioeric marked an inline comment as done.
Closed by commit rL332720: Move #include manipulation code to new 
lib/Tooling/Inclusions. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47068?vs=147504&id=147507#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47068

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
  cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
  cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
  cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
  cfe/trunk/lib/Format/CMakeLists.txt
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Tooling/CMakeLists.txt
  cfe/trunk/lib/Tooling/Core/CMakeLists.txt
  cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
  cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
  cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
  cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
  cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
  cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp

Index: cfe/trunk/lib/Format/CMakeLists.txt
===
--- cfe/trunk/lib/Format/CMakeLists.txt
+++ cfe/trunk/lib/Format/CMakeLists.txt
@@ -20,4 +20,5 @@
   clangBasic
   clangLex
   clangToolingCore
+  clangToolingInclusions
   )
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -31,7 +31,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
Index: cfe/trunk/lib/Tooling/CMakeLists.txt
===
--- cfe/trunk/lib/Tooling/CMakeLists.txt
+++ cfe/trunk/lib/Tooling/CMakeLists.txt
@@ -4,6 +4,7 @@
   )
 
 add_subdirectory(Core)
+add_subdirectory(Inclusions)
 add_subdirectory(Refactoring)
 add_subdirectory(ASTDiff)
 
Index: cfe/trunk/lib/Tooling/Core/CMakeLists.txt
===
--- cfe/trunk/lib/Tooling/Core/CMakeLists.txt
+++ cfe/trunk/lib/Tooling/Core/CMakeLists.txt
@@ -2,8 +2,6 @@
 
 add_clang_library(clangToolingCore
   Diagnostic.cpp
-  HeaderIncludes.cpp
-  IncludeStyle.cpp
   Lookup.cpp
   Replacement.cpp
 
Index: cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
===
--- cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
+++ cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
@@ -0,0 +1,31 @@
+//===--- IncludeStyle.cpp - Style of C++ #include directives -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
+
+using clang::tooling::IncludeStyle;
+
+namespace llvm {
+namespace yaml {
+
+void MappingTraits::mapping(
+IO &IO, IncludeStyle::IncludeCategory &Category) {
+  IO.mapOptional("Regex", Category.Regex);
+  IO.mapOptional("Priority", Category.Priority);
+}
+
+void ScalarEnumerationTraits::enumeration(
+IO &IO, IncludeStyle::IncludeBlocksStyle &Value) {
+  IO.enumCase(Value, "Preserve", IncludeStyle::IBS_Preserve);
+  IO.enumCase(Value, "Merge", IncludeStyle::IBS_Merge);
+  IO.enumCase(Value, "Regroup", IncludeStyle::IBS_Regroup);
+}
+
+} // namespace yaml
+} // namespace llvm
Index: cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -0,0 +1,330 @@
+//===--- HeaderIncludes.cpp - Insert/Delete #includes --*- C++ -*--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+
+LangOptions createLangOpts() {
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus = 1;
+  LangOpts.CPlusPlus11 = 1;
+  LangOpts.CPlusPlus14 = 1;
+  LangOpts.LineComment = 1;
+  LangOpts.CXXOperatorNames = 1;
+  LangOpts.Bool = 1;
+  LangOpts.ObjC1 = 1;
+  LangOpts.ObjC2 = 1;
+  LangOpts.MicrosoftExt = 1;// 

[clang-tools-extra] r332721 - [clangd] Adapt file migration in r332720

2018-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 18 07:17:36 2018
New Revision: 332721

URL: http://llvm.org/viewvc/llvm-project?rev=332721&view=rev
Log:
[clangd] Adapt file migration in r332720

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/Headers.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=332721&r1=332720&r2=332721&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri May 18 07:17:36 2018
@@ -55,6 +55,7 @@ add_clang_library(clangDaemon
   clangSerialization
   clangTooling
   clangToolingCore
+  clangToolingInclusions
   clangToolingRefactor
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}

Modified: clang-tools-extra/trunk/clangd/Headers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=332721&r1=332720&r2=332721&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.h (original)
+++ clang-tools-extra/trunk/clangd/Headers.h Fri May 18 07:17:36 2018
@@ -17,7 +17,7 @@
 #include "clang/Format/Format.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PPCallbacks.h"
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"


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


[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu

2018-05-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Hi Artem,

I've addressed your comments. Any further changes are needed? Thanks.


https://reviews.llvm.org/D45212



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


[PATCH] D47028: [clang-format/ObjC] Correctly annotate single-component ObjC method invocations

2018-05-18 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak accepted this revision.
jolesiak added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Format/TokenAnnotator.cpp:510
+CurrentToken->Previous->Type = TT_SelectorName;
+  }
   // determineStarAmpUsage() thinks that '*' '[' is allocating an

I'd remove braces for consistency.


Repository:
  rC Clang

https://reviews.llvm.org/D47028



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-18 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 147508.
courbet marked 2 inline comments as done.
courbet added a comment.

- More explicit documentation.
- Do not trigger in template and macro contexts.
- More tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp

Index: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
@@ -0,0 +1,103 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t
+
+float ceil(float);
+namespace std {
+double ceil(double);
+long double floor(long double);
+} // namespace std
+
+namespace floats {
+
+struct ConvertsToFloat {
+  operator float() const { return 0.5; }
+};
+
+float operator "" _Pa(unsigned long long);
+
+void not_ok(double d) {
+  int i = 0;
+  i = d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i = 0.5f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i = static_cast(d);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i = ConvertsToFloat();
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i = 15_Pa;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+}
+
+void not_ok_binary_ops(double d) {
+  int i = 0;
+  i += 0.5;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i += 0.5f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i += d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // We warn on the following even though it's not dangerous because there is no
+  // reason to use a double literal here.
+  // TODO(courbet): Provide an automatic fix.
+  i += 2.0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i += 2.0f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+
+  i *= 0.5f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i /= 0.5f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i += (double)0.5f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+}
+
+void ok(double d) {
+  int i = 0;
+  i = 1;
+  i = static_cast(0.5);
+  i = static_cast(d);
+  i = std::ceil(0.5);
+  i = ::std::floor(0.5);
+  {
+using std::ceil;
+i = ceil(0.5f);
+  }
+  i = ceil(0.5f);
+}
+
+void ok_binary_ops(double d) {
+  int i = 0;
+  i += 1;
+  i += static_cast(0.5);
+  i += static_cast(d);
+  i += (int)d;
+  i += std::ceil(0.5);
+  i += ::std::floor(0.5);
+  {
+using std::ceil;
+i += ceil(0.5f);
+  }
+  i += ceil(0.5f);
+}
+
+// We're bailing out in templates and macros.
+template 
+void f(T1 one, T2 two) {
+  one += two;
+}
+
+void template_context() {
+  f(1, 2);
+  f(1, .5);
+}
+
+#define DERP(i, j) (i += j)
+
+void macro_context() {
+  int i = 0;
+  DERP(i, 2);
+  DERP(i, .5);
+}
+
+}  // namespace floats
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -78,6 +78,7 @@
cppcoreguidelines-avoid-goto
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-narrowing-conversions
cppcoreguidelines-no-malloc
cppcoreguidelines-owning-memory
cppcoreguidelines-pro-bounds-array-to-pointer-decay
Index: docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
===
--- 

[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-18 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

Thanks.




Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:35
+  hasSourceExpression(IsFloatExpr),
+  unless(hasParent(castExpr(
+ .bind("cast"),

aaron.ballman wrote:
> I believe this code will not diagnose under this check -- is that intended as 
> a way to silence the check?
> ```
> i += (double)0.5;
> ```
Did you mean `(int)0.5` ?

Yes, the user essentially told us they knew what they were doing. I've added an 
explicit test for this.



Comment at: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp:81
+
+}  // namespace floats

aaron.ballman wrote:
> What should happen in cases like the following:
> ```
> template 
> void f(T1 one, T2 two) {
>   one += two;
> }
> 
> void g() {
>   f(1, 2);
>   f(1, .5);
> }
> 
> #define DERP(i, j) (i += j)
> 
> void h() {
>   int i = 0;
>   DERP(1, 2);
>   DERP(i, .5);
> }
> ```
I added more tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:35
+  hasSourceExpression(IsFloatExpr),
+  unless(hasParent(castExpr(
+ .bind("cast"),

courbet wrote:
> aaron.ballman wrote:
> > I believe this code will not diagnose under this check -- is that intended 
> > as a way to silence the check?
> > ```
> > i += (double)0.5;
> > ```
> Did you mean `(int)0.5` ?
> 
> Yes, the user essentially told us they knew what they were doing. I've added 
> an explicit test for this.
I truly meant `(double)0.5` -- where the cast has no impact on the narrowing 
conversion, but the check still doesn't diagnose because there's an explicit 
cast present. Should the check be checking for explicit casts to the narrowed 
type?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

2018-05-18 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:6776
+  // been invalidated to avoid repeatedly calling this.
+  ToContext.invalidateParents();
+

Can an `Expr` has a parent too? If yes, why not invalidate the parents in 
`Import(Expr*)` ?
I am also a bit concerned to call the invalidation during the import of all 
`Stmt` (and possible during the import of `Expr`s too).
Isn't it enough to invalidate only during `Import(Decl*)`?


https://reviews.llvm.org/D46940



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


[PATCH] D47063: [clangd] Keep only a limited number of idle ASTs in memory

2018-05-18 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added subscribers: arphaman, malaperle.
malaperle added a comment.

In https://reviews.llvm.org/D47063#1104417, @ilya-biryukov wrote:

> Maybe we can even store enough information to not need the AST for navigation 
> at all and build it only for features like refactorings.
>  @sammccall, let me know what are your thoughts on all of this.


That's what I was thinking. I think I also had similar discussion with 
@arphaman. I think storing a limited number of ASTs is a good interim solution.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47063



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


[PATCH] D44954: [clangd] Add "member" symbols to the index

2018-05-18 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D44954#1104178, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D44954#1103664, @malaperle wrote:
>
> > It's probably better to consider this in a future patch. Maybe something 
> > like the first suggestion: vector::push_back and match both. Otherwise, I 
> > would think it might be a bit too verbose to have to spell out all of the 
> > specialization. Maybe we could allow it too. So... all of the above? :)
>
>
> This certainly does not have to be addressed in this patch. Just wanted to 
> collect opinions on what the behavior we want in the long term.
>  My thoughts would be towards allowing only `vector::push_back` and make it 
> match both `push_back`s: in `vector` and `vector`.
>  Other cases might work too, but I wouldn't try implementing something that 
> matches specializations. It's just too complicated in the general case. This 
> will only be used in workspaceSymbol and it's fine to give a few more results 
> there...


Sounds very reasonable.

>>> What scopes will non-scoped enum members have?
>> 
>> Hmm. I think all of them, since you can refer them like that in code too. 
>> Case #1 doesn't work but that was the case before this patch so it can 
>> probably be addressed separately. I'll add some tests though!
> 
> I would vote for making queries `En::A` and `A` match the enumerator, but 
> **not** `::A`. The reasoning is: yes, you can reference it this way in a C++ 
> file, but `workspaceSymbol` is not a real C++ resolve and I think it should 
> match the outline of the code rather than the actual C++ lookup rules.
>  E.g. I wouldn't expect it to match symbols from base classes, etc. This 
> should also simplify implementation too.

I don't have a strong opinion, so I can try this suggestion!




Comment at: clangd/index/Index.h:160
+  /// The Decl::Kind for the context of the symbol, i.e. what contains it.
+  Decl::Kind DeclContextKind;
+  /// Whether or not this is an enumerator inside a scoped enum (C++11).

ioeric wrote:
> malaperle wrote:
> > ioeric wrote:
> > > ilya-biryukov wrote:
> > > > How do we use `DeclContextKind`?
> > > > Why did we decide to not go with a `bool ForCompletion` instead? (I'm 
> > > > probably missing a conversation in the workspaceSymbol review, could 
> > > > you point me to those instead?)
> > > > 
> > > > I'm asking because clang enums are very detailed and designed for use 
> > > > in the compiler, using them in the index seems to complicate things.
> > > > It feels we don't need this level of detail in the symbols. Similar to 
> > > > how we don't store the whole structural type, but rely on string 
> > > > representation of completion label instead.
> > > +1
> > > 
> > > `ForCompletion` sounds reasonable as the current design of index-based 
> > > code completion relies on assumptions about contexts. 
> > My thinking was that the "ForCompletion" boolean was too specific and 
> > tailored for one client use. I thought the Symbol information should not 
> > have that much hard-coded knowledge on how it would be used. It would be 
> > odd to have "ForWorkspaceSymbol", "ForDocumentSymbol", etc. That is why I 
> > was going for a slightly more detailed symbol information that opened the 
> > door for more arbitrary queries for symbol clients. But it complicates 
> > things a bit more and I'd be happy to bring back the "ForCompletion" if it 
> > makes more sense for now.
> I think code completion, with the most complicated use of the index so far, 
> probably deserves a flag :P I would expect/hope other features to be less 
> "picky" about symbols. A high-level flag like `ForCompletion` would help keep 
> knowledge about filtering for code completion (e.g. enums ...) inside symbol 
> collector, which I think could be a win.
> 
> FWIW, `ForCompletion` makes it sound like a symbols is collected specifically 
> for code completion. Maybe something like `bool SupportGlobalCompletion` 
> would be better?
> Maybe something like bool SupportGlobalCompletion would be better?

Sounds good!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[clang-tools-extra] r332723 - Silence more truncation warnings; NFC.

2018-05-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 18 07:53:32 2018
New Revision: 332723

URL: http://llvm.org/viewvc/llvm-project?rev=332723&view=rev
Log:
Silence more truncation warnings; NFC.

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

Modified: clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp?rev=332723&r1=332722&r2=332723&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp Fri May 18 
07:53:32 2018
@@ -102,15 +102,15 @@ TEST(QualityTests, SymbolRelevanceSignal
   EXPECT_LT(Forbidden.evaluate(), Default.evaluate());
 
   SymbolRelevanceSignals PoorNameMatch;
-  PoorNameMatch.NameMatch = 0.2;
+  PoorNameMatch.NameMatch = 0.2f;
   EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate());
 }
 
 TEST(QualityTests, SortText) {
-  EXPECT_LT(sortText(std::numeric_limits::infinity()), 
sortText(1000.2));
-  EXPECT_LT(sortText(1000.2), sortText(1));
-  EXPECT_LT(sortText(1), sortText(0.3));
-  EXPECT_LT(sortText(0.3), sortText(0));
+  EXPECT_LT(sortText(std::numeric_limits::infinity()), 
sortText(1000.2f));
+  EXPECT_LT(sortText(1000.2f), sortText(1));
+  EXPECT_LT(sortText(1), sortText(0.3f));
+  EXPECT_LT(sortText(0.3f), sortText(0));
   EXPECT_LT(sortText(0), sortText(-10));
   EXPECT_LT(sortText(-10), sortText(-std::numeric_limits::infinity()));
 


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


[PATCH] D47070: [CUDA] Upgrade linked bitcode to enable inlining

2018-05-18 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: tra, jlebar.
Herald added a subscriber: cfe-commits.

Revision https://reviews.llvm.org/rC329829 added the architecture to 
"target-features". This
prevents inlining of previously generated bitcode because the
feature sets don't match. Thus duplicate the information from
"target-cpu" to avoid writing special cases in the analysis.

I'm not sure if that will save us in the long term because inlining
will break again when we add new features. Additionally, using later
CUDA versions might raise the PTX version which is also a feature...


Repository:
  rC Clang

https://reviews.llvm.org/D47070

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenCUDA/Inputs/device-code-2.ll
  test/CodeGenCUDA/Inputs/device-code.ll
  test/CodeGenCUDA/link-device-bitcode.cu

Index: test/CodeGenCUDA/link-device-bitcode.cu
===
--- test/CodeGenCUDA/link-device-bitcode.cu
+++ test/CodeGenCUDA/link-device-bitcode.cu
@@ -56,15 +56,24 @@
 // Make sure device_mul_or_add() is present in IR, is internal and
 // calls __nvvm_reflect().
 // CHECK-IR-LABEL: define internal float @_Z17device_mul_or_addff(
+// CHECK-IR-SAME: [[MUL_OR_ADD:#[0-9]+]] {
 // CHECK-IR-NLD-LABEL: define float @_Z17device_mul_or_addff(
 // CHECK-IR: call i32 @__nvvm_reflect
 // CHECK-IR: ret float
 
 // Make sure we've linked in and internalized only needed functions
 // from the second bitcode file.
 // CHECK-IR-2-LABEL: define internal double @__nv_sin
+// CHECK-IR-2-SAME: [[IR2ATTR:#[0-9]+]] {
 // CHECK-IR-2-LABEL: define internal double @__nv_exp
+// CHECK-IR-2-SAME: [[IR2ATTR]] {
 // CHECK-IR-2-NOT: double @__unused
 
+// CHECK-IR: attributes [[MUL_OR_ADD]] = {
+// CHECK-IR-SAME: "target-features"="+ptx42,+sm_35"
+
+// CHECK-IR-2: attributes [[IR2ATTR]] = {
+// CHECK-IR-2-SAME: "target-features"="+sm_35"
+
 // Verify that NVVMReflect pass is among the passes run by NVPTX back-end.
 // CHECK-REFLECT: Replace occurrences of __nvvm_reflect() calls with 0/1
Index: test/CodeGenCUDA/Inputs/device-code.ll
===
--- test/CodeGenCUDA/Inputs/device-code.ll
+++ test/CodeGenCUDA/Inputs/device-code.ll
@@ -16,7 +16,7 @@
ret void
 }
 
-define float @_Z17device_mul_or_addff(float %a, float %b) {
+define float @_Z17device_mul_or_addff(float %a, float %b) #0 {
   %reflect = call i32 @__nvvm_reflect(i8* addrspacecast (i8 addrspace(1)* getelementptr inbounds ([8 x i8], [8 x i8] addrspace(1)* @"$str", i32 0, i32 0) to i8*))
   %cmp = icmp ne i32 %reflect, 0
   br i1 %cmp, label %use_mul, label %use_add
@@ -36,3 +36,5 @@
 
   ret float %ret
 }
+
+attributes #0 = { "target-cpu"="sm_35" "target-features"="+ptx42" }
Index: test/CodeGenCUDA/Inputs/device-code-2.ll
===
--- test/CodeGenCUDA/Inputs/device-code-2.ll
+++ test/CodeGenCUDA/Inputs/device-code-2.ll
@@ -2,15 +2,16 @@
 
 target triple = "nvptx-unknown-cuda"
 
-define double @__nv_sin(double %a) {
+define double @__nv_sin(double %a) #0 {
ret double 1.0
 }
 
-define double @__nv_exp(double %a) {
+define double @__nv_exp(double %a) #0 {
ret double 3.0
 }
 
 define double @__unused(double %a) {
ret double 2.0
 }
 
+attributes #0 = { "target-cpu"="sm_35" }
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1790,12 +1790,45 @@
   }
 }
 
+static bool hasTargetFeature(llvm::StringRef FeatureList,
+ llvm::StringRef Feature) {
+  StringRef Rest = FeatureList;
+  while (!Rest.empty()) {
+auto Split = Rest.split(',');
+if (Split.first == Feature)
+  return true;
+Rest = Split.second;
+  }
+
+  return false;
+}
+
 void CodeGenModule::AddDefaultFnAttrs(llvm::Function &F) {
   llvm::AttrBuilder FuncAttrs;
   ConstructDefaultFnAttrList(F.getName(),
  F.hasFnAttribute(llvm::Attribute::OptimizeNone),
  /* AttrOnCallsite = */ false, FuncAttrs);
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
+
+  if (getTriple().isNVPTX()) {
+// Revision 329829 added the architecture as a "target-feature". Duplicate
+// this information from "target-cpu" to maintain the ability to inline
+// functions from bitcode files compiled with older versions of LLVM/Clang.
+auto TargetCpu = F.getFnAttribute("target-cpu");
+if (TargetCpu.isStringAttribute()) {
+  llvm::StringRef CpuAttr = TargetCpu.getValueAsString();
+
+  auto TargetFeatures = F.getFnAttribute("target-features");
+  if (TargetFeatures.isStringAttribute()) {
+llvm::StringRef FeatureList = TargetFeatures.getValueAsString();
+if (!hasTargetFeature(FeatureList, CpuAttr.str())) {
+  F.addFnAttr("target-features", (FeatureList + ",+" + CpuAttr).str());
+}
+  } 

[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

2018-05-18 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl added inline comments.



Comment at: lib/AST/ASTImporter.cpp:6776
+  // been invalidated to avoid repeatedly calling this.
+  ToContext.invalidateParents();
+

martong wrote:
> Can an `Expr` has a parent too? If yes, why not invalidate the parents in 
> `Import(Expr*)` ?
> I am also a bit concerned to call the invalidation during the import of all 
> `Stmt` (and possible during the import of `Expr`s too).
> Isn't it enough to invalidate only during `Import(Decl*)`?
The Import(Expr) function just defers to Import(Stmt) so a call there would be 
redundant as Alexey commented.

I don't think it would be enough to invalidate in Import(Decl), because 
Import(Stmt) is part of the public API. I don't know if it makes sense to just 
import Stmts and if there is any user code doing that, but it is theoretically 
possible. In that case we should make Import(Stmt) and Import(Expr) private.

I wouldn't be too concerned about too many calls to invalidate, since the 
function doesn't do anything once the parent info has been released and it will 
only be rebuilt once someone calls ACtx::getParents - which is not the case 
while importing.


https://reviews.llvm.org/D46940



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


[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

2018-05-18 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: rnkovacs.

Ok, thanks for the explanation. Now it looks good to me.


https://reviews.llvm.org/D46940



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-18 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:35
+  hasSourceExpression(IsFloatExpr),
+  unless(hasParent(castExpr(
+ .bind("cast"),

aaron.ballman wrote:
> courbet wrote:
> > aaron.ballman wrote:
> > > I believe this code will not diagnose under this check -- is that 
> > > intended as a way to silence the check?
> > > ```
> > > i += (double)0.5;
> > > ```
> > Did you mean `(int)0.5` ?
> > 
> > Yes, the user essentially told us they knew what they were doing. I've 
> > added an explicit test for this.
> I truly meant `(double)0.5` -- where the cast has no impact on the narrowing 
> conversion, but the check still doesn't diagnose because there's an explicit 
> cast present. Should the check be checking for explicit casts to the narrowed 
> type?
OK, then that's fine (I added a test for that for): there is an explicit cast 
to double, but then the compiler generates an extra cast to int on top, which 
triggers.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-18 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.

I think this generally LGTM. You should wait a bit to see if @alexfh has any 
other concerns.




Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:35
+  hasSourceExpression(IsFloatExpr),
+  unless(hasParent(castExpr(
+ .bind("cast"),

courbet wrote:
> aaron.ballman wrote:
> > courbet wrote:
> > > aaron.ballman wrote:
> > > > I believe this code will not diagnose under this check -- is that 
> > > > intended as a way to silence the check?
> > > > ```
> > > > i += (double)0.5;
> > > > ```
> > > Did you mean `(int)0.5` ?
> > > 
> > > Yes, the user essentially told us they knew what they were doing. I've 
> > > added an explicit test for this.
> > I truly meant `(double)0.5` -- where the cast has no impact on the 
> > narrowing conversion, but the check still doesn't diagnose because there's 
> > an explicit cast present. Should the check be checking for explicit casts 
> > to the narrowed type?
> OK, then that's fine (I added a test for that for): there is an explicit cast 
> to double, but then the compiler generates an extra cast to int on top, which 
> triggers.
Ah, excellent, thank you!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


r332724 - [HIP] Support offloading by linker script

2018-05-18 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 18 08:07:56 2018
New Revision: 332724

URL: http://llvm.org/viewvc/llvm-project?rev=332724&view=rev
Log:
[HIP] Support offloading by linker script

To support linking device code in different source files, it is necessary to
embed fat binary at host linking stage.

This patch emits an external symbol for fat binary in host codegen, then
embed the fat binary by lld through a linker script.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/CodeGenCUDA/device-stub.cu

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=332724&r1=332723&r2=332724&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri May 18 08:07:56 2018
@@ -586,6 +586,8 @@ def fno_cuda_rdc : Flag<["-"], "fno-cuda
 def fcuda_short_ptr : Flag<["-"], "fcuda-short-ptr">, Flags<[CC1Option]>,
   HelpText<"Use 32-bit pointers for accessing const/local/shared address 
spaces.">;
 def fno_cuda_short_ptr : Flag<["-"], "fno-cuda-short-ptr">;
+def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-script">,
+  Group, Flags<[NoArgumentUnused, HelpHidden]>;
 def dA : Flag<["-"], "dA">, Group;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode in addition to normal output">;

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=332724&r1=332723&r2=332724&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Fri May 18 08:07:56 2018
@@ -27,6 +27,8 @@ using namespace clang;
 using namespace CodeGen;
 
 namespace {
+constexpr unsigned CudaFatMagic = 0x466243b1;
+constexpr unsigned HIPFatMagic = 0x48495046; // "HIPF"
 
 class CGNVCUDARuntime : public CGCUDARuntime {
 
@@ -310,19 +312,20 @@ llvm::Function *CGNVCUDARuntime::makeReg
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
+  bool IsHIP = CGM.getLangOpts().HIP;
   // No need to generate ctors/dtors if there is no GPU binary.
-  std::string GpuBinaryFileName = CGM.getCodeGenOpts().CudaGpuBinaryFileName;
-  if (GpuBinaryFileName.empty())
+  StringRef CudaGpuBinaryFileName = CGM.getCodeGenOpts().CudaGpuBinaryFileName;
+  if (CudaGpuBinaryFileName.empty() && !IsHIP)
 return nullptr;
 
-  // void __cuda_register_globals(void* handle);
+  // void __{cuda|hip}_register_globals(void* handle);
   llvm::Function *RegisterGlobalsFunc = makeRegisterGlobalsFn();
   // We always need a function to pass in as callback. Create a dummy
   // implementation if we don't need to register anything.
   if (RelocatableDeviceCode && !RegisterGlobalsFunc)
 RegisterGlobalsFunc = makeDummyFunction(getRegisterGlobalsFnTy());
 
-  // void ** __cudaRegisterFatBinary(void *);
+  // void ** __{cuda|hip}RegisterFatBinary(void *);
   llvm::Constant *RegisterFatbinFunc = CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(VoidPtrPtrTy, VoidPtrTy, false),
   addUnderscoredPrefixToName("RegisterFatBinary"));
@@ -334,12 +337,16 @@ llvm::Function *CGNVCUDARuntime::makeMod
   // global variable and save a reference in GpuBinaryHandle to be cleaned up
   // in destructor on exit. Then associate all known kernels with the GPU 
binary
   // handle so CUDA runtime can figure out what to call on the GPU side.
-  llvm::ErrorOr> GpuBinaryOrErr =
-  llvm::MemoryBuffer::getFileOrSTDIN(GpuBinaryFileName);
-  if (std::error_code EC = GpuBinaryOrErr.getError()) {
-CGM.getDiags().Report(diag::err_cannot_open_file)
-<< GpuBinaryFileName << EC.message();
-return nullptr;
+  std::unique_ptr CudaGpuBinary;
+  if (!IsHIP) {
+llvm::ErrorOr> CudaGpuBinaryOrErr =
+llvm::MemoryBuffer::getFileOrSTDIN(CudaGpuBinaryFileName);
+if (std::error_code EC = CudaGpuBinaryOrErr.getError()) {
+  CGM.getDiags().Report(diag::err_cannot_open_file)
+  << CudaGpuBinaryFileName << EC.message();
+  return nullptr;
+}
+CudaGpuBinary = std::move(CudaGpuBinaryOrErr.get());
   }
 
   llvm::Function *ModuleCtorFunc = llvm::Function::Create(
@@ -353,28 +360,60 @@ llvm::Function *CGNVCUDARuntime::makeMod
   CtorBuilder.SetInsertPoint(CtorEntryBB);
 
   const char *FatbinConstantName;
-  if (RelocatableDeviceCode)
+  const char *FatbinSectionName;
+  const char *ModuleIDSectionName;
+  StringRef ModuleIDPrefix;
+  llvm::Constant *FatBinStr;
+  unsigned FatMagic;
+  if (IsHIP) {
+FatbinConstantName = "

[PATCH] D46472: [HIP] Support offloading by linker script

2018-05-18 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332724: [HIP] Support offloading by linker script (authored 
by yaxunl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46472?vs=145480&id=147511#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46472

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/CodeGenCUDA/device-stub.cu

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -586,6 +586,8 @@
 def fcuda_short_ptr : Flag<["-"], "fcuda-short-ptr">, Flags<[CC1Option]>,
   HelpText<"Use 32-bit pointers for accessing const/local/shared address spaces.">;
 def fno_cuda_short_ptr : Flag<["-"], "fno-cuda-short-ptr">;
+def fhip_dump_offload_linker_script : Flag<["-"], "fhip-dump-offload-linker-script">,
+  Group, Flags<[NoArgumentUnused, HelpHidden]>;
 def dA : Flag<["-"], "dA">, Group;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode in addition to normal output">;
Index: cfe/trunk/test/CodeGenCUDA/device-stub.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-stub.cu
+++ cfe/trunk/test/CodeGenCUDA/device-stub.cu
@@ -1,25 +1,25 @@
 // RUN: echo "GPU binary would be here" > %t
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - \
-// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,CUDA
+// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,CUDA,CUDANORDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
-// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN:   | FileCheck %s -check-prefixes=NOGLOBALS,CUDANOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - \
-// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,CUDA
+// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,CUDA,CUDARDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
 // RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,HIP
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS -x hip \
-// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN:   | FileCheck %s -check-prefixes=NOGLOBALS,HIPNOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - -x hip \
-// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,HIP
+// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,HIP,HIPRDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - -x hip\
 // RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
@@ -64,21 +64,26 @@
 // * constant unnamed string with the kernel name
 // ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
-// ALL: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
-// NORDC-SAME: section ".nv_fatbin", align 8
-// RDC-SAME: section "__nv_relfatbin", align 8
+// HIP: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin"
+// CUDA: @[[FATBIN:.*]] = private unnamed_addr constant{{.*GPU binary would be here.*}}\00",
+// CUDANORDC-SAME: section ".nv_fatbin", align 8
+// CUDARDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
-// CUDA: @__[[PREFIX:cuda]]_fatbin_wrapper = internal constant
-// CUDA-SAME: { i32, i32, i8*, i8* }
-// HIP: @__[[PREFIX:hip]]_fatbin_wrapper = internal constant
-// HIP-SAME:  { i32, i32, i8*, i8* }
-// ALL-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
-// ALL-SAME: section ".nvFatBinSegment"
+// ALL: @__[[PREFIX:cuda|hip]]_fatbin_wrapper = internal constant
+// ALL-SAME: { i32, i32, i8*, i8* }
+// CUDA-SAME: { i32 1180844977, i32 1,
+// HIP-SAME: { i32 1212764230, i32 1,
+// CUDA-SAME: i8* getelementptr inbounds ({{.*}}@[[FATBIN]], i64 0, i64 0),
+// HIP-SAME:  i8* @[[FATBIN]],
+// ALL-SAME: i8* null }
+// CUDA-SAME: section ".nvFatBinSegment"
+// HIP-SAME: section ".hipFatBinSegment"
 // * variable to save GPU binary handle after initialization
 // NORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null
 // * constant unnamed string with NVModuleID
 // RDC: [[MODULE_ID_GLOBAL:@.*]] = private unnamed_addr constant
-// RDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32
+// CUDARDC-SAME: c"[[MODULE_ID:.+

[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-18 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

Great, thanks for the review !


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



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


r332727 - [clang-format/ObjC] Correctly annotate single-component ObjC method invocations

2018-05-18 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Fri May 18 08:27:02 2018
New Revision: 332727

URL: http://llvm.org/viewvc/llvm-project?rev=332727&view=rev
Log:
[clang-format/ObjC] Correctly annotate single-component ObjC method invocations

Summary:
Previously, clang-format's parser would fail to annotate the
selector in a single-component Objective-C method invocation with
`TT_SelectorName`. For example, the following:

  [foo bar];

would parse `bar` as `TT_Unknown`:

  M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=identifier L=34 PPK=2
  FakeLParens= FakeRParens=0 II=0x559d5db51770 Text='bar'

This caused us to fail to insert a space after a closing cast rparen,
so the following:

  [((Foo *)foo) bar];

would format as:

  [((Foo *)foo)bar];

This diff fixes the issue by ensuring we annotate the selector
in a single-component Objective-C method invocation as
`TT_SelectorName`.

Test Plan: New tests added. Ran tests with:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: jolesiak

Subscribers: Wizard, klimek, hokein, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=332727&r1=332726&r2=332727&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri May 18 08:27:02 2018
@@ -501,6 +501,12 @@ private:
 }
 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
   CurrentToken->Type = TT_ObjCMethodExpr;
+  // If we haven't seen a colon yet, make sure the last identifier
+  // before the r_square is tagged as a selector name component.
+  if (!ColonFound && CurrentToken->Previous &&
+  CurrentToken->Previous->is(TT_Unknown) &&
+  canBeObjCSelectorComponent(*CurrentToken->Previous))
+CurrentToken->Previous->Type = TT_SelectorName;
   // determineStarAmpUsage() thinks that '*' '[' is allocating an
   // array of pointers, but if '[' starts a selector then '*' is a
   // binary operator.

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=332727&r1=332726&r2=332727&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Fri May 18 08:27:02 2018
@@ -792,6 +792,10 @@ TEST_F(FormatTestObjC, FormatObjCMethodE
"  a = 42;\n"
"}];");
 
+  // Space between cast rparen and selector name component.
+  verifyFormat("[((Foo *)foo) bar];");
+  verifyFormat("[((Foo *)foo) bar:1 blech:2];");
+
   // Message receiver taking multiple lines.
   Style.ColumnLimit = 20;
   // Non-corner case.


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


[PATCH] D47028: [clang-format/ObjC] Correctly annotate single-component ObjC method invocations

2018-05-18 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:510
+CurrentToken->Previous->Type = TT_SelectorName;
+  }
   // determineStarAmpUsage() thinks that '*' '[' is allocating an

jolesiak wrote:
> I'd remove braces for consistency.
Thanks, done.


Repository:
  rC Clang

https://reviews.llvm.org/D47028



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


[PATCH] D47028: [clang-format/ObjC] Correctly annotate single-component ObjC method invocations

2018-05-18 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton updated this revision to Diff 147516.
benhamilton marked an inline comment as done.
benhamilton added a comment.

Style


Repository:
  rC Clang

https://reviews.llvm.org/D47028

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -792,6 +792,10 @@
"  a = 42;\n"
"}];");
 
+  // Space between cast rparen and selector name component.
+  verifyFormat("[((Foo *)foo) bar];");
+  verifyFormat("[((Foo *)foo) bar:1 blech:2];");
+
   // Message receiver taking multiple lines.
   Style.ColumnLimit = 20;
   // Non-corner case.
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -501,6 +501,12 @@
 }
 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
   CurrentToken->Type = TT_ObjCMethodExpr;
+  // If we haven't seen a colon yet, make sure the last identifier
+  // before the r_square is tagged as a selector name component.
+  if (!ColonFound && CurrentToken->Previous &&
+  CurrentToken->Previous->is(TT_Unknown) &&
+  canBeObjCSelectorComponent(*CurrentToken->Previous))
+CurrentToken->Previous->Type = TT_SelectorName;
   // determineStarAmpUsage() thinks that '*' '[' is allocating an
   // array of pointers, but if '[' starts a selector then '*' is a
   // binary operator.


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -792,6 +792,10 @@
"  a = 42;\n"
"}];");
 
+  // Space between cast rparen and selector name component.
+  verifyFormat("[((Foo *)foo) bar];");
+  verifyFormat("[((Foo *)foo) bar:1 blech:2];");
+
   // Message receiver taking multiple lines.
   Style.ColumnLimit = 20;
   // Non-corner case.
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -501,6 +501,12 @@
 }
 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
   CurrentToken->Type = TT_ObjCMethodExpr;
+  // If we haven't seen a colon yet, make sure the last identifier
+  // before the r_square is tagged as a selector name component.
+  if (!ColonFound && CurrentToken->Previous &&
+  CurrentToken->Previous->is(TT_Unknown) &&
+  canBeObjCSelectorComponent(*CurrentToken->Previous))
+CurrentToken->Previous->Type = TT_SelectorName;
   // determineStarAmpUsage() thinks that '*' '[' is allocating an
   // array of pointers, but if '[' starts a selector then '*' is a
   // binary operator.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47028: [clang-format/ObjC] Correctly annotate single-component ObjC method invocations

2018-05-18 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332727: [clang-format/ObjC] Correctly annotate 
single-component ObjC method invocations (authored by benhamilton, committed by 
).

Changed prior to commit:
  https://reviews.llvm.org/D47028?vs=147516&id=147517#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47028

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -501,6 +501,12 @@
 }
 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
   CurrentToken->Type = TT_ObjCMethodExpr;
+  // If we haven't seen a colon yet, make sure the last identifier
+  // before the r_square is tagged as a selector name component.
+  if (!ColonFound && CurrentToken->Previous &&
+  CurrentToken->Previous->is(TT_Unknown) &&
+  canBeObjCSelectorComponent(*CurrentToken->Previous))
+CurrentToken->Previous->Type = TT_SelectorName;
   // determineStarAmpUsage() thinks that '*' '[' is allocating an
   // array of pointers, but if '[' starts a selector then '*' is a
   // binary operator.
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -792,6 +792,10 @@
"  a = 42;\n"
"}];");
 
+  // Space between cast rparen and selector name component.
+  verifyFormat("[((Foo *)foo) bar];");
+  verifyFormat("[((Foo *)foo) bar:1 blech:2];");
+
   // Message receiver taking multiple lines.
   Style.ColumnLimit = 20;
   // Non-corner case.


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -501,6 +501,12 @@
 }
 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
   CurrentToken->Type = TT_ObjCMethodExpr;
+  // If we haven't seen a colon yet, make sure the last identifier
+  // before the r_square is tagged as a selector name component.
+  if (!ColonFound && CurrentToken->Previous &&
+  CurrentToken->Previous->is(TT_Unknown) &&
+  canBeObjCSelectorComponent(*CurrentToken->Previous))
+CurrentToken->Previous->Type = TT_SelectorName;
   // determineStarAmpUsage() thinks that '*' '[' is allocating an
   // array of pointers, but if '[' starts a selector then '*' is a
   // binary operator.
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -792,6 +792,10 @@
"  a = 42;\n"
"}];");
 
+  // Space between cast rparen and selector name component.
+  verifyFormat("[((Foo *)foo) bar];");
+  verifyFormat("[((Foo *)foo) bar:1 blech:2];");
+
   // Message receiver taking multiple lines.
   Style.ColumnLimit = 20;
   // Non-corner case.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

2018-05-18 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.

LGTM. Aaron, could you please confirm that AST changes are fine?




Comment at: include/clang/AST/ASTContext.h:638
+ReleaseParentMapEntries();
+PointerParents = nullptr;
+  }

I'd prefer to call reset(), but I won't insist on it.


https://reviews.llvm.org/D46940



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


[PATCH] D47069: [ASTImporter] Enable disabled but passing test

2018-05-18 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rC Clang

https://reviews.llvm.org/D47069



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


[PATCH] D47069: [ASTImporter] Enable disabled but passing test

2018-05-18 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332728: [ASTImporter] Enable disabled but passing test 
(authored by martong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47069?vs=147506&id=147524#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47069

Files:
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1399,7 +1399,7 @@
   EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace());
 }
 
-TEST_P(ASTImporterTestBase, DISABLED_IDNSOfNonmemberOperator) {
+TEST_P(ASTImporterTestBase, IDNSOfNonmemberOperator) {
   Decl *FromTU = getTuDecl(
   R"(
   struct X {};


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1399,7 +1399,7 @@
   EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace());
 }
 
-TEST_P(ASTImporterTestBase, DISABLED_IDNSOfNonmemberOperator) {
+TEST_P(ASTImporterTestBase, IDNSOfNonmemberOperator) {
   Decl *FromTU = getTuDecl(
   R"(
   struct X {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332728 - [ASTImporter] Enable disabled but passing test

2018-05-18 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri May 18 08:46:18 2018
New Revision: 332728

URL: http://llvm.org/viewvc/llvm-project?rev=332728&view=rev
Log:
[ASTImporter] Enable disabled but passing test

Summary:
There is a test which passes since D32947, but it was forgotten to be enabled.
This patch enables that disabled test.

Reviewers: a.sidorin, r.stahl, xazax.hun

Subscribers: rnkovacs, dkrupp, cfe-commits

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

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

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=332728&r1=332727&r2=332728&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Fri May 18 08:46:18 2018
@@ -1399,7 +1399,7 @@ TEST_P(ASTImporterTestBase, IDNSOrdinary
   EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace());
 }
 
-TEST_P(ASTImporterTestBase, DISABLED_IDNSOfNonmemberOperator) {
+TEST_P(ASTImporterTestBase, IDNSOfNonmemberOperator) {
   Decl *FromTU = getTuDecl(
   R"(
   struct X {};


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


[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute

2018-05-18 Thread Alfred Zien via Phabricator via cfe-commits
QF5690 added a comment.

It's been a couple of months now, @rjmccall any ETA's?


Repository:
  rC Clang

https://reviews.llvm.org/D44539



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


[PATCH] D47074: [Tooling] Add an overload of runToolOnCodeWithArgs that takes VFS

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: bkramer.
Herald added subscribers: cfe-commits, klimek.

... to support purely VFS-based tools.


Repository:
  rC Clang

https://reviews.llvm.org/D47074

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


Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -155,27 +155,37 @@
 
 bool runToolOnCodeWithArgs(
 FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
 const std::vector &Args, const Twine &FileName,
 const Twine &ToolName,
-std::shared_ptr PCHContainerOps,
-const FileContentMappings &VirtualMappedFiles) {
+std::shared_ptr PCHContainerOps) {
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
-  llvm::IntrusiveRefCntPtr OverlayFileSystem(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
-  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
-  new vfs::InMemoryFileSystem);
-  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+
   llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  new FileManager(FileSystemOptions(), VFS));
   ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster();
   ToolInvocation Invocation(
   getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileNameRef), 
FileNameRef),
   ToolAction, Files.get(),
   std::move(PCHContainerOps));
+  return Invocation.run();
+}
+
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+const std::vector &Args, const Twine &FileName,
+const Twine &ToolName,
+std::shared_ptr PCHContainerOps,
+const FileContentMappings &VirtualMappedFiles) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
 
   SmallString<1024> CodeStorage;
-  InMemoryFileSystem->addFile(FileNameRef, 0,
+  InMemoryFileSystem->addFile(FileName, 0,
   llvm::MemoryBuffer::getMemBuffer(
   
Code.toNullTerminatedStringRef(CodeStorage)));
 
@@ -185,7 +195,8 @@
 llvm::MemoryBuffer::getMemBuffer(FilenameWithContent.second));
   }
 
-  return Invocation.run();
+  return runToolOnCodeWithArgs(ToolAction, Code, OverlayFileSystem, Args,
+   FileName, ToolName);
 }
 
 std::string getAbsolutePath(StringRef File) {
Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -187,6 +187,15 @@
 std::make_shared(),
 const FileContentMappings &VirtualMappedFiles = FileContentMappings());
 
+// Similar to the overload except this takes a VFS.
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
+const std::vector &Args, const Twine &FileName = "input.cc",
+const Twine &ToolName = "clang-tool",
+std::shared_ptr PCHContainerOps =
+std::make_shared());
+
 /// Builds an AST for 'Code'.
 ///
 /// \param Code C++ code.


Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -155,27 +155,37 @@
 
 bool runToolOnCodeWithArgs(
 FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
 const std::vector &Args, const Twine &FileName,
 const Twine &ToolName,
-std::shared_ptr PCHContainerOps,
-const FileContentMappings &VirtualMappedFiles) {
+std::shared_ptr PCHContainerOps) {
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
-  llvm::IntrusiveRefCntPtr OverlayFileSystem(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
-  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
-  new vfs::InMemoryFileSystem);
-  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+
   llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  new FileManager(FileSystemOptions(), VFS));
   ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster();
   ToolInvocation Invocation(
   getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileNameRef), FileNameRef),
   ToolAction, Files.get(),
   std::move(PCHContainerOps));
+  return Invocation.run();
+}
+
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+const std::vector &Args, const Twine &FileName,
+const Twine &ToolName,
+std::shared_ptr PCHContainerOps,
+const FileContentMappings &VirtualMappedFiles) {
+  llvm::IntrusiveRefCntPtr OverlayF

[PATCH] D47074: [Tooling] Add an overload of runToolOnCodeWithArgs that takes VFS

2018-05-18 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rC Clang

https://reviews.llvm.org/D47074



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


r332731 - [Tooling] Add an overload of runToolOnCodeWithArgs that takes VFS

2018-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 18 09:06:19 2018
New Revision: 332731

URL: http://llvm.org/viewvc/llvm-project?rev=332731&view=rev
Log:
[Tooling] Add an overload of runToolOnCodeWithArgs that takes VFS

Summary: ... to support purely VFS-based tools.

Reviewers: bkramer

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Tooling.h
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/include/clang/Tooling/Tooling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Tooling.h?rev=332731&r1=332730&r2=332731&view=diff
==
--- cfe/trunk/include/clang/Tooling/Tooling.h (original)
+++ cfe/trunk/include/clang/Tooling/Tooling.h Fri May 18 09:06:19 2018
@@ -187,6 +187,15 @@ bool runToolOnCodeWithArgs(
 std::make_shared(),
 const FileContentMappings &VirtualMappedFiles = FileContentMappings());
 
+// Similar to the overload except this takes a VFS.
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
+const std::vector &Args, const Twine &FileName = "input.cc",
+const Twine &ToolName = "clang-tool",
+std::shared_ptr PCHContainerOps =
+std::make_shared());
+
 /// Builds an AST for 'Code'.
 ///
 /// \param Code C++ code.

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=332731&r1=332730&r2=332731&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Fri May 18 09:06:19 2018
@@ -155,27 +155,37 @@ namespace tooling {
 
 bool runToolOnCodeWithArgs(
 FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
 const std::vector &Args, const Twine &FileName,
 const Twine &ToolName,
-std::shared_ptr PCHContainerOps,
-const FileContentMappings &VirtualMappedFiles) {
+std::shared_ptr PCHContainerOps) {
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
-  llvm::IntrusiveRefCntPtr OverlayFileSystem(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
-  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
-  new vfs::InMemoryFileSystem);
-  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+
   llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  new FileManager(FileSystemOptions(), VFS));
   ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster();
   ToolInvocation Invocation(
   getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileNameRef), 
FileNameRef),
   ToolAction, Files.get(),
   std::move(PCHContainerOps));
+  return Invocation.run();
+}
+
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+const std::vector &Args, const Twine &FileName,
+const Twine &ToolName,
+std::shared_ptr PCHContainerOps,
+const FileContentMappings &VirtualMappedFiles) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
 
   SmallString<1024> CodeStorage;
-  InMemoryFileSystem->addFile(FileNameRef, 0,
+  InMemoryFileSystem->addFile(FileName, 0,
   llvm::MemoryBuffer::getMemBuffer(
   
Code.toNullTerminatedStringRef(CodeStorage)));
 
@@ -185,7 +195,8 @@ bool runToolOnCodeWithArgs(
 llvm::MemoryBuffer::getMemBuffer(FilenameWithContent.second));
   }
 
-  return Invocation.run();
+  return runToolOnCodeWithArgs(ToolAction, Code, OverlayFileSystem, Args,
+   FileName, ToolName);
 }
 
 std::string getAbsolutePath(StringRef File) {


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


[clang-tools-extra] r332732 - Trying to fix clang-move tests on windows build bot broken by r332717

2018-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 18 09:08:18 2018
New Revision: 332732

URL: http://llvm.org/viewvc/llvm-project?rev=332732&view=rev
Log:
Trying to fix clang-move tests on windows build bot broken by r332717

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10702

Modified:
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp?rev=332732&r1=332731&r2=332732&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Fri May 18 
09:08:18 2018
@@ -24,10 +24,6 @@ namespace clang {
 namespace move {
 namespace {
 
-const char TestHeaderName[] = "foo.h";
-
-const char TestCCName[] = "foo.cc";
-
 const char TestHeader[] = "namespace a {\n"
   "class C1; // test\n"
   "template  class C2;\n"
@@ -196,6 +192,15 @@ const char ExpectedNewCC[] = "namespace
  "} // namespace b\n"
  "} // namespace a\n";
 
+#ifdef _WIN32
+const char WorkingDir[] = "C:\\test";
+#else
+const char WorkingDir[] = "/test";
+#endif
+
+const char TestHeaderName[] = "foo.h";
+const char TestCCName[] = "foo.cc";
+
 std::map
 runClangMoveOnCode(const move::MoveDefinitionSpec &Spec,
const char *const Header = TestHeader,
@@ -203,9 +208,9 @@ runClangMoveOnCode(const move::MoveDefin
DeclarationReporter *const Reporter = nullptr) {
   clang::RewriterTestContext Context;
 
+  Context.InMemoryFileSystem->setCurrentWorkingDirectory(WorkingDir);
+
   std::map FileToFileID;
-  std::vector> FileToSourceText = {
-  {TestHeaderName, Header}, {TestCCName, CC}};
 
   auto CreateFiles = [&Context, &FileToFileID](llvm::StringRef Name,
llvm::StringRef Code) {
@@ -215,25 +220,21 @@ runClangMoveOnCode(const move::MoveDefin
   };
   CreateFiles(Spec.NewCC, "");
   CreateFiles(Spec.NewHeader, "");
-  CreateFiles(Spec.OldHeader, Header);
-  CreateFiles(Spec.OldCC, CC);
+  CreateFiles(TestHeaderName, Header);
+  CreateFiles(TestCCName, CC);
 
   std::map FileToReplacements;
-  llvm::SmallString<128> InitialDirectory;
-  std::error_code EC = llvm::sys::fs::current_path(InitialDirectory);
-  assert(!EC);
-  (void)EC;
-  ClangMoveContext MoveContext = {Spec, FileToReplacements,
-  InitialDirectory.str(), "LLVM",
+  ClangMoveContext MoveContext = {Spec, FileToReplacements, WorkingDir, "LLVM",
   Reporter != nullptr};
 
   auto Factory = llvm::make_unique(
   &MoveContext, Reporter);
 
+ // std::string IncludeArg = Twine("-I" + WorkingDir;
   tooling::runToolOnCodeWithArgs(
-  Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"},
-  TestCCName, "clang-move", std::make_shared(),
-  FileToSourceText);
+  Factory->create(), CC, Context.InMemoryFileSystem,
+  {"-std=c++11", "-fparse-all-comments", "-I."}, TestCCName, "clang-move",
+  std::make_shared());
   formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm");
   // The Key is file name, value is the new code after moving the class.
   std::map Results;


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


[PATCH] D47074: [Tooling] Add an overload of runToolOnCodeWithArgs that takes VFS

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332731: [Tooling] Add an overload of runToolOnCodeWithArgs 
that takes VFS (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47074?vs=147526&id=147529#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47074

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


Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -187,6 +187,15 @@
 std::make_shared(),
 const FileContentMappings &VirtualMappedFiles = FileContentMappings());
 
+// Similar to the overload except this takes a VFS.
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
+const std::vector &Args, const Twine &FileName = "input.cc",
+const Twine &ToolName = "clang-tool",
+std::shared_ptr PCHContainerOps =
+std::make_shared());
+
 /// Builds an AST for 'Code'.
 ///
 /// \param Code C++ code.
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -155,27 +155,37 @@
 
 bool runToolOnCodeWithArgs(
 FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
 const std::vector &Args, const Twine &FileName,
 const Twine &ToolName,
-std::shared_ptr PCHContainerOps,
-const FileContentMappings &VirtualMappedFiles) {
+std::shared_ptr PCHContainerOps) {
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
-  llvm::IntrusiveRefCntPtr OverlayFileSystem(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
-  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
-  new vfs::InMemoryFileSystem);
-  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+
   llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  new FileManager(FileSystemOptions(), VFS));
   ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster();
   ToolInvocation Invocation(
   getSyntaxOnlyToolArgs(ToolName, Adjuster(Args, FileNameRef), 
FileNameRef),
   ToolAction, Files.get(),
   std::move(PCHContainerOps));
+  return Invocation.run();
+}
+
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+const std::vector &Args, const Twine &FileName,
+const Twine &ToolName,
+std::shared_ptr PCHContainerOps,
+const FileContentMappings &VirtualMappedFiles) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
 
   SmallString<1024> CodeStorage;
-  InMemoryFileSystem->addFile(FileNameRef, 0,
+  InMemoryFileSystem->addFile(FileName, 0,
   llvm::MemoryBuffer::getMemBuffer(
   
Code.toNullTerminatedStringRef(CodeStorage)));
 
@@ -185,7 +195,8 @@
 llvm::MemoryBuffer::getMemBuffer(FilenameWithContent.second));
   }
 
-  return Invocation.run();
+  return runToolOnCodeWithArgs(ToolAction, Code, OverlayFileSystem, Args,
+   FileName, ToolName);
 }
 
 std::string getAbsolutePath(StringRef File) {


Index: include/clang/Tooling/Tooling.h
===
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -187,6 +187,15 @@
 std::make_shared(),
 const FileContentMappings &VirtualMappedFiles = FileContentMappings());
 
+// Similar to the overload except this takes a VFS.
+bool runToolOnCodeWithArgs(
+FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
+const std::vector &Args, const Twine &FileName = "input.cc",
+const Twine &ToolName = "clang-tool",
+std::shared_ptr PCHContainerOps =
+std::make_shared());
+
 /// Builds an AST for 'Code'.
 ///
 /// \param Code C++ code.
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -155,27 +155,37 @@
 
 bool runToolOnCodeWithArgs(
 FrontendAction *ToolAction, const Twine &Code,
+llvm::IntrusiveRefCntPtr VFS,
 const std::vector &Args, const Twine &FileName,
 const Twine &ToolName,
-std::shared_ptr PCHContainerOps,
-const FileContentMappings &VirtualMappedFiles) {
+std::shared_ptr PCHContainerOps) {
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
-  llvm::IntrusiveRefCntPtr OverlayFileSystem(
-  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
-  llvm::I

[PATCH] D47058: [ASTImporter] Fix ClassTemplateSpecialization in wrong DC

2018-05-18 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Hi Gabor! I have a question.




Comment at: lib/AST/ASTImporter.cpp:4305
+// Add to the DC only if it was an explicit specialization/instantiation.
+if (D2->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
+  LexicalDC->addDeclInternal(D2);

Can we write `if (D2->isExplicitInstantiationOrSpecialization())` instead? How 
we should treat TSK_Undeclared case?


Repository:
  rC Clang

https://reviews.llvm.org/D47058



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


[PATCH] D47058: [ASTImporter] Fix ClassTemplateSpecialization in wrong DC

2018-05-18 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin requested changes to this revision.
a.sidorin added a comment.
This revision now requires changes to proceed.

(Sorry, accepted accidentially).


Repository:
  rC Clang

https://reviews.llvm.org/D47058



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


[PATCH] D47044: Ensure that we only visit a destructor for a reference if type information is available.

2018-05-18 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

That could work. Is the implementation similar?


Repository:
  rC Clang

https://reviews.llvm.org/D47044



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


r332734 - Fix unused variable warning in r332724

2018-05-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 18 09:29:42 2018
New Revision: 332734

URL: http://llvm.org/viewvc/llvm-project?rev=332734&view=rev
Log:
Fix unused variable warning in r332724

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=332734&r1=332733&r2=332734&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Fri May 18 09:29:42 2018
@@ -1330,6 +1330,7 @@ void tools::AddHIPLinkerScript(const Too
   C.getSingleOffloadToolChain());
   assert(HIPTC->getTriple().getArch() == llvm::Triple::amdgcn &&
  "Wrong platform");
+  (void)HIPTC;
 
   // Construct clang-offload-bundler command to bundle object files for
   // for different GPU archs.


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


Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Vedant Kumar via cfe-commits
Hi Eric,

I think there might be a cyclic dependency issue here, possibly one that's only 
visible with LLVM_ENABLE_MODULES=On. I see:

While building module 'Clang_Tooling' imported from 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:   
  
While building module 'Clang_Format' imported from 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:
   
In file included from :1:  
 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Format/Format.h:20:10:
 fatal error: cyclic dependency in module 'Clang_Tooling': Clang_Tooling $> 
Clang_Format -> Clang_Tooling   
 
#include "clang/Tooling/Inclusions/IncludeStyle.h"
 ^  
While building module 'Clang_Tooling' imported from 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
In file included from :22: 
 
In file included from 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringAction.h:14:
In file included from 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h:14:
In file included from 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:16:
In file included from 
/Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h:14:
/Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:10:
 fatal error: could not build module 'Clang_Format'
#include "clang/Format/Format.h"
 ^~~
/Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:10:
 fatal error: could not build module 'Clang_Tooling'
#include "clang/Tooling/Execution.h"
 ^~~
3 errors generated.

Could you take a look?

thanks,
vedant

> On May 18, 2018, at 7:16 AM, Eric Liu via cfe-commits 
>  wrote:
> 
> Author: ioeric
> Date: Fri May 18 07:16:37 2018
> New Revision: 332720
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=332720&view=rev
> Log:
> Move #include manipulation code to new lib/Tooling/Inclusions.
> 
> Summary:
> clangToolingCore is linked into almost everything (incl. clang), but
> not few tools need #include manipulation at this point. So pull this into a
> separate library in Tooling.
> 
> Reviewers: ilya-biryukov
> 
> Subscribers: klimek, mgorny, cfe-commits, thakis
> 
> Differential Revision: https://reviews.llvm.org/D47068
> 
> Added:
>cfe/trunk/include/clang/Tooling/Inclusions/
>cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
>  - copied, changed from r332717, 
> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
>  - copied, changed from r332717, 
> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>cfe/trunk/lib/Tooling/Inclusions/
>cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
>  - copied, changed from r332717, cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
>  - copied, changed from r332717, 
> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
>  - copied, changed from r332717, 
> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> Removed:
>cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> Modified:
>cfe/trunk/include/clang/Format/Format.h
>cfe/trunk/lib/Format/CMakeLists.txt
>cfe/trunk/lib/Format/Format.cpp
>cfe/trunk/lib/Tooling/CMakeLists.txt
>cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
> 
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=332720&r1=332719&r2=332720&view=diff
> ==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Fri May 18 07:16:37 2018
> @@ -16,8 +16,8 @@
> #define LLVM_CLANG_FORMAT_FORMAT_H
> 
> #include "clang/Basic/LangOptions.h"
> -#include "clang/Tooling/Core/IncludeStyle.h"
> #include "clang/Tooling/Core/Replacement.h"
> +#include "clang/Tooling/Inclusions/IncludeStyle.h"
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/Support/Regex.h"
> #include 
> 
> Removed: c

Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Eric Liu via cfe-commits
Hi Vedant,

It seems that your build was not using cmake files in the source tree?
lib/Tooling/Inclusions/
is a (new) standalone library (clangToolingInclusions, similar to
clangToolingCore). You might need update your build to reflect this change.
Let me know if you have any further question.

Thanks,
Eric

On Fri, May 18, 2018 at 6:41 PM Vedant Kumar  wrote:

> Hi Eric,
>
> I think there might be a cyclic dependency issue here, possibly one that's
> only visible with LLVM_ENABLE_MODULES=On. I see:
>
> While building module 'Clang_Tooling' imported from
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
>
> While building module 'Clang_Format' imported from
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:
>
> In file included from :1:
>
>
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Format/Format.h:20:10:
> fatal error: cyclic dependency in module 'Clang_Tooling': Clang_Tooling $>
> Clang_Format -> Clang_Tooling
>
> #include "clang/Tooling/Inclusions/IncludeStyle.h"
>  ^
> While building module 'Clang_Tooling' imported from
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
> In file included from :22:
>
> In file included from
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringAction.h:14:
> In file included from
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h:14:
> In file included from
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:16:
> In file included from
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h:14:
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:10:
> fatal error: could not build module 'Clang_Format'
> #include "clang/Format/Format.h"
>  ^~~
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:10:
> fatal error: could not build module 'Clang_Tooling'
> #include "clang/Tooling/Execution.h"
>
>  ^~~
> 3 errors generated.
>
> Could you take a look?
>
> thanks,
> vedant
>
> > On May 18, 2018, at 7:16 AM, Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: ioeric
> > Date: Fri May 18 07:16:37 2018
> > New Revision: 332720
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332720&view=rev
> > Log:
> > Move #include manipulation code to new lib/Tooling/Inclusions.
> >
> > Summary:
> > clangToolingCore is linked into almost everything (incl. clang), but
> > not few tools need #include manipulation at this point. So pull this
> into a
> > separate library in Tooling.
> >
> > Reviewers: ilya-biryukov
> >
> > Subscribers: klimek, mgorny, cfe-commits, thakis
> >
> > Differential Revision: https://reviews.llvm.org/D47068
> >
> > Added:
> >cfe/trunk/include/clang/Tooling/Inclusions/
> >cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
> >  - copied, changed from r332717,
> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
> >  - copied, changed from r332717,
> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >cfe/trunk/lib/Tooling/Inclusions/
> >cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
> >  - copied, changed from r332717,
> cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> >cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
> >  - copied, changed from r332717,
> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
> >  - copied, changed from r332717,
> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> > Removed:
> >cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> > Modified:
> >cfe/trunk/include/clang/Format/Format.h
> >cfe/trunk/lib/Format/CMakeLists.txt
> >cfe/trunk/lib/Format/Format.cpp
> >cfe/trunk/lib/Tooling/CMakeLists.txt
> >cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> >cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
> >
> > Modified: cfe/trunk/include/clang/Format/Format.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=332720&r1=332719&r2=332720&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/Format/Format.h (original)
> > +++ cfe/trunk/include/clang/Format/Format.h Fri May 18 07:16:37 2018
> > @@ -16,8 +16,8 @@
> > #define LLVM_CLANG_FORMAT_FORMAT_H
> >
> > #include "clang/Basic/LangOptions.h"
> > -#include "clang/Tooling/Core/IncludeStyle.h"
> > #include "clang/Tooling/C

[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-05-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147541.
leonardchan added a comment.

Updated formatting


Repository:
  rC Clang

https://reviews.llvm.org/D46911

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_errors.cpp

Index: test/Frontend/fixed_point_errors.cpp
===
--- /dev/null
+++ test/Frontend/fixed_point_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;// expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;// expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;// expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;   // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum;   // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum; // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/fixed_point_errors.c
===
--- /dev/null
+++ test/Frontend/fixed_point_errors.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+long long _Fract longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+unsigned long long _Fract u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+
+_Sat int i;  // expected-error{{'int' cannot be saturated. Only _Fract and _Accum can.}}
+_Sat _Sat _Fract fract;  // expected-warning{{duplicate '_Sat' declaration specifier}}
+
+_Sat long long _Accum sat_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat unsigned long long _Accum sat_u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat long long _Fract sat_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+_Sat unsigned long long _Fract sat_u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
Index: test/Frontend/fixed_point.c
===
--- /dev/null
+++ test/Frontend/fixed_point.c
@@ -0,0 +1,82 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+signed short _Fract s_short_fract;
+signed _Fract s_fract;
+signed long _Fract s_long_fract;
+unsigned short _Fract u_short_fract;
+unsigned _Fract u_fract;
+unsigned long _Fract u_long_fract;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+short _Fract short_fract;
+_Fract fract;
+long _Fract long_fract;
+
+// Saturated fixed point types
+_Sat signed short _Accum sat_s_short_accum;
+_Sat signed _Accum sat_s_accum;
+_Sat signed long _Accum sat_s_long_accum;
+_Sat unsigned short _Accum sat_u_short_accum;
+_Sat unsigned _Accum sat_u_accum;
+_Sat unsigned long _Accum sat_u_long_accum;
+_Sat signed short _Fract sat_s_short_fract;
+_Sat signed _Fract sat_s_fract;
+_Sat signed long _Fract sat_s_long_fract;
+_Sat unsigned short _Fract sat_u_short_fract;
+_Sat unsigned _Fract sat_u_fract;
+_Sat unsigned long _Fract sat_u_long_fract;
+
+// Aliased saturated fixed point types
+_Sat short _Accum sat_short_accum;
+_Sat _Accum sat_accum;
+_Sat l

[PATCH] D47065: [clangd] Enable parsing of non-doxygen comments in global-symbol-builder

2018-05-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Should we also change the behavior in dynamic index?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47065



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


[PATCH] D46667: [OpenCL, OpenMP] Fix crash when OpenMP used in OpenCL file

2018-05-18 Thread Mike Rice via Phabricator via cfe-commits
mikerice updated this revision to Diff 147538.
mikerice added a comment.

Sorry for the delay in getting back to this.  I've found that we are using many 
OpenMP directives not just simd.  We'd like to continue doing that.

I updated the patch to provide TypeSourceInfo for OMPCapturedExprDecls.  I 
changed the test to check for captures (in the AST dump) for a few OpenMP 
directives.


https://reviews.llvm.org/D46667

Files:
  include/clang/AST/DeclOpenMP.h
  lib/AST/DeclOpenMP.cpp
  test/SemaOpenCL/with_openmp.cl


Index: test/SemaOpenCL/with_openmp.cl
===
--- /dev/null
+++ test/SemaOpenCL/with_openmp.cl
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-dump -x cl %s 2>&1 | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK: FunctionDecl{{.*}}getVal
+// CHECK: ParmVarDecl{{.*}}v
+// CHECK: ParmVarDecl{{.*}}m
+// CHECK: OMPDeclareSimdDeclAttr
+#pragma omp declare simd
+inline float getVal(const float v, const float m)
+{
+  return v * m + 0.5F;
+}
+
+// CHECK: FunctionDecl{{.*}}KFunc
+// CHECK-NEXT: ParmVarDecl{{.*}}data
+// CHECK-NEXT: ParmVarDecl{{.*}}size
+__kernel void KFunc(__global int *data, int size) {
+  float foo[128];
+// CHECK: OMPSimdDirective
+// CHECK: OMPCapturedExprDecl
+// CHECK-NEXT: ImplicitCastExpr{{.*}}LValueToRValue
+// CHECK-NEXT: DeclRefExpr {{.*}}ParmVar{{.*}}size
+  #pragma omp simd simdlen(16)
+  for (int i = 0; i < size; ++i) {
+foo[i] = getVal(*data, 1);
+  }
+
+// CHECK: OMPParallelForDirective
+// CHECK: OMPCapturedExprDecl
+// CHECK-NEXT: ImplicitCastExpr{{.*}}LValueToRValue
+// CHECK-NEXT: DeclRefExpr {{.*}}ParmVar{{.*}}size
+  #pragma omp parallel for
+  for (int i = 0; i < size; ++i) {
+foo[i] = *data + 1;
+  }
+// CHECK: OMPTaskLoopDirective
+// CHECK: OMPCapturedExprDecl
+// CHECK-NEXT: ImplicitCastExpr{{.*}}LValueToRValue
+// CHECK-NEXT: DeclRefExpr {{.*}}ParmVar{{.*}}size
+  #pragma omp taskloop
+  for (int i = 0; i < size; ++i) {
+foo[i] = *data + 1;
+  }
+
+// CHECK: OMPParallelDirective
+  #pragma omp parallel
+  {
+// CHECK: OMPForDirective
+// CHECK: OMPCapturedExprDecl
+// CHECK-NEXT: ImplicitCastExpr{{.*}}LValueToRValue
+// CHECK-NEXT: DeclRefExpr {{.*}}ParmVar{{.*}}size
+#pragma omp for
+for (int i = 0; i < size; ++i) {
+  foo[i] = *data + 1;
+}
+  }
+}
Index: lib/AST/DeclOpenMP.cpp
===
--- lib/AST/DeclOpenMP.cpp
+++ lib/AST/DeclOpenMP.cpp
@@ -92,13 +92,14 @@
 OMPCapturedExprDecl *OMPCapturedExprDecl::Create(ASTContext &C, DeclContext 
*DC,
  IdentifierInfo *Id, QualType 
T,
  SourceLocation StartLoc) {
-  return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T, StartLoc);
+  return new (C, DC) OMPCapturedExprDecl(
+  C, DC, Id, T, C.getTrivialTypeSourceInfo(T), StartLoc);
 }
 
 OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext &C,
  unsigned ID) {
-  return new (C, ID)
-  OMPCapturedExprDecl(C, nullptr, nullptr, QualType(), SourceLocation());
+  return new (C, ID) OMPCapturedExprDecl(C, nullptr, nullptr, QualType(),
+ /*TInfo=*/nullptr, SourceLocation());
 }
 
 SourceRange OMPCapturedExprDecl::getSourceRange() const {
Index: include/clang/AST/DeclOpenMP.h
===
--- include/clang/AST/DeclOpenMP.h
+++ include/clang/AST/DeclOpenMP.h
@@ -189,8 +189,9 @@
   void anchor() override;
 
   OMPCapturedExprDecl(ASTContext &C, DeclContext *DC, IdentifierInfo *Id,
-  QualType Type, SourceLocation StartLoc)
-  : VarDecl(OMPCapturedExpr, C, DC, StartLoc, StartLoc, Id, Type, nullptr,
+  QualType Type, TypeSourceInfo *TInfo,
+  SourceLocation StartLoc)
+  : VarDecl(OMPCapturedExpr, C, DC, StartLoc, StartLoc, Id, Type, TInfo,
 SC_None) {
 setImplicit();
   }


Index: test/SemaOpenCL/with_openmp.cl
===
--- /dev/null
+++ test/SemaOpenCL/with_openmp.cl
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-dump -x cl %s 2>&1 | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK: FunctionDecl{{.*}}getVal
+// CHECK: ParmVarDecl{{.*}}v
+// CHECK: ParmVarDecl{{.*}}m
+// CHECK: OMPDeclareSimdDeclAttr
+#pragma omp declare simd
+inline float getVal(const float v, const float m)
+{
+  return v * m + 0.5F;
+}
+
+// CHECK: FunctionDecl{{.*}}KFunc
+// CHECK-NEXT: ParmVarDecl{{.*}}data
+// CHECK-NEXT: ParmVarDecl{{.*}}size
+__kernel void KFunc(__global int *data, int size) {
+  float foo[128];
+// CHECK: OMPSimdDirective
+// CHECK: OMPCapturedExprDecl
+// CHECK-NEXT: ImplicitCastExpr{{.*}}LValueToRValue
+// CHECK-NEXT: DeclRefExpr {{.*}}ParmVar{{.*}}size
+  #pragma omp simd simdlen(16)
+  for (

Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Vedant Kumar via cfe-commits
I wiped my build directory, updated to r332734 and rebuilt, but hit the same 
error while building check-clang.

For completeness, I did:

$ cmake -G Ninja /Users/vsk/src/llvm.org-master/llvm -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=On -DCLANG_ENABLE_ARCMT=Off -DCLANG_
ENABLE_STATIC_ANALYZER=Off -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" 
-DLLVM_ENABLE_MODULES=On
$ ninja check-clang

Are you able to reproduce the issue?

vedant

> On May 18, 2018, at 9:46 AM, Eric Liu  wrote:
> 
> Hi Vedant,
> 
> It seems that your build was not using cmake files in the source tree? 
> lib/Tooling/Inclusions/ is a (new) standalone library 
> (clangToolingInclusions, similar to clangToolingCore). You might need update 
> your build to reflect this change. Let me know if you have any further 
> question.
> 
> Thanks,
> Eric
> 
> On Fri, May 18, 2018 at 6:41 PM Vedant Kumar  wrote:
> Hi Eric,
> 
> I think there might be a cyclic dependency issue here, possibly one that's 
> only visible with LLVM_ENABLE_MODULES=On. I see:
> 
> While building module 'Clang_Tooling' imported from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10: 
> 
> While building module 'Clang_Format' imported from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:
>
> In file included from :1:
>   
>  
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Format/Format.h:20:10:
>  fatal error: cyclic dependency in module 'Clang_Tooling': Clang_Tooling $> 
> Clang_Format -> Clang_Tooling 
>
> #include "clang/Tooling/Inclusions/IncludeStyle.h"
>  ^  
> While building module 'Clang_Tooling' imported from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
> In file included from :22:   
>
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringAction.h:14:
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h:14:
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:16:
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h:14:
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:10:
>  fatal error: could not build module 'Clang_Format'
> #include "clang/Format/Format.h"
>  ^~~
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:10:
>  fatal error: could not build module 'Clang_Tooling'
> #include "clang/Tooling/Execution.h"  
>   
>  ^~~
> 3 errors generated.
> 
> Could you take a look?
> 
> thanks,
> vedant
> 
> > On May 18, 2018, at 7:16 AM, Eric Liu via cfe-commits 
> >  wrote:
> > 
> > Author: ioeric
> > Date: Fri May 18 07:16:37 2018
> > New Revision: 332720
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=332720&view=rev
> > Log:
> > Move #include manipulation code to new lib/Tooling/Inclusions.
> > 
> > Summary:
> > clangToolingCore is linked into almost everything (incl. clang), but
> > not few tools need #include manipulation at this point. So pull this into a
> > separate library in Tooling.
> > 
> > Reviewers: ilya-biryukov
> > 
> > Subscribers: klimek, mgorny, cfe-commits, thakis
> > 
> > Differential Revision: https://reviews.llvm.org/D47068
> > 
> > Added:
> >cfe/trunk/include/clang/Tooling/Inclusions/
> >cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
> >  - copied, changed from r332717, 
> > cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
> >  - copied, changed from r332717, 
> > cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >cfe/trunk/lib/Tooling/Inclusions/
> >cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
> >  - copied, changed from r332717, 
> > cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> >cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
> >  - copied, changed from r332717, 
> > cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
> >  - copied, changed from r332717, 
> > cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> > Removed:
> >cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >cfe/trunk/lib/Tooling/Core/Heade

r332738 - [X86] Fix a bad cast from mask16 to mask8 in _mm256_mask_cvtepi16_epi8 introduced in r332266.

2018-05-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Fri May 18 10:18:46 2018
New Revision: 332738

URL: http://llvm.org/viewvc/llvm-project?rev=332738&view=rev
Log:
[X86] Fix a bad cast from mask16 to mask8 in _mm256_mask_cvtepi16_epi8 
introduced in r332266.

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

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=332738&r1=332737&r2=332738&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Fri May 18 10:18:46 2018
@@ -1556,14 +1556,14 @@ _mm256_cvtepi16_epi8 (__m256i __A) {
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm256_mask_cvtepi16_epi8 (__m128i __O, __mmask16 __M, __m256i __A) {
-  return (__m128i)__builtin_ia32_selectb_128((__mmask8)__M,
+  return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M,
  
(__v16qi)_mm256_cvtepi16_epi8(__A),
  (__v16qi)__O);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm256_maskz_cvtepi16_epi8 (__mmask16 __M, __m256i __A) {
-  return (__m128i)__builtin_ia32_selectb_128((__mmask8)__M,
+  return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M,
  
(__v16qi)_mm256_cvtepi16_epi8(__A),
  (__v16qi)_mm_setzero_si128());
 }


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


[PATCH] D46667: [OpenCL, OpenMP] Fix crash when OpenMP used in OpenCL file

2018-05-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/SemaOpenCL/with_openmp.cl:1
+// RUN: %clang_cc1 -verify -fopenmp -ast-dump -x cl %s 2>&1 | FileCheck %s
+// expected-no-diagnostics

Still the same question, do we really want to support full OpenMP for OpenCL or 
only simd?


https://reviews.llvm.org/D46667



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


[PATCH] D46982: Do not enable RTTI with -fexceptions, for PS4

2018-05-18 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

So on PS4, `-fsanitize=vptr` without an explicit `-frtti` will warn and disable 
the sanitizer, rather than implicitly enabling RTTI.  As well as exceptions no 
longer implicitly enabling full RTTI.
In short, we never implicitly enable RTTI, which was the intention.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D46982



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


Re: [PATCH] D47067: Update NRVO logic to support early return

2018-05-18 Thread Arthur O'Dwyer via cfe-commits
https://reviews.llvm.org/D47067 is a "Restricted Differential Revision",
which I've never seen before!
Peanut gallery says: This sounds awesome. How does this change interact
with the diagnostics issued by -Wpessimizing-move and -Wreturn-std-move?
Should any new test cases be added for those diagnostics?


On Fri, May 18, 2018 at 7:12 AM, Taiju Tsuiki via Phabricator via
cfe-commits  wrote:

> tzik created this revision.
> Herald added a subscriber: cfe-commits.
>
> The previous implementation misses an opportunity to apply NRVO (Named
> Return Value
>
> Optimization) below. That discourages user to write early return code.
> --
>
> struct Foo {};
>
> Foo f(bool b) {
>
>   if (b)
> return Foo();
>   Foo oo;
>   return oo;
>
> }
> -
>
> That is, we can/should apply RVO for a return statement if it refers a
> non-parameter local variable,
> and the variable is referred by all return statements reachable from the
> variable declaration.
> While, the previous implementation disables the RVO in a scope if there
> are multiple return
> statements that refers different variables.
>
> On the new algorithm, local variables are in NRVO_Candidate state at
> first, and a return
> statement changes it to NRVO_Disabled for all visible variables but the
> return statement refers.
> Then, at the end of the function AST traversal, NRVO is enabled for
> variables in NRVO_Candidate
> state and refers from at least one return statement.
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D47067
>
> Files:
>   include/clang/AST/Decl.h
>   include/clang/Sema/Scope.h
>   lib/Sema/Scope.cpp
>   lib/Sema/SemaDecl.cpp
>   lib/Sema/SemaStmt.cpp
>   lib/Serialization/ASTReaderDecl.cpp
>   lib/Serialization/ASTWriterDecl.cpp
>   test/CodeGenCXX/nrvo.cpp
>
>
> ___
> 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] D46910: [Support] Avoid normalization in sys::getDefaultTargetTriple

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

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D46910



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


Re: [PATCH] D47067: Update NRVO logic to support early return

2018-05-18 Thread tzik via cfe-commits
Ah, sorry. It's still work in progress for now.
I'll resend this soon after adding tests and updating comments there.

2018年5月19日(土) 2:41 Arthur O'Dwyer :

> https://reviews.llvm.org/D47067 is a "Restricted Differential Revision",
> which I've never seen before!
> Peanut gallery says: This sounds awesome. How does this change interact
> with the diagnostics issued by -Wpessimizing-move and -Wreturn-std-move?
> Should any new test cases be added for those diagnostics?
>
>
> On Fri, May 18, 2018 at 7:12 AM, Taiju Tsuiki via Phabricator via
> cfe-commits  wrote:
>
>> tzik created this revision.
>> Herald added a subscriber: cfe-commits.
>>
>> The previous implementation misses an opportunity to apply NRVO (Named
>> Return Value
>>
>> Optimization) below. That discourages user to write early return code.
>> --
>>
>> struct Foo {};
>>
>> Foo f(bool b) {
>>
>>   if (b)
>> return Foo();
>>   Foo oo;
>>   return oo;
>>
>> }
>> -
>>
>> That is, we can/should apply RVO for a return statement if it refers a
>> non-parameter local variable,
>> and the variable is referred by all return statements reachable from the
>> variable declaration.
>> While, the previous implementation disables the RVO in a scope if there
>> are multiple return
>> statements that refers different variables.
>>
>> On the new algorithm, local variables are in NRVO_Candidate state at
>> first, and a return
>> statement changes it to NRVO_Disabled for all visible variables but the
>> return statement refers.
>> Then, at the end of the function AST traversal, NRVO is enabled for
>> variables in NRVO_Candidate
>> state and refers from at least one return statement.
>>
>>
>> Repository:
>>   rC Clang
>>
>> https://reviews.llvm.org/D47067
>>
>> Files:
>>   include/clang/AST/Decl.h
>>   include/clang/Sema/Scope.h
>>   lib/Sema/Scope.cpp
>>   lib/Sema/SemaDecl.cpp
>>   lib/Sema/SemaStmt.cpp
>>   lib/Serialization/ASTReaderDecl.cpp
>>   lib/Serialization/ASTWriterDecl.cpp
>>   test/CodeGenCXX/nrvo.cpp
>>
>>
>> ___
>> 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] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147549.

Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = Context.LongAccumTy;
+  break;
+case PREDEF_TYPE_USHORT_ACCUM_ID:

Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Amara Emerson via cfe-commits
Hi Eric,

Green dragon buildbots have started failing too, e.g.: 
http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/10222/

If you don’t have a quick fix can you please revert it.

Thanks,
Amara

> On May 18, 2018, at 7:46 PM, Eric Liu  wrote:
> 
> Hi Vedant,
> 
> It seems that your build was not using cmake files in the source tree? 
> lib/Tooling/Inclusions/ is a (new) standalone library 
> (clangToolingInclusions, similar to clangToolingCore). You might need update 
> your build to reflect this change. Let me know if you have any further 
> question.
> 
> Thanks,
> Eric
> 
> On Fri, May 18, 2018 at 6:41 PM Vedant Kumar  > wrote:
> Hi Eric,
> 
> I think there might be a cyclic dependency issue here, possibly one that's 
> only visible with LLVM_ENABLE_MODULES=On. I see:
> 
> While building module 'Clang_Tooling' imported from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10: 
> 
> While building module 'Clang_Format' imported from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:
>
> In file included from :1:
>   
>  
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Format/Format.h:20:10:
>  fatal error: cyclic dependency in module 'Clang_Tooling': Clang_Tooling $> 
> Clang_Format -> Clang_Tooling 
>
> #include "clang/Tooling/Inclusions/IncludeStyle.h"
>  ^  
> While building module 'Clang_Tooling' imported from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
> In file included from :22:   
>
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringAction.h:14:
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h:14:
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:16:
> In file included from 
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h:14:
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:10:
>  fatal error: could not build module 'Clang_Format'
> #include "clang/Format/Format.h"
>  ^~~
> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:10:
>  fatal error: could not build module 'Clang_Tooling'
> #include "clang/Tooling/Execution.h"  
>   
>  ^~~
> 3 errors generated.
> 
> Could you take a look?
> 
> thanks,
> vedant
> 
> > On May 18, 2018, at 7:16 AM, Eric Liu via cfe-commits 
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> > 
> > Author: ioeric
> > Date: Fri May 18 07:16:37 2018
> > New Revision: 332720
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=332720&view=rev 
> > 
> > Log:
> > Move #include manipulation code to new lib/Tooling/Inclusions.
> > 
> > Summary:
> > clangToolingCore is linked into almost everything (incl. clang), but
> > not few tools need #include manipulation at this point. So pull this into a
> > separate library in Tooling.
> > 
> > Reviewers: ilya-biryukov
> > 
> > Subscribers: klimek, mgorny, cfe-commits, thakis
> > 
> > Differential Revision: https://reviews.llvm.org/D47068 
> > 
> > 
> > Added:
> >cfe/trunk/include/clang/Tooling/Inclusions/
> >cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
> >  - copied, changed from r332717, 
> > cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
> >  - copied, changed from r332717, 
> > cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >cfe/trunk/lib/Tooling/Inclusions/
> >cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
> >  - copied, changed from r332717, 
> > cfe/trunk/lib/Tooling/Core/CMakeLists.txt
> >cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
> >  - copied, changed from r332717, 
> > cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
> >  - copied, changed from r332717, 
> > cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> > Removed:
> >cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
> >cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
> >cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
> >cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
> > Modified:

Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Eric Liu via cfe-commits
Sorry, I'll look into it right now. Will revert it if I can't find a quick
fix.

On Fri, May 18, 2018, 19:49 Amara Emerson  wrote:

> Hi Eric,
>
> Green dragon buildbots have started failing too, e.g.:
> http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/10222/
>
> If you don’t have a quick fix can you please revert it.
>
> Thanks,
> Amara
>
>
> On May 18, 2018, at 7:46 PM, Eric Liu  wrote:
>
> Hi Vedant,
>
> It seems that your build was not using cmake files in the source tree? 
> lib/Tooling/Inclusions/
> is a (new) standalone library (clangToolingInclusions, similar to
> clangToolingCore). You might need update your build to reflect this change.
> Let me know if you have any further question.
>
> Thanks,
> Eric
>
> On Fri, May 18, 2018 at 6:41 PM Vedant Kumar  wrote:
>
>> Hi Eric,
>>
>> I think there might be a cyclic dependency issue here, possibly one
>> that's only visible with LLVM_ENABLE_MODULES=On. I see:
>>
>> While building module 'Clang_Tooling' imported from /Users/vsk/src/
>> llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
>>
>> While building module 'Clang_Format' imported from /Users/vsk/src/
>> llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:
>>
>> In file included from :1:
>>
>>
>> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Format/Format.h:20:10:
>> fatal error: cyclic dependency in module 'Clang_Tooling': Clang_Tooling $>
>> Clang_Format -> Clang_Tooling
>>
>> #include "clang/Tooling/Inclusions/IncludeStyle.h"
>>  ^
>> While building module 'Clang_Tooling' imported from /Users/vsk/src/
>> llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
>> In file included from :22:
>>
>> In file included from /Users/vsk/src/llvm.org
>> -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringAction.h:14:
>> In file included from /Users/vsk/src/llvm.org
>> -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h:14:
>> In file included from /Users/vsk/src/llvm.org
>> -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:16:
>> In file included from /Users/vsk/src/llvm.org
>> -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h:14:
>> /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:10:
>> fatal error: could not build module 'Clang_Format'
>> #include "clang/Format/Format.h"
>>  ^~~
>> /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:10:
>> fatal error: could not build module 'Clang_Tooling'
>> #include "clang/Tooling/Execution.h"
>>
>>  ^~~
>> 3 errors generated.
>>
>> Could you take a look?
>>
>> thanks,
>> vedant
>>
>> > On May 18, 2018, at 7:16 AM, Eric Liu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >
>> > Author: ioeric
>> > Date: Fri May 18 07:16:37 2018
>> > New Revision: 332720
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=332720&view=rev
>> > Log:
>> > Move #include manipulation code to new lib/Tooling/Inclusions.
>> >
>> > Summary:
>> > clangToolingCore is linked into almost everything (incl. clang), but
>> > not few tools need #include manipulation at this point. So pull this
>> into a
>> > separate library in Tooling.
>> >
>> > Reviewers: ilya-biryukov
>> >
>> > Subscribers: klimek, mgorny, cfe-commits, thakis
>> >
>> > Differential Revision: https://reviews.llvm.org/D47068
>> >
>> > Added:
>> >cfe/trunk/include/clang/Tooling/Inclusions/
>> >cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
>> >  - copied, changed from r332717,
>> cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
>> >  - copied, changed from r332717,
>> cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >cfe/trunk/lib/Tooling/Inclusions/
>> >cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
>> >  - copied, changed from r332717,
>> cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
>> >  - copied, changed from r332717,
>> cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
>> >  - copied, changed from r332717,
>> cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> > Removed:
>> >cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
>> >cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
>> >cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
>> >cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
>> > Modified:
>> >cfe/trunk/include/clang/Format/Format.h
>> >cfe/trunk/lib/Format/CMakeLists.txt
>> >cfe/trunk/lib/Format/Format.cpp
>> >cfe/trunk/lib/Tooling/CMakeLists.txt
>> >cfe/trunk/lib/Tooling/Core/CMakeLists.txt
>> >cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
>> >
>> > Modified: cfe/trunk/include/clang/Format/For

[PATCH] D47070: [CUDA] Upgrade linked bitcode to enable inlining

2018-05-18 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

I defer to Art on this one.


Repository:
  rC Clang

https://reviews.llvm.org/D47070



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


Re: [PATCH] D47067: Update NRVO logic to support early return

2018-05-18 Thread Roman Lebedev via cfe-commits
On Fri, May 18, 2018 at 8:47 PM, tzik via cfe-commits
 wrote:
> Ah, sorry. It's still work in progress for now.
> I'll resend this soon after adding tests and updating comments there.
See Herald rules for exact syntax, but i think adding "[private]" into
the subject
would have prevented it from going live.

> 2018年5月19日(土) 2:41 Arthur O'Dwyer :
>>
>> https://reviews.llvm.org/D47067 is a "Restricted Differential Revision",
>> which I've never seen before!
>> Peanut gallery says: This sounds awesome. How does this change interact
>> with the diagnostics issued by -Wpessimizing-move and -Wreturn-std-move?
>> Should any new test cases be added for those diagnostics?
>>
>>
>> On Fri, May 18, 2018 at 7:12 AM, Taiju Tsuiki via Phabricator via
>> cfe-commits  wrote:
>>>
>>> tzik created this revision.
>>> Herald added a subscriber: cfe-commits.
>>>
>>> The previous implementation misses an opportunity to apply NRVO (Named
>>> Return Value
>>>
>>> Optimization) below. That discourages user to write early return code.
>>> --
>>>
>>> struct Foo {};
>>>
>>> Foo f(bool b) {
>>>
>>>   if (b)
>>> return Foo();
>>>   Foo oo;
>>>   return oo;
>>>
>>> }
>>> -
>>>
>>> That is, we can/should apply RVO for a return statement if it refers a
>>> non-parameter local variable,
>>> and the variable is referred by all return statements reachable from the
>>> variable declaration.
>>> While, the previous implementation disables the RVO in a scope if there
>>> are multiple return
>>> statements that refers different variables.
>>>
>>> On the new algorithm, local variables are in NRVO_Candidate state at
>>> first, and a return
>>> statement changes it to NRVO_Disabled for all visible variables but the
>>> return statement refers.
>>> Then, at the end of the function AST traversal, NRVO is enabled for
>>> variables in NRVO_Candidate
>>> state and refers from at least one return statement.
>>>
>>>
>>> Repository:
>>>   rC Clang
>>>
>>> https://reviews.llvm.org/D47067
>>>
>>> Files:
>>>   include/clang/AST/Decl.h
>>>   include/clang/Sema/Scope.h
>>>   lib/Sema/Scope.cpp
>>>   lib/Sema/SemaDecl.cpp
>>>   lib/Sema/SemaStmt.cpp
>>>   lib/Serialization/ASTReaderDecl.cpp
>>>   lib/Serialization/ASTWriterDecl.cpp
>>>   test/CodeGenCXX/nrvo.cpp
>>>
>>>
>>> ___
>>> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47070: [CUDA] Upgrade linked bitcode to enable inlining

2018-05-18 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: echristo.
tra added a comment.

This was not intended. :-( I was unaware that GetCPUAndFeaturesAttributes() 
would add any feature that looks like a valid CPU name to the target-cpu 
attribute.
All I needed is to make builtins available or not. Setting them as function 
attributes is not what we need here.

I'm not sure what's the best way to deal with this. On one hand I do need to 
make some builtins available depending on combination of GPU arch and PTX 
version. The only way to do it is via the features. On the other hand, the 
features appear to propagate to LLVM IR, which is something I don't need or 
want.

One way would be to introduce some sort of feature blacklist which would 
prevent them from being converted to function attributes.
Or, perhaps, we can change TARGET_BUILTIN or create something similar which 
would allow availability of builtins w/o relying on features.

As a short-term fix we can disable feature-to-function attribute propagation 
for NVPTX until we fix it.

@echristo -- any other suggestions?


Repository:
  rC Clang

https://reviews.llvm.org/D47070



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


[PATCH] D43281: [AMDGPU] fixes for lds f32 builtins

2018-05-18 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

I'm looking at how the address space mapping works for builtins, and I think 
what's there is just uselessly broken and needs to be fixed. It seems to be 
operating under the assumption that the address spaces the target defines are 
totally disjoint from the language address spaces




Comment at: lib/CodeGen/CGBuiltin.cpp:9909-9913
+LangAS::opencl_local != E->getArg(0)
+->getType()
+->getPointeeType()
+.getQualifiers()
+.getAddressSpace() ||

Condition backwards


Repository:
  rC Clang

https://reviews.llvm.org/D43281



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


[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147560.

Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = Context.LongAccumTy;
+  break;
+case PREDEF_TYPE_USHORT_ACCUM_ID:

[PATCH] D46667: [OpenCL, OpenMP] Fix crash when OpenMP used in OpenCL file

2018-05-18 Thread Mike Rice via Phabricator via cfe-commits
mikerice added inline comments.



Comment at: test/SemaOpenCL/with_openmp.cl:1
+// RUN: %clang_cc1 -verify -fopenmp -ast-dump -x cl %s 2>&1 | FileCheck %s
+// expected-no-diagnostics

ABataev wrote:
> Still the same question, do we really want to support full OpenMP for OpenCL 
> or only simd?
We think it makes sense to have full support.  We are using OpenCL for devices 
that can run full OpenMP.  Is there any known problem with allowing full 
support?


https://reviews.llvm.org/D46667



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


[PATCH] D47007: [Sanitizer] CStringChecker fix for strlcpy when no bytes are copied to the dest buffer

2018-05-18 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.

I've been thinking if we could de-duplicate this whole set of branches that 
computes the return value so that we didn't have to fix every bug twice. Maybe 
move it to an auxiliary function.




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1795
 // copied element, or a pointer to the start of the destination buffer.
 Result = (returnEnd ? UnknownVal() : DstVal);
   } else {

Do we need to consider `returnEnd` on the short path as well?



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1869-1875
   if (returnPtr) {
 // If this is a stpcpy-style copy, but we were unable to check for a buffer
 // overflow, we still need a result. Conjure a return value.
 if (returnEnd && Result.isUnknown()) {
   Result = svalBuilder.conjureSymbolVal(nullptr, CE, LCtx, C.blockCount());
 }
   }

Do we need to do that on the short path as well?


Repository:
  rC Clang

https://reviews.llvm.org/D47007



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


r332749 - MC: Change the streamer ctors to take an object writer instead of a stream. NFCI.

2018-05-18 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri May 18 11:26:45 2018
New Revision: 332749

URL: http://llvm.org/viewvc/llvm-project?rev=332749&view=rev
Log:
MC: Change the streamer ctors to take an object writer instead of a stream. 
NFCI.

The idea is that a client that wants split dwarf would create a
specific kind of object writer that creates two files, and use it to
create the streamer.

Part of PR37466.

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

Modified:
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=332749&r1=332748&r2=332749&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Fri May 18 11:26:45 2018
@@ -29,6 +29,7 @@
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCObjectFileInfo.h"
+#include "llvm/MC/MCObjectWriter.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
 #include "llvm/MC/MCRegisterInfo.h"
@@ -426,11 +427,12 @@ static bool ExecuteAssembler(AssemblerIn
 MCTargetOptions MCOptions;
 std::unique_ptr MAB(
 TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
+std::unique_ptr OW = MAB->createObjectWriter(*Out);
 
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
-T, Ctx, std::move(MAB), *Out, std::move(CE), *STI, Opts.RelaxAll,
-Opts.IncrementalLinkerCompatible,
+T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
+Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }


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


[PATCH] D47050: MC: Change the streamer ctors to take an object writer instead of a stream. NFCI.

2018-05-18 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332749: MC: Change the streamer ctors to take an object 
writer instead of a stream. (authored by pcc, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47050?vs=147430&id=147564#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47050

Files:
  tools/driver/cc1as_main.cpp


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -29,6 +29,7 @@
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCObjectFileInfo.h"
+#include "llvm/MC/MCObjectWriter.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
 #include "llvm/MC/MCRegisterInfo.h"
@@ -426,11 +427,12 @@
 MCTargetOptions MCOptions;
 std::unique_ptr MAB(
 TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
+std::unique_ptr OW = MAB->createObjectWriter(*Out);
 
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
-T, Ctx, std::move(MAB), *Out, std::move(CE), *STI, Opts.RelaxAll,
-Opts.IncrementalLinkerCompatible,
+T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
+Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -29,6 +29,7 @@
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCObjectFileInfo.h"
+#include "llvm/MC/MCObjectWriter.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
 #include "llvm/MC/MCRegisterInfo.h"
@@ -426,11 +427,12 @@
 MCTargetOptions MCOptions;
 std::unique_ptr MAB(
 TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
+std::unique_ptr OW = MAB->createObjectWriter(*Out);
 
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
-T, Ctx, std::move(MAB), *Out, std::move(CE), *STI, Opts.RelaxAll,
-Opts.IncrementalLinkerCompatible,
+T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
+Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-05-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147566.

Repository:
  rC Clang

https://reviews.llvm.org/D46911

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_errors.cpp

Index: test/Frontend/fixed_point_errors.cpp
===
--- /dev/null
+++ test/Frontend/fixed_point_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;// expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;// expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;// expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;   // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum;   // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum; // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/fixed_point_errors.c
===
--- /dev/null
+++ test/Frontend/fixed_point_errors.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+long long _Fract longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+unsigned long long _Fract u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+
+_Sat int i;  // expected-error{{'int' cannot be saturated. Only _Fract and _Accum can.}}
+_Sat _Sat _Fract fract;  // expected-warning{{duplicate '_Sat' declaration specifier}}
+
+_Sat long long _Accum sat_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat unsigned long long _Accum sat_u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat long long _Fract sat_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+_Sat unsigned long long _Fract sat_u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
Index: test/Frontend/fixed_point.c
===
--- /dev/null
+++ test/Frontend/fixed_point.c
@@ -0,0 +1,82 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+signed short _Fract s_short_fract;
+signed _Fract s_fract;
+signed long _Fract s_long_fract;
+unsigned short _Fract u_short_fract;
+unsigned _Fract u_fract;
+unsigned long _Fract u_long_fract;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+short _Fract short_fract;
+_Fract fract;
+long _Fract long_fract;
+
+// Saturated fixed point types
+_Sat signed short _Accum sat_s_short_accum;
+_Sat signed _Accum sat_s_accum;
+_Sat signed long _Accum sat_s_long_accum;
+_Sat unsigned short _Accum sat_u_short_accum;
+_Sat unsigned _Accum sat_u_accum;
+_Sat unsigned long _Accum sat_u_long_accum;
+_Sat signed short _Fract sat_s_short_fract;
+_Sat signed _Fract sat_s_fract;
+_Sat signed long _Fract sat_s_long_fract;
+_Sat unsigned short _Fract sat_u_short_fract;
+_Sat unsigned _Fract sat_u_fract;
+_Sat unsigned long _Fract sat_u_long_fract;
+
+// Aliased saturated fixed point types
+_Sat short _Accum sat_short_accum;
+_Sat _Accum sat_accum;
+_Sat long _Accum sat_long_accum;
+_Sat short _Fract sat_

  1   2   3   >