[PATCH] D48862: [OpenEmbedded] Fix lib paths for OpenEmbedded targets

2018-07-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This has been breaking our bots since it has landed (both Linux and macOS 
ones), here's a log: 
https://logs.chromium.org/v/?s=fuchsia%2Fbuildbucket%2Fcr-buildbucket.appspot.com%2F8939527016533487696%2F%2B%2Fsteps%2Fclang%2F0%2Fsteps%2Fcheck-clang%2F0%2Fstdout

In our Clang toolchain 
,
 we set libc++ to be the default C++ library and compiler-rt to be the default 
runtime library. In your case you need to explicitly set `-stdlib=libstdc++` 
and `-rtlib=libgcc` if you're relying on those being used in your tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D48862



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


[PATCH] D49899: Force test/Driver/fuchsia.c(pp) to use lld

2018-07-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D49899



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


[PATCH] D46822: [RISCV] Add driver for riscv32-unknown-elf baremetal target

2018-07-31 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.
Herald added subscribers: rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, 
jrtc27.

ping, Alex, could you commit that?


Repository:
  rC Clang

https://reviews.llvm.org/D46822



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


[PATCH] D49758: [clangd] allow clients to pass in compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Just a few nits left.




Comment at: clangd/ClangdLSPServer.cpp:422
+std::move(Entry.second.workingDirectory),
+llvm::sys::path::filename(File),
+std::move(Entry.second.compilationCommand),

Other usages of FileName in tooling::CompileCommand seem to set this either to 
an absolute or a relative-to-cwd path to the file for the command.
Maybe put the whole filepath there too? (even though I don't think we 
particularly rely on this anywhere in clangd)



Comment at: clangd/ClangdLSPServer.cpp:539
+static_cast(CDB.get())->invalidate(File);
+  else if (CachingCDB)
+CachingCDB->invalidate(File);

Other methods already assume it's non-null for directory-based CDB, so maybe 
remove the check for it being non-null here or replace the check with an assert?



Comment at: test/clangd/did-change-configuration-params.test:43
+#
+# ERR: Updating file /clangd-test/foo.c with command [/clangd-test2] clang -c 
foo.c -Wall -Werror
+# Don't reparse the second file:

Matching the stderr output seems fragile, but that's the only way to inspect 
the actual compile command that's used, so that's probably fine here.
However, the paths on windows will probably differ (notice the regexp matches 
for file uris), so we might need to do the regexp match here as well, 
e.g.`Updating file {{.*}}foo.c with command ...` to keep the Windows buildbots 
happy.


https://reviews.llvm.org/D49758



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


[PATCH] D49871: Improve support of PDB as an external layout source

2018-07-31 Thread Aleksandr Urakov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338353: Improve support of PDB as an external layout source 
(authored by aleksandr.urakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49871?vs=157531&id=158185#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49871

Files:
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/test/CodeGenCXX/Inputs/override-layout-nameless-struct-union.layout
  cfe/trunk/test/CodeGenCXX/Inputs/override-layout-packed-base.layout
  cfe/trunk/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
  cfe/trunk/test/CodeGenCXX/override-layout-packed-base.cpp

Index: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
===
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
@@ -2452,7 +2452,9 @@
   auto RoundingAlignment = Alignment;
   if (!MaxFieldAlignment.isZero())
 RoundingAlignment = std::min(RoundingAlignment, MaxFieldAlignment);
-  NonVirtualSize = Size = Size.alignTo(RoundingAlignment);
+  if (!UseExternalLayout)
+Size = Size.alignTo(RoundingAlignment);
+  NonVirtualSize = Size;
   RequiredAlignment = std::max(
   RequiredAlignment, Context.toCharUnitsFromBits(RD->getMaxAlignment()));
   layoutVirtualBases(RD);
@@ -2653,21 +2655,16 @@
   LastFieldIsNonZeroWidthBitfield = false;
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
-  if (IsUnion) {
-placeFieldAtOffset(CharUnits::Zero());
-Size = std::max(Size, Info.Size);
-  } else {
-CharUnits FieldOffset;
-if (UseExternalLayout) {
-  FieldOffset =
-  Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  assert(FieldOffset >= Size && "field offset already allocated");
-} else {
-  FieldOffset = Size.alignTo(Info.Alignment);
-}
-placeFieldAtOffset(FieldOffset);
-Size = FieldOffset + Info.Size;
-  }
+  CharUnits FieldOffset;
+  if (UseExternalLayout)
+FieldOffset =
+Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
+  else if (IsUnion)
+FieldOffset = CharUnits::Zero();
+  else
+FieldOffset = Size.alignTo(Info.Alignment);
+  placeFieldAtOffset(FieldOffset);
+  Size = std::max(Size, FieldOffset + Info.Size);
 }
 
 void MicrosoftRecordLayoutBuilder::layoutBitField(const FieldDecl *FD) {
@@ -2692,18 +2689,17 @@
   }
   LastFieldIsNonZeroWidthBitfield = true;
   CurrentBitfieldSize = Info.Size;
-  if (IsUnion) {
-placeFieldAtOffset(CharUnits::Zero());
-Size = std::max(Size, Info.Size);
-// TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
-  } else if (UseExternalLayout) {
+  if (UseExternalLayout) {
 auto FieldBitOffset = External.getExternalFieldOffset(FD);
 placeFieldAtBitOffset(FieldBitOffset);
 auto NewSize = Context.toCharUnitsFromBits(
 llvm::alignTo(FieldBitOffset + Width, Context.getCharWidth()));
-assert(NewSize >= Size && "bit field offset already allocated");
-Size = NewSize;
+Size = std::max(Size, NewSize);
 Alignment = std::max(Alignment, Info.Alignment);
+  } else if (IsUnion) {
+placeFieldAtOffset(CharUnits::Zero());
+Size = std::max(Size, Info.Size);
+// TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
   } else {
 // Allocate a new block of memory and place the bitfield in it.
 CharUnits FieldOffset = Size.alignTo(Info.Alignment);
Index: cfe/trunk/test/CodeGenCXX/Inputs/override-layout-packed-base.layout
===
--- cfe/trunk/test/CodeGenCXX/Inputs/override-layout-packed-base.layout
+++ cfe/trunk/test/CodeGenCXX/Inputs/override-layout-packed-base.layout
@@ -0,0 +1,18 @@
+
+*** Dumping AST Record Layout
+Type: class B<0>
+
+Layout: 
+
+*** Dumping AST Record Layout
+Type: class B<1>
+
+Layout: 
+
+*** Dumping AST Record Layout
+Type: class C
+
+Layout: 
Index: cfe/trunk/test/CodeGenCXX/Inputs/override-layout-nameless-struct-union.layout
===
--- cfe/trunk/test/CodeGenCXX/Inputs/override-layout-nameless-struct-union.layout
+++ cfe/trunk/test/CodeGenCXX/Inputs/override-layout-nameless-struct-union.layout
@@ -0,0 +1,16 @@
+
+*** Dumping AST Record Layout
+Type: struct S
+
+Layout: 
+
+*** Dumping AST Record Layout
+Type: union U
+
+Layout: 
Index: cfe/trunk/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
===
--- cfe/trunk/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
+++ cfe/trunk/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -w -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-layout-nameless-struct-union.layout %s | FileCheck %s
+
+// CHECK: Type: struct S

[PATCH] D49833: [clangd] Receive compilationDatabasePath in 'initialize' request

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D49833#1181651, @malaperle wrote:

> Was there any objection to this patch? It would have been nice to have this 
> before the branching.


Sorry for the delay, somehow missed this update in my inbox.

In https://reviews.llvm.org/D49833#1177230, @malaperle wrote:

> LSP:
>
> > Until the server has responded to the initialize request with an 
> > InitializeResult, the client must not send any additional requests or 
> > notifications to the server.
>
> So the client is free to send "didOpen" or any request after the 
> "initialize", which means we could end up parsing files with wrong commands 
> before we get the first "didChangeConfiguration". In fact, in our indexing 
> prototype we start indexing as soon as the "initialize" is processed and we 
> do not know whether or not there will be a didChangeConfiguration soon after.
>  Setting the CDB path as part of the initialize seems more natural and less 
> error-prone.


Thanks for clarifying the use-case, that does seem like the best option if you 
want to start indexing as soon as you initialize.

Overall LG, just a small suggestion on how to rearrange the options.




Comment at: clangd/Protocol.h:362
+  // than the protocol specified type of 'any'.
+  llvm::Optional initializationOptions;
 };

Maybe add another level of indirection from the start to make sure we'll be 
able to add more init options later without breaking the existing clients?
```
/// Clangd-specific initialization options that can be passed on the initial 
initialization request.
struct ClangdInitOptions {
  llvm::Optional initialConfiguration; 
  // can add more options here in a backwards-compatible manner
};

struct InitializeParams {
  /// 
  llvm::Optional initializationOptions;
};
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49833



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


[PATCH] D50043: [RISCV] RISC-V using -fuse-init-array by default

2018-07-31 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng created this revision.
kito-cheng added reviewers: asb, apazos.
Herald added subscribers: cfe-commits, rkruppe, rogfer01, shiva0217, 
fedor.sergeev.

RISC-V target using -fuse-init-array even for bare-mental target.


Repository:
  rC Clang

https://reviews.llvm.org/D50043

Files:
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2553,7 +2553,9 @@
   getTriple().getOS() == llvm::Triple::NaCl ||
   (getTriple().getVendor() == llvm::Triple::MipsTechnologies &&
!getTriple().hasEnvironment()) ||
-  getTriple().getOS() == llvm::Triple::Solaris;
+  getTriple().getOS() == llvm::Triple::Solaris ||
+  getTriple().getArch() == llvm::Triple::riscv32 ||
+  getTriple().getArch() == llvm::Triple::riscv64;
 
   if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
  options::OPT_fno_use_init_array, UseInitArrayDefault))


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2553,7 +2553,9 @@
   getTriple().getOS() == llvm::Triple::NaCl ||
   (getTriple().getVendor() == llvm::Triple::MipsTechnologies &&
!getTriple().hasEnvironment()) ||
-  getTriple().getOS() == llvm::Triple::Solaris;
+  getTriple().getOS() == llvm::Triple::Solaris ||
+  getTriple().getArch() == llvm::Triple::riscv32 ||
+  getTriple().getArch() == llvm::Triple::riscv64;
 
   if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
  options::OPT_fno_use_init_array, UseInitArrayDefault))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r337453 - [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-31 Thread Eric Liu via cfe-commits
Thanks a lot for looking into this!

You are right, the change in SemaAccess seemed to have done the job to fix
the protected member bug in specific. I think I made the change in
SemaCodeComplete before SemaAccess and didn't realized the previous one was
unnecessary to fix the tests. I think the accessing context/naming class is
still wrong though. Basically, we want the naming class to be the derived
class instead of the base class if the access is from a derived class.
Without this,  accessibility check is relaxed, but it probably doesn't have
very negative impact on code completion experience, so I think it's okay to
revert the change in SemaCodeComplete. Thanks again!

On Mon, Jul 30, 2018 at 5:22 PM Ilya Biryukov  wrote:

> Prtially reverted the commit in r338255 to fix a very frequent crash.
> The code seemed obviously wrong there (calling accessibility checking,
> passing a possibly unrelated class) and the tests didn't break after
> reverting it.
>
> Let me know if I missed anything.
>
> On Thu, Jul 19, 2018 at 3:37 PM Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ioeric
>> Date: Thu Jul 19 06:32:00 2018
>> New Revision: 337453
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=337453&view=rev
>> Log:
>> [CodeComplete] Fix accessibilty of protected members from base class.
>>
>> Summary:
>> Currently, protected members from base classes are marked as
>> inaccessible when completing in derived class. This patch fixes the
>> problem by
>> setting the naming class correctly when looking up results in base class
>> according to [11.2.p5].
>>
>> Reviewers: aaron.ballman, sammccall, rsmith
>>
>> Reviewed By: aaron.ballman
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D49421
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaAccess.cpp
>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>> cfe/trunk/test/Index/complete-access-checks.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=337453&r1=337452&r2=337453&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaAccess.cpp Thu Jul 19 06:32:00 2018
>> @@ -11,6 +11,7 @@
>>  //
>>
>>  
>> //===--===//
>>
>> +#include "clang/Basic/Specifiers.h"
>>  #include "clang/Sema/SemaInternal.h"
>>  #include "clang/AST/ASTContext.h"
>>  #include "clang/AST/CXXInheritance.h"
>> @@ -1856,29 +1857,31 @@ void Sema::CheckLookupAccess(const Looku
>>}
>>  }
>>
>> -/// Checks access to Decl from the given class. The check will take
>> access
>> +/// Checks access to Target from the given class. The check will take
>> access
>>  /// specifiers into account, but no member access expressions and such.
>>  ///
>> -/// \param Decl the declaration to check if it can be accessed
>> +/// \param Target the declaration to check if it can be accessed
>>  /// \param Ctx the class/context from which to start the search
>> -/// \return true if the Decl is accessible from the Class, false
>> otherwise.
>> -bool Sema::IsSimplyAccessible(NamedDecl *Decl, DeclContext *Ctx) {
>> +/// \return true if the Target is accessible from the Class, false
>> otherwise.
>> +bool Sema::IsSimplyAccessible(NamedDecl *Target, DeclContext *Ctx) {
>>if (CXXRecordDecl *Class = dyn_cast(Ctx)) {
>> -if (!Decl->isCXXClassMember())
>> +if (!Target->isCXXClassMember())
>>return true;
>>
>> +if (Target->getAccess() == AS_public)
>> +  return true;
>>  QualType qType = Class->getTypeForDecl()->getCanonicalTypeInternal();
>> +// The unprivileged access is AS_none as we don't know how the
>> member was
>> +// accessed, which is described by the access in DeclAccessPair.
>> +// `IsAccessible` will examine the actual access of Target (i.e.
>> +// Decl->getAccess()) when calculating the access.
>>  AccessTarget Entity(Context, AccessedEntity::Member, Class,
>> -DeclAccessPair::make(Decl, Decl->getAccess()),
>> -qType);
>> -if (Entity.getAccess() == AS_public)
>> -  return true;
>> -
>> +DeclAccessPair::make(Target, AS_none), qType);
>>  EffectiveContext EC(CurContext);
>>  return ::IsAccessible(*this, EC, Entity) != ::AR_inaccessible;
>>}
>> -
>> -  if (ObjCIvarDecl *Ivar = dyn_cast(Decl)) {
>> +
>> +  if (ObjCIvarDecl *Ivar = dyn_cast(Target)) {
>>  // @public and @package ivars are always accessible.
>>  if (Ivar->getCanonicalAccessControl() == ObjCIvarDecl::Public ||
>>  Ivar->getCanonicalAccessControl() == ObjCIvarDecl::Package)
>>
>> Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=337453&r1=337452&r2=337453&view=diff
>>
>> =

[PATCH] D49991: [clangd] Do not build AST if no diagnostics were requested

2018-07-31 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49991



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


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: ioeric.
Herald added subscribers: jfb, arphaman, jkorous, MaskRay, javed.absar.

After r338256, clangd stopped reporting diagnostics if WantDiags::No request
is followed by a WantDiags::Yes request but the AST can be reused.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045

Files:
  clangd/TUScheduler.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -390,5 +390,38 @@
   ASSERT_FALSE(DoUpdate(getInputs(Source, OtherSourceContents)));
 }
 
+TEST_F(TUSchedulerTests, NoChangeDiags) {
+  TUScheduler S(
+  /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
+  /*StorePreambleInMemory=*/true, PreambleParsedCallback(),
+  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+  ASTRetentionPolicy());
+
+  auto FooCpp = testPath("foo.cpp");
+  auto Contents = "int a; int b;";
+
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::No,
+   [](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  S.runWithAST("touchAST", FooCpp, [](llvm::Expected IA) {
+// Make sure the AST was actually built.
+cantFail(std::move(IA));
+  });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+
+  // Even though the inputs didn't change and AST can be reused, we need to
+  // report the diagnostics, as they were not reported previously.
+  std::atomic SeenDiags(false);
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { SeenDiags = true; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+  ASSERT_TRUE(SeenDiags);
+
+  // Subsequent request does not get any diagnostics callback because the same
+  // diags have previously been reported and the inputs didn't change.
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -228,6 +228,9 @@
   Semaphore &Barrier;
   /// Inputs, corresponding to the current state of AST.
   ParseInputs FileInputs;
+  /// Whether the diagnostics for the current FileInputs were reported to the
+  /// users before.
+  bool DiagsWereReported = false;
   /// Size of the last AST
   /// Guards members used by both TUScheduler and the worker thread.
   mutable std::mutex Mutex;
@@ -330,7 +333,9 @@
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 
 tooling::CompileCommand OldCommand = std::move(FileInputs.CompileCommand);
+bool PrevDiagsWereReported = DiagsWereReported;
 FileInputs = Inputs;
+DiagsWereReported = false;
 
 log("Updating file {0} with command [{1}] {2}", FileName,
 Inputs.CompileCommand.Directory,
@@ -366,7 +371,12 @@
 OldPreamble.reset();
 PreambleWasBuilt.notify();
 
-if (CanReuseAST) {
+if (CanReuseAST)
+  DiagsWereReported = PrevDiagsWereReported;
+else
+  IdleASTs.take(this); // Remove the old AST if it's still in cache.
+
+if (DiagsWereReported) {
   // Take a shortcut and don't build the AST if neither the inputs nor the
   // preamble have changed.
   // Note that we do not report the diagnostics, since they should not have
@@ -380,20 +390,24 @@
   FileName);
   return;
 }
-// Remove the old AST if it's still in cache.
-IdleASTs.take(this);
 
 // Build the AST for diagnostics.
-llvm::Optional AST =
-buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
+llvm::Optional> AST = IdleASTs.take(this);
+if (!AST) {
+  llvm::Optional NewAST =
+  buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
+  AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : nullptr;
+}
+
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
-if (WantDiags != WantDiagnostics::No && AST)
-  OnUpdated(AST->getDiagnostics());
+if (WantDiags != WantDiagnostics::No && *AST) {
+  OnUpdated((*AST)->getDiagnostics());
+  DiagsWereReported = true;
+}
 // Stash the AST in the cache for further use.
-IdleASTs.put(this,
- AST ? llvm::make_unique(std::move(*AST)) : nullptr);
+IdleASTs.put(this, std::move(*AST));
   };
 
   startTask("Update", Bind(Task, std::move(OnUpdated)), WantDiags);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman

[PATCH] D50047: [compiler-rt] [test] Use approximate comparison on float types

2018-07-31 Thread Luka Ercegovcevic via Phabricator via cfe-commits
erceg95 created this revision.
erceg95 added reviewers: compnerd, scanon, mgorny.
Herald added a subscriber: dberris.

We are resubmitting this patch (https://reviews.llvm.org/D28862) as it still 
causes this test of fail on Ubuntu 18.04 , Ubuntu GLIBC 2.27-3ubuntu1.


https://reviews.llvm.org/D50047

Files:
  test/builtins/Unit/divsc3_test.c


Index: test/builtins/Unit/divsc3_test.c
===
--- test/builtins/Unit/divsc3_test.c
+++ test/builtins/Unit/divsc3_test.c
@@ -15,6 +15,7 @@
 #include "int_lib.h"
 #include 
 #include 
+#include 
 #include 
 
 // REQUIRES: c99-complex
@@ -50,6 +51,25 @@
 return non_zero;
 }
 
+// check for equality assuming that both real and imaginary parts
+// can differ by exactly 1 representable value, in order to handle
+// different levels of accuracy on 32-bit x86
+static bool approx_equal(float _Complex a, float _Complex b) {
+if (a != b) {
+float ra = __real__ a;
+float ia = __imag__ a;
+float rb = __real__ b;
+float ib = __imag__ b;
+
+if (ra != rb && nextafterf(ra, rb) != rb)
+return false;
+if (ia != ib && nextafterf(ia, ib) != ib)
+return false;
+}
+
+return true;
+}
+
 int test__divsc3(float a, float b, float c, float d)
 {
 float _Complex r = __divsc3(a, b, c, d);
@@ -103,7 +123,7 @@
 {
 float _Complex z = (a * c + b * d) / (c * c + d * d)
  + (b * c - a * d) / (c * c + d * d) * _Complex_I;
-if (r != z)
+if (!approx_equal(r, z))
 return 1;
 }
 break;


Index: test/builtins/Unit/divsc3_test.c
===
--- test/builtins/Unit/divsc3_test.c
+++ test/builtins/Unit/divsc3_test.c
@@ -15,6 +15,7 @@
 #include "int_lib.h"
 #include 
 #include 
+#include 
 #include 
 
 // REQUIRES: c99-complex
@@ -50,6 +51,25 @@
 return non_zero;
 }
 
+// check for equality assuming that both real and imaginary parts
+// can differ by exactly 1 representable value, in order to handle
+// different levels of accuracy on 32-bit x86
+static bool approx_equal(float _Complex a, float _Complex b) {
+if (a != b) {
+float ra = __real__ a;
+float ia = __imag__ a;
+float rb = __real__ b;
+float ib = __imag__ b;
+
+if (ra != rb && nextafterf(ra, rb) != rb)
+return false;
+if (ia != ib && nextafterf(ia, ib) != ib)
+return false;
+}
+
+return true;
+}
+
 int test__divsc3(float a, float b, float c, float d)
 {
 float _Complex r = __divsc3(a, b, c, d);
@@ -103,7 +123,7 @@
 {
 float _Complex z = (a * c + b * d) / (c * c + d * d)
  + (b * c - a * d) / (c * c + d * d) * _Complex_I;
-if (r != z)
+if (!approx_equal(r, z))
 return 1;
 }
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r337453 - [CodeComplete] Fix accessibilty of protected members from base class.

2018-07-31 Thread Ilya Biryukov via cfe-commits
I actually tried to pass the correct derived scope to
CodeCompletionDeclConsumer on construction, it was not a lot of code and I
think this should fix the problem you're describing.
I'll send a patch.

On Tue, Jul 31, 2018 at 11:33 AM Eric Liu  wrote:

> Thanks a lot for looking into this!
>
> You are right, the change in SemaAccess seemed to have done the job to fix
> the protected member bug in specific. I think I made the change in
> SemaCodeComplete before SemaAccess and didn't realized the previous one was
> unnecessary to fix the tests. I think the accessing context/naming class is
> still wrong though. Basically, we want the naming class to be the derived
> class instead of the base class if the access is from a derived class.
> Without this,  accessibility check is relaxed, but it probably doesn't have
> very negative impact on code completion experience, so I think it's okay to
> revert the change in SemaCodeComplete. Thanks again!
>
> On Mon, Jul 30, 2018 at 5:22 PM Ilya Biryukov 
> wrote:
>
>> Prtially reverted the commit in r338255 to fix a very frequent crash.
>> The code seemed obviously wrong there (calling accessibility checking,
>> passing a possibly unrelated class) and the tests didn't break after
>> reverting it.
>>
>> Let me know if I missed anything.
>>
>> On Thu, Jul 19, 2018 at 3:37 PM Eric Liu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ioeric
>>> Date: Thu Jul 19 06:32:00 2018
>>> New Revision: 337453
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=337453&view=rev
>>> Log:
>>> [CodeComplete] Fix accessibilty of protected members from base class.
>>>
>>> Summary:
>>> Currently, protected members from base classes are marked as
>>> inaccessible when completing in derived class. This patch fixes the
>>> problem by
>>> setting the naming class correctly when looking up results in base class
>>> according to [11.2.p5].
>>>
>>> Reviewers: aaron.ballman, sammccall, rsmith
>>>
>>> Reviewed By: aaron.ballman
>>>
>>> Subscribers: cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D49421
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaAccess.cpp
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> cfe/trunk/test/Index/complete-access-checks.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=337453&r1=337452&r2=337453&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaAccess.cpp Thu Jul 19 06:32:00 2018
>>> @@ -11,6 +11,7 @@
>>>  //
>>>
>>>  
>>> //===--===//
>>>
>>> +#include "clang/Basic/Specifiers.h"
>>>  #include "clang/Sema/SemaInternal.h"
>>>  #include "clang/AST/ASTContext.h"
>>>  #include "clang/AST/CXXInheritance.h"
>>> @@ -1856,29 +1857,31 @@ void Sema::CheckLookupAccess(const Looku
>>>}
>>>  }
>>>
>>> -/// Checks access to Decl from the given class. The check will take
>>> access
>>> +/// Checks access to Target from the given class. The check will take
>>> access
>>>  /// specifiers into account, but no member access expressions and such.
>>>  ///
>>> -/// \param Decl the declaration to check if it can be accessed
>>> +/// \param Target the declaration to check if it can be accessed
>>>  /// \param Ctx the class/context from which to start the search
>>> -/// \return true if the Decl is accessible from the Class, false
>>> otherwise.
>>> -bool Sema::IsSimplyAccessible(NamedDecl *Decl, DeclContext *Ctx) {
>>> +/// \return true if the Target is accessible from the Class, false
>>> otherwise.
>>> +bool Sema::IsSimplyAccessible(NamedDecl *Target, DeclContext *Ctx) {
>>>if (CXXRecordDecl *Class = dyn_cast(Ctx)) {
>>> -if (!Decl->isCXXClassMember())
>>> +if (!Target->isCXXClassMember())
>>>return true;
>>>
>>> +if (Target->getAccess() == AS_public)
>>> +  return true;
>>>  QualType qType =
>>> Class->getTypeForDecl()->getCanonicalTypeInternal();
>>> +// The unprivileged access is AS_none as we don't know how the
>>> member was
>>> +// accessed, which is described by the access in DeclAccessPair.
>>> +// `IsAccessible` will examine the actual access of Target (i.e.
>>> +// Decl->getAccess()) when calculating the access.
>>>  AccessTarget Entity(Context, AccessedEntity::Member, Class,
>>> -DeclAccessPair::make(Decl, Decl->getAccess()),
>>> -qType);
>>> -if (Entity.getAccess() == AS_public)
>>> -  return true;
>>> -
>>> +DeclAccessPair::make(Target, AS_none), qType);
>>>  EffectiveContext EC(CurContext);
>>>  return ::IsAccessible(*this, EC, Entity) != ::AR_inaccessible;
>>>}
>>> -
>>> -  if (ObjCIvarDecl *Ivar = dyn_cast(Decl)) {
>>> +
>>> +  if (ObjCIvarDecl *Ivar = dyn_cast(Target)) {
>>>  // @public 

[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Overall LG, just a suggestion to make the code a bit easier to follow.




Comment at: clangd/TUScheduler.cpp:379
+
+if (DiagsWereReported) {
   // Take a shortcut and don't build the AST if neither the inputs nor the

The implicit condition here is that we can reuse AST and diagnostics were not 
reported. I think we can be more explicit here by moving this early return into 
the `CanReuseAST` if branch. By doing this, we could also get rid of 
`PrevDiagsWereReported`. An additional state variable seems to have made the 
flow less clear.



Comment at: clangd/TUScheduler.cpp:405
 // spam us with updates.
-if (WantDiags != WantDiagnostics::No && AST)
-  OnUpdated(AST->getDiagnostics());
+if (WantDiags != WantDiagnostics::No && *AST) {
+  OnUpdated((*AST)->getDiagnostics());

This was preexisting, but it might worth adding a comment explaining when 
`*AST` would be false.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045



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


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 158201.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Added a comment


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045

Files:
  clangd/TUScheduler.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -390,5 +390,38 @@
   ASSERT_FALSE(DoUpdate(getInputs(Source, OtherSourceContents)));
 }
 
+TEST_F(TUSchedulerTests, NoChangeDiags) {
+  TUScheduler S(
+  /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
+  /*StorePreambleInMemory=*/true, PreambleParsedCallback(),
+  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+  ASTRetentionPolicy());
+
+  auto FooCpp = testPath("foo.cpp");
+  auto Contents = "int a; int b;";
+
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::No,
+   [](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  S.runWithAST("touchAST", FooCpp, [](llvm::Expected IA) {
+// Make sure the AST was actually built.
+cantFail(std::move(IA));
+  });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+
+  // Even though the inputs didn't change and AST can be reused, we need to
+  // report the diagnostics, as they were not reported previously.
+  std::atomic SeenDiags(false);
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { SeenDiags = true; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+  ASSERT_TRUE(SeenDiags);
+
+  // Subsequent request does not get any diagnostics callback because the same
+  // diags have previously been reported and the inputs didn't change.
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -228,6 +228,9 @@
   Semaphore &Barrier;
   /// Inputs, corresponding to the current state of AST.
   ParseInputs FileInputs;
+  /// Whether the diagnostics for the current FileInputs were reported to the
+  /// users before.
+  bool DiagsWereReported = false;
   /// Size of the last AST
   /// Guards members used by both TUScheduler and the worker thread.
   mutable std::mutex Mutex;
@@ -330,7 +333,9 @@
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 
 tooling::CompileCommand OldCommand = std::move(FileInputs.CompileCommand);
+bool PrevDiagsWereReported = DiagsWereReported;
 FileInputs = Inputs;
+DiagsWereReported = false;
 
 log("Updating file {0} with command [{1}] {2}", FileName,
 Inputs.CompileCommand.Directory,
@@ -366,7 +371,12 @@
 OldPreamble.reset();
 PreambleWasBuilt.notify();
 
-if (CanReuseAST) {
+if (CanReuseAST)
+  DiagsWereReported = PrevDiagsWereReported;
+else
+  IdleASTs.take(this); // Remove the old AST if it's still in cache.
+
+if (DiagsWereReported) {
   // Take a shortcut and don't build the AST if neither the inputs nor the
   // preamble have changed.
   // Note that we do not report the diagnostics, since they should not have
@@ -380,20 +390,25 @@
   FileName);
   return;
 }
-// Remove the old AST if it's still in cache.
-IdleASTs.take(this);
 
 // Build the AST for diagnostics.
-llvm::Optional AST =
-buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
+llvm::Optional> AST = IdleASTs.take(this);
+if (!AST) {
+  llvm::Optional NewAST =
+  buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
+  AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : nullptr;
+}
+
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
-if (WantDiags != WantDiagnostics::No && AST)
-  OnUpdated(AST->getDiagnostics());
+// Note *AST can be still be null if buildAST fails.
+if (WantDiags != WantDiagnostics::No && *AST) {
+  OnUpdated((*AST)->getDiagnostics());
+  DiagsWereReported = true;
+}
 // Stash the AST in the cache for further use.
-IdleASTs.put(this,
- AST ? llvm::make_unique(std::move(*AST)) : nullptr);
+IdleASTs.put(this, std::move(*AST));
   };
 
   startTask("Update", Bind(Task, std::move(OnUpdated)), WantDiags);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/TUScheduler.cpp:379
+
+if (DiagsWereReported) {
   // Take a shortcut and don't build the AST if neither the inputs nor the

ioeric wrote:
> The implicit condition here is that we can reuse AST and diagnostics were not 
> reported. I think we can be more explicit here by moving this early return 
> into the `CanReuseAST` if branch. By doing this, we could also get rid of 
> `PrevDiagsWereReported`. An additional state variable seems to have made the 
> flow less clear.
The problem with that would be that the value of `DiagsWereReported` would be 
stale for ~40 lines between the assignment to `FileInputs` and this point.
So I'm not sure about this trade-off. WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045



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


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: rjmccall, rsmith, erichkeane.

https://reviews.llvm.org/rC337815 / https://reviews.llvm.org/D49508 had to 
cannibalize one bit of `CastExprBitfields::BasePathSize` in order to squeeze 
`PartOfExplicitCast` boolean.
That reduced the maximal value of `PartOfExplicitCast` from 9 bits (~512) down 
to 8 bits (~256).
Apparently, that mattered. Too bad there weren't any tests.
It caused PR38356 .

So we need to increase `PartOfExplicitCast` back at least to 9 bits, or a bit 
more.
For obvious reasons, we can't do that in `CastExprBitfields` - that would blow 
up the size of every `Expr`.
So we need to either just add a variable into the `CastExpr` (as done here),
or use `llvm::TrailingObjects`. The latter does not seem to be straight-forward.
Perhaps, that needs to be done not for the `CastExpr` itself, but for all of 
it's `final` children.


Repository:
  rC Clang

https://reviews.llvm.org/D50050

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  test/CodeGenCXX/castexpr-basepathsize-threshold.cpp


Index: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
===
--- /dev/null
+++ test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// https://bugs.llvm.org/show_bug.cgi?id=38356
+// We only check that we do not crash.
+
+template 
+struct d : d {};
+template 
+struct d {
+  a f[0];
+};
+struct g {
+  static g h(unsigned);
+};
+struct i {
+  void j() const;
+  // Current maximum depth of recursive template instantiation is 1024,
+  // thus, this \/ threshold value is used here. BasePathSize in CastExpr might
+  // not fit it, so we are testing that we do fit it.
+  // If -ftemplate-depth= is provided, larger values (4096 and up) cause 
crashes
+  // elsewhere.
+  d f;
+};
+void i::j() const {
+  const void *k{f.f};
+  (void)k;
+}
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -204,7 +204,6 @@
 
 unsigned Kind : 6;
 unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr.
-unsigned BasePathSize : 32 - 6 - 1 - NumExprBits;
   };
 
   class CallExprBitfields {
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -2790,17 +2790,21 @@
 private:
   Stmt *Op;
 
+  // BasePathSize needs to have width of 9 bits (or more, up to 14(?) bits),
+  // so it does not fit into CastExprBitfields, where we only have 8 bits left.
+  unsigned BasePathSize : 14;
+
   bool CastConsistency() const;
 
   const CXXBaseSpecifier * const *path_buffer() const {
 return const_cast(this)->path_buffer();
   }
   CXXBaseSpecifier **path_buffer();
 
   void setBasePathSize(unsigned basePathSize) {
-CastExprBits.BasePathSize = basePathSize;
-assert(CastExprBits.BasePathSize == basePathSize &&
-   "basePathSize doesn't fit in bits of CastExprBits.BasePathSize!");
+BasePathSize = basePathSize;
+assert(BasePathSize == basePathSize &&
+   "basePathSize doesn't fit in bits of BasePathSize!");
   }
 
 protected:
@@ -2859,8 +2863,8 @@
 
   typedef CXXBaseSpecifier **path_iterator;
   typedef const CXXBaseSpecifier * const *path_const_iterator;
-  bool path_empty() const { return CastExprBits.BasePathSize == 0; }
-  unsigned path_size() const { return CastExprBits.BasePathSize; }
+  bool path_empty() const { return BasePathSize == 0; }
+  unsigned path_size() const { return BasePathSize; }
   path_iterator path_begin() { return path_buffer(); }
   path_iterator path_end() { return path_buffer() + path_size(); }
   path_const_iterator path_begin() const { return path_buffer(); }


Index: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
===
--- /dev/null
+++ test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// https://bugs.llvm.org/show_bug.cgi?id=38356
+// We only check that we do not crash.
+
+template 
+struct d : d {};
+template 
+struct d {
+  a f[0];
+};
+struct g {
+  static g h(unsigned);
+};
+struct i {
+  void j() const;
+  // Current maximum depth of recursive template instantiation is 1024,
+  // thus, this \/ threshold value is used here. BasePathSize in CastExpr might
+  // not fit it, so we are testing that we do fit it.
+  // If -ftemplate-depth= is provided, larger values (4096 and up) cause crashes
+  // elsewhere.
+  d f;
+};
+void i::j() const {
+  const void *k{f.f};
+  (void)k;
+}
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -204,7 +204,6 @@
 
 unsigned Kind : 6;
 unsigned Part

[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 158211.
yvvan added a comment.

Restore missing tests


https://reviews.llvm.org/D49794

Files:
  include/clang-c/Index.h
  include/clang/Basic/Diagnostic.h
  include/clang/Basic/DiagnosticOptions.def
  include/clang/Driver/Options.td
  lib/Basic/DiagnosticIDs.cpp
  lib/Basic/Warnings.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Frontend/Inputs/header-with-warning.h
  test/Frontend/warnings-ignore-from-includes.cpp
  test/Index/ignore-warnings-from-headers.cpp
  test/Index/ignore-warnings-from-headers.h
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: test/Index/ignore-warnings-from-headers.h
===
--- /dev/null
+++ test/Index/ignore-warnings-from-headers.h
@@ -0,0 +1 @@
+void f(int unusedInHeader) {}
Index: test/Index/ignore-warnings-from-headers.cpp
===
--- /dev/null
+++ test/Index/ignore-warnings-from-headers.cpp
@@ -0,0 +1,7 @@
+#include "ignore-warnings-from-headers.h"
+
+void g(int unusedInMainFile) {}
+
+// RUN: env CINDEXTEST_IGNORE_NONERRORS_FROM_INCLUDED_FILES=1 c-index-test -test-load-source function %s -Wunused-parameter 2>&1 | FileCheck %s
+// CHECK-NOT: warning: unused parameter 'unusedInHeader'
+// CHECK: warning: unused parameter 'unusedInMainFile'
Index: test/Frontend/warnings-ignore-from-includes.cpp
===
--- /dev/null
+++ test/Frontend/warnings-ignore-from-includes.cpp
@@ -0,0 +1,7 @@
+#include "header-with-warning.h"
+
+static void f1(void) {}
+
+// RUN: %clang_cc1 -I%S/Inputs/ -Wunused-function -fsuppress-non-errors-from-included-files %s 2>&1 | FileCheck %s
+// CHECK-NOT: warning: unused function 'f0'
+// CHECK: warning: unused function 'f1'
Index: test/Frontend/Inputs/header-with-warning.h
===
--- /dev/null
+++ test/Frontend/Inputs/header-with-warning.h
@@ -0,0 +1 @@
+static void f0(void) {}
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3398,6 +3398,9 @@
   if (options & CXTranslationUnit_KeepGoing)
 Diags->setSuppressAfterFatalError(false);
 
+  if (options & CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles)
+  Diags->setSuppressNonErrorsFromIncludedFiles(true);
+
   // Recover resources if we crash before exiting this function.
   llvm::CrashRecoveryContextCleanupRegistrar >
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -84,6 +84,8 @@
 options |= CXTranslationUnit_KeepGoing;
   if (getenv("CINDEXTEST_LIMIT_SKIP_FUNCTION_BODIES_TO_PREAMBLE"))
 options |= CXTranslationUnit_LimitSkipFunctionBodiesToPreamble;
+  if (getenv("CINDEXTEST_IGNORE_NONERRORS_FROM_INCLUDED_FILES"))
+options |= CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles;
 
   return options;
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1223,6 +1223,8 @@
   Args.getLastArg(OPT_diagnostic_serialized_file, OPT__serialize_diags))
 Opts.DiagnosticSerializationFile = A->getValue();
   Opts.IgnoreWarnings = Args.hasArg(OPT_w);
+  Opts.SuppressNonErrorsFromIncludedFiles =
+  Args.hasArg(OPT_fsuppress_non_errors_from_included_files);
   Opts.NoRewriteMacros = Args.hasArg(OPT_Wno_rewrite_macros);
   Opts.Pedantic = Args.hasArg(OPT_pedantic);
   Opts.PedanticErrors = Args.hasArg(OPT_pedantic_errors);
Index: lib/Basic/Warnings.cpp
===
--- lib/Basic/Warnings.cpp
+++ lib/Basic/Warnings.cpp
@@ -46,6 +46,7 @@
   bool ReportDiags) {
   Diags.setSuppressSystemWarnings(true);  // Default to -Wno-system-headers
   Diags.setIgnoreAllWarnings(Opts.IgnoreWarnings);
+  Diags.setSuppressNonErrorsFromIncludedFiles(Opts.SuppressNonErrorsFromIncludedFiles);
   Diags.setShowOverloads(Opts.getShowOverloads());
 
   Diags.setElideType(Opts.ElideType);
Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -477,6 +477,14 @@
   Result = diag::Severity::Fatal;
   }
 
+  // If requested, ignore non-errors from all included files.
+  if (Diag.SuppressNonErrorsFromIncludedFiles &&
+  Result <= diag::Severity::Warning && Loc.isValid() &&
+  !Diag.getSourceManager().isInMainFile(
+  Diag.getSourceManager().getExpansionLoc(Loc))) {
+return diag::Severity::Ignored;
+  }
+
   // Custom diagnostics always are emitted in system headers.
   bool ShowInSystemHeader =
   !GetDia

[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2018-07-31 Thread Lassi Niemistö via Phabricator via cfe-commits
lassi.niemisto added a comment.

My project team would also highly appreciate if this got implemented. Currently 
working around the issue by post-formatting the clang-formatted files with 
uncrustify and filtering it so that it only touches lines starting with #.


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-07-31 Thread Samuel Antao via Phabricator via cfe-commits
sfantao added a comment.

Hi Doru,

Thanks for updating the patch. I've a few comments below.




Comment at: include/clang/Driver/Compilation.h:312
+  /// \param skipBundler - bool value set once by the driver.
+  void setSkipOffloadBundler(bool skipBundler);
+

gtbercea wrote:
> sfantao wrote:
> > Why is this a property of the compilation and not of a set of actions 
> > referring to a given target? That would allow one to combine in the same 
> > compilation targets requiring the bundler and targets that wouldn't. 
> This was a way to pass this information to the OpenMP NVPTX device toolchain.
> 
> Both the Driver OpenMP NVPTX toolchain need to agree on the usage of the new 
> scheme (proposed in this patch) or the old scheme (the one that is in the 
> compiler today).
> 
> 
I understand, but the way I see it is that it is the toolchain that skips the 
bundler not the compilation. I understand that as of this patch, you skip only 
if there is a single nvptx target. If you have more than one target, as some 
tests do, some toolchains will still need the bundler. So, we are making what 
happens with the nvptx target dependent of other toolchains. Is this an 
intended effect of this patch?



Comment at: lib/Driver/Compilation.cpp:276
+void Compilation::setSkipOffloadBundler(bool skipBundler) {
+  skipOffloadBundler = skipBundler;
+}

gtbercea wrote:
> sfantao wrote:
> > Given the logic you have below, you are assuming this is not set to false 
> > ever. It would be wise to get an assertion here in case you end up having 
> > toolchains skipping and others don't. If that is just not supported a 
> > diagnostic should be added instead.
> > 
> > The convention is that local variables use CamelCase.
> The checks I added in the Driver will set this flag to true if all toolchains 
> Clang offloads to support the skipping of the bundler/unbundler for object 
> files. Currently only NVPTX toolchain can skip the bundler/unbundler for 
> object files so the code path in this patch will be taken only for:
> 
> -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
Ok, if that is the case, just add an assertion here.



Comment at: lib/Driver/Driver.cpp:2943
+}
+  }
+

gtbercea wrote:
> sfantao wrote:
> > Can you just implement this check in the definition of `Compilation: 
> > canSkipClangOffloadBundler` and get rid of `setSkipOffloadBundler`? All the 
> > requirted information is already in `Compilation` under `C.getInputArgs()`.
> The driver needs to have the result of this check available. The flag is 
> passed to the step which adds host-device dependencies. If the bundler can be 
> skipped then the unbundling action is not required.
> 
> I guess this could be implemented in Compilation. Even so I would like it to 
> happen only once like it does here and not every time someone queries the 
> "can I skip the bundler" flag.
> 
> I wanted this check to happen only once hence why I put in on the driver 
> side. The result of this check needs to be available in Driver.cpp and in 
> Cuda.cpp files (see usage in this patch). Compilation keeps track of the flag 
> because skipping the bundler is an all or nothing flag: you can skip the 
> bundler/unbundler for object files if and only if all toolchains you are 
> offloading to can skip it.
> 
Right, in these circumstances "can skip bundler" is the same as "do I have a 
single toolchain" and "is that toolchain nvptx". This is fairly inexpensive to 
do, so I don't really see the need to record this state in the driver. It will 
also be clearer what are the conditions for which you skip the bundler.



Comment at: lib/Driver/ToolChains/Cuda.cpp:496
+  ? CudaVirtualArchToString(VirtualArchForCudaArch(gpu_arch))
+  : GPUArch.str().c_str();
+  const char *PtxF =

Why don't create fatbins instead of cubins in all cases. For the purposes of 
OpenMP they are equivalent, i.e. nvlink can interpret them in the same way, no?



Comment at: lib/Driver/ToolChains/Cuda.cpp:517
+//   --image=profile=sm_35@compute_35,file=ompprint.compute_35.sm_35.cubin
+//   --embedded-fatbin=ompprint.fatbin.c --cuda --device-c
+const char *Exec = Args.MakeArgString(TC.GetProgramPath("fatbinary"));

I'd move this comment to the top of this session so that we know what is going 
on in the code above.



Comment at: lib/Driver/ToolChains/Cuda.cpp:524
+// the hash of the full path of the file.
+std::hash hash_fn;
+size_t hash = hash_fn(llvm::sys::path::filename(Output.getFilename()));

CamelCase



Comment at: lib/Driver/ToolChains/Cuda.cpp:664
+  // Anything that's not a file name is potentially a static library
+  // so treat it as such.
+  if (C.canSkipOffloadBundler())

So, what if it is not a static library?



r338360 - Fix linux-header-search.cpp with CLANG_DEFAULT_CXX_STDLIB

2018-07-31 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Tue Jul 31 04:36:14 2018
New Revision: 338360

URL: http://llvm.org/viewvc/llvm-project?rev=338360&view=rev
Log:
Fix linux-header-search.cpp with CLANG_DEFAULT_CXX_STDLIB

This configuration was broken after r338294 because Clang might
be configured to always use libc++.

Modified:
cfe/trunk/test/Driver/linux-header-search.cpp

Modified: cfe/trunk/test/Driver/linux-header-search.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-header-search.cpp?rev=338360&r1=338359&r2=338360&view=diff
==
--- cfe/trunk/test/Driver/linux-header-search.cpp (original)
+++ cfe/trunk/test/Driver/linux-header-search.cpp Tue Jul 31 04:36:14 2018
@@ -496,7 +496,7 @@
 
 // Check header search on OpenEmbedded ARM.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
-// RUN: -target arm-oe-linux-gnueabi \
+// RUN: -target arm-oe-linux-gnueabi -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -507,7 +507,7 @@
 
 // Check header search on OpenEmbedded AArch64.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
-// RUN: -target aarch64-oe-linux \
+// RUN: -target aarch64-oe-linux -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 


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


[PATCH] D48862: [OpenEmbedded] Fix lib paths for OpenEmbedded targets

2018-07-31 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

I fixed `linux-header-search.cpp` by adding `-stdlib=libstdc++` in r338360 
because I was seeing the same failure and that's what agreed to do in these 
cases. If you can verify that it fixes your problems, I think it's safe to add 
`-rtlib=libgcc` to the other test.


Repository:
  rL LLVM

https://reviews.llvm.org/D48862



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


[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/Driver/Options.td:1745
 HelpText<"remap file source paths in debug info">;
+def fsuppress_non_errors_from_included_files : Flag<["-"], 
"fsuppress-non-errors-from-included-files">,
+  Group, Flags<[CC1Option]>;

Why would we ever want to suppress diagnostics from *all* included files in the 
compiler mode?

That seems more appropriate in the tooling mode (e.g. IDE integration, etc.). 
However, that could probably be done without modifications of core clang bits, 
e.g. by writing a DiagnosticsConsumer that ignores diagnostics coming from 
outside the main file.


https://reviews.llvm.org/D49794



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


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 158216.
ilya-biryukov added a comment.

- Moved early return into the CanReuseAST branch


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045

Files:
  clangd/TUScheduler.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -390,5 +390,38 @@
   ASSERT_FALSE(DoUpdate(getInputs(Source, OtherSourceContents)));
 }
 
+TEST_F(TUSchedulerTests, NoChangeDiags) {
+  TUScheduler S(
+  /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
+  /*StorePreambleInMemory=*/true, PreambleParsedCallback(),
+  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+  ASTRetentionPolicy());
+
+  auto FooCpp = testPath("foo.cpp");
+  auto Contents = "int a; int b;";
+
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::No,
+   [](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  S.runWithAST("touchAST", FooCpp, [](llvm::Expected IA) {
+// Make sure the AST was actually built.
+cantFail(std::move(IA));
+  });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+
+  // Even though the inputs didn't change and AST can be reused, we need to
+  // report the diagnostics, as they were not reported previously.
+  std::atomic SeenDiags(false);
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { SeenDiags = true; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+  ASSERT_TRUE(SeenDiags);
+
+  // Subsequent request does not get any diagnostics callback because the same
+  // diags have previously been reported and the inputs didn't change.
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -228,6 +228,9 @@
   Semaphore &Barrier;
   /// Inputs, corresponding to the current state of AST.
   ParseInputs FileInputs;
+  /// Whether the diagnostics for the current FileInputs were reported to the
+  /// users before.
+  bool DiagsWereReported = false;
   /// Size of the last AST
   /// Guards members used by both TUScheduler and the worker thread.
   mutable std::mutex Mutex;
@@ -330,7 +333,9 @@
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 
 tooling::CompileCommand OldCommand = std::move(FileInputs.CompileCommand);
+bool PrevDiagsWereReported = DiagsWereReported;
 FileInputs = Inputs;
+DiagsWereReported = false;
 
 log("Updating file {0} with command [{1}] {2}", FileName,
 Inputs.CompileCommand.Directory,
@@ -366,34 +371,45 @@
 OldPreamble.reset();
 PreambleWasBuilt.notify();
 
-if (CanReuseAST) {
-  // Take a shortcut and don't build the AST if neither the inputs nor the
-  // preamble have changed.
-  // Note that we do not report the diagnostics, since they should not have
-  // changed either. All the clients should handle the lack of OnUpdated()
-  // call anyway to handle empty result from buildAST.
-  // FIXME(ibiryukov): the AST could actually change if non-preamble
-  // includes changed, but we choose to ignore it.
-  // FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
-  // current file at this point?
-  log("Skipping rebuild of the AST for {0}, inputs are the same.",
-  FileName);
-  return;
+if (!CanReuseAST) {
+  IdleASTs.take(this); // Remove the old AST if it's still in cache.
+}
+else {
+  // Since we don't need to rebuild the AST, we might've already reported
+  // the diagnostics for it.
+  DiagsWereReported = PrevDiagsWereReported;
+  if (DiagsWereReported) {
+// Take a shortcut and don't report the diagnostics, since they should
+// not changed. All the clients should handle the lack of OnUpdated()
+// call anyway to handle empty result from buildAST.
+// FIXME(ibiryukov): the AST could actually change if non-preamble
+// includes changed, but we choose to ignore it.
+// FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
+// current file at this point?
+log("Skipping rebuild of the AST for {0}, inputs are the same.",
+FileName);
+return;
+  }
+}
+
+// Get the AST for diagnostics.
+llvm::Optional> AST = IdleASTs.take(this);
+if (!AST) {
+  llvm::Optional NewAST =
+  buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
+  AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : nullptr;
 }
-//

[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added inline comments.



Comment at: clangd/TUScheduler.cpp:379
+
+if (DiagsWereReported) {
   // Take a shortcut and don't build the AST if neither the inputs nor the

ilya-biryukov wrote:
> ioeric wrote:
> > The implicit condition here is that we can reuse AST and diagnostics were 
> > not reported. I think we can be more explicit here by moving this early 
> > return into the `CanReuseAST` if branch. By doing this, we could also get 
> > rid of `PrevDiagsWereReported`. An additional state variable seems to have 
> > made the flow less clear.
> The problem with that would be that the value of `DiagsWereReported` would be 
> stale for ~40 lines between the assignment to `FileInputs` and this point.
> So I'm not sure about this trade-off. WDYT?
Update after chatting offline: we agreed to keep the `PrevDiagsWereReported` 
and move the early return into the original if branch to make the dependencies 
between DiagsWereReported and CanReuseAST more explicit. This comment should be 
done now.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045



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


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/TUScheduler.cpp:381
+  DiagsWereReported = PrevDiagsWereReported;
+  if (DiagsWereReported) {
+// Take a shortcut and don't report the diagnostics, since they should

I think checking `PrevDiagsWereReported` here would be more straightforward.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045



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


[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-31 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- added a comment.

The state of this patch:

- user interface is as agreed-upon, giving end-users the capability to filter 
out floats and ints as it makes sense for their code base
- code is clean
- documentation is up to date
- default ignore lists are sensible

There is one outstanding improvement request - to combine the two float/double 
lists into a single APFloat but that requires more refactoring outside this 
check and the benefit lies mainly in a future extensibility and the saving of a 
couple hundred bytes.

@aaron.ballman - can we get this merged as-is and improve it later? I'd like to 
see this check available in Clang7.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114



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


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added inline comments.



Comment at: clangd/TUScheduler.cpp:381
+  DiagsWereReported = PrevDiagsWereReported;
+  if (DiagsWereReported) {
+// Take a shortcut and don't report the diagnostics, since they should

ioeric wrote:
> I think checking `PrevDiagsWereReported` here would be more straightforward.
Good point. Done.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045



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


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 158217.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Check for PrevDiagsWereReported


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50045

Files:
  clangd/TUScheduler.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -390,5 +390,38 @@
   ASSERT_FALSE(DoUpdate(getInputs(Source, OtherSourceContents)));
 }
 
+TEST_F(TUSchedulerTests, NoChangeDiags) {
+  TUScheduler S(
+  /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
+  /*StorePreambleInMemory=*/true, PreambleParsedCallback(),
+  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+  ASTRetentionPolicy());
+
+  auto FooCpp = testPath("foo.cpp");
+  auto Contents = "int a; int b;";
+
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::No,
+   [](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  S.runWithAST("touchAST", FooCpp, [](llvm::Expected IA) {
+// Make sure the AST was actually built.
+cantFail(std::move(IA));
+  });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+
+  // Even though the inputs didn't change and AST can be reused, we need to
+  // report the diagnostics, as they were not reported previously.
+  std::atomic SeenDiags(false);
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { SeenDiags = true; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+  ASSERT_TRUE(SeenDiags);
+
+  // Subsequent request does not get any diagnostics callback because the same
+  // diags have previously been reported and the inputs didn't change.
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -228,6 +228,9 @@
   Semaphore &Barrier;
   /// Inputs, corresponding to the current state of AST.
   ParseInputs FileInputs;
+  /// Whether the diagnostics for the current FileInputs were reported to the
+  /// users before.
+  bool DiagsWereReported = false;
   /// Size of the last AST
   /// Guards members used by both TUScheduler and the worker thread.
   mutable std::mutex Mutex;
@@ -330,7 +333,9 @@
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 
 tooling::CompileCommand OldCommand = std::move(FileInputs.CompileCommand);
+bool PrevDiagsWereReported = DiagsWereReported;
 FileInputs = Inputs;
+DiagsWereReported = false;
 
 log("Updating file {0} with command [{1}] {2}", FileName,
 Inputs.CompileCommand.Directory,
@@ -366,34 +371,45 @@
 OldPreamble.reset();
 PreambleWasBuilt.notify();
 
-if (CanReuseAST) {
-  // Take a shortcut and don't build the AST if neither the inputs nor the
-  // preamble have changed.
-  // Note that we do not report the diagnostics, since they should not have
-  // changed either. All the clients should handle the lack of OnUpdated()
-  // call anyway to handle empty result from buildAST.
-  // FIXME(ibiryukov): the AST could actually change if non-preamble
-  // includes changed, but we choose to ignore it.
-  // FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
-  // current file at this point?
-  log("Skipping rebuild of the AST for {0}, inputs are the same.",
-  FileName);
-  return;
+if (!CanReuseAST) {
+  IdleASTs.take(this); // Remove the old AST if it's still in cache.
+}
+else {
+  // Since we don't need to rebuild the AST, we might've already reported
+  // the diagnostics for it.
+  if (PrevDiagsWereReported) {
+DiagsWereReported = true;
+// Take a shortcut and don't report the diagnostics, since they should
+// not changed. All the clients should handle the lack of OnUpdated()
+// call anyway to handle empty result from buildAST.
+// FIXME(ibiryukov): the AST could actually change if non-preamble
+// includes changed, but we choose to ignore it.
+// FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
+// current file at this point?
+log("Skipping rebuild of the AST for {0}, inputs are the same.",
+FileName);
+return;
+  }
+}
+
+// Get the AST for diagnostics.
+llvm::Optional> AST = IdleASTs.take(this);
+if (!AST) {
+  llvm::Optional NewAST =
+  buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
+  AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : n

r338353 - Improve support of PDB as an external layout source

2018-07-31 Thread Aleksandr Urakov via cfe-commits
Author: aleksandr.urakov
Date: Tue Jul 31 01:27:06 2018
New Revision: 338353

URL: http://llvm.org/viewvc/llvm-project?rev=338353&view=rev
Log:
Improve support of PDB as an external layout source

Summary:
This patch improves support of PDB as an external layout source
in the next cases:

- Multiple non-virtual inheritance from packed base classes. When using
  external layout, there's no need to align `NonVirtualSize` of a base class.
  It may cause an overlapping when the next base classes will be layouted
  (but there is a slightly different case in the test because I can't find
  a way to specify a base offset);
- Support of nameless structs and unions. There is no info about nameless child
  structs and unions in Microsoft cl-emitted PDBs. Instead all its fields
  are just treated as outer structure's (union's) fields. This also causes
  a fields overlapping, and makes it possible for unions to have fields located
  at a non-zero offset.

Reviewers: rsmith, zturner, rnk, mstorsjo, majnemer

Reviewed By: rnk

Subscribers: cfe-commits

Tags: #clang

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

Added:

cfe/trunk/test/CodeGenCXX/Inputs/override-layout-nameless-struct-union.layout
cfe/trunk/test/CodeGenCXX/Inputs/override-layout-packed-base.layout
cfe/trunk/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
cfe/trunk/test/CodeGenCXX/override-layout-packed-base.cpp
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=338353&r1=338352&r2=338353&view=diff
==
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Tue Jul 31 01:27:06 2018
@@ -2452,7 +2452,9 @@ void MicrosoftRecordLayoutBuilder::cxxLa
   auto RoundingAlignment = Alignment;
   if (!MaxFieldAlignment.isZero())
 RoundingAlignment = std::min(RoundingAlignment, MaxFieldAlignment);
-  NonVirtualSize = Size = Size.alignTo(RoundingAlignment);
+  if (!UseExternalLayout)
+Size = Size.alignTo(RoundingAlignment);
+  NonVirtualSize = Size;
   RequiredAlignment = std::max(
   RequiredAlignment, Context.toCharUnitsFromBits(RD->getMaxAlignment()));
   layoutVirtualBases(RD);
@@ -2653,21 +2655,16 @@ void MicrosoftRecordLayoutBuilder::layou
   LastFieldIsNonZeroWidthBitfield = false;
   ElementInfo Info = getAdjustedElementInfo(FD);
   Alignment = std::max(Alignment, Info.Alignment);
-  if (IsUnion) {
-placeFieldAtOffset(CharUnits::Zero());
-Size = std::max(Size, Info.Size);
-  } else {
-CharUnits FieldOffset;
-if (UseExternalLayout) {
-  FieldOffset =
-  Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
-  assert(FieldOffset >= Size && "field offset already allocated");
-} else {
-  FieldOffset = Size.alignTo(Info.Alignment);
-}
-placeFieldAtOffset(FieldOffset);
-Size = FieldOffset + Info.Size;
-  }
+  CharUnits FieldOffset;
+  if (UseExternalLayout)
+FieldOffset =
+Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
+  else if (IsUnion)
+FieldOffset = CharUnits::Zero();
+  else
+FieldOffset = Size.alignTo(Info.Alignment);
+  placeFieldAtOffset(FieldOffset);
+  Size = std::max(Size, FieldOffset + Info.Size);
 }
 
 void MicrosoftRecordLayoutBuilder::layoutBitField(const FieldDecl *FD) {
@@ -2692,18 +2689,17 @@ void MicrosoftRecordLayoutBuilder::layou
   }
   LastFieldIsNonZeroWidthBitfield = true;
   CurrentBitfieldSize = Info.Size;
-  if (IsUnion) {
-placeFieldAtOffset(CharUnits::Zero());
-Size = std::max(Size, Info.Size);
-// TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
-  } else if (UseExternalLayout) {
+  if (UseExternalLayout) {
 auto FieldBitOffset = External.getExternalFieldOffset(FD);
 placeFieldAtBitOffset(FieldBitOffset);
 auto NewSize = Context.toCharUnitsFromBits(
 llvm::alignTo(FieldBitOffset + Width, Context.getCharWidth()));
-assert(NewSize >= Size && "bit field offset already allocated");
-Size = NewSize;
+Size = std::max(Size, NewSize);
 Alignment = std::max(Alignment, Info.Alignment);
+  } else if (IsUnion) {
+placeFieldAtOffset(CharUnits::Zero());
+Size = std::max(Size, Info.Size);
+// TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
   } else {
 // Allocate a new block of memory and place the bitfield in it.
 CharUnits FieldOffset = Size.alignTo(Info.Alignment);

Added: 
cfe/trunk/test/CodeGenCXX/Inputs/override-layout-nameless-struct-union.layout
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/Inputs/override-layout-nameless-struct-union.layout?rev=338353&view=auto
==
--- 
cfe/trunk/test/CodeGenCXX/Inputs/override-layout-namel

Re: r338239 - [mips64][clang] Provide the signext attribute for i32 return values

2018-07-31 Thread Stefan Maksimovic via cfe-commits
I missed to include the changes to tests affected by that commit.

I've included them in r338246.


Regards,

Stefan


From: Friedman, Eli 
Sent: 30 July 2018 21:22:45
To: Stefan Maksimovic; cfe-commits@lists.llvm.org
Subject: Re: r338239 - [mips64][clang] Provide the signext attribute for i32 
return values

On 7/30/2018 3:44 AM, Stefan Maksimovic via cfe-commits wrote:
> Author: smaksimovic
> Date: Mon Jul 30 03:44:46 2018
> New Revision: 338239
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338239&view=rev
> Log:
> [mips64][clang] Provide the signext attribute for i32 return values
>
> Additional info: see r338019.
>
> Differential Revision: https://reviews.llvm.org/D49289
>
> Modified:
>  cfe/trunk/lib/CodeGen/TargetInfo.cpp

I'd like to see some test coverage for this.

-El

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

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


[clang-tools-extra] r338361 - [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jul 31 04:47:52 2018
New Revision: 338361

URL: http://llvm.org/viewvc/llvm-project?rev=338361&view=rev
Log:
[clangd] Report diagnostics even if WantDiags::No AST was reused

Summary:
After r338256, clangd stopped reporting diagnostics if WantDiags::No request
is followed by a WantDiags::Yes request but the AST can be reused.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: javed.absar, MaskRay, jkorous, arphaman, jfb, cfe-commits

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

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

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=338361&r1=338360&r2=338361&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Tue Jul 31 04:47:52 2018
@@ -228,6 +228,9 @@ private:
   Semaphore &Barrier;
   /// Inputs, corresponding to the current state of AST.
   ParseInputs FileInputs;
+  /// Whether the diagnostics for the current FileInputs were reported to the
+  /// users before.
+  bool DiagsWereReported = false;
   /// Size of the last AST
   /// Guards members used by both TUScheduler and the worker thread.
   mutable std::mutex Mutex;
@@ -330,7 +333,9 @@ void ASTWorker::update(
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 
 tooling::CompileCommand OldCommand = std::move(FileInputs.CompileCommand);
+bool PrevDiagsWereReported = DiagsWereReported;
 FileInputs = Inputs;
+DiagsWereReported = false;
 
 log("Updating file {0} with command [{1}] {2}", FileName,
 Inputs.CompileCommand.Directory,
@@ -366,34 +371,44 @@ void ASTWorker::update(
 OldPreamble.reset();
 PreambleWasBuilt.notify();
 
-if (CanReuseAST) {
-  // Take a shortcut and don't build the AST if neither the inputs nor the
-  // preamble have changed.
-  // Note that we do not report the diagnostics, since they should not have
-  // changed either. All the clients should handle the lack of OnUpdated()
-  // call anyway to handle empty result from buildAST.
-  // FIXME(ibiryukov): the AST could actually change if non-preamble
-  // includes changed, but we choose to ignore it.
-  // FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
-  // current file at this point?
-  log("Skipping rebuild of the AST for {0}, inputs are the same.",
-  FileName);
-  return;
+if (!CanReuseAST) {
+  IdleASTs.take(this); // Remove the old AST if it's still in cache.
+} else {
+  // Since we don't need to rebuild the AST, we might've already reported
+  // the diagnostics for it.
+  if (PrevDiagsWereReported) {
+DiagsWereReported = true;
+// Take a shortcut and don't report the diagnostics, since they should
+// not changed. All the clients should handle the lack of OnUpdated()
+// call anyway to handle empty result from buildAST.
+// FIXME(ibiryukov): the AST could actually change if non-preamble
+// includes changed, but we choose to ignore it.
+// FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
+// current file at this point?
+log("Skipping rebuild of the AST for {0}, inputs are the same.",
+FileName);
+return;
+  }
+}
+
+// Get the AST for diagnostics.
+llvm::Optional> AST = IdleASTs.take(this);
+if (!AST) {
+  llvm::Optional NewAST =
+  buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
+  AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : 
nullptr;
 }
-// Remove the old AST if it's still in cache.
-IdleASTs.take(this);
 
-// Build the AST for diagnostics.
-llvm::Optional AST =
-buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
-if (WantDiags != WantDiagnostics::No && AST)
-  OnUpdated(AST->getDiagnostics());
+// Note *AST can be still be null if buildAST fails.
+if (WantDiags != WantDiagnostics::No && *AST) {
+  OnUpdated((*AST)->getDiagnostics());
+  DiagsWereReported = true;
+}
 // Stash the AST in the cache for further use.
-IdleASTs.put(this,
- AST ? llvm::make_unique(std::move(*AST)) : 
nullptr);
+IdleASTs.put(this, std::move(*AST));
   };
 
   startTask("Update", Bind(Task, std::move(OnUpdated)), WantDiags);

Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedul

[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

I already mentioned in the review inherited by this one that this way covers 
also loaded plugins with different consumers. So let's assume that driver loads 
clang-tidy and some other plugins and runs over each file in the project.
It makes sense not to include clang-tidy diagnostics coming from headers, at 
least for third-party headers (you can still run clang over specific headers 
themselves to get diagnostics for them).


https://reviews.llvm.org/D49794



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


[PATCH] D50045: [clangd] Report diagnostics even if WantDiags::No AST was reused

2018-07-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338361: [clangd] Report diagnostics even if WantDiags::No 
AST was reused (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50045?vs=158217&id=158218#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50045

Files:
  clang-tools-extra/trunk/clangd/TUScheduler.cpp
  clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
@@ -390,5 +390,39 @@
   ASSERT_FALSE(DoUpdate(getInputs(Source, OtherSourceContents)));
 }
 
+TEST_F(TUSchedulerTests, NoChangeDiags) {
+  TUScheduler S(
+  /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
+  /*StorePreambleInMemory=*/true, PreambleParsedCallback(),
+  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+  ASTRetentionPolicy());
+
+  auto FooCpp = testPath("foo.cpp");
+  auto Contents = "int a; int b;";
+
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::No,
+   [](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  S.runWithAST("touchAST", FooCpp, [](llvm::Expected IA) {
+// Make sure the AST was actually built.
+cantFail(std::move(IA));
+  });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+
+  // Even though the inputs didn't change and AST can be reused, we need to
+  // report the diagnostics, as they were not reported previously.
+  std::atomic SeenDiags(false);
+  S.update(FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+   [&](std::vector) { SeenDiags = true; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+  ASSERT_TRUE(SeenDiags);
+
+  // Subsequent request does not get any diagnostics callback because the same
+  // diags have previously been reported and the inputs didn't change.
+  S.update(
+  FooCpp, getInputs(FooCpp, Contents), WantDiagnostics::Auto,
+  [&](std::vector) { ADD_FAILURE() << "Should not be called."; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/TUScheduler.cpp
===
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp
@@ -228,6 +228,9 @@
   Semaphore &Barrier;
   /// Inputs, corresponding to the current state of AST.
   ParseInputs FileInputs;
+  /// Whether the diagnostics for the current FileInputs were reported to the
+  /// users before.
+  bool DiagsWereReported = false;
   /// Size of the last AST
   /// Guards members used by both TUScheduler and the worker thread.
   mutable std::mutex Mutex;
@@ -330,7 +333,9 @@
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 
 tooling::CompileCommand OldCommand = std::move(FileInputs.CompileCommand);
+bool PrevDiagsWereReported = DiagsWereReported;
 FileInputs = Inputs;
+DiagsWereReported = false;
 
 log("Updating file {0} with command [{1}] {2}", FileName,
 Inputs.CompileCommand.Directory,
@@ -366,34 +371,44 @@
 OldPreamble.reset();
 PreambleWasBuilt.notify();
 
-if (CanReuseAST) {
-  // Take a shortcut and don't build the AST if neither the inputs nor the
-  // preamble have changed.
-  // Note that we do not report the diagnostics, since they should not have
-  // changed either. All the clients should handle the lack of OnUpdated()
-  // call anyway to handle empty result from buildAST.
-  // FIXME(ibiryukov): the AST could actually change if non-preamble
-  // includes changed, but we choose to ignore it.
-  // FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
-  // current file at this point?
-  log("Skipping rebuild of the AST for {0}, inputs are the same.",
-  FileName);
-  return;
+if (!CanReuseAST) {
+  IdleASTs.take(this); // Remove the old AST if it's still in cache.
+} else {
+  // Since we don't need to rebuild the AST, we might've already reported
+  // the diagnostics for it.
+  if (PrevDiagsWereReported) {
+DiagsWereReported = true;
+// Take a shortcut and don't report the diagnostics, since they should
+// not changed. All the clients should handle the lack of OnUpdated()
+// call anyway to handle empty result from buildAST.
+// FIXME(ibiryukov): the AST could actually change if non-preamble
+// includes changed, but we choose to ignore it.
+// FIXME(ibiryukov): should we refresh the cache in IdleASTs for the
+// current file at this point?
+log("Skipping rebuild of the AST for {0}, inputs are the same

[PATCH] D49918: [clang-tidy] Sequence declaration in while statement before the condition

2018-07-31 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG modulo outstanding comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49918



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


[PATCH] D47267: [UnrollAndJam] Add unroll_and_jam pragma handling

2018-07-31 Thread Dave Green via Phabricator via cfe-commits
dmgreen updated this revision to Diff 158219.
dmgreen added a comment.

Rebase.

Michael, you happy with this part?

The pragma clang loop part is off in https://reviews.llvm.org/D47320. Let me 
know if/when I should do something with that.


https://reviews.llvm.org/D47267

Files:
  include/clang/Basic/Attr.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/CodeGen/CGLoopInfo.h
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenCXX/pragma-unroll-and-jam.cpp
  test/Parser/pragma-unroll-and-jam.cpp

Index: test/Parser/pragma-unroll-and-jam.cpp
===
--- /dev/null
+++ test/Parser/pragma-unroll-and-jam.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// Note that this puts the expected lines before the directives to work around
+// limitations in the -verify mode.
+
+void test(int *List, int Length, int Value) {
+  int i = 0;
+
+#pragma unroll_and_jam
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+#pragma nounroll_and_jam
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+#pragma unroll_and_jam 4
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+/* expected-error {{expected ')'}} */ #pragma unroll_and_jam(4
+/* expected-error {{missing argument; expected an integer value}} */ #pragma unroll_and_jam()
+/* expected-warning {{extra tokens at end of '#pragma unroll_and_jam'}} */ #pragma unroll_and_jam 1 2
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+/* expected-warning {{extra tokens at end of '#pragma nounroll_and_jam'}} */ #pragma nounroll_and_jam 1
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+#pragma unroll_and_jam
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll_and_jam'}} */ int j = Length;
+#pragma unroll_and_jam 4
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll_and_jam'}} */ int k = Length;
+#pragma nounroll_and_jam
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll_and_jam'}} */ int l = Length;
+
+/* expected-error {{incompatible directives '#pragma nounroll_and_jam' and '#pragma unroll_and_jam(4)'}} */ #pragma unroll_and_jam 4
+#pragma nounroll_and_jam
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+#pragma nounroll_and_jam
+#pragma unroll(4)
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+// pragma clang unroll_and_jam is disabled for the moment
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+#pragma unroll_and_jam
+/* expected-error {{expected statement}} */ }
Index: test/CodeGenCXX/pragma-unroll-and-jam.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pragma-unroll-and-jam.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple arm-none-eabi -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+void unroll_and_jam(int *List, int Length, int Value) {
+  // CHECK: define {{.*}} @_Z14unroll_and_jam
+#pragma unroll_and_jam
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
+  List[i * Length + j] = Value;
+}
+  }
+}
+
+void unroll_and_jam_count(int *List, int Length, int Value) {
+  // CHECK: define {{.*}} @_Z20unroll_and_jam_count
+#pragma unroll_and_jam(4)
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_2:.*]]
+  List[i * Length + j] = Value;
+}
+  }
+}
+
+void nounroll_and_jam(int *List, int Length, int Value) {
+  // CHECK: define {{.*}} @_Z16nounroll_and_jam
+#pragma nounroll_and_jam
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_3:.*]]
+  List[i * Length + j] = Value;
+}
+  }
+}
+
+void clang_unroll_plus_nounroll_and_jam(int *List, int Length, int Value) {
+  // CHECK: define {{.*}} @_Z34clang_unroll_plus_nounroll_and_jam
+#pragma nounroll_and_jam
+#pragma unroll(4)
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
+  List[i *

[PATCH] D47196: [Time-report ](2): Recursive timers in Clang

2018-07-31 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 updated this revision to Diff 158221.
avt77 added a comment.
Herald added a subscriber: eraman.

Accordingly to efriedma suggestion I removed start/stopFrontendTimer where it's 
possible and inserted FrontendTimeRAII in several new places. As result the 
patch becomes bigger and bigger. And as another result I got output like here 
(on compiler bootstrap):

 0.5920 (165) _ZSt7declvalv (*)
 0.5960 (155) _ZSt7declvalv (*)
 0.5960 (162) _ZSt7declvalv (*)
 0.6000 (167) _ZSt7declvalv (*)
 0.6040 (155) _ZSt7declvalv (*)
 0.6040 (160) _ZSt7declvalv (*)
 0.6040 (169) _ZSt7declvalv (*)
 
(the above is grep output from build log file)

It means we compile the same function many times inside many files and it 
should be optimised in some way.
Another thought: I should add "human" names to simplify the mangling names 
resolution.


https://reviews.llvm.org/D47196

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.h
  include/clang/Frontend/Utils.h
  lib/AST/Decl.cpp
  lib/AST/Expr.cpp
  lib/Analysis/AnalysisDeclContext.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendTiming.cpp
  lib/Parse/CMakeLists.txt
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/TreeTransform.h
  test/Frontend/ftime-report-template-decl.cpp
  test/Headers/opencl-c-header.cl

Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -71,4 +71,5 @@
 }
 #endif //__OPENCL_C_VERSION__
 
-// CHECK-MOD: Reading modules
+// CHECK-DAG-MOD: Clang Timers: CodeGen Functions
+// CHECK-DAG-MOD: Reading modules
Index: test/Frontend/ftime-report-template-decl.cpp
===
--- test/Frontend/ftime-report-template-decl.cpp
+++ test/Frontend/ftime-report-template-decl.cpp
@@ -3,9 +3,15 @@
 
 // Template function declarations
 template 
-void foo();
+T foo(T bar) {
+  T Result = bar * bar + bar / 1.2 + bar;
+  return Result;
+};
 template 
-void foo();
+T foo(T bar, U bar2) {
+  T Result = bar2 * bar + bar / 1.2 + bar2;
+  return Result;
+};
 
 // Template function definitions.
 template 
@@ -130,9 +136,15 @@
 template 
 oneT L<0>::O::Fun(U) { return one; }
 
-void Instantiate() {
+double Instantiate() {
   sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
   sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
+  int R1 = foo(123) + foo(177.2) - foo(331.442);
+  char R2 = foo('d', 1234) * foo(1.26);
+  int R3 = foo(1.2) + foo(11.22) / foo(66.77);
+  double R4 = foo(34.56, 1234);
+  double R5 = R1 + R2 * R3 - R4 + one[0] * foo(15.52) - two[1] / foo(51.25);
+  return R5 * R1 + R4 / R3 + R2;
 }
 }
 
@@ -150,7 +162,10 @@
 };
 _Wrap_alloc::rebind w;
 
-// CHECK: Miscellaneous Ungrouped Timers
+// FIXME:  We need more complex test to increase the compilation time;
+// otherwise we see the foolowing message from time to time only.
+// VIOLATILE-CHECK: Clang Timers: CodeGen Functions
+// CHECK-DAG: Miscellaneous Ungrouped Timers
 // CHECK-DAG: LLVM IR Generation Time
 // CHECK-DAG: Code Generation Time
 // CHECK: Total
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -27,6 +27,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtOpenMP.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Sema/Designator.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Ownership.h"
@@ -11002,6 +11003,18 @@
 
   LSI->CallOperator = NewCallOperator;
 
+  FrontendTimeRAII FTRAII(
+  FrontendTimesIsEnabled,
+  getFrontendFunctionTimeCtx(), {NewCallOperator, 0.0});
+
+//  if (FrontendTimesIsEnabled) {
+//// At this point we're sure we're dealing with some function that's why
+//// we're starting the corresponding time slice. We'll stop it in
+//// Sema::ActOnFinishFunctionBody.
+//getFrontendFunctionTimeCtx()->startFrontendTimer(
+//{NewCallOperator, 0.0});
+//  }
+
   for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
I != NumParams; ++I) {
 auto *P = NewCallOperator->getParamDecl(I);
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -128,6 +128,9 @@
 }
 // Add template arguments from a function template specialization.
 else if (FunctionDecl *Function = dyn_cast(Ctx)) {
+  FrontendTimeRAII FTRAII(
+  FrontendTimesIsE

r338366 - clang-format: try to make the doc for ConstructorInitializerAllOnOneLineOrOnePerLine more clear

2018-07-31 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Jul 31 05:42:02 2018
New Revision: 338366

URL: http://llvm.org/viewvc/llvm-project?rev=338366&view=rev
Log:
clang-format: try to make the doc for 
ConstructorInitializerAllOnOneLineOrOnePerLine more clear

PR38080 complained that the "OnePerLine" case wasn't previously shown.

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=338366&r1=338365&r2=338366&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Tue Jul 31 05:42:02 2018
@@ -1134,17 +1134,21 @@ the configuration (without a prefix: ``A
   .. code-block:: c++
 
 true:
-SomeClass::Constructor()
-: (), (), 
(a) {
-  return 0;
-}
+FitsOnOneLine::Constructor()
+: a(aa), a(aa) {}
+
+DoesntFit::Constructor()
+: a(aa),
+  a(aa),
+  a(aa) {}
 
 false:
-SomeClass::Constructor()
-: (), (),
-  (a) {
-  return 0;
-}
+FitsOnOneLine::Constructor()
+: a(aa), a(aa) {}
+
+DoesntFit::Constructor()
+: a(aa), a(aa),
+  a(aa) {}
 
 **ConstructorInitializerIndentWidth** (``unsigned``)
   The number of characters to use for indentation of constructor


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


[PATCH] D50056: [NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle-llvm/handle_llvm.cpp.

2018-07-31 Thread Andrei Elovikov via Phabricator via cfe-commits
a.elovikov created this revision.
a.elovikov added reviewers: emmettneyman, erichkeane.

I don't have the whole list of GCC binaries available so I determined the exact
version where the warning disappeared via:

https://github.com/gcc-mirror/gcc/blob/gcc-4_9_0-release/gcc/cp/typeck.c#L6863
https://github.com/gcc-mirror/gcc/blob/gcc-4_8_5-release/gcc/cp/typeck.c#L6652


https://reviews.llvm.org/D50056

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -149,7 +149,21 @@
   EE->runStaticConstructorsDestructors(false);
 
   typedef void (*func)(int*, int*, int*, int);
-  func f = reinterpret_cast(EE->getPointerToFunction(EntryFunc)); 
+#if defined(__GNUC__) && ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
+  // Silence
+  //
+  //   warning: ISO C++ forbids casting between pointer-to-function and
+  //   pointer-to-object [-Wpedantic]
+  //
+  // Since C++11 this casting is conditionally supported and GCC versions
+  // starting from 4.9.0 don't warn about the cast.
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+  func f = reinterpret_cast(EE->getPointerToFunction(EntryFunc));
+#if defined(__GNUC__) && ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
+  #pragma GCC diagnostic pop
+#endif
 
   // Define some dummy arrays to use an input for now
   int a[] = {1};


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -149,7 +149,21 @@
   EE->runStaticConstructorsDestructors(false);
 
   typedef void (*func)(int*, int*, int*, int);
-  func f = reinterpret_cast(EE->getPointerToFunction(EntryFunc)); 
+#if defined(__GNUC__) && ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
+  // Silence
+  //
+  //   warning: ISO C++ forbids casting between pointer-to-function and
+  //   pointer-to-object [-Wpedantic]
+  //
+  // Since C++11 this casting is conditionally supported and GCC versions
+  // starting from 4.9.0 don't warn about the cast.
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+  func f = reinterpret_cast(EE->getPointerToFunction(EntryFunc));
+#if defined(__GNUC__) && ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
+  #pragma GCC diagnostic pop
+#endif
 
   // Define some dummy arrays to use an input for now
   int a[] = {1};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49865: Inform the AST of #pragma FENV_ACCESS use

2018-07-31 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 158229.
kpn added a comment.

Thanks for the fast turnaround! I don't have commit access, can I get you to 
commit it for me? And can I get you to put my email address 
 in the commit message?

I'll start looking at Sema like you said.


https://reviews.llvm.org/D49865

Files:
  include/clang/AST/Expr.h
  include/clang/Basic/LangOptions.h
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaAttr.cpp

Index: lib/Sema/SemaAttr.cpp
===
--- lib/Sema/SemaAttr.cpp
+++ lib/Sema/SemaAttr.cpp
@@ -773,6 +773,18 @@
   }
 }
 
+void Sema::ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC) {
+  switch (FPC) {
+  case LangOptions::FEA_On:
+FPFeatures.setAllowFEnvAccess();
+break;
+  case LangOptions::FEA_Off:
+FPFeatures.setDisallowFEnvAccess();
+break;
+  }
+}
+
+
 void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
SourceLocation Loc) {
   // Visibility calculations will consider the namespace's visibility.
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -674,6 +674,9 @@
   case tok::annot_pragma_fp_contract:
 HandlePragmaFPContract();
 return nullptr;
+  case tok::annot_pragma_fenv_access:
+HandlePragmaFEnvAccess();
+return nullptr;
   case tok::annot_pragma_fp:
 HandlePragmaFP();
 break;
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -348,6 +348,11 @@
 ConsumeAnnotationToken();
 return StmtError();
 
+  case tok::annot_pragma_fenv_access:
+ProhibitAttributes(Attrs);
+HandlePragmaFEnvAccess();
+return StmtEmpty();
+
   case tok::annot_pragma_opencl_extension:
 ProhibitAttributes(Attrs);
 HandlePragmaOpenCLExtension();
@@ -914,6 +919,9 @@
 case tok::annot_pragma_fp:
   HandlePragmaFP();
   break;
+case tok::annot_pragma_fenv_access:
+  HandlePragmaFEnvAccess();
+  break;
 case tok::annot_pragma_ms_pointers_to_members:
   HandlePragmaMSPointersToMembers();
   break;
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -106,8 +106,19 @@
 tok::OnOffSwitch OOS;
 if (PP.LexOnOffSwitch(OOS))
  return;
-if (OOS == tok::OOS_ON)
+if (OOS == tok::OOS_ON) {
   PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
+
+  MutableArrayRef Toks(PP.getPreprocessorAllocator().Allocate(1),
+1);
+  Toks[0].startToken();
+  Toks[0].setKind(tok::annot_pragma_fenv_access);
+  Toks[0].setLocation(Tok.getLocation());
+  Toks[0].setAnnotationEndLoc(Tok.getLocation());
+  Toks[0].setAnnotationValue(reinterpret_cast(
+   static_cast(OOS)));
+  PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true);
+}
   }
 };
 
@@ -591,6 +602,30 @@
   ConsumeAnnotationToken();
 }
 
+void Parser::HandlePragmaFEnvAccess() {
+  assert(Tok.is(tok::annot_pragma_fenv_access));
+  tok::OnOffSwitch OOS =
+static_cast(
+reinterpret_cast(Tok.getAnnotationValue()));
+
+  LangOptions::FEnvAccessModeKind FPC;
+  switch (OOS) {
+  case tok::OOS_ON:
+FPC = LangOptions::FEA_On;
+break;
+  case tok::OOS_OFF:
+FPC = LangOptions::FEA_Off;
+break;
+  case tok::OOS_DEFAULT:
+FPC = LangOptions::FEA_Off;
+break;
+  }
+
+  Actions.ActOnPragmaFEnvAccess(FPC);
+  ConsumeAnnotationToken();
+}
+
+
 StmtResult Parser::HandlePragmaCaptured()
 {
   assert(Tok.is(tok::annot_pragma_captured));
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -8433,6 +8433,10 @@
   /// \#pragma clang fp contract
   void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC);
 
+  /// ActOnPragmaFenvAccess - Called on well formed
+  /// \#pragma STDC FENV_ACCESS
+  void ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC);
+
   /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
   /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
   void AddAlignmentAttributesForRecord(RecordDecl *RD);
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -668,6 +668,10 @@
   void HandlePragmaFPContract();
 
   /// Handle the annotation token produced for
+  /// #pragma STDC FENV_ACCESS...
+  void HandlePragmaFEnvAccess();
+
+  /// \brief Handle the annotation token produced f

[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D49794#1182078, @yvvan wrote:

> I already mentioned in the review inherited by this one that this way covers 
> also loaded plugins with different consumers. So let's assume that driver 
> loads clang-tidy and some other plugins and runs over each file in the 
> project.
>  It makes sense not to include clang-tidy diagnostics coming from headers, at 
> least for third-party headers (you can still run clang over specific headers 
> themselves to get diagnostics for them).


For third-party headers, sure (as I mentioned before, we already use -isystem 
include directive for third party libs to achieve the same thing). But ignoring 
diagnostics from **all** the headers does not seem particularly useful.


https://reviews.llvm.org/D49794



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


[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

And we already saw, that -isystem is not the best choice for that. And by the 
way - clang-tidy has this filtering in consumer which does not exist in it's 
plugin-mode so it spits all system diagnostics all the time...


https://reviews.llvm.org/D49794



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


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Its not that it needs to be 'at least 9 bits', IMO 9 bits was too small as well.

What I'd prefer to this solution is similar to what John McCall said on 
PR38356: Add the size to the trailing allocated space.  Check out the 'create' 
methods for all of these, and make the first sizeof(void*) bytes be the size.  
I'd also suggest using 1 bit in CastExprBits to be a 'is base path empty', so 
that you don't have to allocate for it at all.




Comment at: include/clang/AST/Expr.h:2796
+  unsigned BasePathSize : 14;
+
   bool CastConsistency() const;

The comment there is wrong.  It was wrong at 9 bits as well, since it cannot 
handle our implimits.  I'd like to see if you can find where the implimit for 
direct/indirect bases is stored, and write a static-assert for it here.



Comment at: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp:1
+// RUN: %clang_cc1 %s -emit-llvm -o -
+

First, most of this test can be further simplified.  Second, I'd like to see a 
test that actually tests the limit without hitting the recursive template limit.



Comment at: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp:20
+  // not fit it, so we are testing that we do fit it.
+  // If -ftemplate-depth= is provided, larger values (4096 and up) cause 
crashes
+  // elsewhere.

Shouldn't we cover 16k?  


Repository:
  rC Clang

https://reviews.llvm.org/D50050



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


[PATCH] D49991: [clangd] Do not build AST if no diagnostics were requested

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 158234.
ilya-biryukov added a comment.

- Rebase onto head


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49991

Files:
  clangd/TUScheduler.cpp


Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -391,19 +391,22 @@
   }
 }
 
+// We only need to build the AST if diagnostics were requested.
+if (WantDiags == WantDiagnostics::No)
+  return;
+
 // Get the AST for diagnostics.
 llvm::Optional> AST = IdleASTs.take(this);
 if (!AST) {
   llvm::Optional NewAST =
   buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
   AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : 
nullptr;
 }
-
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
 // Note *AST can be still be null if buildAST fails.
-if (WantDiags != WantDiagnostics::No && *AST) {
+if (*AST) {
   OnUpdated((*AST)->getDiagnostics());
   DiagsWereReported = true;
 }


Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -391,19 +391,22 @@
   }
 }
 
+// We only need to build the AST if diagnostics were requested.
+if (WantDiags == WantDiagnostics::No)
+  return;
+
 // Get the AST for diagnostics.
 llvm::Optional> AST = IdleASTs.take(this);
 if (!AST) {
   llvm::Optional NewAST =
   buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
   AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : nullptr;
 }
-
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
 // Note *AST can be still be null if buildAST fails.
-if (WantDiags != WantDiagnostics::No && *AST) {
+if (*AST) {
   OnUpdated((*AST)->getDiagnostics());
   DiagsWereReported = true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In https://reviews.llvm.org/D49114#1182071, @0x8000- wrote:

> The state of this patch:
>
> - user interface is as agreed-upon, giving end-users the capability to filter 
> out floats and ints as it makes sense for their code base
> - code is clean
> - documentation is up to date
> - default ignore lists are sensible
>
>   There is one outstanding improvement request - to combine the two 
> float/double lists into a single APFloat but that requires more refactoring 
> outside this check and the benefit lies mainly in a future extensibility and 
> the saving of a couple hundred bytes.
>
>   @aaron.ballman - can we get this merged as-is and improve it later? I'd 
> like to see this check available in Clang7.


In my opinion this check is in good shape. 
One thing that came to my mind: hexadecimal floating point literals. They 
should work out of the box, but could you add a test that they are recognized 
correctly?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-07-31 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 3 inline comments as done.
gtbercea added a comment.

Answers to comments.




Comment at: include/clang/Driver/Compilation.h:312
+  /// \param skipBundler - bool value set once by the driver.
+  void setSkipOffloadBundler(bool skipBundler);
+

sfantao wrote:
> gtbercea wrote:
> > sfantao wrote:
> > > Why is this a property of the compilation and not of a set of actions 
> > > referring to a given target? That would allow one to combine in the same 
> > > compilation targets requiring the bundler and targets that wouldn't. 
> > This was a way to pass this information to the OpenMP NVPTX device 
> > toolchain.
> > 
> > Both the Driver OpenMP NVPTX toolchain need to agree on the usage of the 
> > new scheme (proposed in this patch) or the old scheme (the one that is in 
> > the compiler today).
> > 
> > 
> I understand, but the way I see it is that it is the toolchain that skips the 
> bundler not the compilation. I understand that as of this patch, you skip 
> only if there is a single nvptx target. If you have more than one target, as 
> some tests do, some toolchains will still need the bundler. So, we are making 
> what happens with the nvptx target dependent of other toolchains. Is this an 
> intended effect of this patch?
Bundler is skipped only for the OpenMP NVPTX toolchain. I'm not sure what you 
mean by "other toolchain".



Comment at: lib/Driver/Compilation.cpp:276
+void Compilation::setSkipOffloadBundler(bool skipBundler) {
+  skipOffloadBundler = skipBundler;
+}

sfantao wrote:
> gtbercea wrote:
> > sfantao wrote:
> > > Given the logic you have below, you are assuming this is not set to false 
> > > ever. It would be wise to get an assertion here in case you end up having 
> > > toolchains skipping and others don't. If that is just not supported a 
> > > diagnostic should be added instead.
> > > 
> > > The convention is that local variables use CamelCase.
> > The checks I added in the Driver will set this flag to true if all 
> > toolchains Clang offloads to support the skipping of the bundler/unbundler 
> > for object files. Currently only NVPTX toolchain can skip the 
> > bundler/unbundler for object files so the code path in this patch will be 
> > taken only for:
> > 
> > -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
> Ok, if that is the case, just add an assertion here.
If one of the toolchains in the list of toolchains can't skip then none of them 
skip. If all can skip then they all skip. What assertion would you like me to 
add?



Comment at: lib/Driver/Driver.cpp:2943
+}
+  }
+

sfantao wrote:
> gtbercea wrote:
> > sfantao wrote:
> > > Can you just implement this check in the definition of `Compilation: 
> > > canSkipClangOffloadBundler` and get rid of `setSkipOffloadBundler`? All 
> > > the requirted information is already in `Compilation` under 
> > > `C.getInputArgs()`.
> > The driver needs to have the result of this check available. The flag is 
> > passed to the step which adds host-device dependencies. If the bundler can 
> > be skipped then the unbundling action is not required.
> > 
> > I guess this could be implemented in Compilation. Even so I would like it 
> > to happen only once like it does here and not every time someone queries 
> > the "can I skip the bundler" flag.
> > 
> > I wanted this check to happen only once hence why I put in on the driver 
> > side. The result of this check needs to be available in Driver.cpp and in 
> > Cuda.cpp files (see usage in this patch). Compilation keeps track of the 
> > flag because skipping the bundler is an all or nothing flag: you can skip 
> > the bundler/unbundler for object files if and only if all toolchains you 
> > are offloading to can skip it.
> > 
> Right, in these circumstances "can skip bundler" is the same as "do I have a 
> single toolchain" and "is that toolchain nvptx". This is fairly inexpensive 
> to do, so I don't really see the need to record this state in the driver. It 
> will also be clearer what are the conditions for which you skip the bundler.
That is true for now but if more toolchains get added to the list of toolchains 
that can skip the bundler then you want to factor it out and make it happen 
only once in a toolchain-independent point in the code. Otherwise you will 
carry that list of toolchains everywhere in the code where you need to do the 
check.

Also if you are to do this at toolchain level you will not be able to check if 
the other toolchains were able to skip or not. For now ALL toolchains must skip 
or ALL toolchains don't skip the bundler.



Comment at: lib/Driver/ToolChains/Cuda.cpp:496
+  ? CudaVirtualArchToString(VirtualArchForCudaArch(gpu_arch))
+  : GPUArch.str().c_str();
+  const char *PtxF =

sfantao wrote:
> Why don't create fatbins instead of cubins in all cases. For the purposes of 
> OpenMP they are equ

[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Anyways, if c++ part does not seem relevant I'm fine if we only have libclang 
part from https://reviews.llvm.org/D48116.

BTW I don't remember if you answered something to my suggestion of adding flag 
-ithird-party as an alternative to -isystem which does not lock files and helps 
to filter diagnostics, etc.


https://reviews.llvm.org/D49794



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


[PATCH] D42762: Rewrite the VS Integration Scripts

2018-07-31 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Thanks for pushing this through!

Will you upload the vsix to the marketplace? (Use the 
llvm-vs-code-extensi...@google.com account, which despite the name is also used 
for the clang-format vs plugin etc.)

Then I can update the docs to point at it.


Repository:
  rC Clang

https://reviews.llvm.org/D42762



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


[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D49794#1182220, @yvvan wrote:

> And we already saw, that -isystem is not the best choice for that.


Are you referring to the file-locking on Windows? 
Any other reasons why the -isystem trick might be non-ideal?

> And by the way - clang-tidy has this filtering in consumer which does not 
> exist in it's plugin-mode so it spits all system diagnostics all the time...

I would still argue against adding this option in the current form to the 
compiler. I don't see how that might be useful to non-clang-tidy, 
non-editor-integration users.

What's the 'plugin mode' of clang-tidy? I don't seem to able to Google it :-)


https://reviews.llvm.org/D49794



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


[PATCH] D47618: __c11_atomic_load's _Atomic can be const

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

LGTM from OpenCL side! Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47618



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


[clang-tools-extra] r338378 - [clangd] Do not build AST if no diagnostics were requested

2018-07-31 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jul 31 06:45:37 2018
New Revision: 338378

URL: http://llvm.org/viewvc/llvm-project?rev=338378&view=rev
Log:
[clangd] Do not build AST if no diagnostics were requested

Summary:
It can be removed from the cache before the first access anyway, so
building it can be a waste of time.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits

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

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

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=338378&r1=338377&r2=338378&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Tue Jul 31 06:45:37 2018
@@ -391,6 +391,10 @@ void ASTWorker::update(
   }
 }
 
+// We only need to build the AST if diagnostics were requested.
+if (WantDiags == WantDiagnostics::No)
+  return;
+
 // Get the AST for diagnostics.
 llvm::Optional> AST = IdleASTs.take(this);
 if (!AST) {
@@ -398,12 +402,11 @@ void ASTWorker::update(
   buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
   AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : 
nullptr;
 }
-
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
 // Note *AST can be still be null if buildAST fails.
-if (WantDiags != WantDiagnostics::No && *AST) {
+if (*AST) {
   OnUpdated((*AST)->getDiagnostics());
   DiagsWereReported = true;
 }


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


[PATCH] D49991: [clangd] Do not build AST if no diagnostics were requested

2018-07-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338378: [clangd] Do not build AST if no diagnostics were 
requested (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D49991

Files:
  clang-tools-extra/trunk/clangd/TUScheduler.cpp


Index: clang-tools-extra/trunk/clangd/TUScheduler.cpp
===
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp
@@ -391,19 +391,22 @@
   }
 }
 
+// We only need to build the AST if diagnostics were requested.
+if (WantDiags == WantDiagnostics::No)
+  return;
+
 // Get the AST for diagnostics.
 llvm::Optional> AST = IdleASTs.take(this);
 if (!AST) {
   llvm::Optional NewAST =
   buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
   AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : 
nullptr;
 }
-
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
 // Note *AST can be still be null if buildAST fails.
-if (WantDiags != WantDiagnostics::No && *AST) {
+if (*AST) {
   OnUpdated((*AST)->getDiagnostics());
   DiagsWereReported = true;
 }


Index: clang-tools-extra/trunk/clangd/TUScheduler.cpp
===
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp
@@ -391,19 +391,22 @@
   }
 }
 
+// We only need to build the AST if diagnostics were requested.
+if (WantDiags == WantDiagnostics::No)
+  return;
+
 // Get the AST for diagnostics.
 llvm::Optional> AST = IdleASTs.take(this);
 if (!AST) {
   llvm::Optional NewAST =
   buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
   AST = NewAST ? llvm::make_unique(std::move(*NewAST)) : nullptr;
 }
-
 // We want to report the diagnostics even if this update was cancelled.
 // It seems more useful than making the clients wait indefinitely if they
 // spam us with updates.
 // Note *AST can be still be null if buildAST fails.
-if (WantDiags != WantDiagnostics::No && *AST) {
+if (*AST) {
   OnUpdated((*AST)->getDiagnostics());
   DiagsWereReported = true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50060: [clang-tidy] add all clang-tidy modules to plugin

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: alexfh, aaron.ballman, hokein.
Herald added subscribers: cfe-commits, xazax.hun, mgorny, srhines.

This patch addresses PR38359 and adds all existing clang-tidy
modules to the plugin that can be used together with libclang.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50060

Files:
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/plugin/ClangTidyPlugin.cpp

Index: clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -78,26 +78,51 @@
 namespace clang {
 namespace tidy {
 
+// This anchor is used to force the linker to link the AbseilModule.
+extern volatile int AbseilModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
+AbseilModuleAnchorSource;
+
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
+// This anchor is used to force the linker to link the BoostModule.
+extern volatile int BoostModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
+BoostModuleAnchorSource;
+
 // This anchor is used to force the linker to link the CERTModule.
 extern volatile int CERTModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
-// This anchor is used to force the linker to link the LLVMModule.
-extern volatile int LLVMModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
-LLVMModuleAnchorSource;
-
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
+// This anchor is used to force the linker to link the FuchsiaModule.
+extern volatile int FuchsiaModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
+FuchsiaModuleAnchorSource;
+
 // This anchor is used to force the linker to link the GoogleModule.
 extern volatile int GoogleModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
 GoogleModuleAnchorSource;
 
+// This anchor is used to force the linker to link the HICPPModule.
+extern volatile int HICPPModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
+HICPPModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LLVMModule.
+extern volatile int LLVMModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
+LLVMModuleAnchorSource;
+
 // This anchor is used to force the linker to link the MiscModule.
 extern volatile int MiscModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
@@ -111,7 +136,12 @@
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
-  MPIModuleAnchorSource;
+MPIModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ObjCModule.
+extern volatile int ObjCModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
+ObjCModuleAnchorSource;
 
 // This anchor is used to force the linker to link the PerformanceModule.
 extern volatile int PerformanceModuleAnchorSource;
@@ -128,10 +158,10 @@
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
 ReadabilityModuleAnchorSource;
 
-// This anchor is used to force the linker to link the ObjCModule.
-extern volatile int ObjCModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
-ObjCModuleAnchorSource;
+// This anchor is used to force the linker to link the ZirconModule.
+extern volatile int ZirconModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =
+ZirconModuleAnchorSource;
 
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/plugin/CMakeLists.txt
===
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -8,19 +8,23 @@
   clangFrontend
   clangSema
   clangTidy
-  clangTidyAndroidModule
   clangTidyAbseilModule
+  clangTidyAndroidModule
   clangTidyBoostModule
+  clangTidyBugproneModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
+  clangTidyFuchsiaModule
   clangTidyGoogleModule
+  clangTidyHICPPModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
+  clangTidyZirconModule
   clangTooling
   )

[PATCH] D50060: [clang-tidy] add all clang-tidy modules to plugin

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I reordered the anchoring list to be in alphabetical order as well!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50060



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


[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

In https://reviews.llvm.org/D49794#1182272, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D49794#1182220, @yvvan wrote:
>
> > And we already saw, that -isystem is not the best choice for that.
>
>
> Are you referring to the file-locking on Windows? 
>  Any other reasons why the -isystem trick might be non-ideal?


File locking is the first one. Another one comes with "plugin mode" of tidy.

>> And by the way - clang-tidy has this filtering in consumer which does not 
>> exist in it's plugin-mode so it spits all system diagnostics all the time...
> 
> I would still argue against adding this option in the current form to the 
> compiler. I don't see how that might be useful to non-clang-tidy, 
> non-editor-integration users.
> 
> What's the 'plugin mode' of clang-tidy? I don't seem to able to Google it :-)

Clang tidy is not only a standalone tool but also a plugin. It's almost never 
used this way (but we do that in Qt Creator to combine it with Clazy) and it 
also seems that some of the recent checks are added only to standalone tool 
(which is easy to fix).
Being loaded into clang as plugin it does not support most of clang-tidy 
command line options and is not able to filter system includes. I'm not sure 
it's possible to fix both of these issues (and probably some other).


https://reviews.llvm.org/D49794



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


[PATCH] D46822: [RISCV] Add driver for riscv32-unknown-elf baremetal target

2018-07-31 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC338385: [RISCV] Add driver for riscv32-unknown-elf baremetal 
target (authored by xbolva00, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46822

Files:
  lib/Driver/CMakeLists.txt
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/RISCV.cpp
  lib/Driver/ToolChains/RISCV.h
  test/Driver/Inputs/basic_riscv32_tree/bin/riscv32-unknown-elf-ld
  
test/Driver/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/crtbegin.o
  
test/Driver/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/crtend.o
  
test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/include/c++/8.0.1/.keep
  test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib/crt0.o
  test/Driver/riscv32-toolchain.c

Index: lib/Driver/CMakeLists.txt
===
--- lib/Driver/CMakeLists.txt
+++ lib/Driver/CMakeLists.txt
@@ -57,6 +57,7 @@
   ToolChains/NetBSD.cpp
   ToolChains/OpenBSD.cpp
   ToolChains/PS4CPU.cpp
+  ToolChains/RISCV.cpp
   ToolChains/Solaris.cpp
   ToolChains/TCE.cpp
   ToolChains/WebAssembly.cpp
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -37,6 +37,7 @@
 #include "ToolChains/NetBSD.h"
 #include "ToolChains/OpenBSD.h"
 #include "ToolChains/PS4CPU.h"
+#include "ToolChains/RISCV.h"
 #include "ToolChains/Solaris.h"
 #include "ToolChains/TCE.h"
 #include "ToolChains/WebAssembly.h"
@@ -4399,6 +4400,10 @@
   case llvm::Triple::avr:
 TC = llvm::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+TC = llvm::make_unique(*this, Target, Args);
+break;
   default:
 if (Target.getVendor() == llvm::Triple::Myriad)
   TC = llvm::make_unique(*this, Target,
Index: lib/Driver/ToolChains/RISCV.h
===
--- lib/Driver/ToolChains/RISCV.h
+++ lib/Driver/ToolChains/RISCV.h
@@ -0,0 +1,57 @@
+//===--- RISCV.h - RISCV ToolChain Implementations --*- 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_LIB_DRIVER_TOOLCHAINS_RISCV_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_RISCV_H
+
+#include "Gnu.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY RISCVToolChain : public Generic_ELF {
+public:
+  RISCVToolChain(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args);
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void
+  addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const override;
+
+protected:
+  Tool *buildLinker() const override;
+};
+
+} // end namespace toolchains
+
+namespace tools {
+namespace RISCV {
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+  Linker(const ToolChain &TC) : GnuTool("RISCV::Linker", "ld", TC) {}
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+} // end namespace RISCV
+} // end namespace tools
+
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_RISCV_H
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1877,7 +1877,8 @@
 
   static const char *const RISCV32LibDirs[] = {"/lib", "/lib32"};
   static const char *const RISCVTriples[] = {"riscv32-unknown-linux-gnu",
- "riscv64-unknown-linux-gnu"};
+ "riscv64-unknown-linux-gnu",
+ "riscv32-unknown-elf"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
   static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",
Index: lib/Driver/ToolChains/RISCV.cpp
===
--- lib/Driver/ToolChains/RISCV.cpp
+++ lib/Driver/ToolChains/RISCV.cpp
@@ -0,0 +

r338385 - [RISCV] Add driver for riscv32-unknown-elf baremetal target

2018-07-31 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Tue Jul 31 07:21:46 2018
New Revision: 338385

URL: http://llvm.org/viewvc/llvm-project?rev=338385&view=rev
Log:
[RISCV] Add driver for riscv32-unknown-elf baremetal target

Summary:
This patch adds a driver for the baremetal RISC-V target (i.e. 
riscv32-unknown-elf). For reference, D39963 added basic target info and added 
support for riscv32-linux-unknown-elf.

Patch by: asb (Alex Bradbury)

Reviewers: efriedma, phosek, apazos, espindola, mgrang

Reviewed By: mgrang

Subscribers: jrtc27, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, 
emaste, mgorny, arichardson, rbar, johnrusso, simoncook, jordy.potman.lists, 
sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, 
cfe-commits

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

Added:
cfe/trunk/lib/Driver/ToolChains/RISCV.cpp
cfe/trunk/lib/Driver/ToolChains/RISCV.h
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/bin/
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/bin/riscv32-unknown-elf-ld  
 (with props)
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/lib/
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/lib/gcc/
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/

cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/

cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/crtbegin.o

cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/crtend.o
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/include/

cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/include/c++/

cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/include/c++/8.0.1/

cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/include/c++/8.0.1/.keep
cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib/

cfe/trunk/test/Driver/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib/crt0.o
Modified:
cfe/trunk/lib/Driver/CMakeLists.txt
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c

Modified: cfe/trunk/lib/Driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=338385&r1=338384&r2=338385&view=diff
==
--- cfe/trunk/lib/Driver/CMakeLists.txt (original)
+++ cfe/trunk/lib/Driver/CMakeLists.txt Tue Jul 31 07:21:46 2018
@@ -57,6 +57,7 @@ add_clang_library(clangDriver
   ToolChains/NetBSD.cpp
   ToolChains/OpenBSD.cpp
   ToolChains/PS4CPU.cpp
+  ToolChains/RISCV.cpp
   ToolChains/Solaris.cpp
   ToolChains/TCE.cpp
   ToolChains/WebAssembly.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=338385&r1=338384&r2=338385&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Jul 31 07:21:46 2018
@@ -37,6 +37,7 @@
 #include "ToolChains/NetBSD.h"
 #include "ToolChains/OpenBSD.h"
 #include "ToolChains/PS4CPU.h"
+#include "ToolChains/RISCV.h"
 #include "ToolChains/Solaris.h"
 #include "ToolChains/TCE.h"
 #include "ToolChains/WebAssembly.h"
@@ -4399,6 +4400,10 @@ const ToolChain &Driver::getToolChain(co
   case llvm::Triple::avr:
 TC = llvm::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+TC = llvm::make_unique(*this, Target, 
Args);
+break;
   default:
 if (Target.getVendor() == llvm::Triple::Myriad)
   TC = llvm::make_unique(*this, Target,

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=338385&r1=338384&r2=338385&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Jul 31 07:21:46 2018
@@ -1877,7 +1877,8 @@ void Generic_GCC::GCCInstallationDetecto
 
   static const char *const RISCV32LibDirs[] = {"/lib", "/lib32"};
   static const char *const RISCVTriples[] = {"riscv32-unknown-linux-gnu",
- "riscv64-unknown-linux-gnu"};
+ "riscv64-unknown-linux-gnu",
+ "riscv32-unknown-elf"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
   static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",

Added: cfe/trunk/lib/Driver/ToolChains/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/

[PATCH] D50068: [AArch64][ARM] Add Armv8.4-A tests

2018-07-31 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: samparker, olista01, john.brawn, ab, 
t.p.northover.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

This adds tests for Armv8.4-A, and also some v8.2 and v8.3 tests that were 
missed in previous upstreaming exercises.


https://reviews.llvm.org/D50068

Files:
  lib/Basic/Targets/ARM.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/arm-cortex-cpus.c

Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -287,13 +287,62 @@
 // RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V82A-FP16 %s
 // CHECK-V82A-FP16: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "generic" {{.*}}"-target-feature" "+fullfp16"
 
+// RUN: %clang -target armv8.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A %s
+// RUN: %clang -target arm -march=armv8.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A %s
+// RUN: %clang -target arm -march=armv8.3-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A %s
+// RUN: %clang -target arm -march=armv8.3a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A %s
+// RUN: %clang -target armv8.3a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A %s
+// RUN: %clang -target arm -march=armv8.3a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A %s
+// RUN: %clang -target arm -mlittle-endian -march=armv8.3-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V83A %s
+// CHECK-V83A: "-cc1"{{.*}} "-triple" "armv8.3{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target armebv8.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V83A %s
+// RUN: %clang -target armv8.3a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V83A %s
+// RUN: %clang -target armeb -march=armebv8.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V83A %s
+// RUN: %clang -target armeb -march=armebv8.3-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V83A %s
+// RUN: %clang -target arm -march=armebv8.3a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V83A %s
+// RUN: %clang -target arm -march=armebv8.3-a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V83A %s
+// CHECK-BE-V83A: "-cc1"{{.*}} "-triple" "armebv8.3{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target armv8a-linux-eabi -march=armv8.3-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V83A-FP16 %s
+// CHECK-V83A-FP16: "-cc1"{{.*}} "-triple" "armv8.3{{.*}}" "-target-cpu" "generic" {{.*}}"-target-feature" "+fullfp16"
+
+// RUN: %clang -target armv8.4a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A %s
+// RUN: %clang -target arm -march=armv8.4a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A %s
+// RUN: %clang -target arm -march=armv8.4-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A %s
+// RUN: %clang -target arm -march=armv8.4a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A %s
+// RUN: %clang -target armv8.4a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A %s
+// RUN: %clang -target arm -march=armv8.4a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A %s
+// RUN: %clang -target arm -mlittle-endian -march=armv8.4-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V84A %s
+// CHECK-V84A: "-cc1"{{.*}} "-triple" "armv8.4{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target armebv8.4a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V84A %s
+// RUN: %clang -target armv8.4a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V84A %s
+// RUN: %clang -target armeb -march=armebv8.4a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V84A %s
+// RUN: %clang -target armeb -march=armebv8.4-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V84A %s
+// RUN: %clang -target arm -march=armebv8.4a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V84A %s
+// RUN: %clang -target arm -march=armebv8.4-a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V84A %s
+// CHECK-BE-V84A: "-cc1"{{.*}} "-triple" "armebv8.4{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target armv8a-linux-eabi -march=armv8.4-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V84A-FP16 %s
+// CHECK-V84A-FP16: "-cc1"{{.*}} "-triple" "armv8.4{{.*}}" "-target-cpu" "generic" {{.*}}"-target-feature" "+fullfp16"
+
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
 // RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
 // RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
 // CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target

[PATCH] D49794: [libclang] Allow skipping warnings from all included files

2018-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D49794#1182296, @yvvan wrote:

> Clang tidy is not only a standalone tool but also a plugin. It's almost never 
> used this way (but we do that in Qt Creator to combine it with Clazy) and it 
> also seems that some of the recent checks are added only to standalone tool 
> (which is easy to fix).
>  Being loaded into clang as plugin it does not support most of clang-tidy 
> command line options and is not able to filter system includes. I'm not sure 
> it's possible to fix both of these issues (and probably some other).


Oh, I see, thanks for the pointers. Not related to this discussion, it seems 
reasonable to allow all the same options to be passed into clang-tidy plugin, 
not sure if that's easy or hard in principle to fix it.

The added option seems like a workaround for a bug in clang-tidy and a windows 
locking bug (which is blocker for tools like clangd and libclang-based 
integrations, IMO). I would still vouch for fixing the bugs than adding flags 
that try to workaround those bugs.


https://reviews.llvm.org/D49794



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


[PATCH] D50060: [clang-tidy] add all clang-tidy modules to plugin

2018-07-31 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50060



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


[PATCH] D49953: [compiler-rt] Add a routine to specify the mode used when creating profile dirs.

2018-07-31 Thread Matt Davis via Phabricator via cfe-commits
mattd updated this revision to Diff 158272.
mattd added a comment.

- Renamed the test output and test directory to clean up the more specific test 
example.


https://reviews.llvm.org/D49953

Files:
  lib/profile/InstrProfilingUtil.c
  lib/profile/InstrProfilingUtil.h
  test/profile/instrprof-set-dir-mode.c
  test/profile/instrprof-set-dir-mode2.c

Index: test/profile/instrprof-set-dir-mode2.c
===
--- /dev/null
+++ test/profile/instrprof-set-dir-mode2.c
@@ -0,0 +1,58 @@
+// UNSUPPORTED: windows
+// RUN: %clang_pgogen -o %t.bin %s -DTESTPATH=\"%t.dir\"
+// rm -rf %t.dir
+// RUN: %run %t.bin
+
+#include 
+#include 
+#include 
+#include 
+
+void __llvm_profile_set_dir_mode(unsigned Mode);
+unsigned __llvm_profile_get_dir_mode(void);
+void __llvm_profile_recursive_mkdir(char *Path);
+
+static char *join(const char *Dir, const char *Subdir) {
+  char *Joined = malloc(strlen(Dir) + strlen(Subdir) + 2);
+  if (!Joined)
+return NULL;
+  sprintf(Joined, "%s/%s", Dir, Subdir);
+  return Joined;
+}
+
+static int test(unsigned Mode, const char *Subdir) {
+  int Ret = 0;
+
+  /* Truncate the path removing the filename and adding Subdir. */
+  char *Dir;
+  if (!(Dir = join(TESTPATH, Subdir)))
+return -1;
+
+  /* Create a dir and set the mode accordingly. */
+  __llvm_profile_set_dir_mode(Mode);
+  __llvm_profile_recursive_mkdir(Dir);
+
+  if (Mode != __llvm_profile_get_dir_mode())
+Ret = -1;
+  else {
+const unsigned Expected = ~umask(0) & Mode;
+struct stat DirSt;
+if (stat(Dir, &DirSt) == -1)
+  Ret = -1;
+else if (DirSt.st_mode != Expected) {
+  printf("Modes do not match: Expected %o but found %o (%s)\n", Expected,
+ DirSt.st_mode, Dir);
+  Ret = -1;
+}
+  }
+
+  free(Dir);
+  return Ret;
+}
+
+int main(int argc, const char *argv[]) {
+  if (test(S_IFDIR | 0777, "/foo/bar/baz/") ||
+  test(S_IFDIR | 0666, "/foo/bar/qux/"))
+return -1;
+  return 0;
+}
Index: test/profile/instrprof-set-dir-mode.c
===
--- /dev/null
+++ test/profile/instrprof-set-dir-mode.c
@@ -0,0 +1,17 @@
+// RUN: %clang_pgogen -o %t %s
+// RUN: %run %t
+
+void __llvm_profile_set_dir_mode(unsigned Mode);
+unsigned __llvm_profile_get_dir_mode(void);
+
+int main(void) {
+  __llvm_profile_set_dir_mode(0777);
+  if (__llvm_profile_get_dir_mode() != 0777)
+return -1;
+
+  __llvm_profile_set_dir_mode(0666);
+  if (__llvm_profile_get_dir_mode() != 0666)
+return -1;
+
+  return 0;
+}
Index: lib/profile/InstrProfilingUtil.h
===
--- lib/profile/InstrProfilingUtil.h
+++ lib/profile/InstrProfilingUtil.h
@@ -16,6 +16,12 @@
 /*! \brief Create a directory tree. */
 void __llvm_profile_recursive_mkdir(char *Pathname);
 
+/*! Set the mode used when creating profile directories. */
+void __llvm_profile_set_dir_mode(unsigned Mode);
+
+/*! Return the directory creation mode. */
+unsigned __llvm_profile_get_dir_mode(void);
+
 int lprofLockFd(int fd);
 int lprofUnlockFd(int fd);
 
Index: lib/profile/InstrProfilingUtil.c
===
--- lib/profile/InstrProfilingUtil.c
+++ lib/profile/InstrProfilingUtil.c
@@ -35,6 +35,8 @@
 #include "InstrProfiling.h"
 #include "InstrProfilingUtil.h"
 
+COMPILER_RT_WEAK unsigned lprofDirMode = 0755;
+
 COMPILER_RT_VISIBILITY
 void __llvm_profile_recursive_mkdir(char *path) {
   int i;
@@ -47,12 +49,19 @@
 #ifdef _WIN32
 _mkdir(path);
 #else
-mkdir(path, 0755); /* Some of these will fail, ignore it. */
+/* Some of these will fail, ignore it. */
+mkdir(path, __llvm_profile_get_dir_mode());
 #endif
 path[i] = save;
   }
 }
 
+COMPILER_RT_VISIBILITY
+void __llvm_profile_set_dir_mode(unsigned Mode) { lprofDirMode = Mode; }
+
+COMPILER_RT_VISIBILITY
+unsigned __llvm_profile_get_dir_mode(void) { return lprofDirMode; }
+
 #if COMPILER_RT_HAS_ATOMICS != 1
 COMPILER_RT_VISIBILITY
 uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50060: [clang-tidy] add all clang-tidy modules to plugin

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 158278.
JonasToth added a comment.

- rebase


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50060

Files:
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/plugin/ClangTidyPlugin.cpp

Index: clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -78,26 +78,51 @@
 namespace clang {
 namespace tidy {
 
+// This anchor is used to force the linker to link the AbseilModule.
+extern volatile int AbseilModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
+AbseilModuleAnchorSource;
+
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
+// This anchor is used to force the linker to link the BoostModule.
+extern volatile int BoostModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
+BoostModuleAnchorSource;
+
 // This anchor is used to force the linker to link the CERTModule.
 extern volatile int CERTModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
-// This anchor is used to force the linker to link the LLVMModule.
-extern volatile int LLVMModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
-LLVMModuleAnchorSource;
-
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
+// This anchor is used to force the linker to link the FuchsiaModule.
+extern volatile int FuchsiaModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
+FuchsiaModuleAnchorSource;
+
 // This anchor is used to force the linker to link the GoogleModule.
 extern volatile int GoogleModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
 GoogleModuleAnchorSource;
 
+// This anchor is used to force the linker to link the HICPPModule.
+extern volatile int HICPPModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
+HICPPModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LLVMModule.
+extern volatile int LLVMModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
+LLVMModuleAnchorSource;
+
 // This anchor is used to force the linker to link the MiscModule.
 extern volatile int MiscModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
@@ -111,7 +136,12 @@
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
-  MPIModuleAnchorSource;
+MPIModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ObjCModule.
+extern volatile int ObjCModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
+ObjCModuleAnchorSource;
 
 // This anchor is used to force the linker to link the PerformanceModule.
 extern volatile int PerformanceModuleAnchorSource;
@@ -128,10 +158,10 @@
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
 ReadabilityModuleAnchorSource;
 
-// This anchor is used to force the linker to link the ObjCModule.
-extern volatile int ObjCModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
-ObjCModuleAnchorSource;
+// This anchor is used to force the linker to link the ZirconModule.
+extern volatile int ZirconModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =
+ZirconModuleAnchorSource;
 
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/plugin/CMakeLists.txt
===
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -8,19 +8,23 @@
   clangFrontend
   clangSema
   clangTidy
-  clangTidyAndroidModule
   clangTidyAbseilModule
+  clangTidyAndroidModule
   clangTidyBoostModule
+  clangTidyBugproneModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
+  clangTidyFuchsiaModule
   clangTidyGoogleModule
+  clangTidyHICPPModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
+  clangTidyZirconModule
   clangTooling
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r338393 - [clang-tidy] add all clang-tidy modules to plugin

2018-07-31 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Tue Jul 31 08:23:49 2018
New Revision: 338393

URL: http://llvm.org/viewvc/llvm-project?rev=338393&view=rev
Log:
[clang-tidy] add all clang-tidy modules to plugin

Summary:
This patch addresses PR38359 and adds all existing clang-tidy
modules to the plugin that can be used together with libclang.

Reviewers: alexfh, aaron.ballman, hokein, ilya-biryukov

Reviewed By: alexfh

Subscribers: srhines, mgorny, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp

Modified: clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt?rev=338393&r1=338392&r2=338393&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt Tue Jul 31 
08:23:49 2018
@@ -8,12 +8,15 @@ add_clang_library(clangTidyPlugin
   clangFrontend
   clangSema
   clangTidy
-  clangTidyAndroidModule
   clangTidyAbseilModule
+  clangTidyAndroidModule
   clangTidyBoostModule
+  clangTidyBugproneModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
+  clangTidyFuchsiaModule
   clangTidyGoogleModule
+  clangTidyHICPPModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
@@ -22,5 +25,6 @@ add_clang_library(clangTidyPlugin
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
+  clangTidyZirconModule
   clangTooling
   )

Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp?rev=338393&r1=338392&r2=338393&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp Tue Jul 31 
08:23:49 2018
@@ -78,26 +78,51 @@ static clang::FrontendPluginRegistry::Ad
 namespace clang {
 namespace tidy {
 
+// This anchor is used to force the linker to link the AbseilModule.
+extern volatile int AbseilModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
+AbseilModuleAnchorSource;
+
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
+// This anchor is used to force the linker to link the BoostModule.
+extern volatile int BoostModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
+BoostModuleAnchorSource;
+
 // This anchor is used to force the linker to link the CERTModule.
 extern volatile int CERTModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
-// This anchor is used to force the linker to link the LLVMModule.
-extern volatile int LLVMModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
-LLVMModuleAnchorSource;
-
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
+// This anchor is used to force the linker to link the FuchsiaModule.
+extern volatile int FuchsiaModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
+FuchsiaModuleAnchorSource;
+
 // This anchor is used to force the linker to link the GoogleModule.
 extern volatile int GoogleModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
 GoogleModuleAnchorSource;
 
+// This anchor is used to force the linker to link the HICPPModule.
+extern volatile int HICPPModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
+HICPPModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LLVMModule.
+extern volatile int LLVMModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
+LLVMModuleAnchorSource;
+
 // This anchor is used to force the linker to link the MiscModule.
 extern volatile int MiscModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
@@ -111,7 +136,12 @@ static int LLVM_ATTRIBUTE_UNUSED Moderni
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
-  MPIModuleAnchorSource;
+MPIModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ObjCModule.
+ex

[PATCH] D50060: [clang-tidy] add all clang-tidy modules to plugin

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338393: [clang-tidy] add all clang-tidy modules to plugin 
(authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50060

Files:
  clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp

Index: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -78,26 +78,51 @@
 namespace clang {
 namespace tidy {
 
+// This anchor is used to force the linker to link the AbseilModule.
+extern volatile int AbseilModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
+AbseilModuleAnchorSource;
+
+// This anchor is used to force the linker to link the AndroidModule.
+extern volatile int AndroidModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
+AndroidModuleAnchorSource;
+
+// This anchor is used to force the linker to link the BoostModule.
+extern volatile int BoostModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
+BoostModuleAnchorSource;
+
 // This anchor is used to force the linker to link the CERTModule.
 extern volatile int CERTModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
-// This anchor is used to force the linker to link the LLVMModule.
-extern volatile int LLVMModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
-LLVMModuleAnchorSource;
-
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
+// This anchor is used to force the linker to link the FuchsiaModule.
+extern volatile int FuchsiaModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
+FuchsiaModuleAnchorSource;
+
 // This anchor is used to force the linker to link the GoogleModule.
 extern volatile int GoogleModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
 GoogleModuleAnchorSource;
 
+// This anchor is used to force the linker to link the HICPPModule.
+extern volatile int HICPPModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
+HICPPModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LLVMModule.
+extern volatile int LLVMModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
+LLVMModuleAnchorSource;
+
 // This anchor is used to force the linker to link the MiscModule.
 extern volatile int MiscModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
@@ -111,7 +136,12 @@
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
-  MPIModuleAnchorSource;
+MPIModuleAnchorSource;
+
+// This anchor is used to force the linker to link the ObjCModule.
+extern volatile int ObjCModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
+ObjCModuleAnchorSource;
 
 // This anchor is used to force the linker to link the PerformanceModule.
 extern volatile int PerformanceModuleAnchorSource;
@@ -128,10 +158,10 @@
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
 ReadabilityModuleAnchorSource;
 
-// This anchor is used to force the linker to link the ObjCModule.
-extern volatile int ObjCModuleAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
-ObjCModuleAnchorSource;
+// This anchor is used to force the linker to link the ZirconModule.
+extern volatile int ZirconModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =
+ZirconModuleAnchorSource;
 
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
@@ -8,19 +8,23 @@
   clangFrontend
   clangSema
   clangTidy
-  clangTidyAndroidModule
   clangTidyAbseilModule
+  clangTidyAndroidModule
   clangTidyBoostModule
+  clangTidyBugproneModule
   clangTidyCERTModule
   clangTidyCppCoreGuidelinesModule
+  clangTidyFuchsiaModule
   clangTidyGoogleModule
+  clangTidyHICPPModule
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPer

[PATCH] D48714: [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 158282.
JonasToth added a comment.

rebase to master


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48714

Files:
  clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  test/clang-tidy/hicpp-exception-baseclass.cpp

Index: test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- test/clang-tidy/hicpp-exception-baseclass.cpp
+++ test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -2,6 +2,7 @@
 
 namespace std {
 class exception {};
+class invalid_argument : public exception {};
 } // namespace std
 
 class derived_exception : public std::exception {};
@@ -36,38 +37,38 @@
   try {
 throw non_derived_exception();
 // CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-MESSAGES: 10:1: note: type defined here
   } catch (non_derived_exception &e) {
   }
   throw non_derived_exception();
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-  // CHECK-MESSAGES: 9:1: note: type defined here
+  // CHECK-MESSAGES: 10:1: note: type defined here
 
 // FIXME: More complicated kinds of inheritance should be checked later, but there is
 // currently no way use ASTMatchers for this kind of task.
 #if 0
   // Handle private inheritance cases correctly.
   try {
 throw bad_inheritance();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 10:1: note: type defined here
+// CHECK MESSAGES: 11:1: note: type defined here
 throw no_good_inheritance();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 11:1: note: type defined here
+// CHECK MESSAGES: 12:1: note: type defined here
 throw really_creative();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-// CHECK MESSAGES: 12:1: note: type defined here
+// CHECK MESSAGES: 13:1: note: type defined here
   } catch (...) {
   }
   throw bad_inheritance();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 10:1: note: type defined here
+  // CHECK MESSAGES: 11:1: note: type defined here
   throw no_good_inheritance();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 11:1: note: type defined here
+  // CHECK MESSAGES: 12:1: note: type defined here
   throw really_creative();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-  // CHECK MESSAGES: 12:1: note: type defined here
+  // CHECK MESSAGES: 13:1: note: type defined here
 #endif
 }
 
@@ -91,7 +92,7 @@
   throw deep_hierarchy(); // Ok
 
   try {
-throw terrible_idea(); // Ok, but multiple inheritance isn't clean
+throw terrible_idea();  // Ok, but multiple inheritance isn't clean
   } catch (std::exception &e) { // Can be caught as std::exception, even with multiple inheritance
   }
   throw terrible_idea(); // Ok, but multiple inheritance
@@ -101,14 +102,14 @@
 template 
 void ThrowException() { throw T(); }
 // CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
+// CHECK-MESSAGES: 121:1: note: type defined here
 // CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
+// CHECK-MESSAGES: 121:1: note: type defined here
 // CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 123:1: note: type defined here
+// CHECK-MESSAGES: 124:1: note: type defined here
 // CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
 // CHECK-MESSAGES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-MESSAGES: 10:1: note: type defined here
 #define THROW_EXCEPTION(CLASS) ThrowException()
 #define THROW_BAD_EXCEPTION throw int(42);
 #define THROW_GOOD_EXCEPTION throw std::exception();
@@ -128,7 +129,7 @@
   // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std:

[PATCH] D48714: [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 158284.
JonasToth added a comment.
Herald added subscribers: kbarton, mgorny, nemanjai.

rebase to master


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48714

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/ConstCheck.cpp
  clang-tidy/cppcoreguidelines/ConstCheck.h
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-const.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-const-pointers-as-values.cpp
  test/clang-tidy/cppcoreguidelines-const-values.cpp

Index: test/clang-tidy/cppcoreguidelines-const-values.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-const-values.cpp
@@ -0,0 +1,557 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const %t
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared const
+np_local0 *= 2;
+  }
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+  const int *const p0_p_local1 = &p_local1;
+
+  int p_local2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared const
+  function_in_pointer(&p_local2);
+}
+
+void function_inout_ref(int &inout);
+void function_in_ref(const int &in);
+
+void some_reference_taking() {
+  int np_local0 = 42;
+  const int &r0_np_local0 = np_local0;
+  int &r1_np_local0 = np_local0;
+  r1_np_local0 = 43;
+  const int &r2_np_local0 = r1_np_local0;
+
+  int np_local1 = 42;
+  function_inout_ref(np_local1);
+
+  int p_local0 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+  const int &r0_p_local0 = p_local0;
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+  function_in_ref(p_local1);
+}
+
+double *non_const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const
+  double np_local0 = 24.4;
+
+  return &np_local0;
+}
+
+const double *const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const
+  double p_local1 = 24.4;
+  // CHECK-MESSAGES: 

[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 158285.
JonasToth added a comment.

- Merge branch 'master' into check_const


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/ConstCheck.cpp
  clang-tidy/cppcoreguidelines/ConstCheck.h
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-const.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-const-pointers-as-values.cpp
  test/clang-tidy/cppcoreguidelines-const-values.cpp

Index: test/clang-tidy/cppcoreguidelines-const-values.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-const-values.cpp
@@ -0,0 +1,557 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const %t
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared const
+np_local0 *= 2;
+  }
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+  const int *const p0_p_local1 = &p_local1;
+
+  int p_local2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared const
+  function_in_pointer(&p_local2);
+}
+
+void function_inout_ref(int &inout);
+void function_in_ref(const int &in);
+
+void some_reference_taking() {
+  int np_local0 = 42;
+  const int &r0_np_local0 = np_local0;
+  int &r1_np_local0 = np_local0;
+  r1_np_local0 = 43;
+  const int &r2_np_local0 = r1_np_local0;
+
+  int np_local1 = 42;
+  function_inout_ref(np_local1);
+
+  int p_local0 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+  const int &r0_p_local0 = p_local0;
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+  function_in_ref(p_local1);
+}
+
+double *non_const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const
+  double np_local0 = 24.4;
+
+  return &np_local0;
+}
+
+const double *const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const
+  double p_local1 = 24.4;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: varia

[PATCH] D48714: [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-07-31 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 158286.
JonasToth added a comment.

correct rebase.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48714

Files:
  clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  test/clang-tidy/hicpp-exception-baseclass.cpp

Index: test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- test/clang-tidy/hicpp-exception-baseclass.cpp
+++ test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -2,6 +2,7 @@
 
 namespace std {
 class exception {};
+class invalid_argument : public exception {};
 } // namespace std
 
 class derived_exception : public std::exception {};
@@ -36,38 +37,38 @@
   try {
 throw non_derived_exception();
 // CHECK-MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-MESSAGES: 10:1: note: type defined here
   } catch (non_derived_exception &e) {
   }
   throw non_derived_exception();
   // CHECK-MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-  // CHECK-MESSAGES: 9:1: note: type defined here
+  // CHECK-MESSAGES: 10:1: note: type defined here
 
 // FIXME: More complicated kinds of inheritance should be checked later, but there is
 // currently no way use ASTMatchers for this kind of task.
 #if 0
   // Handle private inheritance cases correctly.
   try {
 throw bad_inheritance();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 10:1: note: type defined here
+// CHECK MESSAGES: 11:1: note: type defined here
 throw no_good_inheritance();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 11:1: note: type defined here
+// CHECK MESSAGES: 12:1: note: type defined here
 throw really_creative();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-// CHECK MESSAGES: 12:1: note: type defined here
+// CHECK MESSAGES: 13:1: note: type defined here
   } catch (...) {
   }
   throw bad_inheritance();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 10:1: note: type defined here
+  // CHECK MESSAGES: 11:1: note: type defined here
   throw no_good_inheritance();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 11:1: note: type defined here
+  // CHECK MESSAGES: 12:1: note: type defined here
   throw really_creative();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-  // CHECK MESSAGES: 12:1: note: type defined here
+  // CHECK MESSAGES: 13:1: note: type defined here
 #endif
 }
 
@@ -91,7 +92,7 @@
   throw deep_hierarchy(); // Ok
 
   try {
-throw terrible_idea(); // Ok, but multiple inheritance isn't clean
+throw terrible_idea();  // Ok, but multiple inheritance isn't clean
   } catch (std::exception &e) { // Can be caught as std::exception, even with multiple inheritance
   }
   throw terrible_idea(); // Ok, but multiple inheritance
@@ -101,14 +102,14 @@
 template 
 void ThrowException() { throw T(); }
 // CHECK-MESSAGES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
+// CHECK-MESSAGES: 121:1: note: type defined here
 // CHECK-MESSAGES: [[@LINE-3]]:31: warning: throwing an exception whose type 'bad_generic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 120:1: note: type defined here
+// CHECK-MESSAGES: 121:1: note: type defined here
 // CHECK-MESSAGES: [[@LINE-5]]:31: warning: throwing an exception whose type 'exotic_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 123:1: note: type defined here
+// CHECK-MESSAGES: 124:1: note: type defined here
 // CHECK-MESSAGES: [[@LINE-7]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
 // CHECK-MESSAGES: [[@LINE-8]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-MESSAGES: 9:1: note: type defined here
+// CHECK-MESSAGES: 10:1: note: type defined here
 #define THROW_EXCEPTION(CLASS) ThrowException()
 #define THROW_BAD_EXCEPTION throw int(42);
 #define THROW_GOOD_EXCEPTION throw std::exception();
@@ -128,7 +129,7 @@
   // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::

[PATCH] D48436: [analyzer][UninitializedObjectChecker] Fixed a false negative by no longer filtering out certain constructor calls

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



Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:681-689
+Optional OtherObject =
+getObjectVal(OtherCtor, Context);
+if (!OtherObject)
+  continue;
+
+// If the CurrentObject is a field of OtherObject, it will be analyzed
+// during the analysis of OtherObject.

NoQ wrote:
> Szelethus wrote:
> > NoQ wrote:
> > > Szelethus wrote:
> > > > NoQ wrote:
> > > > > It seems safer to look at `CXXConstructExpr::getConstructionKind()`.
> > > > > 
> > > > > Taking a `LazyCompoundVal` and converting it back to a region is 
> > > > > definitely a bad idea because the region within `LazyCompoundVal` is 
> > > > > completely immaterial and carries no meaning for the value 
> > > > > represented by this `SVal`; it's not necessarily the region you're 
> > > > > looking for.
> > > > Looking at the singleton test case, I think I need to get that region 
> > > > somehow, and I'm not too sure what you meant under using 
> > > > `CXXConstructExpr::getConstructionKind()`. One thing I could do, is 
> > > > similar to how `getObjectVal` works:
> > > > ```
> > > >   Loc Tmp = Context.getSValBuilder().getCXXThis(OtherCtor->getParent(),
> > > > 
> > > > Context.getStackFrame());
> > > > 
> > > >   auto OtherThis = 
> > > > Context.getState()->getSVal(Tmp).castAs();
> > > > 
> > > >   OtherThis.getRegion(); // Hooray!
> > > > ```
> > > > 
> > > > I have tested it, and it works wonders. Is this a "safe-to-use" region?
> > > You can directly ask `CXXConstructExpr` if it's a field or a base 
> > > constructor. I could describe `getConstructionKind()` as some sort of 
> > > very limited `ConstructionContext` that's available in the AST: it 
> > > explains to you what sort of object is being constructed. I suspect it's 
> > > enough for your purposes.
> > I think I'm aware of how it works, but my issue is that it's very limited:
> > ```
> > enum ConstructionKind { CK_Complete, CK_NonVirtualBase, CK_VirtualBase, 
> > CK_Delegating }
> > ```
> > Sadly, whether the `CXXConstructExpr` was a field construction or a "top 
> > level" (non-field) construction can't be retrieved from 
> > `getConstructionKind()`, as I understand it.
> > 
> > If I were to return true (say that the constructed object will be analyzed 
> > later, thus ignoring it for now) if `getConstructionKind() == CK_Complete`, 
> > the singleton testcase will fail (I have tested it). I'm very confident 
> > that I need to obtain the constructed object's `MemRegion`.
> Whoops, yeah, i was wrong. I mis-remembered that there's a `CK_` for field.
> 
> Then, yeah, the code looks good, let me recall where we were in terms of why 
> do we need it><
"it" as if?


https://reviews.llvm.org/D48436



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


[PATCH] D49890: Clang-Tidy Export Problem

2018-07-31 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Could you describe the specific problem you're solving and provide an example? 
As mentioned by others, a test would be very welcome as well.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49890



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


[PATCH] D50056: [NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle-llvm/handle_llvm.cpp.

2018-07-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:152
   typedef void (*func)(int*, int*, int*, int);
-  func f = reinterpret_cast(EE->getPointerToFunction(EntryFunc)); 
+#if defined(__GNUC__) && ((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
+  // Silence

Clang itself defines these as 4.2, so I don't think we want to disable this 
warning for clang.  I think there needs to be a !defined(__clang) &&...


https://reviews.llvm.org/D50056



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


[PATCH] D49953: [compiler-rt] Add a routine to specify the mode used when creating profile dirs.

2018-07-31 Thread Matt Davis via Phabricator via cfe-commits
mattd updated this revision to Diff 158298.
mattd added a comment.

- Simplify the test case, let the compiler join the literals for us.


https://reviews.llvm.org/D49953

Files:
  lib/profile/InstrProfilingUtil.c
  lib/profile/InstrProfilingUtil.h
  test/profile/instrprof-set-dir-mode.c
  test/profile/instrprof-set-dir-mode2.c

Index: test/profile/instrprof-set-dir-mode2.c
===
--- /dev/null
+++ test/profile/instrprof-set-dir-mode2.c
@@ -0,0 +1,48 @@
+// UNSUPPORTED: windows
+// RUN: %clang_pgogen -o %t.bin %s -DTESTPATH=\"%t.dir\"
+// rm -rf %t.dir
+// RUN: %run %t.bin
+
+#include 
+#include 
+#include 
+#include 
+
+void __llvm_profile_set_dir_mode(unsigned Mode);
+unsigned __llvm_profile_get_dir_mode(void);
+void __llvm_profile_recursive_mkdir(char *Path);
+
+static int test(unsigned Mode, const char *TestDir) {
+  int Ret = 0;
+
+  /* Create a dir and set the mode accordingly. */
+  char *Dir = strdup(TestDir);
+  if (!Dir)
+return -1;
+  __llvm_profile_set_dir_mode(Mode);
+  __llvm_profile_recursive_mkdir(Dir);
+
+  if (Mode != __llvm_profile_get_dir_mode())
+Ret = -1;
+  else {
+const unsigned Expected = ~umask(0) & Mode;
+struct stat DirSt;
+if (stat(Dir, &DirSt) == -1)
+  Ret = -1;
+else if (DirSt.st_mode != Expected) {
+  printf("Modes do not match: Expected %o but found %o (%s)\n", Expected,
+ DirSt.st_mode, Dir);
+  Ret = -1;
+}
+  }
+
+  free(Dir);
+  return Ret;
+}
+
+int main(void) {
+  if (test(S_IFDIR | 0777, TESTPATH "/foo/bar/baz/") ||
+  test(S_IFDIR | 0666, TESTPATH "/foo/bar/qux/"))
+return -1;
+  return 0;
+}
Index: test/profile/instrprof-set-dir-mode.c
===
--- /dev/null
+++ test/profile/instrprof-set-dir-mode.c
@@ -0,0 +1,17 @@
+// RUN: %clang_pgogen -o %t %s
+// RUN: %run %t
+
+void __llvm_profile_set_dir_mode(unsigned Mode);
+unsigned __llvm_profile_get_dir_mode(void);
+
+int main(void) {
+  __llvm_profile_set_dir_mode(0777);
+  if (__llvm_profile_get_dir_mode() != 0777)
+return -1;
+
+  __llvm_profile_set_dir_mode(0666);
+  if (__llvm_profile_get_dir_mode() != 0666)
+return -1;
+
+  return 0;
+}
Index: lib/profile/InstrProfilingUtil.h
===
--- lib/profile/InstrProfilingUtil.h
+++ lib/profile/InstrProfilingUtil.h
@@ -16,6 +16,12 @@
 /*! \brief Create a directory tree. */
 void __llvm_profile_recursive_mkdir(char *Pathname);
 
+/*! Set the mode used when creating profile directories. */
+void __llvm_profile_set_dir_mode(unsigned Mode);
+
+/*! Return the directory creation mode. */
+unsigned __llvm_profile_get_dir_mode(void);
+
 int lprofLockFd(int fd);
 int lprofUnlockFd(int fd);
 
Index: lib/profile/InstrProfilingUtil.c
===
--- lib/profile/InstrProfilingUtil.c
+++ lib/profile/InstrProfilingUtil.c
@@ -35,6 +35,8 @@
 #include "InstrProfiling.h"
 #include "InstrProfilingUtil.h"
 
+COMPILER_RT_WEAK unsigned lprofDirMode = 0755;
+
 COMPILER_RT_VISIBILITY
 void __llvm_profile_recursive_mkdir(char *path) {
   int i;
@@ -47,12 +49,19 @@
 #ifdef _WIN32
 _mkdir(path);
 #else
-mkdir(path, 0755); /* Some of these will fail, ignore it. */
+/* Some of these will fail, ignore it. */
+mkdir(path, __llvm_profile_get_dir_mode());
 #endif
 path[i] = save;
   }
 }
 
+COMPILER_RT_VISIBILITY
+void __llvm_profile_set_dir_mode(unsigned Mode) { lprofDirMode = Mode; }
+
+COMPILER_RT_VISIBILITY
+unsigned __llvm_profile_get_dir_mode(void) { return lprofDirMode; }
+
 #if COMPILER_RT_HAS_ATOMICS != 1
 COMPILER_RT_VISIBILITY
 uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r338321 - Fix use of uninitialized variable in r338299

2018-07-31 Thread via cfe-commits
I think this version is right; the FieldOffset for OpenCL here will be 2 
* getTypeSize(IntTy). The final `FieldOffset += FieldSize` that was 
moved only applies to the non-OpenCL "__descriptor" field.


Scott

On 2018-07-30 19:22, Eric Christopher wrote:

Is 0 right for FieldOffset for OpenCL here? Seems a little odd.

-eric

On Mon, Jul 30, 2018 at 3:56 PM Scott Linder via cfe-commits
 wrote:


Author: scott.linder
Date: Mon Jul 30 15:52:07 2018
New Revision: 338321

URL: http://llvm.org/viewvc/llvm-project?rev=338321&view=rev [1]
Log:
Fix use of uninitialized variable in r338299

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

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


http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321&r1=338320&r2=338321&view=diff

[2]


==

--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 15:52:07 2018
@@ -989,9 +989,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
EltTys.push_back(DBuilder.createMemberType(
Unit, "__descriptor", nullptr, LineNo, FieldSize,
FieldAlign, FieldOffset,
llvm::DINode::FlagZero, DescTy));
+ FieldOffset += FieldSize;
}

- FieldOffset += FieldSize;
Elements = DBuilder.getOrCreateArray(EltTys);

// The __block_literal_generic structs are marked with a special

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



Links:
--
[1] http://llvm.org/viewvc/llvm-project?rev=338321&view=rev
[2]
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321&r1=338320&r2=338321&view=diff
[3] 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] D49833: [clangd] Receive compilationDatabasePath in 'initialize' request

2018-07-31 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

@simark would you mind finishing this patch and committing it? I won't be able 
to finish it given that I started it at a different company, etc.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49833



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2018-07-31 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 158302.
Typz added a comment.
Herald added a subscriber: acoomans.

rebase


Repository:
  rC Clang

https://reviews.llvm.org/D32478

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -267,7 +267,7 @@
   verifyFormat("var x = a() in\n"
".aa.aa;");
   FormatStyle Style = getGoogleJSStyleWithColumns(80);
-  Style.AlignOperands = true;
+  Style.AlignOperands = FormatStyle::OAS_Align;
   verifyFormat("var x = a() in\n"
".aa.aa;",
Style);
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3344,6 +3344,9 @@
"  > c) {\n"
"}",
Style);
+  verifyFormat("return a\n"
+   "   && bbb;",
+   Style);
   verifyFormat("return (a)\n"
"   // comment\n"
"   + b;",
@@ -3372,11 +3375,103 @@
 
   Style.ColumnLimit = 60;
   verifyFormat("zz\n"
-   "= b\n"
+   "= \n"
"  >> (aa);",
Style);
 }
 
+TEST_F(FormatTest, ExpressionIndentationStrictAlign) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  Style.AlignOperands = FormatStyle::OAS_AlignAfterOperator;
+
+  verifyFormat("bool value = a\n"
+   "   + a\n"
+   "   + a\n"
+   "  == a\n"
+   " * b\n"
+   " + b\n"
+   "  && a\n"
+   " * a\n"
+   " > c;",
+   Style);
+  verifyFormat("if (a\n"
+   "* \n"
+   "+ aa\n"
+   "== bbb) {\n}",
+   Style);
+  verifyFormat("if (a\n"
+   "+ \n"
+   "  * aa\n"
+   "== bbb) {\n}",
+   Style);
+  verifyFormat("if (a\n"
+   "== \n"
+   "   * aa\n"
+   "   + bbb) {\n}",
+   Style);
+  verifyFormat("if () {\n"
+   "} else if (a\n"
+   "   && b // break\n"
+   "  > c) {\n"
+   "}",
+   Style);
+  verifyFormat("return a\n"
+   "&& bbb;",
+   Style);
+  verifyFormat("return (a)\n"
+   " // comment\n"
+   " + b;",
+   Style);
+  verifyFormat(
+  "int aa = aa\n"
+  "   * bbb\n"
+  "   + cc;",
+  Style);
+
+  verifyFormat("a\n"
+   "=  + ;",
+   Style);
+
+  verifyFormat("return boost::fusion::at_c<0>().second\n"
+   "== boost::fusion::at_c<1>().second;",
+   Style);
+
+  Style.ColumnLimit = 60;
+  verifyFormat("z\n"
+   "= \n"
+ 

[PATCH] D48341: [clang-doc] Refactoring mapper to map by scope

2018-07-31 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-tools-extra/clang-doc/Representation.cpp:49
+template 
+int isChildMergeNecessary(std::vector &Children, T &ChildToMerge) {
+  for (unsigned long I = 0; I < Children.size(); I++) {

The function name doesn't describe what it does. Maybe `getChildIndexIfExists`?



Comment at: clang-tools-extra/clang-doc/Representation.h:190
+
+  std::vector ChildNamespaces;
+  std::vector ChildRecords;

Why are namespaces and records `Reference`s  while others are actual infos. 
Might worth a comment.



Comment at: clang-tools-extra/clang-doc/Representation.h:246
+
+  std::vector ChildNamespaces;
+  std::vector ChildRecords;

Would a record ever have namespace children? Maybe we should assert that this 
doesn't happen?



Comment at: clang-tools-extra/clang-doc/Serialize.cpp:330
+return nullptr;
+  std::unique_ptr IPtr = llvm::make_unique();
+  NamespaceInfo *I = static_cast(IPtr.get());

`auto IPtr = llvm::make_unique();` should work well I think? 
Converting the pointer back and forth seems unnecessary. 



Comment at: clang-tools-extra/test/clang-doc/bc-linkage.cpp:106
+// CHECK-0-NEXT: 
+// CHECK-0-NEXT:   
+// CHECK-0-NEXT:blob data = 'InnerClass'

I'm still a bit concerned about hardcoding a lot of USRs in tests. They are not 
interpretable and generally not interesting for testing. Also as they are 
auto-generated,   it's hard to tell whether they are actually the desired USRs. 
I'm concerned because the maintenance is getting higher as number of tests 
grows - everyone changing USR semantics in the future has to know to regenerate 
clang-doc tests, this can be annoying and potentially unmanageable when a small 
change in clang USR requires changes to many test files in clang-tools-extra :( 
Comparing to the value it brings to test USRs in all tests, I'd still suggest  
simply matching them with a `{{.*}}`and only test USRs in few tests where you 
are actually interested in them.


https://reviews.llvm.org/D48341



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


[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2018-07-31 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Typz added reviewers: krasimir, djasper, klimek.
Herald added a subscriber: acoomans.

When multiple ternary operators are chained, e.g. like an if/else-if/
else-if/.../else sequence, clang-format will keep aligning the colon
with the question mark, which increases the indent for each
conditionals:

  int a = condition1 ? result1
 : condition2 ? result2
  : condition3 ? result3
   : result4;

This patch detects the situation (e.g. conditionals used in false branch
of another conditional), to avoid indenting in that case:

  int a = condition1 ? result1
: condition2 ? result2
: condition3 ? result3
 : result4;

When BreakBeforeTernaryOperators is false, this will format like this:

  int a = condition1 ? result1 :
  condition2 ? result2 :
  conditino3 ? result3 :
   result4;

This formatting style is referenced here:
https://www.fluentcpp.com/2018/02/27/replace-else-if-ternary-operator/
and here:
https://marcmutz.wordpress.com/2010/10/14/top-5-reasons-you-should-love-your-ternary-operator/


Repository:
  rC Clang

https://reviews.llvm.org/D50078

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4801,9 +4801,9 @@
getLLVMStyleWithColumns(60));
   verifyFormat("bool aa = a //\n"
"  ? aaa\n"
-   "  : bbb //\n"
-   "? ccc\n"
-   ": ddd;");
+   "  : bbb //\n"
+   "  ? ccc\n"
+   "  : ddd;");
   verifyFormat("bool aa = a //\n"
"  ? aaa\n"
"  : (bbb //\n"
@@ -4865,6 +4865,113 @@
" // comment\n"
" ? a = b\n"
" : a;");
+
+  // Chained conditionals
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 70;
+  Style.AlignOperands = FormatStyle::OAS_AlignAfterOperator;
+  verifyFormat("return  ? \n"
+   " :  ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? \n"
+   " : bb   ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return aa   ? \n"
+   " :  ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? \n"
+   " :  ? 22\n"
+   ": 33;",
+   Style);
+  verifyFormat("return  ? \n"
+   " :  ? \n"
+   " :  ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? (aaa ? bbb : ccc)\n"
+   " :  ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? \n"
+   " :  ? \n"
+   ": (aaa ? bbb : ccc);",
+   Style);
+  verifyFormat("return  ? (a ? bb\n"
+   " : cc)\n"
+   " :  ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return a? (a ? bb\n"
+   " : cc)\n"
+   " :  ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return a? a = (a ? bb\n"
+   " : dd)\n"

r338399 - [OPENMP] Prevent problems with linking of the static variables.

2018-07-31 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul 31 09:40:15 2018
New Revision: 338399

URL: http://llvm.org/viewvc/llvm-project?rev=338399&view=rev
Log:
[OPENMP] Prevent problems with linking of the static variables.

No need to change the linkage, we can avoid the problem using special variable. 
That points to the original variable and, thus, prevent some of the 
optimizations that might break the compilation.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=338399&r1=338398&r2=338399&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul 31 09:40:15 2018
@@ -9535,21 +9535,6 @@ static GVALinkage basicGVALinkageForFunc
   return GVA_DiscardableODR;
 }
 
-static bool isDeclareTargetToDeclaration(const Decl *VD) {
-  for (const Decl *D : VD->redecls()) {
-if (!D->hasAttrs())
-  continue;
-if (const auto *Attr = D->getAttr())
-  return Attr->getMapType() == OMPDeclareTargetDeclAttr::MT_To;
-  }
-  if (const auto *V = dyn_cast(VD)) {
-if (const VarDecl *TD = V->getTemplateInstantiationPattern())
-  return isDeclareTargetToDeclaration(TD);
-  }
-
-  return false;
-}
-
 static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context,
 const Decl *D, GVALinkage L) {
   // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx
@@ -9566,12 +9551,6 @@ static GVALinkage adjustGVALinkageForAtt
 // visible externally so they can be launched from host.
 if (L == GVA_DiscardableODR || L == GVA_Internal)
   return GVA_StrongODR;
-  } else if (Context.getLangOpts().OpenMP && 
Context.getLangOpts().OpenMPIsDevice &&
- isDeclareTargetToDeclaration(D)) {
-// Static variables must be visible externally so they can be mapped from
-// host.
-if (L == GVA_Internal)
-  return GVA_StrongODR;
   }
   return L;
 }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=338399&r1=338398&r2=338399&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Jul 31 09:40:15 2018
@@ -8109,6 +8109,19 @@ void CGOpenMPRuntime::registerTargetGlob
   VarName = CGM.getMangledName(VD);
   VarSize = CGM.getContext().getTypeSizeInChars(VD->getType());
   Linkage = CGM.getLLVMLinkageVarDefinition(VD, /*IsConstant=*/false);
+  // Temp solution to prevent optimizations of the internal variables.
+  if (CGM.getLangOpts().OpenMPIsDevice && !VD->isExternallyVisible()) {
+std::string RefName = getName({VarName, "ref"});
+if (!CGM.GetGlobalValue(RefName)) {
+  llvm::Constant *AddrRef =
+  getOrCreateInternalVariable(Addr->getType(), RefName);
+  auto *GVAddrRef = cast(AddrRef);
+  GVAddrRef->setConstant(/*Val=*/true);
+  GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
+  GVAddrRef->setInitializer(Addr);
+  CGM.addCompilerUsedGlobal(GVAddrRef);
+}
+  }
   break;
 case OMPDeclareTargetDeclAttr::MT_Link:
   Flags = OffloadEntriesInfoManagerTy::OMPTargetGlobalVarEntryLink;

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=338399&r1=338398&r2=338399&view=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Tue Jul 31 09:40:15 2018
@@ -18,14 +18,15 @@
 // CHECK-DAG: @d = global i32 0,
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals = global %struct.S zeroinitializer,
-// CHECK-DAG: @{{.+}}stat = weak_odr global %struct.S zeroinitializer,
-// CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+42]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+43]]_ctor to i8*)], section 
"llvm.metadata"
+// CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+42]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+43]]_ctor to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(%struct

[PATCH] D49865: Inform the AST of #pragma FENV_ACCESS use

2018-07-31 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 158307.
kpn added a comment.

Replace accidentally lost comment.


https://reviews.llvm.org/D49865

Files:
  include/clang/AST/Expr.h
  include/clang/Basic/LangOptions.h
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaAttr.cpp

Index: lib/Sema/SemaAttr.cpp
===
--- lib/Sema/SemaAttr.cpp
+++ lib/Sema/SemaAttr.cpp
@@ -773,6 +773,18 @@
   }
 }
 
+void Sema::ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC) {
+  switch (FPC) {
+  case LangOptions::FEA_On:
+FPFeatures.setAllowFEnvAccess();
+break;
+  case LangOptions::FEA_Off:
+FPFeatures.setDisallowFEnvAccess();
+break;
+  }
+}
+
+
 void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
SourceLocation Loc) {
   // Visibility calculations will consider the namespace's visibility.
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -674,6 +674,9 @@
   case tok::annot_pragma_fp_contract:
 HandlePragmaFPContract();
 return nullptr;
+  case tok::annot_pragma_fenv_access:
+HandlePragmaFEnvAccess();
+return nullptr;
   case tok::annot_pragma_fp:
 HandlePragmaFP();
 break;
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -348,6 +348,11 @@
 ConsumeAnnotationToken();
 return StmtError();
 
+  case tok::annot_pragma_fenv_access:
+ProhibitAttributes(Attrs);
+HandlePragmaFEnvAccess();
+return StmtEmpty();
+
   case tok::annot_pragma_opencl_extension:
 ProhibitAttributes(Attrs);
 HandlePragmaOpenCLExtension();
@@ -902,6 +907,9 @@
 case tok::annot_pragma_fp:
   HandlePragmaFP();
   break;
+case tok::annot_pragma_fenv_access:
+  HandlePragmaFEnvAccess();
+  break;
 case tok::annot_pragma_ms_pointers_to_members:
   HandlePragmaMSPointersToMembers();
   break;
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -106,8 +106,19 @@
 tok::OnOffSwitch OOS;
 if (PP.LexOnOffSwitch(OOS))
  return;
-if (OOS == tok::OOS_ON)
+if (OOS == tok::OOS_ON) {
   PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
+
+  MutableArrayRef Toks(PP.getPreprocessorAllocator().Allocate(1),
+1);
+  Toks[0].startToken();
+  Toks[0].setKind(tok::annot_pragma_fenv_access);
+  Toks[0].setLocation(Tok.getLocation());
+  Toks[0].setAnnotationEndLoc(Tok.getLocation());
+  Toks[0].setAnnotationValue(reinterpret_cast(
+   static_cast(OOS)));
+  PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true);
+}
   }
 };
 
@@ -591,6 +602,30 @@
   ConsumeAnnotationToken();
 }
 
+void Parser::HandlePragmaFEnvAccess() {
+  assert(Tok.is(tok::annot_pragma_fenv_access));
+  tok::OnOffSwitch OOS =
+static_cast(
+reinterpret_cast(Tok.getAnnotationValue()));
+
+  LangOptions::FEnvAccessModeKind FPC;
+  switch (OOS) {
+  case tok::OOS_ON:
+FPC = LangOptions::FEA_On;
+break;
+  case tok::OOS_OFF:
+FPC = LangOptions::FEA_Off;
+break;
+  case tok::OOS_DEFAULT: // FIXME: Add this cli option when it makes sense.
+FPC = LangOptions::FEA_Off;
+break;
+  }
+
+  Actions.ActOnPragmaFEnvAccess(FPC);
+  ConsumeAnnotationToken();
+}
+
+
 StmtResult Parser::HandlePragmaCaptured()
 {
   assert(Tok.is(tok::annot_pragma_captured));
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -8434,6 +8434,10 @@
   /// \#pragma clang fp contract
   void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC);
 
+  /// ActOnPragmaFenvAccess - Called on well formed
+  /// \#pragma STDC FENV_ACCESS
+  void ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC);
+
   /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
   /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
   void AddAlignmentAttributesForRecord(RecordDecl *RD);
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -668,6 +668,10 @@
   void HandlePragmaFPContract();
 
   /// Handle the annotation token produced for
+  /// #pragma STDC FENV_ACCESS...
+  void HandlePragmaFEnvAccess();
+
+  /// \brief Handle the annotation token produced for
   /// #pragma clang fp ...
   void HandlePragmaFP();
 
Index: include/clang/Basic/TokenKinds.def
===

[PATCH] D49833: [clangd] Receive compilationDatabasePath in 'initialize' request

2018-07-31 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.

In https://reviews.llvm.org/D49833#1182615, @malaperle wrote:

> @simark would you mind finishing this patch and committing it? I won't be 
> able to finish it given that I started it at a different company, etc.


Yes, I'll take it over, thanks for getting it started.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49833



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


[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2018-07-31 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Notes:

- I choose not to add an option to enable this behavior, as I think of it as 
just another way clang-format can (better) format the code; but I can one if 
needed
- Currently, it relies on another patch (https://reviews.llvm.org/D32478), 
which supports aligning the wrapped operator slightly differently. If/since 
that other patch does not seem to make it, I can change this patch to either do 
the alignment in this specific case (e.g. for wrapped ternary operator only) or 
to keep the 'default' behavior of clang-format (e.g. the wrapped colon would be 
aligned with the first condition):

  // i.e. the better looking option, but which requires specific cases when it 
comes after assignment or return:
  int fooo =  ? 0
   :  ? 1
  : ;
  // or the option more consistent with current clang-format behavior:
  int fooo =    ? 0
 :  ? 1
: ;

The current patch supports both behaviors, as it relies on 
https://reviews.llvm.org/D32478 to specify the expected behavior.


Repository:
  rC Clang

https://reviews.llvm.org/D50078



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


[PATCH] D33440: clang-format: better handle statement macros

2018-07-31 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 158308.
Typz marked an inline comment as done.
Typz added a comment.
Herald added a subscriber: acoomans.

Regenerate documentation


Repository:
  rC Clang

https://reviews.llvm.org/D33440

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2472,6 +2472,45 @@
getLLVMStyleWithColumns(40)));
 
   verifyFormat("MACRO(>)");
+
+  // Some macros contain an implicit semicolon.
+  FormatStyle Style = getLLVMStyle();
+  Style.StatementMacros.push_back("FOO");
+  verifyFormat("FOO(a) int b = 0;");
+  verifyFormat("FOO(a)\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO(a);\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO(argc, argv, \"4.0.2\")\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO()\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("void f() {\n"
+   "  FOO(a)\n"
+   "  return a;\n"
+   "}",
+   Style);
+  verifyFormat("FOO(a)\n"
+   "FOO(b)",
+   Style);
+  verifyFormat("int a = 0;\n"
+   "FOO(b)\n"
+   "int c = 0;",
+   Style);
+  verifyFormat("int a = 0;\n"
+   "int x = FOO(a)\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("void foo(int a) { FOO(a) }\n"
+   "uint32_t bar() {}",
+   Style);
 }
 
 TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {
@@ -10728,6 +10767,12 @@
   CHECK_PARSE("ForEachMacros: [BOOST_FOREACH, Q_FOREACH]", ForEachMacros,
   BoostAndQForeach);
 
+  Style.StatementMacros.clear();
+  CHECK_PARSE("StatementMacros: [QUNUSED]", StatementMacros,
+  std::vector{"QUNUSED"});
+  CHECK_PARSE("StatementMacros: [QUNUSED, QT_REQUIRE_VERSION]", StatementMacros,
+  std::vector({"QUNUSED", "QT_REQUIRE_VERSION"}));
+
   Style.IncludeStyle.IncludeCategories.clear();
   std::vector ExpectedCategories = {
   {"abc/.*", 2}, {".*", 1}};
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -125,6 +125,7 @@
   void parseObjCInterfaceOrImplementation();
   bool parseObjCProtocol();
   void parseJavaScriptEs6ImportExport();
+  void parseStatementMacro();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -473,6 +473,10 @@
   }
   LBraceStack.pop_back();
   break;
+case tok::identifier:
+  if (!Tok->is(TT_StatementMacro))
+  break;
+  LLVM_FALLTHROUGH;
 case tok::at:
 case tok::semi:
 case tok::kw_if:
@@ -1098,6 +1102,10 @@
 return;
   }
 }
+if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
+  parseStatementMacro();
+  return;
+}
 // In all other cases, parse the declaration.
 break;
   default:
@@ -1297,6 +1305,11 @@
 return;
   }
 
+  if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
+parseStatementMacro();
+return;
+  }
+
   // See if the following token should start a new unwrapped line.
   StringRef Text = FormatTok->TokenText;
   nextToken();
@@ -2295,6 +2308,16 @@
   }
 }
 
+void UnwrappedLineParser::parseStatementMacro()
+{
+  nextToken();
+  if (FormatTok->is(tok::l_paren))
+parseParens();
+  if (FormatTok->is(tok::semi))
+nextToken();
+  addUnwrappedLine();
+}
+
 LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line,
  StringRef Prefix = "") {
   llvm::dbgs() << Prefix << "Line(" << Line.Level
Index: lib/Format/FormatTokenLexer.h
===
--- lib/Format/FormatTokenLexer.h
+++ lib/Format/FormatTokenLexer.h
@@ -22,6 +22,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/ADT/MapVector.h"
 
 #include 
 
@@ -99,7 +100,8 @@
   // Index (in 'Tokens') of the last token that starts a new line.
   unsigned FirstInLineIndex;
   SmallVector Tokens;
-  SmallVector ForEachMacros;
+
+  llvm::SmallMapVector Macros

[PATCH] D37813: clang-format: better handle namespace macros

2018-07-31 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 158309.
Typz added a comment.
Herald added a subscriber: acoomans.

Regeneration documentation


Repository:
  rC Clang

https://reviews.llvm.org/D37813

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/NamespaceEndCommentsFixer.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -53,6 +53,7 @@
 "  int i;\n"
 "  int j;\n"
 "}"));
+
   EXPECT_EQ("namespace {\n"
 "  int i;\n"
 "  int j;\n"
@@ -249,6 +250,85 @@
 "// unrelated"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, AddsMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+
+  EXPECT_EQ("TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("inline TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("inline TESTSUITE(A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A)",
+fixNamespaceEndComments("TESTSUITE(::A) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A::B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(::A::B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(A, B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A, B) {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(\"Test1\") {\n"
+"  int i;\n"
+"  int j;\n"
+"}// TESTSUITE(\"Test1\")",
+fixNamespaceEndComments("TESTSUITE(\"Test1\") {\n"
+"  int i;\n"
+"  int j;\n"
+"}",
+Style));
+}
+
 TEST_F(NamespaceEndCommentsFixerTest, AddsNewlineIfNeeded) {
   EXPECT_EQ("namespace A {\n"
 "  int i;\n"
@@ -381,6 +461,54 @@
 "}; /* unnamed namespace */"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, KeepsValidMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"} // end anonymous TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"  int i;\n"
+"} // end anonymous TESTSUITE()",
+

[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 158311.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

- Store/prepend it into `llvm::TrailingObjects<>`
- Use `unsigned short`
- Assert that the storage is at least large enough to be compliant with 
implimits 
- Don't allocate even that `unsigned short` unless the path is not empty (use 
one bit in `CastExprBits`)


Repository:
  rC Clang

https://reviews.llvm.org/D50050

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/Stmt.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  test/CodeGenCXX/castexpr-basepathsize-threshold.cpp

Index: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
===
--- /dev/null
+++ test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// https://bugs.llvm.org/show_bug.cgi?id=38356
+// We only check that we do not crash.
+
+template 
+struct d : d {};
+template 
+struct d {
+  a f[0];
+};
+struct g {
+  static g h(unsigned);
+};
+struct i {
+  void j() const;
+  // Current maximum depth of recursive template instantiation is 1024,
+  // thus, this \/ threshold value is used here. BasePathSize in CastExpr might
+  // not fit it, so we are testing that we do fit it.
+  // If -ftemplate-depth= is provided, larger values (4096 and up) cause crashes
+  // elsewhere.
+  d f;
+};
+void i::j() const {
+  const void *k{f.f};
+  (void)k;
+}
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -559,7 +559,9 @@
  SourceLocation RParenLoc,
  SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
  RParenLoc, AngleBrackets);
@@ -571,7 +573,9 @@
 
 CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext &C,
   unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize);
 }
 
@@ -584,7 +588,9 @@
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
   RParenLoc, AngleBrackets);
@@ -596,7 +602,9 @@
 
 CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(const ASTContext &C,
 unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
 }
 
@@ -641,7 +649,9 @@
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
   RParenLoc, AngleBrackets);
@@ -653,7 +663,9 @@
 
 CXXReinterpretCastExpr *
 CXXReinterpretCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
 }
 
@@ -676,7 +688,9 @@
   const CXXCastPath *BasePath,
   SourceLocation L, SourceLocation R) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R);
   if (PathSize)
@@ -687,7 +701,9 @@
 
 CXXFunctionalCastExpr *
 CXXFunctionalCastExpr::CreateEmpt

[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp:1
+// RUN: %clang_cc1 %s -emit-llvm -o -
+

erichkeane wrote:
> First, most of this test can be further simplified.  Second, I'd like to see 
> a test that actually tests the limit without hitting the recursive template 
> limit.
> First, most of this test can be further simplified.
OK? This is what creduce gave me. But yes, i know it has some issues with 
templates.

> Second, I'd like to see a test that actually tests the limit without hitting 
> the recursive template limit.
But that is true already. *this* test does not hit the recursive template limit.



Comment at: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp:20
+  // not fit it, so we are testing that we do fit it.
+  // If -ftemplate-depth= is provided, larger values (4096 and up) cause 
crashes
+  // elsewhere.

erichkeane wrote:
> Shouldn't we cover 16k?  
No, for me `4096` already crashes elsewhere.


Repository:
  rC Clang

https://reviews.llvm.org/D50050



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


[PATCH] D43183: clang-format: introduce `CaseBlockIndent` to control indent in switch

2018-07-31 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 158313.
Typz added a comment.
Herald added a subscriber: acoomans.

Regenerate documentation


Repository:
  rC Clang

https://reviews.llvm.org/D43183

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1010,6 +1010,96 @@
"  return;\n"
"}",
getLLVMStyleWithColumns(34));
+
+  FormatStyle indentClosingBrace = getLLVMStyle();
+  indentClosingBrace.CaseBlockIndent = FormatStyle::CBIS_ClosingBrace;
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "  f();\n"
+   "  break;\n"
+   "}",
+   indentClosingBrace);
+  verifyFormat("switch (x) {\n"
+   "case 1: {\n"
+   "  f();\n"
+   "  break;\n"
+   "  }\n"
+   "case 2: {\n"
+   "  break;\n"
+   "  }\n"
+   "}",
+   indentClosingBrace);
+  verifyFormat("switch (x) {\n"
+   "case 1: {\n"
+   "  f();\n"
+   "  } break;\n"
+   "case 2: {\n"
+   "  } break;\n"
+   "}",
+   indentClosingBrace);
+  verifyFormat("switch (x) {\n"
+   "case 1: {\n"
+   "  f();\n"
+   "  }\n"
+   "  g();\n"
+   "  break;\n"
+   "}",
+   indentClosingBrace);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "  f();\n"
+   "  {\n"
+   "g();\n"
+   "h();\n"
+   "  }\n"
+   "  break;\n"
+   "}",
+   indentClosingBrace);
+
+  FormatStyle indentBlock = getLLVMStyle();
+  indentBlock.CaseBlockIndent = FormatStyle::CBIS_Block;
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "  f();\n"
+   "  break;\n"
+   "}",
+   indentBlock);
+  verifyFormat("switch (x) {\n"
+   "case 1: {\n"
+   "f();\n"
+   "break;\n"
+   "  }\n"
+   "case 2: {\n"
+   "break;\n"
+   "  }\n"
+   "}",
+   indentBlock);
+  verifyFormat("switch (x) {\n"
+   "case 1: {\n"
+   "f();\n"
+   "  } break;\n"
+   "case 2: {\n"
+   "  } break;\n"
+   "}",
+   indentBlock);
+  verifyFormat("switch (x) {\n"
+   "case 1: {\n"
+   "f();\n"
+   "  }\n"
+   "  g();\n"
+   "  break;\n"
+   "}",
+   indentBlock);
+  verifyFormat("switch (x) {\n"
+   "case 1:\n"
+   "  f();\n"
+   "  {\n"
+   "g();\n"
+   "h();\n"
+   "  }\n"
+   "  break;\n"
+   "}",
+   indentBlock);
 }
 
 TEST_F(FormatTest, CaseRanges) {
@@ -10639,6 +10729,13 @@
   CHECK_PARSE("AllowShortFunctionsOnASingleLine: true",
   AllowShortFunctionsOnASingleLine, FormatStyle::SFS_All);
 
+  Style.CaseBlockIndent = FormatStyle::CBIS_Block;
+  CHECK_PARSE("CaseBlockIndent: None", CaseBlockIndent, FormatStyle::CBIS_None);
+  CHECK_PARSE("CaseBlockIndent: ClosingBrace", CaseBlockIndent,
+  FormatStyle::CBIS_ClosingBrace);
+  CHECK_PARSE("CaseBlockIndent: Block", CaseBlockIndent,
+  FormatStyle::CBIS_Block);
+
   Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
   CHECK_PARSE("SpaceBeforeParens: Never", SpaceBeforeParens,
   FormatStyle::SBPO_Never);
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -88,6 +88,10 @@
   void parseFile();
   void parseLevel(bool HasOpeningBrace);
   void parseBlock(bool MustBeDeclaration, bool AddLevel = true,
+  bool MunchSemi = true) {
+parseBlock(MustBeDeclaration, AddLevel ? 1 : 0, MunchSemi);
+  }
+  void parseBlock(bool MustBeDeclaration, int AddLevel,
   bool MunchSemi = true);
   void parseChildBlock();
   void parsePPDirective();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -515,7 +515,7 @@
   return h;
 }
 
-void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
+void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, int AddLevel,

[PATCH] D49918: [clang-tidy] Sequence declaration in while statement before the condition

2018-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 158314.
mboehme added a comment.

Add support for switch statement.

While I'm here, also add support for the init statement in an if statement.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49918

Files:
  clang-tidy/utils/ExprSequence.cpp
  test/clang-tidy/bugprone-use-after-move.cpp


Index: test/clang-tidy/bugprone-use-after-move.cpp
===
--- test/clang-tidy/bugprone-use-after-move.cpp
+++ test/clang-tidy/bugprone-use-after-move.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-use-after-move %t -- -- -std=c++11 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s bugprone-use-after-move %t -- -- -std=c++17 
-fno-delayed-template-parsing
 
 typedef decltype(nullptr) nullptr_t;
 
@@ -1132,13 +1132,30 @@
   }
 }
 
-// If a variable is declared in an if statement, the declaration of the 
variable
-// (which is treated like a reinitialization by the check) is sequenced before
-// the evaluation of the condition (which constitutes a use).
-void ifStmtSequencesDeclAndCondition() {
+// If a variable is declared in an if, while or switch statement, the init
+// statement (for if and switch) is sequenced before the variable declaration,
+// which in turn is sequenced before the evaluation of the condition.
+void ifWhileAndSwitchSequenceInitDeclAndCondition() {
   for (int i = 0; i < 10; ++i) {
-if (A a = A()) {
-  std::move(a);
+A a1;
+if (A a2= std::move(a1)) {
+  std::move(a2);
+}
+  }
+  for (int i = 0; i < 10; ++i) {
+A a1;
+if (A a2 = std::move(a1); A a3 = std::move(a2)) {
+  std::move(a3);
+}
+  }
+  while (A a = A()) {
+std::move(a);
+  }
+  for (int i = 0; i < 10; ++i) {
+A a1;
+switch (A a2 = a1; A a3 = std::move(a2)) {
+  case true:
+std::move(a3);
 }
   }
 }
Index: clang-tidy/utils/ExprSequence.cpp
===
--- clang-tidy/utils/ExprSequence.cpp
+++ clang-tidy/utils/ExprSequence.cpp
@@ -139,11 +139,26 @@
   if (S == ForRange->getLoopVarStmt())
 return ForRange->getBody();
 } else if (const auto *TheIfStmt = dyn_cast(Parent)) {
-  // If statement: If a variable is declared inside the condition, the
-  // expression used to initialize the variable is sequenced before the
-  // evaluation of the condition.
+  // If statement:
+  // - Sequence init statement before variable declaration.
+  // - Sequence variable declaration (along with the expression used to
+  //   initialize it) before the evaluation of the condition.
+  if (S == TheIfStmt->getInit())
+return TheIfStmt->getConditionVariableDeclStmt();
   if (S == TheIfStmt->getConditionVariableDeclStmt())
 return TheIfStmt->getCond();
+} else if (const auto *TheSwitchStmt = dyn_cast(Parent)) {
+  // Ditto for switch statements.
+  if (S == TheSwitchStmt->getInit())
+return TheSwitchStmt->getConditionVariableDeclStmt();
+  if (S == TheSwitchStmt->getConditionVariableDeclStmt())
+return TheSwitchStmt->getCond();
+} else if (const auto *TheWhileStmt = dyn_cast(Parent)) {
+  // While statement: Sequence variable declaration (along with the
+  // expression used to initialize it) before the evaluation of the
+  // condition.
+  if (S == TheWhileStmt->getConditionVariableDeclStmt())
+return TheWhileStmt->getCond();
 }
   }
 


Index: test/clang-tidy/bugprone-use-after-move.cpp
===
--- test/clang-tidy/bugprone-use-after-move.cpp
+++ test/clang-tidy/bugprone-use-after-move.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-use-after-move %t -- -- -std=c++11 -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s bugprone-use-after-move %t -- -- -std=c++17 -fno-delayed-template-parsing
 
 typedef decltype(nullptr) nullptr_t;
 
@@ -1132,13 +1132,30 @@
   }
 }
 
-// If a variable is declared in an if statement, the declaration of the variable
-// (which is treated like a reinitialization by the check) is sequenced before
-// the evaluation of the condition (which constitutes a use).
-void ifStmtSequencesDeclAndCondition() {
+// If a variable is declared in an if, while or switch statement, the init
+// statement (for if and switch) is sequenced before the variable declaration,
+// which in turn is sequenced before the evaluation of the condition.
+void ifWhileAndSwitchSequenceInitDeclAndCondition() {
   for (int i = 0; i < 10; ++i) {
-if (A a = A()) {
-  std::move(a);
+A a1;
+if (A a2= std::move(a1)) {
+  std::move(a2);
+}
+  }
+  for (int i = 0; i < 10; ++i) {
+A a1;
+if (A a2 = std::move(a1); A a3 = std::move(a2)) {
+  std::move(a3);
+}
+  }
+  while (A a = A()) {
+std::move(a);
+  }
+  for (int i = 0; i < 10; ++i) {
+A a1;
+switch (A a2 = a1; A a

[PATCH] D49918: [clang-tidy] Sequence declaration in while statement before the condition

2018-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked an inline comment as done.
mboehme added inline comments.



Comment at: clang-tidy/utils/ExprSequence.cpp:147
 return TheIfStmt->getCond();
+} else if (const auto *TheWhileStmt = dyn_cast(Parent)) {
+  // While statement: If a variable is declared inside the condition, the

aaron.ballman wrote:
> Should we also handle switch statements at the same time?
Good point.

While I was doing this, I noticed that we were also not sequencing init 
statements in if statements correctly, so I've added code for that as well.

The description of the change is now too narrow, so I'll change that in a 
moment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49918



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


[PATCH] D47267: [UnrollAndJam] Add unroll_and_jam pragma handling

2018-07-31 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lib/Sema/SemaStmtAttr.cpp:183
{nullptr, nullptr}};
-
   for (const auto *I : Attrs) {

[nit] unrelated whitespace change?



Comment at: test/CodeGenCXX/pragma-unroll-and-jam.cpp:4
+void unroll_and_jam(int *List, int Length, int Value) {
+  // CHECK: define {{.*}} @_Z14unroll_and_jam
+#pragma unroll_and_jam

[suggestion] `CHECK-LABEL`? (applies to the function names below as well)


https://reviews.llvm.org/D47267



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


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/clang/AST/Expr.h:2791
+public:
+  using BasePathSizeTy = unsigned short;
+  static_assert(std::numeric_limits::max() >= 16384,

I'll let @rjmccall comment here, but I think I'd be willing to give up 2 more 
bytes here and just go with unsigned int.  It has the advantage of likely never 
being an issue again (since 4 billion bases is not an issue).

We might be paying for those 2 ANYWAY with alignment as well, right?



Comment at: include/clang/AST/Expr.h:2800
 
+  BasePathSizeTy BasePathSize() const {
+if (BasePathIsEmpty())

Looking back up, I doubt the need for this either, since we have path_empty and 
path_size below.



Comment at: include/clang/AST/Expr.h:2805
+  }
+  BasePathSizeTy &BasePathSize();
+

Why is this a reference?  This seems odd... It seems that the const-cast magic 
above shouldn't be necessary either.



Comment at: include/clang/AST/Expr.h:2814
+assert(!BasePathIsEmpty() && basePathSize != 0);
+BasePathSize() = basePathSize;
+assert(BasePathSize() == basePathSize &&

This is a super weird way to do this. I really am not a fan of giving a 
reference to that spot instead of just setting it here.  



Comment at: include/clang/AST/Expr.h:2854
 
+  bool BasePathIsEmpty() const { return CastExprBits.BasePathIsEmpty; }
+

Is this necessary?  Shouldn't path_empty just do this?



Comment at: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp:1
+// RUN: %clang_cc1 %s -emit-llvm -o -
+

lebedev.ri wrote:
> erichkeane wrote:
> > First, most of this test can be further simplified.  Second, I'd like to 
> > see a test that actually tests the limit without hitting the recursive 
> > template limit.
> > First, most of this test can be further simplified.
> OK? This is what creduce gave me. But yes, i know it has some issues with 
> templates.
> 
> > Second, I'd like to see a test that actually tests the limit without 
> > hitting the recursive template limit.
> But that is true already. *this* test does not hit the recursive template 
> limit.
Looking again, it is probably reduced sufficiently.  The cast and the 
recurse-depth is the only things that are important, so I guess I'm OK with 
this.


Repository:
  rC Clang

https://reviews.llvm.org/D50050



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


[PATCH] D38320: [clang] Fix serializers for `TypeTemplateParmDecl` + related types

2018-07-31 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande added a comment.

hi @rsmith have a look and let me know if this change looks sensible :)  Please 
make sure I have the right mental model for inheritance in the module case


Repository:
  rC Clang

https://reviews.llvm.org/D38320



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


[PATCH] D50029: [COFF, ARM64] Enable SEH for ARM64 Windows

2018-07-31 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338405: [COFF, ARM64] Enable SEH for ARM64 Windows (authored 
by mgrang, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50029?vs=158147&id=158320#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50029

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/test/CodeGen/exceptions-seh-finally.c
  cfe/trunk/test/CodeGen/exceptions-seh.c


Index: cfe/trunk/test/CodeGen/exceptions-seh.c
===
--- cfe/trunk/test/CodeGen/exceptions-seh.c
+++ cfe/trunk/test/CodeGen/exceptions-seh.c
@@ -2,6 +2,8 @@
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X64
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X86
+// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \
+// RUN: | FileCheck %s --check-prefixes=CHECK,ARM64
 // RUN: %clang_cc1 %s -triple i686-pc-windows-gnu -fms-extensions -emit-llvm 
-o - \
 // RUN: | FileCheck %s --check-prefix=X86-GNU
 // RUN: %clang_cc1 %s -triple x86_64-pc-windows-gnu -fms-extensions -emit-llvm 
-o - \
@@ -29,12 +31,14 @@
 
 // CHECK-LABEL: define dso_local i32 @safe_div(i32 %numerator, i32 
%denominator, i32* %res)
 // X64-SAME:  personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
+// ARM64-SAME:personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME:  personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // CHECK: invoke void @try_body(i32 %{{.*}}, i32 %{{.*}}, i32* %{{.*}}) 
#[[NOINLINE:[0-9]+]]
 // CHECK:   to label %{{.*}} unwind label %[[catchpad:[^ ]*]]
 //
 // CHECK: [[catchpad]]
 // X64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null]
+// ARM64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null]
 // X86: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* bitcast (i32 ()* 
@"?filt$0@0@safe_div@@" to i8*)]
 // CHECK-NEXT: catchret from %[[padtoken]] to label %[[except:[^ ]*]]
 //
@@ -76,8 +80,10 @@
 
 // CHECK-LABEL: define dso_local i32 @filter_expr_capture()
 // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
+// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // X64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]])
+// ARM64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]])
 // X86: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]], i32* %[[code:[^ 
,]*]])
 // CHECK: store i32 42, i32* %[[r]]
 // CHECK: invoke void @j() #[[NOINLINE]]
@@ -92,6 +98,10 @@
 // X64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
 // X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture 
to i8*), i8* %[[fp]], i32 0)
 //
+// ARM64-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"(i8* 
%exception_pointers, i8* %frame_pointer)
+// ARM64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 
()* @filter_expr_capture to i8*), i8* %frame_pointer)
+// ARM64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %[[fp]], i32 0)
+//
 // X86-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"()
 // X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress(i32 1)
 // X86: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %[[ebp]])
@@ -116,6 +126,7 @@
 }
 // CHECK-LABEL: define dso_local i32 @nested_try()
 // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
+// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // CHECK: store i32 42, i32* %[[r:[^ ,]*]]
 // CHECK: invoke void @j() #[[NOINLINE]]
@@ -176,6 +187,7 @@
 }
 // CHECK-LABEL: define dso_local i32 @basic_finally(i32 %g)
 // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
+// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // CHECK: %[[g_addr:[^ ]*]] = alloca i32, align 4
 // CHECK: call void (...) @llvm.localescape(i32* %[[g_addr]])
@@ -275,6 +287,8 @@
 // CHECK: catchret from %[[pad]]
 // X64: %[[code:[^ ]*]] = call i32 @llvm.eh.exceptioncode(token %[[pad]])
 // X64: store i32 %[[code]], i32* %[[code_slot]]
+// ARM64: %[[code:[^ ]*]] = call i32 @llvm.eh.exceptioncode(token %[[pad]])
+// ARM64: store i32 %[[code]], i32* %[[code_slot]]
 // CHECK: %[[ret1:[^ ]*]] = load i32, i32* %[[code_slot]]
 // CHECK: store i32 %[[ret1]], i32* %[[ret_slot]]
 // CHECK: %[[ret2:[^ ]*]] = load 

r338405 - [COFF, ARM64] Enable SEH for ARM64 Windows

2018-07-31 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Jul 31 10:42:05 2018
New Revision: 338405

URL: http://llvm.org/viewvc/llvm-project?rev=338405&view=rev
Log:
[COFF, ARM64] Enable SEH for ARM64 Windows

Reviewers: rnk, mstorsjo, ssijaric, haripul, TomTan

Reviewed By: rnk

Subscribers: kristof.beyls, chrib, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/test/CodeGen/exceptions-seh-finally.c
cfe/trunk/test/CodeGen/exceptions-seh.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=338405&r1=338404&r2=338405&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Jul 31 10:42:05 2018
@@ -1139,7 +1139,8 @@ public:
   bool isSEHTrySupported() const {
 return getTriple().isOSWindows() &&
(getTriple().getArch() == llvm::Triple::x86 ||
-getTriple().getArch() == llvm::Triple::x86_64);
+getTriple().getArch() == llvm::Triple::x86_64 ||
+getTriple().getArch() == llvm::Triple::aarch64);
   }
 
   /// Return true if {|} are normal characters in the asm string.

Modified: cfe/trunk/test/CodeGen/exceptions-seh-finally.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-finally.c?rev=338405&r1=338404&r2=338405&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh-finally.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c Tue Jul 31 10:42:05 2018
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - 
| FileCheck %s
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - 
| FileCheck %s
 
 void abort(void) __attribute__((noreturn));
 void might_crash(void);

Modified: cfe/trunk/test/CodeGen/exceptions-seh.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh.c?rev=338405&r1=338404&r2=338405&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh.c Tue Jul 31 10:42:05 2018
@@ -2,6 +2,8 @@
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X64
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X86
+// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \
+// RUN: | FileCheck %s --check-prefixes=CHECK,ARM64
 // RUN: %clang_cc1 %s -triple i686-pc-windows-gnu -fms-extensions -emit-llvm 
-o - \
 // RUN: | FileCheck %s --check-prefix=X86-GNU
 // RUN: %clang_cc1 %s -triple x86_64-pc-windows-gnu -fms-extensions -emit-llvm 
-o - \
@@ -29,12 +31,14 @@ int safe_div(int numerator, int denomina
 
 // CHECK-LABEL: define dso_local i32 @safe_div(i32 %numerator, i32 
%denominator, i32* %res)
 // X64-SAME:  personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
+// ARM64-SAME:personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME:  personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // CHECK: invoke void @try_body(i32 %{{.*}}, i32 %{{.*}}, i32* %{{.*}}) 
#[[NOINLINE:[0-9]+]]
 // CHECK:   to label %{{.*}} unwind label %[[catchpad:[^ ]*]]
 //
 // CHECK: [[catchpad]]
 // X64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null]
+// ARM64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null]
 // X86: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* bitcast (i32 ()* 
@"?filt$0@0@safe_div@@" to i8*)]
 // CHECK-NEXT: catchret from %[[padtoken]] to label %[[except:[^ ]*]]
 //
@@ -76,8 +80,10 @@ int filter_expr_capture(void) {
 
 // CHECK-LABEL: define dso_local i32 @filter_expr_capture()
 // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
+// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // X64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]])
+// ARM64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]])
 // X86: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]], i32* %[[code:[^ 
,]*]])
 // CHECK: store i32 42, i32* %[[r]]
 // CHECK: invoke void @j() #[[NOINLINE]]
@@ -92,6 +98,10 @@ int filter_expr_capture(void) {
 // X64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
 // X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture 
to i8*), i8* %[[fp]], i32 0)
 //
+// ARM64-LABEL: define internal i32 @"?fi

[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/clang/AST/Expr.h:2805
+  }
+  BasePathSizeTy &BasePathSize();
+

erichkeane wrote:
> Why is this a reference?  This seems odd... It seems that the const-cast 
> magic above shouldn't be necessary either.
Looking more into this, I think the reference here is an 'equal of two evils'.  
I can't catch myself really preferring one way over the other.



Comment at: include/clang/AST/Expr.h:2815
+BasePathSize() = basePathSize;
+assert(BasePathSize() == basePathSize &&
+   "basePathSize doesn't fit in bits of BasePathSize!");

This assert shouldn't be necessary.  I think setBasePathSize could just take 
BasePathSizeTy.


Repository:
  rC Clang

https://reviews.llvm.org/D50050



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


[PATCH] D50088: [Sema] Dig through AutoTypes that have been deduced to an undeduced AutoType in Type::isUndeducedType

2018-07-31 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rsmith.
Herald added a subscriber: dexonsmith.

Clang used to error out on the attached test case because we deduced an auto 
type to an undeduced auto type in the template-id G. This caused 
Sema::CheckNonTypeTemplateParameterType to error out because isUndeducedType() 
returned false. It seems like we want to retain this type sugar, so this patch 
teaches isUndeducedType to dig through any deduced-to-undeduced types.

rdar://41852459

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D50088

Files:
  clang/include/clang/AST/Type.h
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp


Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -335,3 +335,13 @@
   void g(int, int);
   using Int = A::B<&g>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G x;
+  }
+};
+}
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6456,8 +6456,15 @@
 }
 
 inline bool Type::isUndeducedType() const {
-  auto *DT = getContainedDeducedType();
-  return DT && !DT->isDeduced();
+  QualType Ty(this, 0);
+  while (auto *DT = Ty->getContainedDeducedType()) {
+if (!DT->isDeduced())
+  return true;
+Ty = DT->getDeducedType();
+if (Ty.isNull())
+  return false;
+  }
+  return false;
 }
 
 /// Determines whether this is a type for which one can define


Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -335,3 +335,13 @@
   void g(int, int);
   using Int = A::B<&g>::param2;
 }
+
+namespace rdar41852459 {
+template  struct G {};
+
+template  struct S {
+  template  void f() {
+G x;
+  }
+};
+}
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6456,8 +6456,15 @@
 }
 
 inline bool Type::isUndeducedType() const {
-  auto *DT = getContainedDeducedType();
-  return DT && !DT->isDeduced();
+  QualType Ty(this, 0);
+  while (auto *DT = Ty->getContainedDeducedType()) {
+if (!DT->isDeduced())
+  return true;
+Ty = DT->getDeducedType();
+if (Ty.isNull())
+  return false;
+  }
+  return false;
 }
 
 /// Determines whether this is a type for which one can define
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50089: [DWARF v4] Suppressing the __debug_ranges section when there are no ranges

2018-07-31 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp created this revision.
wolfgangp added reviewers: aprantl, JDevlieghere, dblaikie.

One of the clang tests in debuginfo-tests (apple-accel.cpp) insists on checking 
for the existence of the __debug_ranges section (it requires darwin) even for 
trivial code which doesn't need any range lists. My recent patch to implement 
DWARF v5 rnglists suppressed the section for trivial cases and broke the test. 
To pacify the bots I disabled the suppression for DWARF 4, restoring the 
original behavior.

This patch (actually 2, debuginfo-tests is a separate repo) fixes the test and 
re-enables the suppression of unneeded DWARF 4 (and earlier) range lists.

@aprantl , @JDevlieghere Could you please make sure the test change makes 
sense. I am not that well-versed with Mach-O. I'm just trying to force the 
compiler to emit ranges.


https://reviews.llvm.org/D50089

Files:
  apple-accel.cpp
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp


Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2136,7 +2136,7 @@
 return;
   }
 
-  if (getDwarfVersion() >= 5 && NoRangesPresent())
+  if (NoRangesPresent())
 return;
 
   // Start the dwarf ranges section.
Index: apple-accel.cpp
===
--- apple-accel.cpp
+++ apple-accel.cpp
@@ -8,6 +8,7 @@
 // RUN: %clang %s %target_itanium_abi_host_triple -gdwarf-4 -O0 -c -g -o %t-ex
 // RUN: llvm-objdump -section-headers %t-ex | FileCheck %s
 
+__attribute__((section("1,__text_foo"))) void foo() {}
 int main (int argc, char const *argv[]) { return argc; }
 
 // CHECK: __debug_str


Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2136,7 +2136,7 @@
 return;
   }
 
-  if (getDwarfVersion() >= 5 && NoRangesPresent())
+  if (NoRangesPresent())
 return;
 
   // Start the dwarf ranges section.
Index: apple-accel.cpp
===
--- apple-accel.cpp
+++ apple-accel.cpp
@@ -8,6 +8,7 @@
 // RUN: %clang %s %target_itanium_abi_host_triple -gdwarf-4 -O0 -c -g -o %t-ex
 // RUN: llvm-objdump -section-headers %t-ex | FileCheck %s
 
+__attribute__((section("1,__text_foo"))) void foo() {}
 int main (int argc, char const *argv[]) { return argc; }
 
 // CHECK: __debug_str
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: include/clang/AST/Expr.h:2791
+public:
+  using BasePathSizeTy = unsigned short;
+  static_assert(std::numeric_limits::max() >= 16384,

erichkeane wrote:
> I'll let @rjmccall comment here, but I think I'd be willing to give up 2 more 
> bytes here and just go with unsigned int.  It has the advantage of likely 
> never being an issue again (since 4 billion bases is not an issue).
> 
> We might be paying for those 2 ANYWAY with alignment as well, right?
Yes, i do expect that we are paying for 2 bytes in padding already.



Comment at: include/clang/AST/Expr.h:2805
+  }
+  BasePathSizeTy &BasePathSize();
+

erichkeane wrote:
> Why is this a reference?  This seems odd... It seems that the const-cast 
> magic above shouldn't be necessary either.
I'll make it a pointer and replace `BasePathSizeTy BasePathSize() const` with 
`path_size()`.
I don't really think it would be good to get rid of this pointer/reference, 
since then
we'd have more than one function doing what `CastExpr::BasePathSizeTy 
*CastExpr::BasePathSize()` does now.


Repository:
  rC Clang

https://reviews.llvm.org/D50050



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


[libcxx] r338411 - Introduce a new test macro TEST_HAS_C11_FEATURES which is set when the underlying C library has C11 features. In C++17, we use those features. <__config> defines a similar macro, _L

2018-07-31 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jul 31 11:23:57 2018
New Revision: 338411

URL: http://llvm.org/viewvc/llvm-project?rev=338411&view=rev
Log:
Introduce a new test macro TEST_HAS_C11_FEATURES which is set when the 
underlying C library has C11 features. In C++17, we use those features. 
<__config> defines a similar macro, _LIBCPP_HAS_C11_FEATURES, but we don't want 
to use that in the library-independent parts of the tests, so define the new 
one. Also add a libc++-specific test to make sure the two stay in sync.

Added:
libcxx/trunk/test/libcxx/language.support/has_c11_features.pass.cpp
Modified:
libcxx/trunk/test/support/test_macros.h

Added: libcxx/trunk/test/libcxx/language.support/has_c11_features.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/language.support/has_c11_features.pass.cpp?rev=338411&view=auto
==
--- libcxx/trunk/test/libcxx/language.support/has_c11_features.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/language.support/has_c11_features.pass.cpp Tue Jul 
31 11:23:57 2018
@@ -0,0 +1,29 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// We have two macros for checking whether or not the underlying C library
+//  has C11 features:
+// TEST_HAS_C11_FEATURES- which is defined in "test_macros.h"
+// _LIBCPP_HAS_C11_FEATURES - which is defined in <__config>
+// They should always be the same
+
+#ifdef TEST_HAS_C11_FEATURES
+# ifndef _LIBCPP_HAS_C11_FEATURES
+#  error "TEST_HAS_C11_FEATURES is defined, but _LIBCPP_HAS_C11_FEATURES is 
not"
+# endif
+#endif
+
+#ifdef _LIBCPP_HAS_C11_FEATURES
+# ifndef TEST_HAS_C11_FEATURES
+#  error "_LIBCPP_HAS_C11_FEATURES is defined, but TEST_HAS_C11_FEATURES is 
not"
+# endif
+#endif
+
+int main() {}

Modified: libcxx/trunk/test/support/test_macros.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=338411&r1=338410&r2=338411&view=diff
==
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Tue Jul 31 11:23:57 2018
@@ -94,16 +94,6 @@
 #define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor)
 #endif
 
-/* Features that were introduced in C++14 */
-#if TEST_STD_VER >= 14
-#define TEST_HAS_EXTENDED_CONSTEXPR
-#define TEST_HAS_VARIABLE_TEMPLATES
-#endif
-
-/* Features that were introduced after C++14 */
-#if TEST_STD_VER > 14
-#endif
-
 #if TEST_STD_VER >= 11
 #define TEST_ALIGNOF(...) alignof(__VA_ARGS__)
 #define TEST_ALIGNAS(...) alignas(__VA_ARGS__)
@@ -132,6 +122,43 @@
 #define TEST_THROW_SPEC(...) throw(__VA_ARGS__)
 #endif
 
+// Sniff out to see if the underling C library has C11 features
+// Note that at this time (July 2018), MacOS X and iOS do NOT.
+#if __ISO_C_VISIBLE >= 2011
+#  if defined(__FreeBSD__)
+#define TEST_HAS_C11_FEATURES
+#  elif defined(__Fuchsia__)
+#define TEST_HAS_C11_FEATURES
+#  elif defined(__linux__)
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
+#  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define TEST_HAS_C11_FEATURES
+#  endif
+#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#  define TEST_HAS_C11_FEATURES
+#endif
+#  elif defined(_WIN32)
+#if defined(_MSC_VER) && !defined(__MINGW32__)
+#  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+#endif
+#  endif
+#endif
+
+/* Features that were introduced in C++14 */
+#if TEST_STD_VER >= 14
+#define TEST_HAS_EXTENDED_CONSTEXPR
+#define TEST_HAS_VARIABLE_TEMPLATES
+#endif
+
+/* Features that were introduced in C++17 */
+#if TEST_STD_VER >= 17
+#endif
+
+/* Features that were introduced after C++17 */
+#if TEST_STD_VER > 17
+#endif
+
+
 #define TEST_ALIGNAS_TYPE(...) TEST_ALIGNAS(TEST_ALIGNOF(__VA_ARGS__))
 
 #if !TEST_HAS_FEATURE(cxx_rtti) && !defined(__cpp_rtti) \


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


[PATCH] D46822: [RISCV] Add driver for riscv32-unknown-elf baremetal target

2018-07-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please don't commit patches on behalf of someone else if the author hasn't 
specifically requested it.  There might be some issue which the author forgot 
to note on the review.


Repository:
  rC Clang

https://reviews.llvm.org/D46822



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


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 158344.
lebedev.ri marked 6 inline comments as done.
lebedev.ri added a comment.

Address some of @erichkeane review notes.


Repository:
  rC Clang

https://reviews.llvm.org/D50050

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/Stmt.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  test/CodeGenCXX/castexpr-basepathsize-threshold.cpp

Index: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
===
--- /dev/null
+++ test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// https://bugs.llvm.org/show_bug.cgi?id=38356
+// We only check that we do not crash.
+
+template 
+struct d : d {};
+template 
+struct d {
+  a f[0];
+};
+struct g {
+  static g h(unsigned);
+};
+struct i {
+  void j() const;
+  // Current maximum depth of recursive template instantiation is 1024,
+  // thus, this \/ threshold value is used here. BasePathSize in CastExpr might
+  // not fit it, so we are testing that we do fit it.
+  // If -ftemplate-depth= is provided, larger values (4096 and up) cause crashes
+  // elsewhere.
+  d f;
+};
+void i::j() const {
+  const void *k{f.f};
+  (void)k;
+}
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -559,7 +559,9 @@
  SourceLocation RParenLoc,
  SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
  RParenLoc, AngleBrackets);
@@ -571,7 +573,9 @@
 
 CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext &C,
   unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize);
 }
 
@@ -584,7 +588,9 @@
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
   RParenLoc, AngleBrackets);
@@ -596,7 +602,9 @@
 
 CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(const ASTContext &C,
 unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
 }
 
@@ -641,7 +649,9 @@
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
   RParenLoc, AngleBrackets);
@@ -653,7 +663,9 @@
 
 CXXReinterpretCastExpr *
 CXXReinterpretCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
 }
 
@@ -676,7 +688,9 @@
   const CXXCastPath *BasePath,
   SourceLocation L, SourceLocation R) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R);
   if (PathSize)
@@ -687,7 +701,9 @@
 
 CXXFunctionalCastExpr *
 CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
 }
 
I

r338413 - [OPENMP] Change linkage of offloading symbols to support dropping

2018-07-31 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul 31 11:27:42 2018
New Revision: 338413

URL: http://llvm.org/viewvc/llvm-project?rev=338413&view=rev
Log:
[OPENMP] Change linkage of offloading symbols to support dropping
offload targets.

Changed the linkage of omp_offloading.img_start. and 
omp_offloading.img_end. symbols from external to external weak to allow 
dropping of some targets during linking.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_for_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_if_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_num_threads_codegen.cpp
cfe/trunk/test/OpenMP/target_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_simd_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_teams_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_depend_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=338413&r1=338412&r2=338413&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Jul 31 11:27:42 2018
@@ -3750,11 +3750,13 @@ CGOpenMPRuntime::createOffloadingBinaryD
 StringRef T = Device.getTriple();
 std::string BeginName = getName({"omp_offloading", "img_start", ""});
 auto *ImgBegin = new llvm::GlobalVariable(
-M, CGM.Int8Ty, /*isConstant=*/true, llvm::GlobalValue::ExternalLinkage,
+M, CGM.Int8Ty, /*isConstant=*/true,
+llvm::GlobalValue::ExternalWeakLinkage,
 /*Initializer=*/nullptr, Twine(BeginName).concat(T));
 std::string EndName = getName({"omp_offloading", "img_end", ""});
 auto *ImgEnd = new llvm::GlobalVariable(
-M, CGM.Int8Ty, /*isConstant=*/true, llvm::GlobalValue::ExternalLinkage,
+M, CGM.Int8Ty, /*isConstant=*/true,
+llvm::GlobalValue::ExternalWeakLinkage,
 /*Initializer=*/nullptr, Twine(EndName).concat(T));
 
 llvm::Constant *Data[] = {ImgBegin, ImgEnd, HostEntriesBegin,

Modified: cfe/trunk/test/OpenMP/target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen.cpp?rev=338413&r1=338412&r2=338413&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen.cpp Tue Jul 31 11:27:42 2018
@@ -85,8 +85,8 @@
 // Check if offloading descriptor is created.
 // CHECK: [[ENTBEGIN:@.+]] = external constant [[ENTTY]]
 // CHECK: [[ENTEND:@.+]] = external constant [[ENTTY]]
-// CHECK: [[DEVBEGIN:@.+]] = external constant i8
-// CHECK: [[DEVEND:@.+]] = external constant i8
+// CHECK: [[DEVBEGIN:@.+]] = extern_weak constant i8
+// CHECK: [[DEVEND:@.+]] = extern_weak constant i8
 // CHECK: [[IMAGES:@.+]] = internal unnamed_addr constant [1 x [[DEVTY]]] 
[{{.+}} { i8* [[DEVBEGIN]], i8* [[DEVEND]], [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* 
[[ENTEND]] }], comdat($[[REGFN]])
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* 
getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, 
i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 

Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
URL: 

  1   2   3   >